hdj1958
                   
                   
                   
                  Joined: 09 Jul 2009 
                  Posts: 9 
                  Location: tenerife/spain
                    | 
                
                  
                  
                   hi all,
 
if have some questions about "using messages and message queues"
 
 
on microsoft web page "http://msdn.microsoft.com/en-us/library/ms644928(VS.85).aspx" i have found this:
 
"this message loop retrieves messages from the thread's message queue and dispatches them to the appropriate window procedures."
 
 
thats my messageloop:
 
 
getmessageloop:
 
 invoke    GetMessage ,sys_windowmessage ,NULL ,0 ,0
 
 or        eax,eax             ;If the function retrieves the WM_QUIT message, the return value is zero.
 
 jz        ReturnToWindow
 
 cmp       eax,-1              ;If there is an error, the return value is -1
 
 je        ReturnToWindow
 
 
 invoke    TranslateMessage,sys_windowmessage
 
 invoke    DispatchMessage,sys_windowmessage
 
 jmp       getmessageloop
 
 
below on that page i have found in the section "Examining a Message Queue" this one:
 
"Occasionally, an application needs to examine the contents of a thread's message queue from outside the thread's message loop. For example, if 
 
 
an application's window procedure performs a lengthy drawing operation, you may want the user to be able to interrupt the operation. Unless your 
 
 
application periodically examines the message queue during the operation for mouse and keyboard messages, it will not respond to user input until 
 
 
after the operation has completed. The reason for this is that the DispatchMessage function in the thread's message loop does not return until the 
 
 
window procedure finishes processing a message. 
 
if i have understood it well does it mean that dispatchmessage will ever wait until the window procedure finishes processing its actually message AND 
 
 
cannot continue with "jmp getmessageloop"?
 
 
the section "Sending a Message" explain this:
 
The SendMessage function is used to send a message  "DIRECTLY"  to a window procedure. SendMessage calls a window procedure and waits for 
 
 
that procedure to process the message and return a result. 
 
 
is it true that "sendmessage" jumps directly to 
 
proc     MainWindowProc, msg_hwnd, msg_wmsg, msg_wparam, msg_lparam
 
 ....
 
endp
 
and NOT PASS by "getmessageloop:" with "getmessage, translatemessage, dispatchmessage" ?
 
 
the other questions is (from section "Posting a Message"):
 
is it true that "PostMessage places a message at the end of a thread's message queue and returns immediately, without waiting for the thread to 
 
 
process the message"?
 
and does it mean that "postmessage" passes by "getmessageloop" with "getmessage, translatemessage, dispatchmessage" ?
 
 
maybe these questions are a little bit strange for you, but i have some problems with "postmessage" and the message loop, please have a look to 
 
 
the following:
 
 
i have a data base with nearly 100 url which the program has to download, after a click on the menu-item (ID=102) "start download" the download 
 
 
begins, during the download the processor will never pass by "getmessageloop:" so microsoft recommends to use "peekmessage" (see above), but 
 
 
"peekmessage" will NOT REMOVE from the message queue e.g. "WM_PAINT" and some other messages and moreover i have many import 
 
 
functions in the
 
proc     MainWindowProc, msg_hwnd, msg_wmsg, msg_wparam, msg_lparam
 
 ....
 
endp
 
so that i will execute the download (step by step/url by url) and the other functions TOO, and i will not write all the function which i have already in the 
 
 
"proc MainWindowProc" anonther time in a "proc xxxx" with "peekmessage" and when i have finished the download, that there are still waiting some 
 
 
message which i have already proceeded, therefore i have writen the following code:
 
 
 
proc     MainWindowProc, msg_hwnd, msg_wmsg, msg_wparam, msg_lparam
 
 
...
 
 
 cmp   eax,WM_CLOSE
 
 je     mwp_wmclose
 
 cmp     eax,WM_DESTROY
 
 je   mwp_wmdestroy
 
 cmp   eax,WM_SIZE
 
 je      .wm_size003
 
 cmp     eax,WM_PAINT
 
 je     .wm_paint004
 
...
 
 
.wm_subscription102:
 
 cmp eax,IDM_SUBSCRIPTION102
 
 jne .wm_subscription103
 
 
 invoke      EnableMenuItem ,[newsreader_menuhandle] ,IDM_SUBSCRIPTION101 ,MF_GRAYED
 
 invoke      EnableMenuItem ,[newsreader_menuhandle] ,IDM_SUBSCRIPTION102 ,MF_GRAYED
 
 mov eax,[newsreader_subscriptionmemoadr]            ;start subscription list
 
 mov        [newsreader_subscriptionnextpointer],eax        
 
 invoke     PostMessage, [newsreader_mainwindowhandle] ,WM_USER+102 ,0 ,0   ; passing by getmessageloop
 
 jmp     .wm_end
 
 
...
 
 
.wmuser102:
 
 cmp   eax,WM_USER+102
 
 jne .wmuser103
 
 call     newsreadersubscription102downloadrssfeeds
 
 or        eax,eax
 
 jz  .wm_end   ; = ERROR
 
 ; continue next URL
 
 invoke  PostMessage, [newsreader_mainwindowhandle] ,WM_USER+102 ,0 ,0   ; passing by getmessageloop
 
 jmp     .wm_end
 
 
 ....
 
 
.wm_end:
 
        ret
 
 
endp
 
 
this "LOOP" is goeing quite well and does download all url - BUT 
 
a) the menu bar is blocked completly, so that i cannot open/click/choose the menu-item "STOP/BREAK",
 
b) i cannot close the window with a click on "X"
 
 
so - does have somebody an idea where is the stupid mistake - smile,
 
or maybe in which way i could write a better code
 
or maybe somebody does know other threats here where i can find some more helps
 
 
thanks and regards 
                  
                 |