Why is it that in Iczelion's Win32Asm Tutorial Number 3 (A simple window) there is no function prototype for the WndProc procedure? (Function prototype may not be the right term, it's something i remembered from C) Is this because we don't acually call WndProc? The only thing that is done with it is setting it up as SimpleWinClass's message processing procedure. mov wc.lpfnWndProc, OFFSET WndProc So does that mean Windows calls it..? And how often is it called; is it called everytime a message is sent or does Windows call the message proc for every program and then loop and call them all again (assuming windows does call it). Oh and could someone briefly explain to me why we use OFFSET WndProc instead of ADDR? WndProc isn't a data type, are we storing it's name for referencing? Ack I don't know what I'm talking about. ...Matt, the Asm newbie! BTW; These tutorials are well written and appreciated!
Posted on 2001-05-06 14:07:00 by matthew
Why is it that in Iczelion's Win32Asm Tutorial Number 3 (A simple window) there is no function prototype for the WndProc procedure? (Function prototype may not be the right term, it's something i remembered from C) Is this because we don't acually call WndProc? The only thing that is done with it is setting it up as SimpleWinClass's message processing procedure.
Your partly right, it can be left out because we don't use invoke on it, so masm doesn't care about the prototype. However, it is sometimes advisable to add it because masm sometimes doesn't understand the symbol if it's referenced before it's declared.
So does that mean Windows calls it..? And how often is it called; is it called everytime a message is sent or does Windows call the message proc for every program and then loop and call them all again (assuming windows does call it).
Windows calls the function each time a message is sent. But there is a loop. The loop is at the end of the WinMain procedure, with the GetMessage/DispatchMessage functions. This loop continues until the program exits. The loop checks for new messages (GetMessage), does some stuff with it if necessary, then dispatches it with DispatchMessage. It's DispatchMessage that calls the window procedure.
Oh and could someone briefly explain to me why we use OFFSET WndProc instead of ADDR? WndProc isn't a data type, are we storing it's name for referencing?
ADDR is only valid in the context of INVOKE. That's the only thing you can use it for. For everything else, use OFFSET. WndProc isn't a datatype, it's a label (somewhere in the address space). It's not the name that is stored, it's the address of the label (OFFSET WndProc), a pointer to the window procedure so windows knows 'where' it should call. Thomas
Posted on 2001-05-06 15:02:00 by Thomas