Hi Guys,
Ok, I think I know where you guys are headed. We needed to hold the cursor state in a static variable so that we could test and set the appropriate cursor in the function.
Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lCursorName As Long) As Long
Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Declare Function GetCursor Lib "user32" () As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function FileDlgFunction(identifier$, action, suppvalue)
'-------------Cursor Change Constants-----------
Const NORMAL_CURSOR = 32512
Const HOUR_GLASS_CURSOR = 32514
Sub SetMousePointer(lMouseCursor As Long)
Dim hCursor As Long
hCursor = LoadCursor(0, lMouseCursor)
SetCursor hCursor
End Sub
Sub Main
Dim button as integer
Dim identifier$
Dim action as Integer
Dim suppvalue as Integer
Begin Dialog newdlg 183, 52, "Show Hide Hour Glass", .FileDlgFunction
OkButton 130, 6, 50, 14
CancelButton 130, 23, 50, 14
CheckBox 29, 11, 62, 15, "Show HourGlass Cursor", .CheckBox1
End Dialog
Dim dlg As newdlg
button = Dialog(dlg)
End Sub
Function FileDlgFunction(identifier$, action, suppvalue)
Static CurCursor As String
On Error resume next
If CurCursor = "Normal" Then
SetMousePointer HOUR_GLASS_CURSOR
Else
SetMousePointer NORMAL_CURSOR
End If
Select Case action
Case 1
Case 2 'user changed control or clicked a button
If DlgControlID(identifier$)=2 then
If CurCursor = "Normal" Then
CurCursor = "HourGlass"
Else
CurCursor = "Normal"
End If
End If
End Select
End Function
Note: This works with mac's as well as mcx's.
Regards,
Roland