whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

35 Visitors Online


 
...scroll to a certain Position in a TRichEdit/ TMemo?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (43):  
     


procedure TForm1.Button1Click(Sender: TObject);
var
  
itemp: Integer;
begin
  with 
RichEdit1 do
  begin
    
// Move to the last line:
    // Zur letzten Zeile scrollen:
    
SelStart := Length(Text);
    Perform(EM_SCROLLCARET, 0, 0);

    // or: Perform(WM_VSCROLL, SB_BOTTOM,0);

    // Move to the first line:
    // Zur ersten Zeile Scrollen:
    
SelStart := Perform(EM_LINEINDEX, 0, 0);
    Perform(EM_SCROLLCARET, 0, 0);

    // Move to Line 5, Character 3:
    // Cursor auf Linie 5, Postion 3 setzen:
    
SelStart := Perform(EM_LINEINDEX, 5, 0) + 3;
    Perform(EM_SCROLLCARET, 0, 0);

    // Scroll down 1 Line
    // Eine linie nach unten scrollen
    
with RichEdit1 do
    begin
      
itemp := SendMessage(Handle, EM_LINEFROMCHAR, SelStart, 0);
      SelStart := Perform(EM_LINEINDEX, itemp + 1, 0);
      Perform(EM_SCROLLCARET, 0, 0);
    end;

    // Set the focus on the RichEdit:
    // Den Fokus aufs RichEdit setzten:
    
SetFocus;
  end;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners