Tech Off Post

Single Post Permalink

View Thread: WinForms question - Preventing focus from being set to a Form
  • User profile image

    I found this that would solve my problem. Seems a lot of code just to prevent the focus to change.

    EDIT: Well I tried that and it doesn't work for me. The custom tooltip still gets the focus.

    EDIT EDIT: OK the weird thing is that when I'm using the example code from that link and I override OnActivated and call...

    SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);

    ...that the breakpoint in OnActivated is hit, showing the SetWindowPos in the call stack. So the SetWindowPos causes the window to become active. Isn't that what the SWP_NOACTIVATE is supposed to prevent?