-
June 9th, 2004, 10:42 PM
#1
Get message when excute a infinite loop
hi, guys
Is there any functions in Visual C++ which have the same function like DoEvents in VB or doEvents in Java?
I have to make the program get response to a windows message when it is running in a infinite loop.
Is there any fuction can achieve this?
thank u very much in advance!
-
June 10th, 2004, 01:10 AM
#2
Hi there were 96 results, i found by searching these forum for keyword 'DoEvents'. Check it Out here
-
June 10th, 2004, 01:34 AM
#3
Re: Get message when excute a infinite loop
Originally posted by jfk_lili
hi, guys
Is there any functions in Visual C++ which have the same function like DoEvents in VB or doEvents in Java?
I have to make the program get response to a windows message when it is running in a infinite loop.
Is there any fuction can achieve this?
thank u very much in advance!
Code:
void CDlg::DoEvents()
{
MSG msg;
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
-
June 10th, 2004, 03:18 AM
#4
Amit and Alin thank u guys very much. Now it works fine.
and Alin, i hv tried to delete the TranslateMessage, and make it like this:
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE ))
{
DispatchMessage(&msg);
}
and in my program, it works also fine. I hv read MSDN abt TranslateMessage, but i m still not sure about the function of it.
Could u please give me more detail abt it? or is there any article abt it? better wiz an example
Thank u very much in advance!!!
-
June 10th, 2004, 03:45 AM
#5
Hi, jfk_lili !
I have to make the program get response to a windows message when it is running in a infinite loop
In multithreaded system you should use a worker thread to perform a "infinite loop", having your main (GUI) thread still responsible.
Take a look at this J.Newcomer's article:
Using Worker Threads
-
June 10th, 2004, 05:12 AM
#6
Thanks very much VictorN!
so what have been suggested above just can work under a single thread environment? for multi-thread it cannot work?
-
June 10th, 2004, 05:22 AM
#7
for multi-thread it cannot work?
I wrote you: "... you should...", not "you MUST" use a worker thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|