Solved

Need help with TRichEdit

Posted on 1998-02-02
3
250 Views
Last Modified: 2010-04-04
Is there a way to get the character index of the top left corner and bottom right corner of the TRichEdit Client Rectangle?

I'm using Delphi 3.0 for my development

Thanks in Advance
Ermac
0
Comment
Question by:ermac
[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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 50 total points
ID: 1358124
Hi

You use the EM_CHARFROMPOS message.

E.g.  For top left:
var
  ChPos: DWord;
  ChIx: Word;
begin
  ChPos := SendMessage(MyRichEdit.Handle, EM_CHARFROMPOS, 0, MakeLParam(1, 1));
  ChIx := LoWord(ChPos);
  Etc...
end;

Thus, to get character at top left:
  TopLeftCh := Copy(MyRichEdit, ChIx + 1, 1);


(My riched32.dll appears to cause an access violation if invalid coordinates are given...)

Regards,
JB
0
 

Author Comment

by:ermac
ID: 1358125
It doesn't return me the correct character index and I can't get the character index of the bottom right also (It gives me an access violation)

Any ideas?
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1358126
Mmm...  I think this API call is buggy.  I have heard from a colleague that he also couldn't get it to work properly.  (Mine did work, though, for the top-left char index.  Are you using different fonts?  I tried with default font only.)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

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…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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