🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Win32 Message Queue

Started by
3 comments, last by magal 24 years, 8 months ago
You do need those functions to handle the messages that windows receives, such as task-switching, and certain device messages.

The Windows SDK also masks SendMessage calls under different function names to make it easier for you to use, so I would recomend always including those.

------------------
Jim Adams
Co-Designer 'The Light Befallen'
tcm@pobox.com
http://www.lightbefallen.com

Advertisement
Actually, if you intend to use the PostQuitMessage() function to end your program, you're going to have to use the Messaging system. That's what it works through. Basically, it should look something like this:
while(1) { // your loop  if(PeekMessage(&msg, NULL, 0, 0, NULL) {    if(msg.message == WM_QUIT)      break; // that's how you actually quit     // otherwise, pass the message along     TranslateMessage(&msg);    DispatchMessage(&msg);  } // end checking for messages  // do your game stuff that needs to be done  // on a frame to frame basis here} // end while loop// and your shutdown code goes here

I hope that helped

Jonathan

Oops, that should've been :
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) {

That PM_REMOVE saves you the call to GetMessage(). I don't know if it makes any of a performance difference though.

Jonathan

I'm writing a fullscreen DirectDraw game that uses only DirectInput for all the mouse
and keyboard input and I had a doubt about
the game loop. I used the basic Input(),
Process(), Output() functions to update my
surface on each pass on the while(1) loop
but I don't know if I need to place the
Win32 message processing functions like
if(PeekMessage(...))
if(!GetMessage())
return msg.wParam;
Translate
Dispatch

I don't know because, to quit, I use the
PostQuitMessage function. Will it be
processed if I don't use the Win32 message
functions? Will the game quit? Is there any
other way to do it so I don't need to use
these functions?

There's a lot more messages that your program won't probably touch, just get passed on to DefWindowProc() that you _must_ process.

If WM_NCDESTROY, which is a system destroy of a window, is never handled, Windows may not release some data structures associated with your Window.

So if you create any windows in your program (which you probably are) you must handle messages.

This topic is closed to new replies.

Advertisement