i'm trying getting the richedit caret positions. seems that i can't use the caret functions.
LONG firstCharIndex(HWND hwnd)
{
POINT pt;
pt.x=0;
pt.y=0;
LONG n = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&pt);
return LOWORD(n);
}
COORD GetCaretPos( )
{
COORD pos;
//getting the line from caret position:
pos.Y=(LONG) SendMessage(consoleedit, EM_LINEFROMCHAR,(WPARAM)-1,0);
CHARRANGE cr;
cr.cpMin = 0;
cr.cpMax = 0;
SendMessage(consoleedit, EM_EXGETSEL, 0, (LPARAM)&cr);
pos.X=cr.cpMin - firstCharIndex(consoleedit);
DebugText("min: " + to_string(cr.cpMin) + " first: " + to_string(firstCharIndex(consoleedit)) );
return pos;
}
i get the Y correctly, but i don't understand how can i get the X.. can anyone advice me?