JoeBurwell
asked on
Capturing Mouse Input to a modeless dialog box
In my application, selection of specific menu items causes the app to display two dialog boxes -- one for user selection of commands and one to display data. In certain instances the user may wish to continuously retrieve data (activated by clicking on a button the "control" dialog box). At this point the app must enter some type of loop that continuously retrieves the data (CDataRetrieve::OnRepeatRe trieve() ). Once the app enters the loop the user must click on a "Stop Retrieve" button to cancel the continous data retrieval. How can I program the app to stay in the loop while still:
a) allowing the user to left click on the "Stop Retrieve" button; and
b) ignoring any other messages (mouse movement, right click, keyboard entry, ...)
I don't need specific code examples unless it's the easiest way to describe the solution. I just need to know the best way to implement this type of loop.
Thanks in advance!
a) allowing the user to left click on the "Stop Retrieve" button; and
b) ignoring any other messages (mouse movement, right click, keyboard entry, ...)
I don't need specific code examples unless it's the easiest way to describe the solution. I just need to know the best way to implement this type of loop.
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Go to http://www.microsoft.com/msj to download the source code for Microsoft Systems Journal February 1997 Wicked Code. It implements a class called CWaitDialog.
Simply add the following to the body of your loop:
MSG msg;
if (GetMessage(&msg,0,0,0))
{
TranslateMessage(&m sg);
DispatchMessage(&ms g);
};
This will ensure that all messages are dispatched correctly during the execution of the loop - if you're only interested in a particular message range (as you mentioned, e.g. mouse messages, you might want to specify the range in the last 2 parameter of 'GetMessage()', e.g.
if (GetMessage(&msg,0,WM_MOUS EFIRST,WM_ MOUSELAST) )
If you're interested in messages that 'belong' to your dialog, provide its handle as the 2nd parameter to 'GetMessage()'
MSG msg;
if (GetMessage(&msg,0,0,0))
{
TranslateMessage(&m
DispatchMessage(&ms
};
This will ensure that all messages are dispatched correctly during the execution of the loop - if you're only interested in a particular message range (as you mentioned, e.g. mouse messages, you might want to specify the range in the last 2 parameter of 'GetMessage()', e.g.
if (GetMessage(&msg,0,WM_MOUS
If you're interested in messages that 'belong' to your dialog, provide its handle as the 2nd parameter to 'GetMessage()'
ASKER
Thanks for the quick response!
I started looking into the multithread possibility last night and just needed some reassurance. The article listed at codeguru.com should have enough info for me to solve this particular problem.
Thanks again!
I started looking into the multithread possibility last night and just needed some reassurance. The article listed at codeguru.com should have enough info for me to solve this particular problem.
Thanks again!
ASKER