我将一个form封装在dll中,然后再通过程序调用这个dll中的form。但是showmodule过程后,form是弹出了,但是在windows的任务栏下又有了一个任务(让人感觉上像是),这个任务就是弹出的form,这是为什么,应该如何解决?

解决方案 »

  1.   

    dll也是可执行文件,被调用的时候,也会进入到系统内存中,这是我的理解
      

  2.   

    unit Main;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Memo1: TMemo;
        procedure Button1Click(Sender: TObject);
      private
          h : THandle;
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      procedure ss(app: TApplication; cscreen: TScreen);stdcall;external 'DelphiDll.dll' name 'ShowForm';
    implementation
      //procedure ss( a:PInteger );stdcall;external 'Project1.dll' name 'PassArray'
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      ss(Application, Screen);
    end;end.
    传个Applicaion和Screen参数过去就行了.
      

  3.   

    DLL中的代码如下procedure ShowForm(app: TApplication; cscreen: TScreen);stdcall;
    var
      M : TForm1;
    begin
      Application := app;
      Screen := cscreen;
      M := TForm1.Create(Nil);
      M.ShowModal;
      M.Free;
      

  4.   

    jjwwang(风归叶) 的方法,把Application传到dll里面
      

  5.   

    我也传过去了呀,TScreen没有传,我来试试!
      

  6.   

    哦,我没有加上这一句,5555   Application := app;
    还问一下,dll的form的button按钮下的脚本Self.close;为什么就把我怎个程序关闭了呢?
      

  7.   

    经过测试,dll中的form是关闭了,但是我运行的程序还在内存中驻留了。能告诉我这是为什么呢?
      

  8.   

    var
      oldapp :TApplication;
      oldscreen : TScreen;
    procedure ShowForm(app: TApplication; cscreen: TScreen);stdcall;
    var
      M : TForm1;
    begin
      oldapp := Application;
      oldscreen := Screen;
      Application := app;
      Screen := cscreen;
      M := TForm1.Create(Nil);
      M.ShowModal;
      M.Free;
      Application := oldapp;
      Screen := oldscreen;
    end;
    exports
    ShowForm;
      

  9.   

    Application := oldapp;
      Screen := oldscreen;
    还需要还原回去.