[Solved] Change Pop-up Menu Cursor - Can't undo the change

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[Solved] Change Pop-up Menu Cursor - Can't undo the change

Post by IdeasVacuum »

It seems that the only way you can change the cursor of a pop-up menu is to change the system cursor?

If I change the system cursor before displaying the pop-up, that works fine. Cannot get the cursor to change back though.......

Code: Select all


Enumeration
#Win
#Menu
#Popup
EndEnumeration

Global    igCursorIsHand.i = #False
Global       ighArrowCur.i = LoadCursor_(#Null,#IDC_ARROW)
Global   ighCopyArrowCur.i = CopyImage_(ighArrowCur,#IMAGE_CURSOR,0,0,#LR_COPYRETURNORG)
Global     ighHandCursor.i = LoadCursor_(#Null,#IDC_HAND)
Global ighCopyHandCursor.i = CopyImage_(ighHandCursor,#IMAGE_CURSOR,0,0,#LR_COPYRETURNORG)

Procedure Win()
;--------------

       If OpenWindow(#Win, 0, 0, 200, 200, "Test",#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)

                  If CreatePopupImageMenu(#Popup)

                          MenuItem(1, "PB Website")
                          MenuItem(2, "PB Blog")
                          MenuItem(3, "PB Forum")
                           MenuBar()
                          MenuItem(4, "Exit")

                          SetCursor_(ighCopyHandCursor) ;Doesn't work
                  EndIf
       EndIf

EndProcedure

Procedure WaitForUser()
;---------------------

     Repeat
                   iEvent.i = WaitWindowEvent(1)
            Select iEvent

                         Case #WM_RBUTTONDOWN

                               If(igCursorIsHand = #False)

                                       SetSystemCursor_(ighCopyHandCursor,#OCR_NORMAL) ;works
                                        igCursorIsHand = #True
                               EndIf

                               DisplayPopupMenu(#Popup, WindowID(#Win))

                         Case #PB_Event_Menu

                               Select EventMenu()
                           
                                             Case 1 : RunProgram("http://www.purebasic.com")
                                             Case 2 : RunProgram("http://www.purebasic.fr/blog")
                                             Case 3 : RunProgram("http://www.purebasic.fr/english/index.php")
                                             Case 4 : iEvent = #PB_Event_CloseWindow
                               EndSelect
            EndSelect

     Until iEvent = #PB_Event_CloseWindow

EndProcedure

;###Main Entry Point
Win()
WaitForUser()
While WindowEvent():Wend

If(igCursorIsHand = #True)

       SetSystemCursor_(ighCopyArrowCur,#OCR_NORMAL) ;fails
EndIf

End
Now, here is the interesting bit - Right-mouse to pop-up, the hand cursor is displayed. OK.
If 'Exit' is chosen from the menu, the app exits but the cursor does not change to the default arrow, it is still the hand cursor. Not OK....
If any of the other menu items are chosen on the menu, the cursor changes back to the default arrow when it should still be the hand cursor......

Edit: Even more weird: If 'Exit' is chosen from the menu, the app exits but the cursor does not change to the default arrow, it is still the hand cursor. Not OK.... Run the app again, hand cursor is still system cursor, until you right-mouse to select from the pop-up, at which time the arrow cursor is restored! :shock: :shock: :shock:
Last edited by IdeasVacuum on Wed Aug 22, 2012 8:25 pm, edited 1 time in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[Solved] Re: Change Pop-up Menu Cursor - Can't undo the chan

Post by IdeasVacuum »

Aha, the original mouse pointer settings can be restored thus:

Code: Select all

SystemParametersInfo_(#SPI_SETCURSORS,0,#Null,#Null)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply