Recent

Author Topic: What is the proper way to scroll to the bottom of KMemo?  (Read 2365 times)

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
What is the proper way to scroll to the bottom of KMemo?
« on: February 14, 2018, 01:06:03 am »
Platform: Windows Server Essentials 2016, Lazarus 1.8.1 "Fix", FPC 3.0.5, KControls 1.7.1

//  This doesnt' work:
     kemLog.ScrollBy(0, 14);

// SendMessage is not native to FPC (as far as I know, so this is not good)
            txt_blk := kemLog.Blocks.AddTextBlock(lyn);
            kemLog.Blocks.AddParagraph;
            kemLog.SelStart := Length(kemLog.Text);
            SendMessage(kemLog.Handle, EM_SCROLLCARET, 0, 0);

KMemo is not like TRichEdit or TMemo, so all the example on the Internet are not applicable.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What is the proper way to scroll to the bottom of KMemo?
« Reply #1 on: February 14, 2018, 04:44:22 am »
Without trying it myself, I'd suggest you start by looking at things like -
Code: Pascal  [Select][+][-]
  1. KMemo1.ExecuteCommand(ecEditorBottom);

There are a large number of commands like ecEditorBottom (which moves caret to bottom of doc).  What you need will depend on if you want to move the caret or just move the viewport. Anyway, in Lazarus, hover your mouse over the ecEditorBottom and follow the link to KEditCommon and choose your combination !

When you get it working nicely, consider documenting it on http://wiki.freepascal.org/KControls/KmemoNotes - KMemo is a great component but deserves better documentation !

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018