I use Borland's TMemo textpad and want to know the character position of my mouse cursor in the Memo, so in MouseMove I do the following:
// X and Y are in client space
void __fastcall MyApp::Memo1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
TPoint mousePos;
mousePos.x = X;
mousePos.y = Y;
int charPos = SendMessage(Memo1->Handle, EM_CHARFROMPOS, 0, (LPARAM)&mousePos);
}
The problem is charPos is always -1, even when I move the mouse over text in the Memo. Any ides whats wrong?
// X and Y are in client space
void __fastcall MyApp::Memo1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
TPoint mousePos;
mousePos.x = X;
mousePos.y = Y;
int charPos = SendMessage(Memo1->Handle, EM_CHARFROMPOS, 0, (LPARAM)&mousePos);
}
The problem is charPos is always -1, even when I move the mouse over text in the Memo. Any ides whats wrong?