aka block selection, vertical selection, column selection etc.
there are different modes of rectangular text selection. see the attached pic for examples.
now the question is, how do i implement something like that on an edit/richedit control?
Printable View
aka block selection, vertical selection, column selection etc.
there are different modes of rectangular text selection. see the attached pic for examples.
now the question is, how do i implement something like that on an edit/richedit control?
Probably gonna have to make it owner-drawn or something like that.
Or implement the entire control yourself.
gg
OK, so i decided to try this using a richedit control. i subclassed the control and now i'm trying to implement 'normal' text selection. the following code works, but it flickers quite badly. anyone know how to remove the flicker?
the message handlers are in the WndProc of the RichEdit that i subclassed.
[edit]changed MoveCaret function and wm_mousemove handler, but it still flickers[/edit]Code:case WM_LBUTTONDOWN:
{
IsSelecting = true;
SelStartChar = MoveCaret(hWnd, lParam);
return 0;
}
case WM_MOUSEMOVE:
{
if (IsSelecting)
{
SelEndChar = MoveCaret(hWnd, lParam, true, SelStartChar);
}
return 0;
}
case WM_LBUTTONUP:
{
IsSelecting = false;
return 0;
}
//...other stuff
LONG MoveCaret(HWND hWnd, LONG coord, bool Select, LONG SelStart)
{
CHARRANGE cr;
LONG lChResult;
POINTL p;
p.x = LOWORD(coord);
p.y = HIWORD(coord);
lChResult = SendMessage(hWnd, EM_CHARFROMPOS, 0, (LPARAM)&p);
Select == true ? cr.cpMin = SelStart : cr.cpMin = lChResult;
cr.cpMax = lChResult;
SendMessage(hWnd, EM_EXSETSEL, 0, (LPARAM)&cr);
return lChResult;
}