Find if the mouse is over the DBP Window by Dave J4th Sep 2004 8:05
|
---|
Summary Returns a value if the mouse is over the DBP window or not. Description Loads the "User32.DLL" and calls 3 WinAPI functions to determine wether the mouse is hovering over the DBP window or not. Not really that much use but I had to write it for someone so I decided to submit it anyway. The function will return a '-1' if there was an error (unlikely lol), a '0' if the mouse is outside the DBP window and a '1' if it's inside the DBP window. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Load DLL, Get hWnd and Make Memblocks Load DLL "user32.dll", 1 Global hWnd As DWORD hWnd = Call DLL(1, "GetActiveWindow") Make Memblock 1, 8 Make Memblock 2, 16 Do Cls Text 0,0, Str$(CheckMouse()) Loop Function CheckMouse() `Checks whether the mouse is over the DBP window or not Ret = -1 `Get Mouse Position Call DLL 1, "GetCursorPos", Get Memblock Ptr(1) mX = Memblock Word(1,0) mY = Memblock Word(1,4) `Get Window size Call DLL 1, "GetWindowRect", hWnd, Get Memblock Ptr(2) wX1 = Memblock Word(2, 0) wY1 = Memblock Word(2, 4) wX2 = Memblock Word(2, 8) wY2 = Memblock Word(2, 12) `Calculations If (mX > wX1) And (mX < wX2) And (mY > wY1) And (mY < wY2) `In Range Ret = 1 Else `Out of Range Ret = 0 EndIf EndFunction Ret |