Link to home
Start Free TrialLog in
Avatar of haab
haab

asked on

How to grab selected text in a window

Is it possible to get selected text from a window without sending it to the clipboard using the keystrokes Ctrl + C?

What I do at the moment, is that I react on the mouse event WM_LBUTTONUP in windows/controls with classnames that I list in my Delphi program. At the moment of the Mouse Up Event, I also know the handle of that window/control. I send Ctrl + C to that window, but my question is: Is there another way, can the selected text be acquired with for instance the Windows messaging methods, or by other means, not including the clipboard?
Avatar of shaneholmes
shaneholmes

You could program a HotKey to get the current focused controls text, is this what your interested in?

Shane
ASKER CERTIFIED SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of haab

ASKER

Well, it is only the selected text that I want. I already know how to get the entire text of controls; the problem is to grab only the selected text, and the question whether it is possible to do so without involving the clipboard.

Thank you for your kind response, both on this issue and my other question from today regarding the maintaining of clipboard formats!
Avatar of haab

ASKER

I see that you have given some code as well. Thank you! I will try it out!
Again, test for the type of focused control, then use the

 SelText property of the control

MyText:= TEdit(Form1.ActiveControl).SelText;


Shane
SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial