0

I have a control that contains another control inside. The inner control sometimes snatches focus from other controls and I need to place a watch on this and change focus back. I'm subclassing the out control (can't subclass the inner one), and I'm listening for the WM_SETFOCUS message, but this only occurs when I click one of the controls. When the focus is snatched by the inner control itself, I'm getting nothing.

What am I doing wrong?

Chris
  • 8,527
  • 10
  • 34
  • 51
user884248
  • 2,134
  • 3
  • 32
  • 57
  • Maybe you need `WM_KILLFOCUS`? [MSDN here](http://msdn.microsoft.com/en-us/library/windows/desktop/ms646282(v=vs.85).aspx) – Roger Rowland Sep 08 '13 at 10:22
  • WM_KILLFOCUS works fine for the control that focus is being snatched from, but I use this setup as a user control in several places, and I don't want to have to place a WM_KILLFOCUS watch on each one of them. – user884248 Sep 08 '13 at 10:27
  • *"Snatching focus"* and *"change focus back"* is most likely the wrong solution. If you want to prevent a control from gaining focus you simply disable the control. – IInspectable Sep 08 '13 at 12:05
  • I agree, this is a bad solution, but it is the only one I can use. – user884248 Sep 08 '13 at 12:25
  • 1
    It is not a *solution* - this really **is** your problem. Solve that and you won't need to stack another hack on top of a hack. – IInspectable Sep 08 '13 at 13:45

0 Answers0