关于一个动态多页界面的问题求助?(0分)

  • 主题发起人 主题发起人 211liu
  • 开始时间 开始时间
2

211liu

Unregistered / Unconfirmed
GUEST, unregistred user!
[:(][:(]//我想编一个多页界面,自定义了动态类TDynaPage,但是我在最后一个过程中总出错,
即打开一文本文件出错,望高手指教一二,这里就先谢了。
能否发个例子//
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, Tabs, ExtCtrls, Menus, StdCtrls;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
d1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
N24: TMenuItem;
Notebook1: TNotebook;
TabSet1: TTabSet;
StatusBar1: TStatusBar;
OpenDialog1: TOpenDialog;
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
Tdynapage=class(Tobject)
public
curpage:integer;
filelist:Tstringlist;
procedure addpage(sender:Tnotebook;filename:string);
private
end;
procedure getmemo(pi:pointer);
var
Form1: TForm1;
dynapage:Tdynapage;
memo1:Tmemo;
implementation
procedure getmemo(pi:pointer);
var
memo:Tmemo;
begin
memo:=Tmemo.Create(pi);
memo.Parent :=pi;
memo.Align :=alclient;
memo.Color :=clnone;
memo.BorderStyle :=bsnone;
memo1:=memo;
end;
procedure Tdynapage.addpage(sender:Tnotebook;filename:string);
var
pi:pointer;
memo:Tmemo;
begin
sender.pages.add(filename);//当前是加入文件名//
pi:=sender.pages.objects[sender.pages.count-1];
//指针是指在当前页面的前面的//
getmemo(pi);
dynapage.filelist.addobject(filename,memo1);
form1.tabset1.tabs:=sender.pages;
form1.tabset1.tabindex:=sender.pages.count-1;
form1.Notebook1 .pageindex:=form1.tabset1.tabindex;
dynapage.curpage :=sender.pages.count-1;
end;

{$R *.dfm}

procedure TForm1.openClick(Sender: TObject);
begin
if opendialog1.Execute then

begin
dynapage.addpage(notebook1,extractfilename(opendialog1.filename));
notebook1.pages.loadfromfile(opendialog1.filename);
end;
end;

end.
 
后退
顶部