OnLButtonDown and Up
-
On a dialog based application I have attached an OpenGL window which is overlaid on a static control. When the user does a left mouse button down followed by a left mouse button up on the opengl window I want an event to occur. However i have the following constraints: If the user leaves the area of the opengl window and release the left mouse button i don't want the event to happen If they then press the left mouse button down outside of the opengl model and then release it whilst in the opengl window i don't want the event to happen. However if they press the left mouse button inside the opengl window, then leave the opengl window but then come back into it and then release the mouse button the event should happen I've tried using the left button down event on the main dialog however if the user clicks (down or up) on any of the other buttons on the dialog then the main dialog doesn't handle the event. Does anyone know how to handle this set of events (or even what I'm talking about? :-D)? TIA, Andy
-
On a dialog based application I have attached an OpenGL window which is overlaid on a static control. When the user does a left mouse button down followed by a left mouse button up on the opengl window I want an event to occur. However i have the following constraints: If the user leaves the area of the opengl window and release the left mouse button i don't want the event to happen If they then press the left mouse button down outside of the opengl model and then release it whilst in the opengl window i don't want the event to happen. However if they press the left mouse button inside the opengl window, then leave the opengl window but then come back into it and then release the mouse button the event should happen I've tried using the left button down event on the main dialog however if the user clicks (down or up) on any of the other buttons on the dialog then the main dialog doesn't handle the event. Does anyone know how to handle this set of events (or even what I'm talking about? :-D)? TIA, Andy
This is an MFC example, but if you're using straight APIs you can do the same. ::MessageBeep() should get called on the left button up message according to your requirements (unless I need more caffeine)...
void CMyWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);SetCapture();
fInCapture = true;
}void CMyWindow::OnLButtonUp(UINT nFlags, CPoint point)
{
if (fInCapture)
{
ReleaseCapture();
fInCapture = false;CRect clirect;
GetClientRect(&clirect);
if (PtInRect(&clirect, point))
{
//** test
::MessageBeep(-1);
//** end test
}
}CWnd::OnLButtonUp(nFlags, point);
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
This is an MFC example, but if you're using straight APIs you can do the same. ::MessageBeep() should get called on the left button up message according to your requirements (unless I need more caffeine)...
void CMyWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
CWnd::OnLButtonDown(nFlags, point);SetCapture();
fInCapture = true;
}void CMyWindow::OnLButtonUp(UINT nFlags, CPoint point)
{
if (fInCapture)
{
ReleaseCapture();
fInCapture = false;CRect clirect;
GetClientRect(&clirect);
if (PtInRect(&clirect, point))
{
//** test
::MessageBeep(-1);
//** end test
}
}CWnd::OnLButtonUp(nFlags, point);
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: