Please help: problem with creating a win32 window

Started by
16 comments, last by EGD Eric 20 years ago
Why does it need to be static?
Advertisement
http://www.gamedev.net/reference/programming/features/win32wrapper/.
Setting the window procedure as friend allows that function to access all of the members of the class, without it being in the scope of the class.
.
Alright. Thanks for the info people. Now that I''ve put enough time into studying the articlue Oluseyi sent me, along with the good abreviated version from nonpop, There''s still something that escapes me: Where is the application''s Message procedure actually called? I know that WinProc is called somewhere behind the win32 scenes (that was something that I kept trying to find when first learning Win32: "Where''s Winproc being called??"),

but... here you''re declaring your own static _winProc (or, with the tutorial it was called: "msgRouter") which calls the default WinProc at the end. Now, where''s msgRouter (_winProc, or whatever you call it) called? How do I make sure that Win32 calls it?

With PeekMessage, TranslateMessage and DispatchMessage?

How does it know which function to call? Wouldn''t it automatically call WinProc? Or does it matter what its called?
quote:Original post by EGD Eric
How do I make sure that Win32 calls it?

With PeekMessage, TranslateMessage and DispatchMessage?

Aye

quote:How does it know which function to call?

You gave it a pointer to the function (it''s the line that was causing your original error)

quote:Or does it matter what its called?

No
Oh -ho!
Assuming that you aren''t using MFC...
To call this message handling function, either WndProc or msgRouter, you have to set up a windows message loop to translate and dispatch the messages. Here is a sample:

//========================================================//*** RunMessageLoop                                   ***//*** Description: Runs the windows message loop       ***//========================================================WPARAM CMainWindow::RunMessageLoop () {   MSG wndMessage;   wndMessage.message = WM_NULL;   PeekMessage (&wndMessage, NULL, 0, 0, PM_NOREMOVE);   while (wndMessage.message != WM_QUIT)    {      if (PeekMessage (&wndMessage, NULL, 0, 0, PM_REMOVE))        {         TranslateMessage (&wndMessage);         DispatchMessage (&wndMessage);       }      // Do something here...      }       return (wndMessage.wParam);  }


This function is taken out of my wrapper class and is called from my WinMain funciton. When you call DispatchMessage, DispatchMessage will call the correct WndProc function...I hope this helps..
Edmund Weese7-bit Games
quote:Original post by EGD Eric
Why does it need to be static?


callback functions as the windowproc need to be static if they are inside a class
http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement