15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


WM_MOUSEMOVE & CRichEditCtrl

Robert Somrek -- Robert.Somrek@noaa.gov
Monday, December 09, 1996


     Environment: Win95, VC++ 4.1
     
     I have added a status bar pane for Column/Row to a CRichEditView. 
     There are several examples of tracking the caret and updating a 
     col/row when using a CEditView. Unfortunately they don't work 
     correctly with the CRichEditView/CRichEditCtrl combination. Here's the 
     problem:
          
        When the mouse is dragged to select text, it appears that the 
        mousemove event is not passed to the view so the caret cannot be 
        tracked and col/row cannot be updated. When the drag selection is 
        completed, the caret location is not necessarly at the drag 
        endpoint. (This does not happen with CEditView and the col/row pane 
        can be updated dynamically as the mouse is dragged.)
        
     I have set the CRichEditCtrl's event mask to include ENM_MOUSEEVENTS 
     and can catch all mousemove events (standard, MK_CONTROL, etc) through 
     the view's ON_NOTIFY_REFLECT except those events that include 
     MK_LBUTTON (such as a drag selection). Is this a design characteristic 
     of the RichEditCtrl or have I missed something?
     
     
     in MessageMap.....
     ON_NOTIFY_REFLECT(EN_MSGFILTER, OnRichEditCtrlMsgFilter)
     
     code.....
     void CMyREView::OnRichEditCtrlMsgFilter(NMHDR* pNMHDR, LRESULT* pResult)
     {
          MSGFILTER* pMF = (MSGFILTER*)pNMHDR;
          if (pMF->msg == WM_MOUSEMOVE && (pMF->wParam & MK_LBUTTON))
          {
               TRACE("wParam: %d\n", pMsgFilter->wParam);
               \\ line about never executed!!             
          }
          *pRsult = 0;
     }
     
     
     Bob Somrek
     National Weather Service
     robert.somrek@noaa.gov



Lee Thompson -- lee@mail1.nai.net
Thursday, December 12, 1996

One of my older apps does this for a CRichEditView.  The status bar
pane  creation and updating for col/row is copied from the code added by
the component gallery for date and time on the status bar.  The pane is
updated via ON_UPDATE_COMMAND_UI.  When this happens I query the view
for the string to display using something like:

CString CNoteView::GetLine()
{
	CString result;

	int line_num = (int)(GetRichEditCtrl().LineFromChar(-1))+1;//adjust so
not zero based
	int begin_of_line = GetRichEditCtrl().LineIndex(line_num-1);
	CHARRANGE char_range;
	GetRichEditCtrl().GetSel(char_range);
	long char_num = (char_range.cpMin - begin_of_line)+1; //adjust so not
zero based
	sprintf(result.GetBuffer(50),_T("Ln %i, Col %i
"),line_num,(int)char_num);
	result.ReleaseBuffer();
	return result;
}

Hope this helps,

Lee Thompson




| Вернуться в корень Архива |