Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I set Edit1.SelStart when MouseDown is pressed

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there some way in the edit.MouseDown event I can emulate a edit.click?

>Solution :

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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading