multithreading - My message loop in thread is not getting any messages -
i have created thread, want listen mouse messages app receives.
however peekmessage never returning true. tried min , max filter of 0.
here message loop:
peekmessage(lmessage, null, 0, 0, pm_noremove); while (true) { var rez = peekmessage(lmessage, null, 0, 0, pm_remove) if (rez) { // console.log('peekmessage true'); } sleep 1000; } // console.log('message loop eneded'); as hwnd null thought should receive messages window in app, im not getting though. know whats up?
i tried getmessage approach:
var rez = getmessage(lmessage, null, 0, 0); console.log('rez:', rez); however hangs , never gets console.log.
thanks
the documentation peekmessage says:
if hwnd null, peekmessage retrieves messages window belongs current thread, , messages on current thread's message queue hwnd value null.
[emphasis added]
a similar note in getmessage documentation.
the call getmessage stalls because there no message queue thread, , no messages wait for, wait forever.
if need window messages in thread, have thread create own message-only window , use target raw input. create message-only window call createwindowex hwndparent set hwnd_message.
otherwise, you'd need forward messages main message loop using postthreadmessage.
Comments
Post a Comment