Absolute WINAPI Beginner - Just a quick question.

Okay, so I've gone over a couple of the tutorials at http://www.winprog.org/ and have come across something a tad confusing. If you were to exclude the default case (returning a default procedure) in the "msg" switch inside the WndProc() function, assigning the creation of a window (yielding that function) to a handler will ultimately result in a NULL handler.

Now, I assume that this happens because the CreateWindowEx() function calls WndProc() at some point - and because there is nothing telling it to return the default parameters (the value 0 is returned), everything that was passed into the CreateWindowEx() function is simply disregarded.

Is that the case? If so, what is the purpose behind CreateWindowEx() calling the window procedure function before using something like GetMessage(), where it has already been assigned in the class's registration?

Edit:
One last thing - what is the purpose behind including WPARAM and LPARAM inside the WndProc() function, and what do the initial letters stand for? (E.g., W___ parameter, L___ parameter)
Last edited on
As far as I know CreateWindow(Ex) generates a WM_CREATE message before it returns. It doesn't actually call the window procedure. The window procedure is associated with a window via its "window class". The only way I know of to assign a different window procedure to a window is to change the function pointer in its window class.

You don't return a "default procedure" from the window procedure, you return the return value of the default procedure. The return value usually has different meanings depending on the message, often indicating to Windows whether the message was handled or not.

The WPARAM and LPARAM contain additional parameters related to the message, such as the key being pressed in a WM_KEYDOWN message or the mouse coordinates in a WM_MOUSEMOVE message. As for what the W and L stand for, I'd be interested to know this myself.

As most people will probably tell you, MSDN should be your #1 source of information for winapi programming. Just go there and search for any window message, for example, and it will tell you what wparam and lparam contain and what value you should return.
Last edited on
As for what the W and L stand for, I'd be interested to know this myself.

Then see...

What do the letters W and L stand for in WPARAM and LPARAM?
http://blogs.msdn.com/b/oldnewthing/archive/2003/11/25/55850.aspx

Andy
@knn9 Thank you so much for clearing that up - although, I do feel like an absolute fool now.

So, CreateWindowEx()'s generation of the WM_CREATE message is why lack of the default case (that would, as you've stated, return the value of a default procedure - which is ultimately what I meant, just poorly worded) causes the handler to the window to sustain a NULL 'value', even having passed in all appropriate arguments to the window creation function?
Topic archived. No new replies allowed.