Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic copying highlighted text to clipboard (TMemo)

Status
Not open for further replies.

albn

Programmer
Oct 31, 2003
5
US
I know how to do this via pop-up or from the main menu controls, but I would like to know how to have text in the TMemo control copy highlighted text.

Perhaps this can be done via mouse click functions?

Any direction would be nice. Thank you.
 
Check TMemo.CopyToClipboard and/or TMemo.CutToClipboard.

buho (A).


 
This code seems to work when placed in the OnClick event of the TMemo:
Code:
 if Memo1.SelLength > 0 then
   Memo1.CopyToClipboard;

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
If memory serves, you have no need to check SelLength. If the memo have nothing selected the method will do nothing.

buho (A).
 
Delphi Help File said:
Use CopyToClipboard to replace the contents of the Clipboard with the selected text. CopyToClipboard does not clear the Clipboard if no text is selected. If no text is selected, CopyToClipboard does nothing.
You are correct buho - I should have checked the help file first! I was just presuming it would save a needless call to the CopyToClipboard method.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top