1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,StdCtrls,unit2;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
MyScrollBar: TScrollBar;
frm:TFrame2;
procedure MyScrollBarOnScroll(Sender: TObject);
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
ScrollInfo:TScrollInfo;
begin
MyScrollBar:=TScrollBar.Create(self);
with MyScrollBar do
begin
Parent:=panel1;
Align:=alRight;
Kind:=sbVertical;
Visible:=True;
end;
frm:=TFrame2.Create(self);
with frm do
begin
Parent:=panel1;
Align:=alClient;
end;
ScrollInfo.cbSize:=sizeof(ScrollInfo);
GetScrollInfo(frm.Handle,SB_VERT,scrollinfo);
with MyScrollBar do
begin
PageSize:=ScrollInfo.nPage;
Max:=ScrollInfo.nMax;
Min:=ScrollInfo.nMin;
Position:=ScrollInfo.nPos;
OnChange:=MyScrollBarOnScroll;
end;
frm.VertScrollBar.Visible:=False;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
frm.Free;
MyScrollBar.Free;
end;
procedure TForm1.MyScrollBarOnScroll(Sender: TObject);
begin
SendMessage(frm.Handle,WM_VSCROLL,MyScrollBar.Position,0);
end;
end. |
Partager