Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ZoomBoy

Processing a MessageBox

This topic is 6732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am having trouble creating message boxes that work // also using DirectDraw and DInput I have the usual WinMain GetMessage { TranslateMessage() DispatchMessage() } in WinProc() I''ve got WinProc() { .... switch(msg) case (WM_TIMER) // right now I''ve got it set at 18frames/sec { Updateframe(); } .... } UpdateFrame() { PaintScreen() GetMouseInfo() // I use DInput ProcessScreenActions() } in ProcessActions I sometimes want to place a MessageBox in the code to give me a clear answer before I continue on with an action case ChangeWeapon: int nResult = JTChoiceBox("Change Weapon?", JTMB_YESNOCANCEL); if (nResult == YES) ChangeWeapon(); break; My idea in the JTChoiceBox() was to create the PopUpWindow and keep repainting the screen int JTChoiceBox() { pMessageBox = new JTMsgBox("Change Weapon?", JTMB_YESNOCANCEL) while (pMessageBox->TestMsg(ms_flags) == NORESULT) { PaintScreen(); GetMouseInfo(ms_flags); } delete pMessageBox; } But overall I seem to be missing out on the translate/dispatch process or something. my computer keeps freezing One time I put a counter on the _while_ loop that made it loop only 15 times: the screen flashed the box and then I was out of it - not frozen and was functioning; tried it with 200 and it froze Do I have to set up another thread? Do I have to create another pathway through the processing? ........................ ZoomBoy A 2D RPG with skills, weapons, and adventure. See my character editor, Tile editor and diary at Check out my web-site

Share this post


Link to post
Share on other sites
Advertisement


Just reading here something by John DeGoes
"Cutting Edge 3D Programming with C++"

It came out at the same time as Win95 arrived on the scene. In his conversion of
a DOS 3D engine to Win95, he
sets up the window & Inits the ZBuffer
sets up a while(Running) loop
{
checks mousebuttons
moves objects and viewpoints about
clears Z-buffer
shows.window
peekmessage
{
translate
dispatch
}
}
in the WndProc he monitors the mouse and if there''s an exit to the game

Hmmmm....
interesting but I don''t know if it solves any problems



ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site

Share this post


Link to post
Share on other sites
I could be way off target here... but I think that if you go into an infinite loop checking for a message, you are actually denying Windows the chance to generate that message. As far as I knew, this was why Windows programs used callback functions and (as far as I knew) no infinite loops. No doubt a real Win32 programmer can give a better reason...

Share this post


Link to post
Share on other sites
I''ve got a note from someone that the Timer might still be working and that''s calling UpdateFrame

ZoomBoy

Share this post


Link to post
Share on other sites
I''ve got plenty of loops in my game but they don''t hang.
I''m going to be either reformatting my gaming loop with PeekMesage or maybe creating another thread. But I don''t know if the latter would eliminate the problem. But the type of box I''m seeking to emulate is like the MFC modal? AfxMessageBox.
I''ll keep twisting and playign with these idea. It''s not my top priority now.

Kyotan: You''re probably right asbout the need for checking on Windows in this infinite loop. A post earlier of Lamothe''s code had a different main loop set up with PeekMessage being IN it not above it

ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site

Share this post


Link to post
Share on other sites

Just out of curiosity, if ProcessActions is called during the course of your game (after you have initialized the video mode) don''t you have to call FlipToGDI before using any GDI GUI elements (such as messageboxes, dialogs,etc..)?

-mordell

Share this post


Link to post
Share on other sites
mordell, I recognize your genius and recvognize my oversight.
1) When I was in the loop, I had been painting, to the backbuffer, all the items in the messagebox. But because my loop takes control of the whole process, I needed to do all the processes including Flipping between Primary and backbuffer.
2) The need to handle Windows messages made me put in my loop a PeekMessage(). That keeps an eye out for any exit keys.

It looks purrty! Thx for everyones help

ZoomBoy
A 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor and diary at
Check out my web-site

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!