I'm making a program with a database connection. In my code I'm using
Screen.MousePointer = vbHourglass
When I run it in design mode it works perfectly,
you see the hourglass and it stops when the next form is loaded with the data from the database.
But when I make an .exe and I run that the hourglass doesn't appears when it should.
The reason the houglass returns to default when you leave the form is because cursor events are relative to your program only. If a user is multitasking, they will expect to be able to use their other prgrams as normal.
If the cursor becomes default when you move from one form to another, then you shouldput an event in the On Load event of the new form, to set the cursor as an houglass.
The only other advice I can offer is to use API calls. This will set the cursor regardless of programs status. Its fine to use, but if a user moves to another program during its operation, the houglass will remain.
Code:
Const IDC_APPSTARTING = 32650
Const IDC_ARROW = 32512
Const IDC_CROSS = 32515
Const IDC_IBEAM = 32513
Const IDC_ICON = 32641
Const IDC_NO = 32648
Const IDC_SIZE = 32640
Const IDC_SIZEALL = 32646
Const IDC_SIZENESW = 32643
Const IDC_SIZENS = 32645
Const IDC_SIZENWSE = 32642
Const IDC_SIZEWE = 32644
Const IDC_UPARROW = 32516
Const IDC_WAIT = 32514
Declare Function LoadCursor Lib "user32.dll" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub mHourGlass()
' Display the application starting (arrow and hourglass) Windows
' cursor for three seconds. The cursor resource is loaded from Windows. Then
' restore the old cursor (whatever it happens to be).
Dim hCursor As Long ' receives handle to application starting cursor
Dim holdcursor As Long ' receives handle to previously used cursor
Dim retval As Long ' throw-away return value
hCursor = LoadCursor(0, IDC_WAIT) ' load Windows's application starting cursor
holdcursor = SetCursor(hCursor) ' set it to the new cursor
Sleep 3000 ' wait for 3 seconds
retval = SetCursor(holdcursor) ' set it to the previous cursor
End Sub