0

I'm developing in C code that uses the Win32 Api to create multiple windows. I used createWindow twice - to create parent and child windows. I have a message loop

while ( GetMssage (&msg, NULL,0,0)){
.
translate
dispatch
. 
}

But I only get the WND_Proc function called once, instead of twice for each of the windows.

What am I doing wrong?

Jason Plank
  • 2,336
  • 5
  • 31
  • 40
dan
  • 61
  • 2
  • 7
  • Are you actually seeing a successful HWND result from CreateWindow()? We'd probably need to see some actual failing code to give any useful help. – Aaron Nov 10 '09 at 14:16
  • Note that the WM_CREATE message actually is sent to the WndProc during the lifetime of the CreateWindow() call - so if you're setting a breakpoint in the debugger don't step over the CreateWindow() and THEN expect to see a break in your WndProc... – Aaron Nov 10 '09 at 14:24
  • Some suggestions to improve your question: correct the spelling of GetMessage, correct the capitalization of CreateWindow, and please be more specific on what messages you expect to receive. – Gene Goykhman Nov 10 '09 at 14:25

1 Answers1

0

If I'm understanding your question correctly, you should expect your WndProc to receive a single WM_CREATE message for each window created of the window class for which the WndProc is registered.

Your WndProc will not receive a WM_CREATE for a window you create of a different class (like the standard Windows UI controls, for example), even if it is a direct child of a window of the WndProc's class. If you gave us some more specifics on what you are trying to accomplish we could provide suggestions or workarounds.

This question may also shed some more light on your situation.

Community
  • 1
  • 1
Gene Goykhman
  • 1,981
  • 2
  • 16
  • 15
  • Hi - I am not talking about the WM_CREATE message, but rather about general message suchas WM_KEYDOWN : I want to deal with them in both windows. I asked another question with some code examples as well right now. – dan Nov 10 '09 at 14:50
  • @dan: you may have wanted to add a [link](http://stackoverflow.com/questions/1708499/createwindow-win32-api-problem-only-parent-window-gets) to your other question as well ) – ジョージ Mar 02 '12 at 06:10