请问怎么关闭DLL窗体?

解决方案 »

  1.   

    对不起我没说清楚,是通过一个按钮来关闭DLL窗体
      

  2.   

    用Close会报错如下
    Access violation at address 003A1441 in module 'systeam.dll'. Read of address 000002EC.
      

  3.   

    我的DLL窗体是外部创建的和主程序不属一个工程文件再请问一下DLL窗体可以和主程序创建在同一个工程文件里吗?
      

  4.   

    我总是用下面的代码书写DLL中的Form(模式与非模式,从来没有出现错误),代参考:
    function ShowModalForm(ahandle : THandle;aCaption : ShortString) : Boolean;stdcall;export;
    function ShowFormMe(aHandle : THandle;aCaption : ShortString) : LongInt; stdcall;export;
    procedure CloseFormMe(var ahandle : Longint);
    implementation{$R *.DFM}
    function ShowFormMe(aHandle : THandle;aCaption : ShortString) : LongInt;stdcall;
    var
      aForm : TForm1;
    begin
      Application.Handle := aHandle;
      aForm := TForm1.Create(Application);
      aform.Caption := aCaption;
      Result := LongInt(aForm);
      aForm.show;
    end;procedure CloseFormMe(var aHandle : LongInt);
    begin
      if ahandle>0 then
        TForm1(ahandle).free;
      ahandle:=0;
    end;function ShowModalForm(aHandle : THandle;aCaption : ShortString) : Boolean;stdcall;
    var
      aForm : TForm1;
    begin
      Result := false;
      Application.Handle := ahandle;
      aForm := TForm1.Create(Application);
      try
        aForm.Caption := aCaption;
        aForm.ShowModal;
        Result := True;
      finally
         aForm.free;
      end;
    end;