|
Post by colorcodegameauthor on Dec 9, 2019 19:09:13 GMT -5
Hello All,
I recently watched Mark Dunham's Youtube video series on Game Programming. I learned a lot.
I then taught myself how to hide the mouse cursor.
Here is what I came up with. It works. I set bShow as a global variable
'0 gets converted to False in the calldll and hides the cursor
bShow = 0 gosub [CursorToggle]
'1 gets converted to True in the calldll and shows the cursor
bShow = 1 gosub [CursorToggle]
[CursorToggle] calldll #user32, "ShowCursor",_
bShow as boolean,_
CursorShowInt as Long return
'The calldll function returns an Int value that I've named CursorShowInt, I have no use for it currently
I put code into my right mouse click to turn off/on the cursor when I click
[Mouse.RightClick]
if bShow = 0 then bShow = 1 else bShow = 0
gosub [CursorShow]
wait
Hope someone finds this useful, Benjamin
|
|
|
Post by sarossell on Dec 9, 2019 22:17:07 GMT -5
Very cool.
I really enjoyed learning how to work with it. Thanks! I came up with a little demo.
' __ __ __ __ ' | . |_ _ _ |_ |__) /\ (_ | / |__) _ _ | _ | ' |__ | |_) (- | |_ \/ |__) /--\ __) | \__ | \ (_) (_ |( _) . ' / ' ' Program: Hide Cursor ' Date: 19.12.9 ' Version: 1.0 ' Description: DLL call to hide cursor when right mouse button is clicked. ' Notes: Based on original concept by Benjamin "colorcodegameauthor".
nomainwin
WindowWidth = 500 WindowHeight = int(WindowWidth/1.618) UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY = int((DisplayHeight-WindowHeight)/2)
bShow = 0 open "Hide Cursor" for graphics as #g #g, "place 50 100 ; color black"; #g, "\Right click mouse button inside this window to toggle cursor.";
#g, "trapclose [Quit]"
[MainLoop] while 1 #g, "when rightButtonDown [CursorToggle]" wait wend
end
[CursorToggle] calldll #user32, "ShowCursor",_ bShow as boolean,_ CursorShowInt as Long bShow = NOT(bShow) ' Toggle logic. goto [MainLoop]
[Quit] close #g
|
|
|
Post by James Grubbs (Jimmy) on Nov 13, 2023 22:54:22 GMT -5
Thanks for posting this. Was trying to hide the mouse pointer and this worked perfectly.
|
|
honky
Junior Member
Posts: 55
|
Post by honky on Nov 14, 2023 5:38:22 GMT -5
Good morning, What is the point of hiding the cursor? THANKS
|
|
|
Post by tsh73 on Nov 14, 2023 6:26:40 GMT -5
Imagine you are in a shooting game You move mouse, moving some high-tech sprite sights reticle But if you do not hide mouse cursor, you will still get standard mouse pointer over it.
|
|
honky
Junior Member
Posts: 55
|
Post by honky on Nov 15, 2023 4:06:33 GMT -5
Ah okay, in this case the cursor is replaced. Because without cursor, we are like a blind man in a tunnel without light. A PC without cursor is unusable
|
|
|
Post by tsh73 on Nov 15, 2023 7:52:57 GMT -5
In a driving simulator, first person view, you do not need cursor as well.
|
|
|
Post by Walt Decker on Nov 15, 2023 10:01:02 GMT -5
Ah okay, in this case the cursor is replaced. Because without cursor, we are like a blind man in a tunnel without light. A PC without cursor is unusable Not true. I have written data entry and graphics apps where the mouse cursor was not needed at all, in fact, when present it was actually confusing.
|
|
honky
Junior Member
Posts: 55
|
Post by honky on Nov 15, 2023 12:05:14 GMT -5
Sorry, but it's because I only do "everything by mouse". The keyboard is subject to the strikes
|
|
|
Post by Walt Decker on Nov 15, 2023 12:54:25 GMT -5
Sorry, but it's because I only do "everything by mouse". The keyboard is subject to the strikes And the mouse is not? What happens when one of the mouse buttons is pressed and released?
|
|
honky
Junior Member
Posts: 55
|
Post by honky on Nov 16, 2023 5:33:18 GMT -5
Sorry, but it's because I only do "everything by mouse". The keyboard is subject to the strikes And the mouse is not? What happens when one of the mouse buttons is pressed and released?
There is what is planned in the code, and if nothing is planned, nothing happens.
|
|