我的程序是MDI的,但是我怎么做 “上个窗口”和“下个窗口功能”(50分)

  • 主题发起人 主题发起人 winixi
  • 开始时间 开始时间
W

winixi

Unregistered / Unconfirmed
GUEST, unregistred user!
得到上个和下个 MDI子窗口 ?
 
你可以使用主窗体的WindowMenu属性,把你希望作为控制子窗体的菜单项赋给WindowMenu属性,delphi就会自动出来子窗口的功能,就像Word的“窗口(W)”菜单。
这是一个例子:
主窗体:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;

type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
new1: TMenuItem;
window1: TMenuItem;
Cascade1: TMenuItem;
procedure Cascade1Click(Sender: TObject);
procedure new1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses
Unit2;

procedure TForm1.Cascade1Click(Sender: TObject);
begin
Cascade
end;

procedure TForm1.new1Click(Sender: TObject);
var
Form2:TForm2;
begin
Form2 := TForm2.Create(Self);
Form2.Caption := TimeToStr(Now);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.WindowMenu := window1;
end;

end.

******************************************************************
子窗体:
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm2 = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;

end.
 
另外,作为“窗口(W)”菜单的菜单项需要原来就有几个菜单项,比如“平铺”子窗口菜单项,等等。
 
直接 Next()
 
接受答案了.
 
后退
顶部