Question

Suppose that I have the COpenGLControl class derived from CWnd and I'm customizing it for my own purposes.
I want to do something like this:
1- Add a zoom tool toolbar button at top of my dialog.
2- after pressing the toolbar button mentioned the feature explained below gets enabled.
3- If the user clicks the left mouse button we get zoomed in by a factor of two and glTranslate to the position of the user's click.
4-If the user clicks the right mouse button we get zoomed out by a factor of 0.5 and glTranslate to the position of the user's click.
5-If the user clicks another toolbar button the feature explained in two above steps gets disabled.

You know I want to implement something like Zoom Tool in Global Mapper.

I don't have problems with implementing glScale or glTranslate.
Just have problems with the MFC part.
searching the default message handlers, I found that we have WM_LBUTTONDBLCLK,WM_LBUTTONDOWN,WM_LBUTTONUP,WM_RBUTTONDBLCLK,WM_RBUTTONDOWN,WM_RBUTTONUP but not a WM_LBUTTONCLK or WM_RBUTTONCLK?

even if we had WM_LBUTTONCLK or WM_RBUTTONCLK, these event handlers would be enabled and active since creation of the window until closing it but I want them to be active just at a certain time (after clicking zoom tool and before clicking another tool)
I know from here that maybe I need to implement these features in user-defined message handlers but I don't have any idea since I'm new to MFC.
Could you help me give the true idea to start from?

Was it helpful?

Solution

Try something similar to this:

void COpenGLControl::OnLButtonDown(UINT nFlags, CPoint point)
{
    if (zoom_tool_has_been_clicked)
    {
        // do zoom stuff here

        return ;
    }

    CWnd::OnLButtonDown(nFlags, point);
}

Just to give you an idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top