Recent

Author Topic: TMemo: How to force to top SOLVED!  (Read 3578 times)

ProgEd

  • New Member
  • *
  • Posts: 25
TMemo: How to force to top SOLVED!
« on: July 04, 2013, 03:21:35 pm »
There is a behavior difference between the Windows and OS X implementation of TMemo that's driving me crazy. I'm using Lazarus 1.0.10 on both Windows (Win 7) and Max (OS X 10.8 ). I load a TMemo field with lots of text. In Windows it stays at the top (where I want it). However, on the Mac it stays at the bottom forcing the user to scroll to the top manually.

I'm not a Mac programmer so I'm not sure how to address this. What I want is for the TMemo field to be positioned at the top as it is in Windows.

Is there a way to accomplish this?

Thanks,
Ed
« Last Edit: July 04, 2013, 11:52:57 pm by ProgEd »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TMemo: How to force to top
« Reply #1 on: July 04, 2013, 03:56:46 pm »
Probably setting SelStart to zero at the beggining of your program (if the memo already has text). If the user loads it from a file, do the same after that.
« Last Edit: July 04, 2013, 04:04:24 pm by typo »

ProgEd

  • New Member
  • *
  • Posts: 25
Re: TMemo: How to force to top
« Reply #2 on: July 04, 2013, 04:08:26 pm »
Yup, tried that, didn't work.

Thanks for the suggestion!

Ed

jwdietrich

  • Hero Member
  • *****
  • Posts: 1036
    • formatio reticularis
Re: TMemo: How to force to top
« Reply #3 on: July 04, 2013, 10:37:35 pm »
Yup, tried that, didn't work.

Thanks for the suggestion!

Ed

You could try to set SelStart to 0 also in OnActivate and OnShow events.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.6 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

ProgEd

  • New Member
  • *
  • Posts: 25
Re: TMemo: How to force to top SOLVED!
« Reply #4 on: July 04, 2013, 11:51:54 pm »
Okay, it appears the problem was caused by loading the TMemo field in the OnCreate event. By waiting until the OnShow event everything seems to work fine!

One small update -- after the SelStart := 0 you have to do a SetFocus on the control.

Thank you both for your suggestions!

Ed
« Last Edit: September 07, 2013, 05:12:51 pm by ProgEd »