global mouse capture
-
I need a program's main window to roll up when the mouse leaves, I think the best way to do this would be with some kind of global mouse capture function but have no idea how to do this, can someone please point me in the right direction? Much Appreciated, spoonchops
-
I need a program's main window to roll up when the mouse leaves, I think the best way to do this would be with some kind of global mouse capture function but have no idea how to do this, can someone please point me in the right direction? Much Appreciated, spoonchops
I am not sure if this works... but how about this:
void CMyControl::OnLButtonDown(UINT nFlags, CPoint point)
{
CStatic::OnLButtonDown(nFlags, point);
SetCapture(); //claim mouse input
}void CMyControl::OnMouseMove(UINT nFlags, CPoint point)
{
DoStuff(); // <--- your stuff :)
CStatic::OnMouseMove(nFlags, point);
}void CMyControl::OnLButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture(); //back to normal mouse input processing
CStatic::OnLButtonUp(nFlags, point);
}I assume here your control is derived from CStatic.
-
I am not sure if this works... but how about this:
void CMyControl::OnLButtonDown(UINT nFlags, CPoint point)
{
CStatic::OnLButtonDown(nFlags, point);
SetCapture(); //claim mouse input
}void CMyControl::OnMouseMove(UINT nFlags, CPoint point)
{
DoStuff(); // <--- your stuff :)
CStatic::OnMouseMove(nFlags, point);
}void CMyControl::OnLButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture(); //back to normal mouse input processing
CStatic::OnLButtonUp(nFlags, point);
}I assume here your control is derived from CStatic.
Well that's great but it's actually the implementation of the SetCapture() and ReleaseCapture() functions I was after as it were....
-
Well that's great but it's actually the implementation of the SetCapture() and ReleaseCapture() functions I was after as it were....
-
Well that's great but it's actually the implementation of the SetCapture() and ReleaseCapture() functions I was after as it were....
-
I need a program's main window to roll up when the mouse leaves, I think the best way to do this would be with some kind of global mouse capture function but have no idea how to do this, can someone please point me in the right direction? Much Appreciated, spoonchops
You need to make use of TrackMouseEvent. The trick is that entering one of you dialogs child windows will also trigger this, so you will need to do a GetCursorPos() and WindowFromPoint() and then see whether the window with the mouse in it is a child of your dialog. If it is, you then need to retrack the mouse event again, until it leaves the child window and enters/leaves all the windows of your dialog. At the point where its not in your dialog or a child of your dialog you can then roll up your window. Its a bit difficult to get right (we did it here). The above bit was the hardest bit to get working correctly. Roger Allen Sonork 100.10016 WHats brown and sticky? A stick or some smelly stuff!
-
You need to make use of TrackMouseEvent. The trick is that entering one of you dialogs child windows will also trigger this, so you will need to do a GetCursorPos() and WindowFromPoint() and then see whether the window with the mouse in it is a child of your dialog. If it is, you then need to retrack the mouse event again, until it leaves the child window and enters/leaves all the windows of your dialog. At the point where its not in your dialog or a child of your dialog you can then roll up your window. Its a bit difficult to get right (we did it here). The above bit was the hardest bit to get working correctly. Roger Allen Sonork 100.10016 WHats brown and sticky? A stick or some smelly stuff!
Thanks Roger, that's exactly what I was looking for :)