Objective Grid: Giving the right mouse button the same functionality as the left mouse button

Article ID: 711
Last updated: 11 Jun, 2018
Article ID: 711
Last updated: 11 Jun, 2018
Revision: 3
Views: 1569
Posted: 23 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


Is there a way of making the right mouse button act in exactly the same way as the left mouse button when clicking on a grid? Thus the user is able to select a range of cells with the right mouse button etc.


Cause



Action


You should process the WM_RBUTTONDOWN and WM_RBUTTONUP message and then call DoLButtonDown() and DoLButtonUp(), respectively.

One problem is that DoLButtonDown() checks the flags parameter if MK_RBUTTON is set. Therefore, you have to modify this flag when calling DoLButtonDown().

Example:

void CGXGridWnd::OnRButtonDown(UINT flags, CPoint point)
{
SetAutoScroll(FALSE);

if (!DoLButtonDown(flags & ~MK_RBUTTON | MK_LBUTTON, point))

CWnd::OnRButtonDown(flags, point);
}

void CGXGridWnd::OnRButtonUp(UINT flags, CPoint point)
{

if (!DoLButtonUp(flags & ~MK_RBUTTON | MK_LBUTTON, point))
CWnd::OnRButtonUp(flags, point);
SetAutoScroll(TRUE);
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 711
Last updated: 11 Jun, 2018
Revision: 3
Views: 1569
Posted: 23 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category