Retrieve mouse position

Hi, I am writing an app in which I need to retrieve the mouse coordinates 
even when it mouse is outside the main frame.  How do I do it?  Thanks!

xg


0
xg
4/19/2010 5:15:18 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1598 Views

Similar Articles

[PageSpeed] 55

>Hi, I am writing an app in which I need to retrieve the mouse coordinates 
>even when it mouse is outside the main frame.  How do I do it?  Thanks!

Have you tried calling GetCursorPos?
If you want to know when the mouse is moving I think you'll need to
use a hook - have a look at SetWindowsHookEx WH_MOUSE.

Dave
0
David
4/19/2010 8:11:08 AM
IN addition to David's answer, you have not stated the problem you are trying to solve. 

For example, in doing certain actions such as "rubber-band lines", you are operating in a
mode where you need to track the mouse, even though it is outside the bounds of the
window.  This is best done by using SetCapture to capture the mouse during the mouse-down
actions.  These algorithms are well-documented (see the "Scribble" app, the MFC trainging
app, which goes into great detail about this).

You did not say under what conditions you need to actually know where the mouse is, so in
addition to the "rubber banding" issue (including highlighting areas of the window, etc.)
you did not state what you are trying to accomplish; do you KNOW, by some means, when you
should look, or do you need to track the mouse, even though it is being used in some other
app.

Take a look at my hooks article on my MVP TIps site.  
					joe

On Mon, 19 Apr 2010 13:15:18 +0800, "xg" <xg1@yahoo.com> wrote:

>Hi, I am writing an app in which I need to retrieve the mouse coordinates 
>even when it mouse is outside the main frame.  How do I do it?  Thanks!
>
>xg
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
Joseph
4/19/2010 3:06:29 PM
In article <OndAb833KHA.5820@TK2MSFTNGP06.phx.gbl>, xg1@yahoo.com 
says...
> 
> Hi, I am writing an app in which I need to retrieve the mouse coordinates 
> even when it mouse is outside the main frame.  How do I do it?  Thanks!

GetCursorPos().

-- 
    Later,
    Jerry.
0
Jerry
4/19/2010 4:03:28 PM
Reply:

Similar Artilces:

How to retrieve the string from dialog box
Hi All, Does anyone know how to retrieve a string in IDC_STATIC on a dialog box? I have to print out a report with an application version at the bottom line for users to be aware of it in my application. I don't know how to retrieve the string in IDC_STATIC control on a dialog box. It would be very nice that someone let me know how to do that without calling the dialog box. TIA Hwasoo Lee Back 9 wrote: > Hi All, > > Does anyone know how to retrieve a string in IDC_STATIC on a dialog box? > I have to print out a report with an application version at the bottom line &g...

change default file open position for large shared spreadhseet
We have a large multi-sheet shared file that always opens to the second sheet with the entire sheet highlighted. Have to constantly switch back to the first sheet. How do I stop Excel from defaulting to a specific sheet? Or better yet, how do I set which sheet opens first and where it starts? Excel remembers the selection (and sheet) where it was last saved. So you could select the sheet/range that you want before you save the workbook. Or you could have a macro run when excel opens the file and do it for you: This would go in a General module: Option Explicit Sub Au...

retrieve an AVERAGE of a range using VLOOKUP to locate start/end d
Can I calculate the average of a range based on VLOOKUP? In other words, can I get Excel to "look up" the respective START / END dates of an investment position listed in Sheet 1 and then go and locate those 2 distinct cell values in in a different sheet (Sheet 2) utilizing VLOOKUP function and then return the calculated AVERAGE of the cells within that range back into Sheet 1? Appreciate any thoughts if doable in Excel in any way? tAKE A LOOK AT AverageIFS and see if that does what you want. If it were me, I'd probably enter the formula manually, record the resu...

How could I put a cursor on any position I want in scroll bar?
Hi dear! I'd like to put a scrollbar's tap on last position. My program created much some results files since it runned for a couple hours. So It is tiresome to find last test result's file because there are a lot file in that directory. Every time I had to move to last position in scroll bar even though annoying. -------- problem section in my program ------- CFileDialog dlg(TRUE, sFi , NULL, OFN_HIDEREADONLY|OFN_NOCHANGEDIR| OFN_ALLOWMULTISELECT,/...

Retrieve mouse position
Hi, I am writing an app in which I need to retrieve the mouse coordinates even when it mouse is outside the main frame. How do I do it? Thanks! xg >Hi, I am writing an app in which I need to retrieve the mouse coordinates >even when it mouse is outside the main frame. How do I do it? Thanks! Have you tried calling GetCursorPos? If you want to know when the mouse is moving I think you'll need to use a hook - have a look at SetWindowsHookEx WH_MOUSE. Dave IN addition to David's answer, you have not stated the problem you are trying to solve. For examp...

Retrieving comment using range name
I have singular cells in different places referenced by their range names. Is there a way to get the comments corresponding to the referenced ranges (singular cells)? Thanks in advance, Tomek Set testrng = Range("A3:A4", "C3:C4") comment1 = testrng(1).Comment.Text .... commentn = testrng(n).Comment.Text Stefi „topola” ezt írta: > I have singular cells in different places referenced by their range > names. Is there a way to get the comments corresponding to the > referenced ranges (singular cells)? > Thanks in advance, > Tomek > > did yo...

Retrieving messages
Help, I mistakenly restored all the defaults on Outlook (the computer did not crash) losing all the messages and address book. I have had to set up the application from scratch entering account details etc. Question is: are all the messages and contacts still held on the computer even the program needs to be set up again and, if so, how do I retrieve them. Any assistance greatly appreciated. Thanks. P89 If you made a backup of your system or My Documents, search for a file called Outlook.pst. If you have that you can import all the information. Al "peterson89" <peterson...

Retrieving lost messages after Synchronization in Outlook Express
Setup for my hotmail messages to be downloaded to Outlook Express. When tried to connect to see an old message, didn't realize that it was setup to auto synch. My messages were deleted from hotmail, and are now lost on Outlook Express after synching. Is there anyway to retrieve the lost messages from Outlook Express? I really needed some of the items in there, and had downloaded them so they wouldn't be lost. Thanks! ...

Retrieve
Hi how do i retrieve all the postings i have posted in this group. sometimes forget of where i posted my i will be glad to get to know how to pull out my own questions cheers Click on your name to view the profile...Then click 'Recent posts by this user' http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.excel.misc&p=1&tid=467a932d-65b6-4bb1-98e1-25def53a971a&mid=467a932d-65b6-4bb1-98e1-25def53a971a -- Jacob (MVP - Excel) "Amin" wrote: > Hi how ...

Outlook Address Book closes while using mouse
Windows XP (SP3 all patched up) with Outlook 2003 Version 11.8217.8221 SP3 with Exchange Server. Hello all, A couple weeks ago the following started to happen in Outlook AND Publisher 2003. No other programs experience this. First of all Outlook. If you open outlook and then click tools then address book and then click the drop down box under "Show Names from the:" and choose an address book from there with the mouse, Outlook closes up with an error signature: Appname: outlook.exe Appver 11.0.8217.0 AppStamp: 480f95d9 ModName: user32.dll ModVer 5.1.2600.5512 ModStamp: 48...

Dialog text only updated on mouse moves
My PreTranslateMessage() function has code in it to update some of the text in one of my dialog boxes. It works, but instead of updating it every second, it only udpates the text when my mouse is moving or clicking. Any ideas on what might be causing this? Thank you! Well, that's becuase PreTranslateMessage gets called only when there is message in the queue for that window. Instead use a timer. See OnTimer (WM_TIMER) AliR. <PloutzMR@Npt.NUWC.Navy.Mil> wrote in message news:1154456910.215194.170930@s13g2000cwa.googlegroups.com... > My PreTranslateMessage() function has c...

Retrieving
Is there any way to retrieve how many web pages are opened by Internet Explorer, and what URLs are opened by it, from another process? I searched for IHTMLDocument5 and so on, however, I could't find any hint. Please reply. Thanks in advance. Regards, Hyun-jik Bae ...

No free/busy information could be retrieved
Recently migrated from 5.5 to exch2003, once the 5.5 machine was turned off, users free/busy information is not available, if the 5.5 machine is turned on it is available, does anyone know what I need to so that the information is available after 5.5 is turned off? -- Thanks Sounds like you forgot to re-home the System Public Folders (specifically the Free/Busy Public Folder) before turning the old server off. Follow the details in this article for a list of things you should do in order to retire the 5.5 server. http://support.microsoft.com/default.aspx?scid=kb;en-us;307917 - referen...

charts and graphs position shifts when inserting new charts
When i tried to insert new charts or graphs into my slides, the other pictures, (charts/graphs/images etc) gets shifted. I have to re-arrange them again. Is there any way to work around this problem? Which version of PPT are you using? -- Echo [MS PPT MVP] http://www.echosvoice.com What's new in PPT 2007? http://www.echosvoice.com/2007.htm Fixing PowerPoint Annoyances http://tinyurl.com/36grcd PowerPoint 2007 Complete Makeover Kit http://tinyurl.com/32a7nx "wy" <wy@discussions.microsoft.com> wrote in message news:F0684D5E-74BF-4138-A2E3-99C91CAA3FEF@m...

retrieving my questions
I am still learning how to use this system to it's fullest. How can I locate the questions I have asked in the past? Is there an easy way? -- Zunibear in Montana It depends upon how you are viewing this forum. If using Outlook Express, make sure your view is set for all messages. You could then sort by "From". If you don't want to loose the threaded response view, don't sort, but you probably have a copy of any post you did in the "Sent Items" folder in Outlook Express. Look there, find the one you are interested in, and scroll to that date in the f...

crazy mouse?
mouse acts crazy, cells highlight, how do I stop--only in excel This is a known (but unacknowledged by Microsoft) bug. If you have a wheel on your mouse, try clicking it a few times. If you have a USB mouse, disconnect and reconnect it. Otherwise, you're stuck with Ctrl+Alt+Delete to shut down Excel. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "bmwridr" <bmwridr@discussions.microsoft.com> wrote in message news:D7F80D57-7E29-41E1-9D33-772D384F8040@microsoft.com... > mouse acts crazy, cells highlight, how do I...

How to retrieve SYSTEMTIME
When I use: SYSTEMTIME st; MyTime = CTime::GetCurrentTime(); MyTime.GetAsSystemTime(st); st.wHour, st.wMinute,st.wSecond are correctly loaded but st.wMilliseconds is always 000. What am I doing wrong? Ron H. x-- 100 Proof News - http://www.100ProofNews.com x-- 30+ Days Binary Retention with High Completion x-- Access to over 1.9 Terabytes per Day - $8.95/Month x-- UNLIMITED DOWNLOAD On Fri, 16 Sep 2005 10:30:03 -0500, "Ron H" <rharshbarger@mmm.com> wrote: >When I use: > > SYSTEMTIME st; > MyTime = CTime::GetCurrentTime(); > MyTime.GetAsSys...

Changing position of shapes in chart
How do I change to position of shapes and add effects to the organization chart? thanks, Matt Excel 2007, change position with drag and drop, add effects by r-clicking on a shape in the chart, select format shape Matt S wrote: > How do I change to position of shapes and add effects to the organization > chart? thanks, Matt ...

How do I retrieve
Is there a way to restore emails that were in the inbox before I did an easy transfer. System is Windows 7 with Outlook 2007 niether Easy Transfer or copy has any impact on the origonal data, which remains in the origonal PC (unless you did something else to it) "Glenn" <Glenn@discussions.microsoft.com> wrote in message news:0A92A4E7-6B84-4E2E-AD46-65544E08A801@microsoft.com... > Is there a way to restore emails that were in the inbox before I did an > easy > transfer. System is Windows 7 with Outlook 2007 Do you still have access to the origina...

Product key retrieval
A customers single RMS station died, and you guessed it, they lost their Product Key and have no backups of their database. I managed to take the hard drive out and install it in a PC with like hardware and it booted up, so I can start RMS and backup their hard database, but is there anyway to get the key? Perhaps hidden in the registry? Thanks in advance RMS version 2.0.0108 Windows Vista x86 SQL Express 2005 Their RMS reseller should have kept a copy of the license key and delivered the original licenses to the end user. If the software was purchased legally and they registered th...

No Free/busy information could be retrieved
When scheduling meetings we often see this for some people. It doesn't seem to be consistent. I have had users refresh the free/busy and also run the outlook /cleanfreebusy with no success. Any ideas? Jane What version of Outlook are you using? What version of Exchange? How are they connecting to the Exchange server (are they in the same office connecting via LAN or road warriors connecting via VPN or Outlook Anywhere or ?) -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide t...

How to retrieve emials for two different users??
My husband and I share the same email from the same server. But, we have different log ons on our computer. When I open Outlook first, I get my email, read, delete and so on. Then, when my husband opens outlook, he doesn't get any of the emails I just got. How can we each retrieve emails from the server at two different times? you both need to set outlook to leave mail on the server. it's under more settings in account properties. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com ...

Retrieve
Hi is there any way to link the results of a query back into a table, I am setting up a system whereas we have two main databases and a website hosted on Win 2k server using iis with the results displayed in ASP. Basically the query brings up the data that is required and I then need to send these results back into a table on the second database. I have set up "delete query" and then "append query" to stop the replication of data which are both set up automatically to work using a macro, this works except for one problem, the autonumber increments upon each append so...

User unable to retrieve mail after a certain date in Outlook 2007
I have a user using Outlook 2007 with Business Contact Manager over a VPN in cached mode. He is connected to Exchange 2000. He has been unable to retrieve emails since a cut off date 3 days ago. On Outlook Web access he can see the new emails but cannot see them on his Outlook. He has deleted his cached file, recreated it, and done the same for his Mail profile without success. He has not installed any new software. He is able to send emails without problems. There are no error messages. Other users connected to Exchange are unaffected. Suggestions? "AndrewB" <AndrewB@di...

Return row position of first blank cell in range?
In XL2007, is there a worksheet function that will return the row position of the first blank (no formula or data at all) cell in a named range? I've tried LOOKUP and MATCH with no success. Ed Is the range a single column? Do you want the relative row number (relative to the range) or the absolute row number (actual row number)? -- Biff Microsoft Excel MVP "Ed from AZ" <prof_ofwhat@yahoo.com> wrote in message news:e0530b1d-d5fc-4188-8720-f612eac22e84@b1g2000hsg.googlegroups.com... > In XL2007, is there a worksheet function that will return the row > position ...