I know you can use ShowCursor_() to hide the mouse cursor over a window, but is there a simple way to hide it only when it is over a certain gadget?
I'm wondering what the simplest method would be, and Windows-only is fine (I'm writing an MDI based program).
Ideas?
Hide cursor over specific gadget
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Hide cursor over specific gadget
Hi Kenmo
Here is one way. In a Repeat loop, test for the cursor position:
Then test to see if the cursor is inside the 'hot spot' where you don't want it displayed (unusual?) or want to change the cursor graphic:
The above is not a working code snippet, just a guide to the method.
Here is one way. In a Repeat loop, test for the cursor position:
Code: Select all
iCursorX = WindowMouseX(#WIN)
iCursorY = WindowMouseY(#WIN)
Code: Select all
If (iCursorX > 15) And (iCursorX < 75) And (iCursorY > 20) And (iCursorY < 40)
SetCursor_(ighHandCursor)
ElseIf (iCursorX > 750) And (iCursorX < 771) And (iCursorY > 20) And (iCursorY < 40)
SetCursor_(ighHandCursor)
Else
SetCursor_(ighCrossCursor)
EndIf
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Hide cursor over specific gadget
Code: Select all
Procedure SubClassProc(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
Case #WM_SETCURSOR
SetCursor_(0)
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
OpenWindow(0,0,0,800,600,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
hwnd = ImageGadget(0,100,100,0,0,LoadImage(0, #PB_Compiler_Home+"Examples\sources\data\background.bmp"))
SetProp_(hwnd, "oldproc", SetWindowLongPtr_(hwnd, #GWL_WNDPROC, @SubClassProc()))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
BERESHEIT
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Hide cursor over specific gadget
That is a very nice way netmaestro.
To handle more than one gadget:
It's feels a bit weird to lose your cursor though! What is the benefit of hiding the cursor over a gadget kenmo?
To handle more than one gadget:
Code: Select all
Procedure SubClassProc(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, msg)
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, msg)
Case #WM_SETCURSOR
SetCursor_(0)
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Hide cursor over specific gadget
I have an ImageGadget that is updated in near-realtime and draws at the cursor position... I just don't want the Windows cursor to be over it.
Thanks for the examples guys, I'll give them a try.
Thanks for the examples guys, I'll give them a try.
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Hide cursor over specific gadget
Oh I see. Perhaps you could 'park' the cursor away from the action, or offset it's location by a few pixels, or change the cursor to cross-hair so that it does not obscure so much.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.