Mordachai
Mordachai

Reputation: 9672

How can I control focus within a Win32 app?

I have a situation where I have a main window with a toolbar containing some edit fields.

We want the user to be able to keep focus in the edit fields and still be able to right click on the view window (both descendents of the same main window, same thread).

In current tests, I see that the focus messages happen even before the view receives the RMB down message:

  1. Edit = kill focus
  2. View = set focus
  3. View = RMB down

I don't want to have the edit retain focus no matter what: just maintain focus if the user tries to do an RMB click on the view.

Because the focus stuff happens first, I'm a bit at a loss as to how to tell that what's about to happen is the right mouse button down.

Upvotes: 0

Views: 1377

Answers (1)

Hans Passant
Hans Passant

Reputation: 942438

Start by turning on the WS_EX_NOACTIVATE style flag on the right-clicked window. That stops the window manager from automatically activating the clicked window.

Upvotes: 1

Related Questions