Capturing Mouse Input to a modeless dialog box

Posted on 1999-07-21
Medium Priority
Last Modified: 2013-11-20
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::OnRepeatRetrieve() ).  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!
Question by:JoeBurwell
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Author Comment

ID: 1310924
Edited text of question.
LVL 23

Accepted Solution

chensu earned 1200 total points
ID: 1310925
Two methods:

1. Multithread

Look into my article at CodeGuru.

2. PumpMessage

There is an article in MSJ.

LVL 23

Expert Comment

ID: 1310926
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.
LVL 86

Expert Comment

ID: 1310927
Simply add the following to the body of your loop:

MSG msg;

   if (GetMessage(&msg,0,0,0))

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_MOUSEFIRST,WM_MOUSELAST))

If you're interested in messages that 'belong' to your dialog, provide its handle as the 2nd parameter to 'GetMessage()'


Author Comment

ID: 1310928
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!


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question