Click to See Complete Forum and Search --> : RichEditCtrl and mouse message handlers


June 10th, 1999, 04:26 PM
Hello,
My problem is following:
I have dialog with rich edit control on it. I try to intercept WM_LBUTTONDOWN and WM_MOUSEMOVE messages to determine when someone starts to select text in rich edit control. If I click on rich edit control and move mouse without releasing left mouse button and looking at pMsg->wParam for WM_MOUSEMOVE, MK_LBUTTON flag is never set. So I tried to set my own flag when I click on rich edit and move mouse like this:

BOOL CRichTxt::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
{
m_nLButtonDown = TRUE;
..........
}
break;
case WM_LBUTTONUP:
{
m_nLButtonDown = FALSE;
.............................
}
break;
case WM_MOUSEMOVE:
{
if(m_nLButtonDown == TRUE)
{
......................................................
}
}
break;
}

return CRichEditCtrl::PreTranslateMessage(pMsg);
}

But m_nLButtonDown is not set to TRUE until I release left button (text selection is over) and program never enters in if(m_nLButtonDown == TRUE) for WM_MOUSEMOVE.
I need a way to determine that text selection is starting.

Aleksandar Tanasic