You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Hello Everyone, Does anybody have any ideas on how I can detect when the mouse cursor leaves a window. I know how to detect when the mouse enters the window but leaving is another story?
CASE %WM_MOUSEMOVE
DIM bCaptured AS STATIC LONG
'capture the mouse as soon as it enters into the window
'do only once...
IF bCaptured = 0 THEN
Call SetCapture( hWnd )
bCaptured = 1
END IF
'now check if it has left the window, if so, then release
'mouse capture...
IF bCaptured = 1 THEN
Call GetCursorPos( pt )
Call GetWindowRect( hWnd, rc )
IF PtInRect( rc, pt.x, pt.y ) = %FALSE THEN
'Sorry, the mouse is out for some cheese!
Call ReleaseCapture()
bCaptured = 0
END
END IF
HTH
Regards,
Jules
[This message has been edited by Jules Marchildon (edited July 06, 2001).]
Jules, I have run into another problem now. By using the SetCapture method the caption bar nolonger works and thus I cannot close the window. Any suggestions on how to fix this little problem?
Yes, that's a side effect using SDK windows.
It seems a dialogbox msgpump doesn't bother.
Actually, there is a topic on that in MSDN.
For SDK i solved it by writting additional code in the msgpump to unset the capture.
This is pretty old:
Code:
Select Case Msg.Message
Case %WM_KEYDOWN, %WM_KEYUP
'''
Case %WM_SYSCOMMAND
'// Solve a problem while Setcapture is set.
'// TranslateMessage will not perform ok if setcapture is used.
'// A temporary release of the capture is ok.
a = GetCapture()
If a Then
TranslateMessage MSG
SetCapture 0
DispatchMessage MSG
SetCapture a
Iterate
End If
------------------
[This message has been edited by Edwin Knoppert (edited July 09, 2001).]
Hello Edwin, I am releasing it after the cursor exits the window. I just wanted to be able to move and close the window while having the mouse capture. I may have to investigate the TrackMouseEvent once again.
Fire off a code snippet that I can compile and test. I will take a look
at the effects you are trying to achieve. All code is kept confidential
of course.
added later:
Mark, if you want to allow the caption buttons to work while SetCapture is on
then just exclude the height of the caption from the RECT, that will allow
that region to work as normal.
Mark;
Code:
CASE %WM_MOUSEMOVE
DIM bCaptured AS STATIC LONG
'capture the mouse as soon as it enters into the window
'do only once...
IF bCaptured = 0 THEN
Call SetCapture( hWnd )
bCaptured = 1
END IF
'now check if it has left the window, if so, then release
'mouse capture...
IF bCaptured = 1 THEN
Call GetCursorPos( pt )
Call GetWindowRect( hWnd, rc )
'*remove the Caption area from the RECT
rc.nTop = rc.nTop + GetSystemMetrics( hWnd, %SM_CYCAPTION )
IF PtInRect( rc, pt.x, pt.y ) = %FALSE THEN
'Sorry, the mouse is out for some cheese!
Call ReleaseCapture()
bCaptured = 0
END
END IF
Regards,
Jules
[This message has been edited by Jules Marchildon (edited July 10, 2001).]
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment