-
August 13th, 2015, 03:22 AM
#1
[RESOLVED] WM_CREATE and HWND issue
Code:
case WM_CREATE:
if (hwnd == childwindowHandle)
{
x = TRUE;
}
x is never set to true.
This is a child window. This case is in the message switch for the child window's message procedure. There are multiple children of the same class. The child windows are created drawn and functional. This logic exactly works in other cases such as WM_PAINT and WM_LBUTTONDOWN and other logic making referencing the parameter hwnd also has no problems.
Why for WM_CREATE, when in the documentation it states that WM_CREATE is called after window creation but before window visibility, does hwnd not evaluate to the handle of the created window?
Thank you guys, First post ^_^
-Kev
PS. I don't have permission to create tags on this forum but there's no WM_CREATE tab!
-
August 13th, 2015, 03:59 AM
#2
Re: WM_CREATE and HWND issue
Originally Posted by int Kev
Code:
case WM_CREATE:
if (hwnd == childwindowHandle)
{
x = TRUE;
}
x is never set to true.
Did you check whether this code is executed?
Victor Nijegorodov
-
August 13th, 2015, 04:04 AM
#3
Re: WM_CREATE and HWND issue
Originally Posted by VictorN
Did you check whether this code is executed?
This was me checking! Thank you for replying victor, but I'm not sure what you mean. How else can I check for code execution? Should a WM_CREATE msg not be sent to my window procedure upon window creation? And should, too, the code within it's case not then execute?
-
August 13th, 2015, 04:07 AM
#4
Re: WM_CREATE and HWND issue
Other code formerly in this WM_CREATE case executed just fine. Just not if checking the window handle.
-
August 13th, 2015, 04:15 AM
#5
Re: WM_CREATE and HWND issue
Originally Posted by int Kev
This was me checking! Thank you for replying victor, but I'm not sure what you mean.
just set a breakpoint at the line with and start debugging (F5)...
Then press F10 to step through the code and look at the debugger ("auto" or "watch") window to see the values of the variables.
Victor Nijegorodov
-
August 13th, 2015, 04:46 AM
#6
Re: WM_CREATE and HWND issue
What a useful tool! What appears to be happening is that, although the window was created with
childwindowHandle = CreatewindowEx(... etc, assignment happens after any functions on the right finish.
The CreateWindowEx() function runs, a WM_CREATE message is sent and processed, all before the variable childwindowHandle ever gets an assignment, and so, of course hwnd != childwindowHandle.
Victor, this has clarified many things. Thank you.
I've more to figure out, but as far as I'm concerned, thread resolved.
-
August 13th, 2015, 04:53 AM
#7
Re: WM_CREATE and HWND issue
Originally Posted by int Kev
...
Victor, this has clarified many things. Thank you.
I've more to figure out, but as far as I'm concerned, thread resolved.
You are welcome!
And now you can use the Thread Tools (the button on the toolbar above the posts to Mark Thread Resolved.
Victor Nijegorodov
-
August 13th, 2015, 07:11 AM
#8
Re: WM_CREATE and HWND issue
that code makes no sense...
this message is sent to the CHILD window after the window is actually created. so hwnd is that of the newly created child window.
however, your application has no yet had an opportunity to actually know what the new window handle is, because that's exactly what createwindow is for, to inform you that the OS made a window and "here's the new handle for it"
so how would childwindowHandle possibly have the right value if this is the first opportunity (other than hooking) your app gets to know about the new handle.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|