Solved

Text Highighting

Posted on 2001-07-24
5
161 Views
Last Modified: 2010-04-04
I have an app where I would like to highlight a section of text in an Edit box, I know how to highlight the whole text (by drawing the text), however am unsure as to how I can highlight a section.

Any Ideas?
0
Comment
Question by:mattlaver
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 50 total points
ID: 6312296
Setting the properties SelStart and SelLength is the correct way to highlight text in a TEdit. See Delphi help for a sample.
If you use a Windows edit box then send a EM_SETSEL message to the control. See Windows SDK help.
0
 
LVL 2

Expert Comment

by:bugroger
ID: 6313178
hi,

try this:

// HighLightText(Edit1, 1, 3);
Procedure HighLightText(Edit : TEdit; nStart, nEnd : Integer);
Begin
 Windows.SetFocus(Edit.Handle);
 Edit.Perform(EM_SetSel, nStart-1, nEnd);
End;

GL
BUG
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6314126
Hello

  Try that by send message  EM_SETSEL

  Edit1.SetFocus;
  SendMessage(Edit1.Handle, EM_SETSEL, 2, 7);

Best regards
Mohammed Nasman
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6321102
and what about

Edit1.Selstart := 2;
Edit1.SelLength := 7;
0
 
LVL 1

Author Comment

by:mattlaver
ID: 6326127
Thanks, should have known...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question