Capturing mouse without Drag

Posted on 2003-03-26
Medium Priority
Last Modified: 2013-11-20
Hi All,
     I've been trying to have my dialog based Application keep the mouse Focus as a User Clicks a certain point. Here is what the Application should do when the User Clicks certain area.
1. The Mouse Capture Should be Set to the Window even if the Button is Released.
2. The Window Should recieve all Mouse Messages even if Mouse Pointer is not over the window. i.e even if mouse is over any other application or desktop, Application should Recieve its messages.
3. Once Clicked again and Mouse is Already Captured the Capture Should be released.
    Help will be appriciated.
Question by:UsmanAnsari

Expert Comment

ID: 8212977
Typically when capturing the mouse you capture (using CWnd::SetCapture()) in the mouse down event and release in the mouse up event.  There is no requirement you do it that way.

You want to capture on the first mouse down event, then release on the next mouse down event.

This may be confusing to the user if they do not realise they are in some special state.  I recommend that you change the mouse cursor while you have the mouse captured to indicate the special state.

Author Comment

ID: 8217038
Yup that is What I want to Do but the Problem is how do it? as i capture mouse with SetCapture Method once the mouse goes out of the "vision" of the window that has captured it. the Window no longer recieves mouse's messages.
 So what i want is to have the window keep recieving messages even if the mouse is on some other window.

Expert Comment

ID: 8217541
If the mouse pointer moves out of the client area you can check WM_NCMOUSEMOVE /CWnd::OnNcMouseMove  messages.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.


Expert Comment

ID: 8220364
Once you capture you should get mouse move messages even if the mouse is moved off the window.  You may stop getting them if the user manages to change the focus to another program.

Author Comment

ID: 8222917
Check out Zoom+ at
He manages to get Mouse messages even if any other window is activated. this is something i had in mind for myself.
although the source code is provided but I'm having a hard time figuring it out. Help any one...

Accepted Solution

modulo earned 0 total points
ID: 11834295
PAQed, with points refunded (20)

Community Support Moderator

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…
Suggested Courses

600 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