Discussion:
Is it possible to change the cursor style?
(too old to reply)
Dave F.
2005-03-16 10:00:45 UTC
Permalink
Hi

I want to use the cursor that's displayed for the Matchprop command
(Paintbrush) in my own routine.

Is this available to vba?

Thanks

Dave F..
GTVic
2005-03-17 23:08:56 UTC
Permalink
If you wanted to use that icon as a mouse pointer on your VBA form you would screen capture it and use appropriate software to save it as a workable format (like .cur or maybe .ico). Then set the MouseIcon property on your form or controls to that file and finally set the MousePointer value to 99 (custom icon).

If you wanted to show that pointer while picking objects on the AutoCAD screen then I would say you cannot do that from VBA. There are several sw products which modify the AutoCAD screen in some way but I believe most are written in C as an arx module.
bcoward
2005-03-18 04:13:44 UTC
Permalink
Dave,

In your own routine via VBA you could use the LoadCursorFromFile API. I used to use this to load the old Walking Dino curos from old NT4. Look into the API and you'll find other uses for it.

Test the following code..

Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

Public Enum eCursorType
ecAppStarting = 32650 'The application starting (arrow and hourglass) cursor.
ecCross = 32515 'The cross-shaped cursor.
ecIBeam = 32513 'The text selection (I-beam) cursor.
ecIcon = 32641 'The empty icon cursor (Win NT only).
ecNo = 32648 'The circle with slash through it cursor.
ecNormal = 32512 'The normal arrow cursor.
ecSize = 32640 'The four-arrow resize/move cursor (Win NT only).
ecSizeAll = 32646 'The four-arrow resize/move cursor.
ecSizeNESW = 32643 'The double-arrow resize/move cursor pointing to the upper-right and lower-left.
ecSizeNS = 32645 'The double-arrow resize/move cursor pointing up and down.
ecSizeNWSE = 32642 'The double-arrow resize/move cursor pointing to the upper-left and lower-right.
ecSizeWE = 32644 'The double-arrow resize/move cursor pointing left and right.
ecUp = 32516 'The up arrow cursor.
ecWait = 32514 'The waiting (hourglass) cursor.
End Enum



'Purpose : Sets the curson for a specified from, from a file or resource.
'Inputs : lhwndForm The handle to the form.
' [sCursorPath] The path to a cursor.
' [lCursorHwnd] The handle to a cursor.
' [CursorType] A enumerated cursor type.

'Outputs : Returns the handle of the original cursor (to allow the cursor to be reset).

'Notes : Specify one of either the sCursorPath,lCursorHwnd or CursorType parameters.

Function FormCursorSet(lhwndForm As Long, Optional sCursorPath As String, Optional lCursorHwnd As Long, Optional lCursorType As eCursorType) As Long
Const GCL_HCURSOR As Long = (-12)

If Len(Dir$(sCursorPath)) > 0 And Len(sCursorPath) > 0 Then
'Load the cursor from file
lCursorHwnd = LoadCursorFromFile(sCursorPath)
FormCursorSet = SetClassLong(lhwndForm, GCL_HCURSOR, lCursorHwnd)
ElseIf lCursorHwnd Then
'Use the specified cursor handle
FormCursorSet = SetClassLong(lhwndForm, GCL_HCURSOR, lCursorHwnd)
ElseIf lCursorType Then
'Use the specified cursor types
lCursorHwnd = LoadCursor(ByVal 0&, CLng(lCursorType))
FormCursorSet = SetClassLong(lhwndForm, GCL_HCURSOR, lCursorHwnd)
End If
End Function

Good luck,

Bob Coward
CADS, Inc

800-366-0946
***@mindspring.com

Loading...