Solved

Text Highighting

Posted on 2001-07-24
5
156 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:mnasman
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 229
System restore point 4 78
Delphi cmd execution 6 41
How to debug For loops? 3 34
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

22 Experts available now in Live!

Get 1:1 Help Now