Dectect Mouse exiting window

BlitzPlus Forums/BlitzPlus Programming/Dectect Mouse exiting window

Grey Alien(Posted 2005) [#1]
Anyone know how to detect if the mouse pointer has left the window? I am using my own mouse pointer in the window and thus calling Hide Pointer. Problem is that when the mouse pointer exits the window (moves outside the window frame), my mouse pointer is still displayed at the last read coordinates - I really need to hide it when this happens.

Thanks in advance.


CS_TBL(Posted 2005) [#2]
Perhaps store the window x,y,width,height, and work with MouseX(), MouseY() to see whether you're in or out?


Grey Alien(Posted 2005) [#3]
Thanks for the idea, problem is that MouseX and MouseY return the last position in your window even when the mouse has exited it!


Kevin_(Posted 2005) [#4]
Here is another way Grey....

Set the buffer at the Desktop Buffer and get the MouseX and MouseY. Get the X,Y, width and height of your window then just check if the mouse is within the window area (on the desktop). It works for me.


Grey Alien(Posted 2005) [#5]
Good Idea Prof, thanks for that one. I'll try it out.

uh, how do you get the x and y of your window? Of course I also also need to take into account the window edges and the title bar.


CS_TBL(Posted 2005) [#6]
x=GadgetX(window)
y=GadgetY(window)
w=GadgetWidth(window)
h=GadgetHeight(window)

In a way I was already proposing what Prof said :P


Grey Alien(Posted 2005) [#7]
CS_TBL: keywords = Desktop Buffer! ;-)

Thanks for the gadget commands.


Grey Alien(Posted 2005) [#8]
Regretably the gadget commands don't work as I'm not using a Blitz window(gadget) handle I'm using a proper windows handle obtained via User32_FindWindowA("",FULLNAME) because my windowed mode is actually made with the Graphics command and then tweaked to be a proper window. Looks like I'll have to go to Win32 API level to get the X and Y. I'll post back when I find out what the commands are.

[edit], hmm got the API call working fine but luck yet with getting the mouse coords relative to the desktop.