Solved

Need help with TRichEdit

Posted on 1998-02-02
3
245 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

20 Experts available now in Live!

Get 1:1 Help Now