Is possible to create a thread to peek message of a certain window, and block itself if no message is peeked?
Posted on 2003-11-12 07:13:52 by optimus
If i could understand you want to stop looping if no message. Then it is easy, only use WaitMessage api for this. If PeekMessage returns zero then call WaitMessage else loop.
Posted on 2003-11-12 19:31:59 by cakmak
I use the following code for my window. This allows the window to grab greater system processing time if mlPeekActive and mlPeekProccessing. This way I avoid the use of another thread.
  Wait_For_Message:

invoke GetMessage, OFFSET msg, NULL, 0, 0
jmp GotMsg

Message_Loop:
cmp mlPeekActive, TRUE
jne Wait_For_Message
cmp mlPeekProccessing, TRUE
jne Inactive

call Main_Processing
jne Window_Close

Inactive:
invoke PeekMessage, OFFSET msg, NULL, 0, 0, PM_REMOVE
test eax, eax
je Message_Loop
GotMsg:
cmp msg.message, WM_QUIT
je MsgExit
invoke TranslateMessage, OFFSET msg
invoke DispatchMessage, OFFSET msg
jmp Message_Loop

Window_Close:
; display a critical error message

; post close message so window can finish before WM_QUIT
invoke SendMessage, h_Window, WM_CLOSE, 0, 0

; additional shut-down code

mov mlPeekActive, FALSE
mov mlPeekProccessing, FALSE
jmp Wait_For_Message

MsgExit:
invoke PostQuitMessage,msg.wParam

invoke UnregisterClass, wc.lpszClassName, h_Instance
invoke ExitProcess, msg.wParam
Posted on 2003-11-12 19:41:58 by bitRAKE

Is possible to create a thread to peek message of a certain window, and block itself if no message is peeked?

Isn't that the description of GetMessage? You can specify a window handle, instead of getting all messages from the queue. (Maybe you mean something else...)

EDIT: BitRAKE, just saw your post. Great code! :)
Posted on 2003-11-12 19:44:04 by QvasiModo
hmm, i noticed now. You want to create a thread. I didn't tried what you need but must work also.
Posted on 2003-11-12 19:45:44 by cakmak