473,789 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Quick Quetion: GetCursorPos()

26 New Member
Hey there,

I'm experimenting with GetCursorPos instead of "static_cast"in g the LOWORD and HIWORD params. This is because I want to work with positions relative to teh screen.

Myt question is this: Does the POINT object get updated when the mouse is outside of the edge of my program? If not, how do I constantly update the cursor position regardless of whether it's inside the edges of my program?

Thanks guys/gals.
-Jajjo
Jun 1 '09 #1
6 4670
Jajjo
26 New Member
Also,

I found this on MSDN

Remarks

The cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor.
Is that answering my question? I 'm sorta new to all this and can't decipher that jargon :(

Ta
Jajjo
Jun 1 '09 #2
YarrOfDoom
1,247 Recognized Expert Top Contributor
I believe that quote from MSDN tells you that the coordinates that are returned always are absolute coordinates (pixels counted from the top-left corner of your screen), and not relative to the position and size of the window which contains the cursor.

You have to call GetCursorPos every time you want the current position of the cursor, and it works when your cursor is outside of your program's window too.

Here's an extra hint to help you out with future questions: you can easily test these kind of questions yourself by trying it, and outputting the results. It can save you a lot of time because you don't have wait for a response from someone else.
Jun 1 '09 #3
Jajjo
26 New Member
Cool, thanks man :)

I'll strive to test stuff myself in the future.
Jun 1 '09 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
It's been a very long time but are they still using WinProc? I seem to remember putting in a handler for the WM_MOUSEMOVE message. Every time the mouse moves that handler gets called.
Jun 1 '09 #5
Studlyami
464 Recognized Expert Contributor
@YarrOfDoom
I believe that the pixels are counted from the primary monitor. This means that if you are working on multiple monitors you could receive negative coordinates as the primary monitor is 0,0.
Jun 1 '09 #6
YarrOfDoom
1,247 Recognized Expert Top Contributor
You're probably right about that, I'll try it out as soon as I've connected my KVM-switch here.

edit: apparently my KVM switch doesn't work with a DVI-VGA converter, so I can't test.
Jun 1 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1158
by: nasirmajor | last post by:
dear alls, i have a simple (not for me) quetion for c# or vb.net programmers. i want a user to give any number and a programme prints a fibonacci series for that number.thanks
0
2812
by: ntm | last post by:
Hi all you good m8 I try to make my first small program in vb, but im not very succesfull :D (Im using Visual Studio 2005) Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand. But to start with i will be very happy if i can get "user32" dll to work :) Therefore i have try this code - but i got a 18 character long number back as...
8
6659
by: Rajesh Soni | last post by:
Hi! I'm getting a PInvoke error while trying to execute the following code... declaration: Structure POINTAPI Dim x As IntPtr
1
6135
by: Damjan Malis | last post by:
Hi guys... could anyone please help me with my problem getting mouse cursor position while desktop being locked (WIN + L). MSDN says: "The input desktop must be the current desktop when you call GetCursorPos. Call OpenInputDesktop to determine whether the current desktop is the input desktop. If it is not, call SetThreadDesktop with the HDESK returned by OpenInputDesktop to switch to that desktop." src:...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.