ExamineMouse *Solved, Props to netmaestro*
-
- Enthusiast
- Posts: 125
- Joined: Sat Jun 17, 2006 3:15 pm
ExamineMouse *Solved, Props to netmaestro*
Why does examine mouse:
+-+ Prevent the cursor from leaving the window
+-+ Hide the default cursor
Is there a way to stop both those effects?
Thanks,
Ori
+-+ Prevent the cursor from leaving the window
+-+ Hide the default cursor
Is there a way to stop both those effects?
Thanks,
Ori
Last edited by ..::Origin::.. on Fri Aug 25, 2006 8:30 am, edited 1 time in total.
-
- Enthusiast
- Posts: 196
- Joined: Tue Sep 30, 2003 4:32 pm
- Location: The Netherlands
Correct see the manual this snipit from the help file:
Jan V.
Code: Select all
PureBasic provides a full access to mices plugged to the computer. It supports standard mouses upto 3 buttons. This library is optimized and use very low level functions especially for use with games. Don't use the commands of this library in a regular application, in this case carry out the mouse query with WindowMouseX(), WindowMouseY() and EventType(). Under Windows the DirectX technology is used.
Life goes to Fast, Enjoy!!
PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!
AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!
AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
-
- Enthusiast
- Posts: 125
- Joined: Sat Jun 17, 2006 3:15 pm
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
If you need access to the whole desktop when you're running a windowed screen application or game, you can't do InitMouse() and ExamineMouse() and you can't use the commands in the Mouse library. PureBasic or API substitutes exist for all these commands and you'll need to use those:
MouseX(), MouseY(): WindowMouseX(), WindowMouseY()
MouseDeltaX(), MouseDeltaY(): compute these with code from earlier values
MouseLocate(): MapWindowPoints_(), SetCursorPos_()
MouseButton(): GetAsyncKeyState_(#VK_LBUTTON), GetAsyncKeyState_(#VK_RBUTTON)
MouseX(), MouseY(): WindowMouseX(), WindowMouseY()
MouseDeltaX(), MouseDeltaY(): compute these with code from earlier values
MouseLocate(): MapWindowPoints_(), SetCursorPos_()
MouseButton(): GetAsyncKeyState_(#VK_LBUTTON), GetAsyncKeyState_(#VK_RBUTTON)
BERESHEIT
-
- Enthusiast
- Posts: 125
- Joined: Sat Jun 17, 2006 3:15 pm
Ah-ha, sweet. So it was acctualy my engine and not the functions screwing up on me.
I've re-written my engine to work with these functions instead, although i've found that WindowMouseX()/WindowMouseY() wont be reported unless the mouse has acctualy moved in the window.
I'm thinking of something that may fix this, any advice would be good.
Edit: No, it did not work.
I've re-written my engine to work with these functions instead, although i've found that WindowMouseX()/WindowMouseY() wont be reported unless the mouse has acctualy moved in the window.
I'm thinking of something that may fix this, any advice would be good.
Edit: No, it did not work.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Code: Select all
; Yet another useless program from netmaestro
;
; Shows example procedures for using mouse commands in
; windowed screens when you don't want the mouse captured
Global LBTN_STATUS, RBTN_STATUS
Procedure LeftButtonPushed()
If GetAsyncKeyState_(#VK_LBUTTON) & 32768
LBTN_STATUS = 1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure RightButtonPushed()
If GetAsyncKeyState_(#VK_RBUTTON) & 32768
RBTN_STATUS = 1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure LeftButtonReleased()
If GetAsyncKeyState_(#VK_LBUTTON) & 32768
LBTN_STATUS=1
ProcedureReturn #False
Else
If LBTN_STATUS
LBTN_STATUS=0
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
Procedure RightButtonReleased()
If GetAsyncKeyState_(#VK_RBUTTON) & 32768
RBTN_STATUS=1
ProcedureReturn #False
Else
If RBTN_STATUS
RBTN_STATUS=0
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
Procedure Locate(x,y)
cp.point
MapWindowPoints_(WindowID(0),0,@cp,1)
SetCursorPos_(cp\x+20, cp\y+20) ; 20 = Offset of WindowedScreen on Window
ProcedureReturn
EndProcedure
Procedure GetMouseX()
ProcedureReturn WindowMouseX(0)-20 ; 20 = Offset as above
EndProcedure
Procedure GetMouseY()
ProcedureReturn WindowMouseY(0)-20
EndProcedure
Procedure MouseInScreen()
If GetMouseX() >= 0 And GetMouseX() <= 480 And GetMouseY() >=0 And GetMouseY()<=440
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
InitSprite()
OpenWindow(0,0,0,640,480, "Windowed Screen Mouse Substitutes", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
TextGadget(0,520,20,110,20,"")
TextGadget(1,520,60,110,20,"")
TextGadget(2,520,100,110,20,"")
TextGadget(3,520,140,110,20,"")
ButtonGadget(4,520,180,110,20,"Set Cursor to 0,0")
OpenWindowedScreen(WindowID(0),20,20,480,440,0,0,0)
Repeat
ev=WindowEvent()
If ev=#PB_Event_Gadget
If EventGadget()=4
Locate(0,0)
EndIf
EndIf
If MouseInScreen()
outstr.s = Str(GetMouseX())+","+Str(GetMouseY())
Else
outstr.s = "0,0"
EndIf
SetGadgetText(0,outstr)
If LeftButtonPushed() ; will test true while button is down
SetGadgetText(1, "LeftButton DOWN")
Else
SetGadgetText(1,"LefButton UP")
EndIf
If RightButtonPushed() ; will test true while button is down
SetGadgetText(2, "RightButton DOWN")
Else
SetGadgetText(2,"RightButton UP")
EndIf
If RightButtonReleased() ; only fires once on release
SetGadgetText(3, "RightButton Released")
Delay(300)
SetGadgetText(3,"")
EndIf
If LeftButtonReleased() ; only fires once on release
SetGadgetText(3, "LeftButton Released")
Delay(300)
SetGadgetText(3,"")
EndIf
Delay(1)
Until ev=#WM_CLOSE
Last edited by netmaestro on Fri Aug 25, 2006 10:33 am, edited 1 time in total.
BERESHEIT
-
- Enthusiast
- Posts: 125
- Joined: Sat Jun 17, 2006 3:15 pm
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
In the code I posted, the mouse position is being reported and displayed in each loop. If WindowMouseX() or Y() were not testing correctly, it would display 0,0 right away. As the coordinates always display correct, it is working. If it isn't working for you, perhaps you could post some code.
Didn't mean to offend - just might as well post it all as post cut-out pieces of a demo.Thanks, but i said i figured that out.
BERESHEIT
-
- Enthusiast
- Posts: 125
- Joined: Sat Jun 17, 2006 3:15 pm
Hmm, interesting. I just had a look at your example with the debug and it seems to do what i was hoping mine would do... I'll keep looking through mine, will edit when if something comes up.
Edit:
...WindowWaitEvent()...*Rolls Eyes* - EVIL!!
Argh, sorry for wasting your time or offending you(if i did) netmaestro.
Thanks alot for the help, i hope i can pay you back one day.
*Solved*
Edit:
...WindowWaitEvent()...*Rolls Eyes* - EVIL!!
Argh, sorry for wasting your time or offending you(if i did) netmaestro.
Thanks alot for the help, i hope i can pay you back one day.
*Solved*