Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Scrollbar of memo : scroll down on  opening

Posted on 2007-12-03
14
Medium Priority
?
707 Views
Last Modified: 2008-02-01
Can't  make memo be  on text end instead of start of text.
procedure TForm2.DOreading(Ime:string);
    var
         DATAfile: textfile;
         READline: string;
  begin
     AssignFile(  DATAfile,Ime);
     Reset(  DATAfile);
 
     While not EOF (  DATAfile) do begin
     ReadLn(  DATAfile,READline);
     F.Memo1.Lines.Add (READline);
     end;
              // in this way doesent work
     F.  memo1.SelStart := length(memo1.Text);
     F.memo1.Perform(EM_ScrollCaret,0,0);
     
 
CloseFile( DATAfile);
 
  end;

Open in new window

0
Comment
Question by:pr2501
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 20401377
try this:
  Memo1.Lines.LoadFromFile('C:\readme.txt');
  Memo1.SelStart := Length(Memo1.Lines.Text) - 1;
  Memo1.SelLength := 1;


ziolko.
0
 

Author Comment

by:pr2501
ID: 20401525

procedure TForm2.DOreading(Ime:string);
    var
         DATAfile: textfile;
         READline: string;
  begin
     AssignFile(  DATAfile,Ime);
     Reset(  DATAfile);
 
     While not EOF (  DATAfile) do begin
     ReadLn(  DATAfile,READline);
     F.Memo1.Lines.Add (READline);
     end;
              // in this way doesent work
   Memo1.SelStart := Length(Memo1.Lines.Text) - 1;
  Memo1.SelLength := 1;
 
 
CloseFile( DATAfile);
 
  end;

Open in new window

0
 

Author Comment

by:pr2501
ID: 20401536


Can't make to work it in code before.

Problem if the text of memo has more lines that  memo is large:i can
see first par of text- not last.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 21

Expert Comment

by:ziolko
ID: 20401660
do you have scrollbars on your memo? if so then where are they positioned after setting Selstart and SelLength?

ziolko.
0
 

Author Comment

by:pr2501
ID: 20401749
 on the top
0
 
LVL 21

Expert Comment

by:ziolko
ID: 20401770
you can use Memo1.Lines.LoadFromFile() instead of AssignFile()

and this works for me just fine:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.LoadFromFile('c:\text.txt');
  Memo1.SelStart := Length(Memo1.Lines.Text) - 1;
  Memo1.SelLength := 1;
  Memo1.SetFocus;
end;

ziolko.
0
 

Author Comment

by:pr2501
ID: 20401945
In may code (code snippet) can't  do scrollbar go down.

I have added scrollbar from  memo Properties: scrollbas ssvertical.  













procedure TForm2.DOread(Ime:string);
    begin
  Memo1.Lines.LoadFromFile('c:\text.txt');
  Memo1.SelStart := Length(Memo1.Lines.Text) - 1;
  Memo1.SelLength := 1;
  Memo1.SetFocus;
end;

Open in new window

0
 

Author Comment

by:pr2501
ID: 20401983


 sorry i was to fast
procedure TForm2.DOread(Ime:string);

the IME wasn't  the c:\text.txt'

I have to work on it.

Thank you
0
 

Author Comment

by:pr2501
ID: 20402007

For itch speedButon i have to read deferent file.
Can you see  the reason way it hasn't work from next code:


 
procedure TForm2.FormShow(Sender: TObject);
   begin
      DOread   ('C:\PC1\Montaza\'+TSpeedButton(Sp).Caption+'\'+TSpeedButton(Sp).Caption+'.txt');
   end;
end.
 
procedure TForm2.DOread(Name:string);
    begin
  Memo1.Lines.LoadFromFile(Name);
  Memo1.SelStart := Length(Memo1.Lines.Text) - 1;
  Memo1.SelLength := 1;
  Memo1.SetFocus;
end

Open in new window

0
 
LVL 21

Expert Comment

by:ziolko
ID: 20402023
first of all validate that this
'C:\PC1\Montaza\'+TSpeedButton(Sp).Caption+'\'+TSpeedButton(Sp).Caption+'.txt'
points to existing file.


ziolko.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 20402036
and use OnActivate instead of OnShow, OnActivate guarantees you that all components are properly created and ready to take user input

ziolko.
0
 

Author Comment

by:pr2501
ID: 20402048

It exist because i can read text into memo.

But the vertical scrollbar is  still positioned  the top.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 20402078
call DoRead routine in OnActivate event handler not OnShow

ziolko.
0
 

Author Comment

by:pr2501
ID: 20402087
 thank you
it's Ok
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 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