473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Quick Quetion: GetCursorPos()

26
Hey there,

I'm experimenting with GetCursorPos instead of "static_cast"ing 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 4651
Jajjo
26
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 Expert 1GB
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
Cool, thanks man :)

I'll strive to test stuff myself in the future.
Jun 1 '09 #4
weaknessforcats
9,208 Expert Mod 8TB
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 Expert 256MB
@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 Expert 1GB
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
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
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...
8
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
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.