Solved

Text Highighting

Posted on 2001-07-24
5
158 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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