Mega Code Archive
Memo nesnesini harici scrollbar ile kaydırmak
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MemoComponentUnit, SourceEditUnit, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ScrollBar1: TScrollBar;
CodeEdit: TSourceEdit;
Button3: TButton;
Edit1: TEdit;
Timer1: TTimer;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Son : integer = 0;
i: integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessage(CodeEdit.Handle, { HWND of the Memo Control }
WM_VSCROLL, { Windows Message }
SB_LINEDOWN, { Scroll Command }
0) { Not Used }
(*
SendMessage(Memo.Handle, { HWND of the Memo Control }
WM_VSCROLL, { Windows Message }
SB_PAGEUP, { Scroll Command }
0); { Not Used }
*)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SendMessage(CodeEdit.Handle, { HWND of the Memo Control }
WM_VSCROLL, { Windows Message }
SB_LINEUP,
0)
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i: integer;
begin
ScrollBar1.Max := CodeEdit.LineCount - 20;
//ScrollBar1.PageSize := 11;
ScrollBar1.Height := CodeEdit.Height;
for i:=1 to CodeEdit.LineCount do
SendMessage(CodeEdit.Handle, WM_VSCROLL, SB_LINEUP, 0);
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
Edit2.Text := IntToStr(ScrollBar1.Position);
if ScrollBar1.Position - Son > 0 then
for i:= 1 to ScrollBar1.Position - Son do
SendMessage(CodeEdit.Handle, WM_VSCROLL, SB_LINEDOWN, 0); //LINEUP
if ScrollBar1.Position - Son < 0 then
for i:= 1 to Son - ScrollBar1.Position do
SendMessage(CodeEdit.Handle, WM_VSCROLL, SB_LINEUP, 0); //LINEUP
Son := ScrollBar1.Position;
end;
end.