hi,

in my DirectDraw game i have the following problem: if i click on "New Game" or "Options" nothing happens till i move my mouse or do another event (press keyboard key). but if i press "Quit" the app directly quits, even if i don't move my mouse. this could be because i call "DestroyWindow" on click, and this sends a message to my message loop. so i think it's a problem with the message loop:



StartLoop:
cmp app_flag,1
jne _nonactive

invoke PeekMessage, addr msg, NULL, 0, 0, PM_REMOVE
and eax, eax
jz IdleTime
cmp [msg.message], WM_QUIT
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop

IdleTime:
.if gameruns==0
invoke ReadKeyboard
.if keyboard_state[DIK_DOWN]
mov gameruns,1
.endif
.if repainted==0
invoke RepaintScreen
mov repainted,1
.endif
.endif
invoke snakemainproc
jmp StartLoop

_nonactive:

invoke ReadMouse
.if menuid==MENU_MAIN
invoke RepaintMenu
.elseif menuid==MENU_OPTIONS
invoke RepaintOptions
.endif



invoke GetMessage,ADDR msg,NULL,0,0
and eax, eax
jz ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:


during the time that i'm in the menu, app_flag is zero, so it should always jump to _nonactive, and depending on the menuid it should paint the main menu or the options menu. but it stays in the main menu till i move my mouse or press a keyboard key.

yes, on pressing "options" i do a "mov menuid,MENU_OPTIONS" :tongue:

please help, bye
Posted on 2002-07-25 08:39:07 by NOP-erator
Suggestion:

Get rid of the flags! Set up some custom messages:



WM_MENU_NEWGAME equ WM_USER + 200


And use PostMessage to place it in the messagequeue of your window
when the user clicks an item. Much better way, IMO.
Posted on 2002-07-25 08:52:21 by bazik
thanks bazik! this solved my problem! :alright: :alright:

90h-py:grin:
Posted on 2002-07-25 09:27:21 by NOP-erator