mousex(), mousey()

BlitzMax Forums/BlitzMax Programming/mousex(), mousey()

CS_TBL(Posted 2006) [#1]
How do I get the mouse-on-screen coordinates with maxgui? Not using classic Graphics, just a maxgui-window here. I want to make my own dragbar in my own window. Made it before in B+, went well.. it's just that I need the mouseposition on the screen in maxgui..!


Dreamora(Posted 2006) [#2]
Check for the mousemove event, it holds the mouse position.


Eric(Posted 2006) [#3]
Global MX:Int
Global MY:Int
Select EventID()
 Case Event_MouseMove
	MX=EventX()
	MY=EventY() 
End Select


This is just meant to put you on the right track. Hope it helps.


CS_TBL(Posted 2006) [#4]
Eric: doesn't work. I need the mousecoord on the screen, not the coordinate on a canvas/panel, just the way it worked in B+! I need to compare my canvas-x/y with the screen x/y, that's why I need screencoords. :P


Eric(Posted 2006) [#5]
oh I misunderstood.. Does EnablePolledInput() Work?

nope...I just tried it.


CS_TBL(Posted 2006) [#6]
nope, besides I refuse any polling on this planet. Events it will be and stay.. :P


Kanati(Posted 2006) [#7]
Think you need GetCurrentPositionEx()


CS_TBL(Posted 2006) [#8]
where to find/how to use?


CS_TBL(Posted 2006) [#9]
Ok, it's in msdn, more specific then: "how to use?"

BOOL GetCurrentPositionEx(
  HDC hdc,        // handle to device context
  LPPOINT lpPoint // current position
);


and:

typedef struct tagPOINT { 
  LONG x; 
  LONG y; 
} POINT, *PPOINT; 



* no experience with all this.. :P


Grey Alien(Posted 2006) [#10]
Type TPoint
	Field X
	Field Y
End Type

Function ccGetCursorPos:TPoint()
	'Returns a TPoint
	?Win32 
	Local point:TPoint = New TPoint
	If Not GetCursorPos(point) Then
    	ccRunTimeError ("Error Getting Cursor Pos")	
		Return Null
	Else
		Return point
	EndIf
	?
End Function


This get's it relative to the desktop top left, not sure if it helps. BUT you can work out your window (or client area) top left and calc the X Y in the app. All part of my Game Framework ;-)


CS_TBL(Posted 2006) [#11]
erhm, what's GetCursorPos ? :P And is it multi-platform anyway?


Grey Alien(Posted 2006) [#12]
oops:

?win32
Extern "win32"
	Function GetCursorPos%(point: Byte Ptr)
End Extern
?


and um ... the win32 answers your second question...

Anyway, I posted that cos the MSDN code you posted is Windows based too ... Big ;-p


CS_TBL(Posted 2006) [#13]
hm, dunno if it works.. it only returns the 'screencoord' from a canvas, not just the coord of 'whatever'.. have to try. Anyway, the classic mousex() and mousey() from B+ are lost it seems..


Grey Alien(Posted 2006) [#14]
what only returns screen coord from a convas? My code returns relative to the desktop for sure I use it!


CS_TBL(Posted 2006) [#15]
hm.. I don't think it works.. it bugs.. and it's more or less 1:1 c/p'ed from a B+ source where it worked..
Bottomline: someone oughta bring back the mousex/y from the grave, where they'll work everywhere on screen.., in any circumstances!