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.
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;
}
[edit]changed MoveCaret function and wm_mousemove handler, but it still flickers[/edit]