Processing a MessageBox

Started by
6 comments, last by ZoomBoy 24 years, 1 month ago
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
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
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...
I''ve got a note from someone that the Timer might still be working and that''s calling UpdateFrame

ZoomBoy
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

any other comments would be of some help


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
__________________________________________

Yeah, sure... we are laughing WITH you ...
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

This topic is closed to new replies.

Advertisement