I have an Edit that when the user right clicks on the text I need to set the edit.selstart position.
The edit.mousedown does not seem to set it but edit.click does.
So if a user left clicked on the text then right clicks the selstart is correct but if they have not left clicked first selstart is 0.
Is there some way in the edit.MouseDown event I can emulate a edit.click?
Try this, works for me:
uses
..., Windows;
procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
Edit1.SelStart := LOWORD(Edit1.Perform(EM_CHARFROMPOS, 0, MAKELPARAM(X, Y)));
end;