2

I have an edit control. In the parent window I'm listening a WM_COMMAND message. But my control doesn't send it on change. Moreover, when I'm watching messages with Spy I can see only different keyboard messages on the edit control itself and the only message in the main parent window is WM_CTLCOLOREDIT.

P.S.: The only interesting thing I'm doing - I'm creating an edit with HWND_MESSAGE parent and assign a parent later with SetParent();

nikitablack
  • 4,359
  • 2
  • 35
  • 68
  • Why are you making a message only window be the parent? Did you explore what happens if you don't do that. – David Heffernan Jun 08 '15 at 12:21
  • @DavidHeffernan In the beginning I don't know the parent of the control - it's created dynamically. Later I'm setting a parent and even changing a parent during runtime. Creating control with a parent behaves well, i.e. everything works as expected. – nikitablack Jun 08 '15 at 12:29
  • Yep, digging more deeply I found an [article](https://support2.microsoft.com/default.aspx?scid=KB;EN-US;Q104069). That's weird (. – nikitablack Jun 08 '15 at 12:37

1 Answers1

3

For an edit control, notifications are sent to the original parent of the control. That is, in your case, the message only window.

In a comment to a similar question Raymond Chen says:

Many controls cache the original parent. Not much you can do about it.

You may be best postponing creation of the edit control until you have created its parent.

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490