SetCursor API problems...

G

Guest

Hello..

I'm attempting to use API functions to change the mouse cursor to a
crosshair when a certain chart is activated. Have pulled some code off
another post, but it does not seem to work. Does anyone have any other
sugestions:

Code sample:

Private Declare Function LoadCursorBynum Lib "user32" Alias _
"LoadCursorA" (ByVal hinstance As Long, ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As
Long

Public Const IDC_CROSS = 32515& ' Crosshair

Public Function MouseCursor(CursorType As Long)
Dim lngRet As Long
lngRet = LoadCursorBynum(0&, CursorType)
lngRet = SetCursor(lngRet)
End Function

Thanks,
Dave


----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...df7bbc8&dg=microsoft.public.excel.programming
 
G

Guest

....just bumping this up a bit!

I want to be able to force the mouse pointer to a cross hair icon so that
users can pick off values from a graph easily. Unfortunatley the
Application.Cursor property does not have this flexibility.

This SetCursor API function should work in theory, but seems to be overuled
by the Excel app?

Thanks again,
Dave
 
N

NickHK

Dave,
If you try that code in a Button-click event, you can get the Cursor to
change to a cross hairs, but as soon as you move it, Excel resets it.
I can see a quick change to the cross hair over a chart, but Excel
immediately resets it.

The API call appear to return valid hCursor values, so the calls succeed,
but are over-ridden by Excel.

Looks like you would have to get more complex to fight against Excel to
achieve this.

NickHK

Dave Ramage said:
...just bumping this up a bit!

I want to be able to force the mouse pointer to a cross hair icon so that
users can pick off values from a graph easily. Unfortunatley the
Application.Cursor property does not have this flexibility.

This SetCursor API function should work in theory, but seems to be overuled
by the Excel app?

Thanks again,
Dave
http://www.microsoft.com/office/com...df7bbc8&dg=microsoft.public.excel.programming
 
G

Guest

I was affraid of that, but thanks anyway!

NickHK said:
Dave,
If you try that code in a Button-click event, you can get the Cursor to
change to a cross hairs, but as soon as you move it, Excel resets it.
I can see a quick change to the cross hair over a chart, but Excel
immediately resets it.

The API call appear to return valid hCursor values, so the calls succeed,
but are over-ridden by Excel.

Looks like you would have to get more complex to fight against Excel to
achieve this.

NickHK


http://www.microsoft.com/office/com...df7bbc8&dg=microsoft.public.excel.programming
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top