Advertisement

Non GL Question: Window messages and/or monitoring a variable? (help!!)

Started by May 23, 2001 10:30 AM
1 comment, last by deadbeat 23 years, 9 months ago
ok im confused. what im trying to do is when my program receives a specific window message I want it to go into a loop to do some stuff. problem is that if i send that message from another window, the window that sent the message basically "freezes" until the window receiving the message is finished with its loop of code. obviously i do not want this to happen...... I tried creating a work around by when it receives the window message setting a boolean to true and then having the program do this in its next cycle (this is used in nehes tut''s to draw the scene when not receiving window messages). something like this: while(!done){ if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ if (msg.message == WM_QUIT){ done = true; }else{ TranslateMessage (&msg) ; DispatchMessage (&msg) ; } }else if (dostuff == true){ //code here } now it works but it causes my cpu usage to stay at 100% while the program is running and obviously i dont want that either. there has to be a better way, anybody with any ideas please help! thanks -db jeff@hype52.com www.pricezapper.com
-dbjeff@hype52.comwww.pricezapper.com
Well, I''m assuming that you''re using SendMessage() to send the message from one window to another. What you want to do is change that to PostMessage(). The difference is that SendMessage() doesn''t return until the message has been processed. That is why that window will freeze until the other window has done it''s stuff. PostMessage() on the other hand puts the message in the queue and returns imediatly. This way the window that posted the message shouldn''t freeze while the other is processing the message.

j.w.
Advertisement
thanks a lot man! i figured there was something like that, there *had* to be, it just didnt make sense. thanks a lot!

i knew i loved this forum. :}

-db
jeff@hype52.com
www.pricezapper.com
-dbjeff@hype52.comwww.pricezapper.com

This topic is closed to new replies.

Advertisement