0

So here's what I'm trying to achieve. I have a simple chat winforms application that I want to be put on top of other applications that are fullscreen, I don't want it to take focus but I'd like it to accept the user input in the text box. I've achieved the first part so far and my chat app stays on top of other apps without taking its focus. Here's what I've used:

const int WS_EX_NOACTIVATE = 0x8000000;
protected override CreateParams CreateParams
{
    get
    {
        CreateParams ret = base.CreateParams;
        ret.ExStyle |= WS_EX_NOACTIVATE;
        return ret;
    }
}


public Form1()
{
    InitializeComponent();
    TopMost = true;
}

Now the problem is that I can't write anything into the textbox. All buttons work fine, I can click them and they trigger events, but the textbox doesn't take any input.

JanRad
  • 327
  • 2
  • 12

1 Answers1

0

Override this parameters inf your Form class and erase TopMost = true; from your code. This will work and will gain focus when trying to edit textbox.

protected override bool ShowWithoutActivation
{
    get { return true; }
}

private const int WS_EX_TOPMOST = 0x00000008;
protected override CreateParams CreateParams
{
    get
    {
        CreateParams createParams = base.CreateParams;
        createParams.ExStyle |= WS_EX_TOPMOST;
        return createParams;
    }
}

Found it here: Look at second answer

Community
  • 1
  • 1
c_str
  • 369
  • 1
  • 4
  • 14
  • btw, I tested it, it's working for me. Form fires at certain time and does not appear gaining focus. I can keep writting and moving arrows in other applications even if this appears. – c_str May 07 '16 at 05:59
  • The thing is that I was using WS_EX_NOACTIVE so that my app stays on top of the full screen one but also when I click it the windows taskbar doesn't show up. I guess I either have chat and taskbar or none. – JanRad May 07 '16 at 08:35
  • I think that having topmost on a Fullscreen application is senseless. It's intended to be a FULLscreen application to avoid other stuff appear, even Steam avoids it unless you call focus to Steam windows with Shift+Tab or the browser/media players when playing fullscreen videos (Why would you want a window over a video?) Windows 8.X and 10 do this, they even send Windows Notifications if you're fullscreen in non DiretcX/OpenGL app's and is annoying xc! As a user of Windows, I'd hate a windows be always topmost every time, even in fullscreen D: jajaja – c_str May 07 '16 at 18:25
  • It's supposed to be a chat application, so when playing a game You could have a little window shown somewhere where You can talk. Also the plan is to do the topmost optional with a checkbox to change the state. I just didn't want to show the windows taskbar when the app has focus but I guess everything comes with a price. – JanRad May 07 '16 at 19:28