Solved

Trichedit : Offset

Posted on 2000-03-21
6
391 Views
Last Modified: 2010-04-04
hi,

under D3/Win98 i have a Trichedit with scrollbars
and a large text inside.
when the vertical scrollbar is used, i want to know
how many pixels offset has the first visible line
to the first line of the text.
or in other words: how many pixels are scrolled ?

thanks
titz
0
Comment
Question by:titz
  • 4
  • 2
6 Comments
 
LVL 2

Expert Comment

by:kotik
ID: 2641286
Hi!
It's only a suggestion, try this:

var
  Position: integer;
begin
  SendMessage(RichEdit.Handle, EM_POSFROMCHAR, Position, 0
);
end;

Regarding to the Win32 Help:
A returned coordinate can be negative if the character has been scrolled outside the edit control's client area.

So you can get abs(Position) to get the real offset.

Regards,
Kot.



0
 
LVL 2

Accepted Solution

by:
kotik earned 50 total points
ID: 2641312
This is the correct version:


{ Y coordinate is what you need }
procedure TForm1.Button2Click(Sender: TObject);
var
  Position: TPoint;
begin
  SendMessage(RichEdit1.Handle, EM_POSFROMCHAR, Integer(@Position), 0);
  Label1.Caption := Format('CordX: %d, CordY: %d', [Position.X, Position.Y]);
end;

Regards,
Kot.
 
0
 
LVL 1

Author Comment

by:titz
ID: 2650279
hi kotik,

that was the exact answer ! it works well.

but i have an additional question: i thought i could get the action of the scrollbars in an onpaint-event.
but now i found : there is no onpaint-event in Trichedit. Do you have an idea what kind ogf event i can use for to know that the scrollbars are active ?

thanks
titz
 
0
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.

 
LVL 2

Expert Comment

by:kotik
ID: 2653834
To be able to handle scrollbar events you have to create your own handler, like this (I have done it for a TMemo, but I think it will work with TRichEdit too):
interface
....
{ Add to your RichEdit component }
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
....

implementation

procedure TFileMemo.WMVScroll(var Message: TWMVScroll);
begin
  { Do what you need here }
  Inherited; // call inherited, if you need it
end;

You can get more info in Win32 Help. Look for WM_SCROLL message.

Tell me if you have problems with implementing.

Regards,
Kot.





0
 
LVL 1

Author Comment

by:titz
ID: 2654448
hi kotik,

thanks: it works. i did the same before (with wm_vscroll-message), but i
forgot the "inherited" .

Many thanks and a nice weekend
titz
0
 
LVL 2

Expert Comment

by:kotik
ID: 2654543
Glad to help you.

Regards,
Kot.

P.S. Nice nickname :)
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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
delphi parse string to params 3 99
Delphi inherited method 6 63
RESTRequest Parameter 4 12
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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