How to get global cursor info using GetCursorInfo

I was not able to call GetCursorInfo method in the "user32" lib in VBCODE. Can the expert please show how this method can be implemented in a vb project
Thanks in advance
manish_tgAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shiju SasidharanAssoc Project ManagerCommented:
hi

here is an example that uses GetCursorInfo
u can Download  Source code from this link

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=50310&lngWId=1

;-)
Shiju
0
Mikal613Commented:
GetCursorInfo Function

--------------------------------------------------------------------------------

The GetCursorInfo function retrieves information about the global cursor.

Syntax

BOOL GetCursorInfo(          PCURSORINFO pci
);
Parameters

pci
[out] Pointer to a CURSORINFO structure that receives the information. Note that you must set CURSORINFO.cbSize to sizeof(CURSORINFO) before calling this function.
Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.




Function Information

Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 98, Windows  
0
zzzzzoocCommented:
Form1:
------------------------
Option Explicit

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type PCURSORINFO
    cbSize As Long
    flags As Long
    hCursor As Long
    ptScreenPos As POINTAPI
End Type

Private Declare Function GetCursorInfo Lib "user32.dll" (ByRef pci As PCURSORINFO) As Long
Private Sub Form_Load()
    Dim typCI As PCURSORINFO
    typCI.cbSize = Len(typCI)
    If GetCursorInfo(typCI) <> 0 Then
        Debug.Print typCI.flags, typCI.hCursor, typCI.ptScreenPos.x & "," & typCI.ptScreenPos.y
    End If
End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mikal613Commented:
GetCursor will return a handle to the current cursor which you could then compare with a standard pointer to see which it is

GetCursorInfo returns a CURSORINFO struct which also includes if it is visible and its position.


To test which sort of pointer is being shown, you could use CopyImage to copy the selected cursor's image and CopyImage on system cursor (which you load using LoadCursor) then compare the bits of the image...

0
manish_tgAuthor Commented:
Thanks zzzzzooc . Your code was what I was requiring and it worked perfectly thanks.

Can you tell we what FLAGS and HCURSOR values means.

Actually I am using this information to find whether the mouse is being handled exclusively by some directX application or it is under the control of the window OS.

When i using any normal windows application, i get Flag=1 and HCURSOR=5254

but when I am using a Fulscreen Game Application that uses DirectX, i get Flag=0 and HCURSOR=0

Can i assume that whenever Flag and HCURSOR are zero, it means the mouse is being accessed exclusively by some directX application? Thanks for your code
0
zzzzzoocCommented:
The below is documentation on the structure.

"CURSORINFO Structure"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorstructures/cursorinfo.asp

>> it means the mouse is being accessed exclusively by some directX application
As the link above mentions, Flag will be 0 if the cursor is hidden and hCursor will be 0 if the current cursor has no handle to a loaded cursor. Usually for DirectX games, they'll use their own cursors and hide the current one, so it's safe to use this method. You may want to test different games, though.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
manish_tgAuthor Commented:
Thanks buddy. A very useful comments and you have solved by big problem cheers!!!. This should work on NT and XP too....right, I have tested on 98.
0
zzzzzoocCommented:
"Minimum operating systems Windows 98, Windows NT 4.0 SP6"

Worked for me on Win2k Pro. Good luck. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

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.