已有一窗体mainform ,点其中一按钮弹出itemform窗体,并且该窗体可以在任务栏中显示出来。
点itemform窗体中的一个按钮弹出additemform窗体,该窗体在任务栏中不显示。
现在想只有对additemform窗体进行操作完后,其它窗体才可用,并且additemform窗体在那两个窗体的上边显示,如果点了mainform或itemform窗体,都会把焦点集中在additemform上。类似messagebox的那种功能。
请高手帮忙!
我的做法是在mainform中用itemform.show;在itemform中用additemform.showmodal;
可是additemform无法显示在两个窗体的前边,另外点任务栏中上的itemform时无法让焦点在additemform上。
点itemform窗体中的一个按钮弹出additemform窗体,该窗体在任务栏中不显示。
现在想只有对additemform窗体进行操作完后,其它窗体才可用,并且additemform窗体在那两个窗体的上边显示,如果点了mainform或itemform窗体,都会把焦点集中在additemform上。类似messagebox的那种功能。
请高手帮忙!
我的做法是在mainform中用itemform.show;在itemform中用additemform.showmodal;
可是additemform无法显示在两个窗体的前边,另外点任务栏中上的itemform时无法让焦点在additemform上。
参考下面吧,
Form1是你的mainform,
Form2是你的itemform,
Form3是你的additemform.program Project1;uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3};{$R *.res}begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
//Application.CreateForm(TForm2, Form2);
//Application.CreateForm(TForm3, Form3);
Application.Run;
end.unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
protected
procedure WMSysCommand(var msg: TMessage); message WM_ACTIVATE;
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses
Unit2,
Unit3;{$R *.dfm}procedure TForm1.WMSysCommand(var msg: TMessage);
begin
if Assigned(Form3) then
Form3.SetFocus
else
inherited;
end;procedure TForm1.btn1Click(Sender: TObject);
begin
Application.CreateForm(TForm2, Form2);
Form2.Show;
end;end.unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm2 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;var
Form2: TForm2;implementationuses
Unit3;{$R *.dfm}procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent := GetDesktopWindow;
end;procedure TForm2.btn1Click(Sender: TObject);
begin
Application.CreateForm(TForm3, Form3);
Form3.ShowModal;
Form3.Free;
Form3 := nil;
end;end.unit Unit3;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm3 = class(TForm)
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
IsExist: Boolean;
end;var
Form3: TForm3;implementationuses
Unit2;{$R *.dfm}procedure TForm3.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.WndParent := Form2.Handle;
end;end.