Recent

Author Topic: This should be easy: Get the top most visible point of a widget  (Read 652 times)

EganSolo

  • Full Member
  • ***
  • Posts: 212
Given an LCL widget (say TMemo), I want to find the topmost point of the memo which is visible as I scroll.

I've tried Tmemo.Top, Tmemo.ClientOrigin.Y, TMemo.ClientRect.Top, TMemo.BoundsRect.Top and it's none of those. I've googled that question and no dice.

A little nudge would be much appreciated!

 :)

engkin

  • Hero Member
  • *****
  • Posts: 2692
Re: This should be easy: Get the top most visible point of a widget
« Reply #1 on: April 06, 2021, 05:17:13 am »
As you scroll what? :)

Do you mean TMemo.VertScrollBar.ScrollPos?

EganSolo

  • Full Member
  • ***
  • Posts: 212
Re: This should be easy: Get the top most visible point of a widget
« Reply #2 on: April 06, 2021, 08:02:18 am »
Hi engkin,
Yes, as I scroll! Are you saying that Tmemo.VertScrollBar.ScrollPos is the value for the topmost visible line in the memo?

Wow! I thought it would be a property of the memo itself. I didn't think it would be in the scroll bar.

Thanks for the nudge! Much appreciate it!


jamie

  • Hero Member
  • *****
  • Posts: 4444
Re: This should be easy: Get the top most visible point of a widget
« Reply #3 on: April 06, 2021, 11:19:03 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   caption :=  Hi(Dword(SendMessage(Memo1.Handle, EM_CHARFROMPOS,0,0))).Tostring;
  4. end;                                                                            
  5.  

If you are in windows that will show you what line number is at the top left corner of the memo..

this is 0 based index and don't forget to add the Windows unit..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018