Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - GetCursorPos with VB.NET. How to use it?

Reply
 
Old 02-01-2009   #1 (permalink)
Willian F. Lopes


 
 

GetCursorPos with VB.NET. How to use it?

Hi!

I'm trying to use the GetCursorPos function with VB.NET. I did this:

1) A create Module. In this module I have this code:

Public Structure POINTAPI
Public x As Long
Public y As Long
End Structure

Public Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As
POINTAPI) As Long

2) In my main form I put a timer and it tick event I have this code:

Dim p As POINTAPI
Dim l As Long

' Get pointer position.
l = GetCursorPos(p)

' Display information.
Me.Text = CStr(p.x) + ", " + CStr(p.y)

My problem is that my mouse coordinates are always 0 ("0,0"). Where is my
error?

Thanks,

Willian




My System SpecsSystem Spec
Old 02-02-2009   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: GetCursorPos with VB.NET. How to use it?

William,

Will you please be so kind not to multipost, I see a long discussion about
this in an other newsgroup.

Cor

"Willian F. Lopes" <profwillian@xxxxxx> wrote in message
news:uSAl4OMhJHA.3380@xxxxxx
Quote:

> Hi!
>
> I'm trying to use the GetCursorPos function with VB.NET. I did this:
>
> 1) A create Module. In this module I have this code:
>
> Public Structure POINTAPI
> Public x As Long
> Public y As Long
> End Structure
>
> Public Declare Function GetCursorPos Lib "user32" (ByVal lpPoint As
> POINTAPI) As Long
>
> 2) In my main form I put a timer and it tick event I have this code:
>
> Dim p As POINTAPI
> Dim l As Long
>
> ' Get pointer position.
> l = GetCursorPos(p)
>
> ' Display information.
> Me.Text = CStr(p.x) + ", " + CStr(p.y)
>
> My problem is that my mouse coordinates are always 0 ("0,0"). Where is my
> error?
>
> Thanks,
>
> Willian
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46