+ -
当前位置:首页 → 问答吧 → 这段代码会弹出两个窗体,应该如何修改呢?

这段代码会弹出两个窗体,应该如何修改呢?

时间:2011-09-20

来源:互联网

Delphi(Pascal) code


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus,U_Myinterface;//在工程加入U_Myinterface这个unit,让exe也和bpl使用同一个接口。

type
Tmain = class(TForm)
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    bpl1: TMenuItem;
    procedure bpl1Click(Sender: TObject);
private
    { Private declarations }
public
    { Public declarations }
    my:Myinterface;
end;

var
main: Tmain;

implementation

{$R *.dfm}

procedure Tmain.bpl1Click(Sender: TObject);
var
hModule: THandle;
frm:TForm;
begin
hModule := LoadPackage('Plabel.bpl');       //动态载入包
frm:=TForm(TComponentClass(FindClass('Tform1')).Create(Application)); //创建form,
frm.ShowModal;          //show出来,如果需要用MDI方式,只需要把form的formstyle改了,然后用下面的代码即可
my:=TComponentClass(FindClass('Tform1')).Create(Application) as Myinterface; //转化为接口
my.show123('11');                                    //调用接口函数     
end;

end.



作者: wensoft80   发布时间: 2011-09-20

frm:=TForm(TComponentClass(FindClass('Tform1')).Create(Application)); //创建form,

my:=TComponentClass(FindClass('Tform1')).Create(Application) as Myinterface; //转化为接口

主要是第二句,应该如何修改才能不弹出窗体?

作者: wensoft80   发布时间: 2011-09-20