Recent

Author Topic: TMemo and TDBMemo won't scroll ...  (Read 8412 times)

Amnon82

  • New Member
  • *
  • Posts: 37
TMemo and TDBMemo won't scroll ...
« on: April 01, 2007, 07:09:10 pm »
I'm writing a installer for a linux distro. I display the copied files to the hdd in a memo. The only thing:

The memo don't scroll down. I'm using lazarus 0.9.23. What can be the problem?

Code: [Select]
//Processandwait example by Amnon82
//Version 20070312-1
//
//Create a form with one button on it.
//Copy this sourcecode to your pas.
//Compile it in lazarus.


unit unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons, Process,
  StdCtrls, DbCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    DBMemo1: TDBMemo;
    Edit1: TEdit;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure Processandwait(Executable : String);
var
  AProcess1: TProcess;
  AStringList: TStringList;

begin
  AStringList := TStringList.Create;
  try
  AProcess1 := TProcess.Create(nil);
  AProcess1.CommandLine := Executable;
  AProcess1.Options := AProcess1.Options+ [poUsePipes];

 {Execute}
  AProcess1.Execute;
  {Wait to finish}
  while AProcess1.running = true do
  begin
  form1.button1.enabled:=false;
  AStringList.LoadFromStream(AProcess1.Output);
  if form1.radiobutton2.checked= true
  then
  Form1.dbmemo1.lines.add(Astringlist.text)
    else
  form1.edit1.text:=Astringlist.text;
  sleep (400);
  Application.ProcessMessages;
  end;
  finally
     AStringList.LoadFromStream(AProcess1.Output);
  if form1.radiobutton2.checked=true
  then
  Form1.dbmemo1.lines.add(Astringlist.text);
    AProcess1.Free;
    AStringlist.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

 if radiobutton2.checked=true then
 Processandwait('sudo ./copypaldo.sh')
 else
 Processandwait('sudo ./gettable2.sh') ;
 button1.enabled:=true;
 showmessage('done');

end;

initialization
  {$I unit1.lrs}

end.  

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: TMemo and TDBMemo won
« Reply #1 on: April 04, 2007, 06:14:32 am »
Please report it as a bug in BugTtracker.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: TMemo and TDBMemo won
« Reply #2 on: April 04, 2007, 09:35:26 am »
No, first search the forums and the internet for lazarus and delphi examples. I am pretty sure this question has been asked before.

The bug tracker is not for asking questions.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1946
RE: TMemo and TDBMemo won
« Reply #3 on: April 04, 2007, 11:34:30 am »
Memo1.SelStart := Length(Memo1.Lines.Text)-1;

DougNettleton

  • Jr. Member
  • **
  • Posts: 84
Memo & DBMemo
« Reply #4 on: April 04, 2007, 05:38:10 pm »
Drop either on a form and a button "Add A Line".  Add the following procedure...

procedure TForm1.Button1Click(Sender: TObject);
begin
  DBMemo1.Lines.Add('Here is a line!');
end;

Run, Click the button until the memo is full and scrolling seems to work fine.  You do need to change the ScrollBars property from the default ssNone.  Horizontal Scrolling only works if WordWrap is set to False

HTH,

Doug

 

TinyPortal © 2005-2018