多个窗口 (20分)

  • 主题发起人 主题发起人 stamf
  • 开始时间 开始时间
S

stamf

Unregistered / Unconfirmed
GUEST, unregistred user!
一个project里面有多个form,一个应用程序似乎只能在任务栏上显示一个按钮,
有什么办法让每个窗口都显示一个按钮?

例如 project1 里面有 form1 form2,form1是主窗口
当form1.show form2.show,这时候,只在任务栏上有一个按钮,有没有办法让
from1和form2各产生一个按钮?
 
------Project.dpr----
program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};

{$R *.RES}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
application.showmainform:=false;
if paramcount=0 then
begin
form1.show;
end
else
begin
if paramstr(1)='1' then
begin
form2.show;
end;
end;
Application.Run;
end.

-----Unit1.pas------
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
VAR AFORM:tform2;
begin
AFORM:=tform2.CREATE(APPLICATION);
aform.show;
end;

end.
------Unit2.pas---------
unit Unit2;

interface

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

type
TForm2 = class(TForm)
private
procedure CreateParams(VAR Params: TCreateParams); override;
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.DFM}

procedure TForm2.CreateParams(VAR Params: TCreateParams);
begin
Inherited CreateParams(Params);
Params.WndParent := GetDesktopWindow; //※※※※
end;


end.
 
接受答案了.
 
后退
顶部