as far as I know, after the thread creation is not the message queue. You need to call GetMessage or PeekMessage function about news, but still not receive information after I call
MSDN:
reference When a message is blocked by UIPI the last error, retrieved with GetLastError, is set to 5 (access denied). The thread to which The message is posted must have created a message queue, or else The call to PostThreadMessage fails. Use The following method to handle this situation. Create an event object, then Create the thread. Use the WaitForSingleObject function to wait for the event to be set to the signaled state before calling PostThreadMessage. In the thread to which the message will be posted, call PeekMessage to here to force the system to create the message queue. PeekMessage (& amp; MSG, NULL, WM_USER, PM_NOREMOVE WM_USER) Set the event, to indicate that the thread is ready to receive the posted messages. Although know meaning in Chinese but don't understand completely Below is the thread now do: easy language code . version 2The support library spec The subroutine thread Local variable MSG, MSG, MSG type of variable is to receive the information PeekMessage (MSG, 0 # WM_USER, # WM_USER, # PM_NOREMOVE) 'first check the message queue "0" this should be to create a queue? Judge circulation first (=true) in the operation of the PeekMessage (MSG, 0 # WM_USER, # WM_USER, # PM_REMOVE) 'check message queue "returns 0 "Debug output (MSG) message, MSG. WParam, MSG. The lParam) o 'output is 0 Sleep (2000) . Determine circulation tail () Then I API_PostThreadMessage (thread Id, 1, 1, 1) returns 0 first and then call GetLastError () returns 1159 Or delivery failure ah why PostThreadMessage at the back of the three parameters can be set to? For online answer such as follows CodePudding user response:
Use getmessage, don't sleep, don't worry cycle into suspended animation Dim MSGS as MSG Do If getmessage (0, 0, MSGS)=0, then exit the do The select case MSGS. Message Case WM_MOUSEMOVE . Case... . End the select Loop Such a process CodePudding user response:
If you don't want to replace with peekmessage need waitmessage sleep