Solved

Text Highighting

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now