我用创建了一个dll窗体
在此dll窗体里我想再创建一个子的模式窗体
却老是出错,请指教!
代码:如下
我在dll窗体上一个按钮中写:
with  tform2.create(dllform) do
try
  showmodal;
finally
  free;
end;
能创建,但老出现一个内存错误的问题!如何改呢?

解决方案 »

  1.   

    在dll窗体上一个按钮中写:
    Form2 := TForm2.create(dllform);
    Form2.ShowModal;
    Form2.Free;
      

  2.   

    Form2 := TForm2.create(dllform);
      

  3.   

    create是没问题的,但showmodal或者show的时候就出现内存问题了!
    呵呵
    怎么办?
      

  4.   

    dll模块代码如下library Main;{ Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }uses
      SysUtils,
      Classes,
      Forms,
      CMain in 'CMain.pas' {fmMain},
      P_date in 'P_date.pas' {Frm_zipson};{$R *.res}var
      Form1: TfmMain;procedure OpenForm(ParentHandle,AppHandle: Longword) ;stdcall;
    begin
      Application.Handle := AppHandle;
      Form1 := TfmMain.CreateParented(ParentHandle);
      Form1.Show;
    end;procedure ActiveForm();stdcall;
    begin
      Form1.BringToFront;
    end;procedure FreeForm();stdcall;
    begin
      FreeAndNil(Form1);
    end;procedure ShowMapForm();stdcall;
    begin
    //
    end;exports OpenForm;
    exports ActiveForm;
    exports FreeForm;
    exports ShowMapForm; begin
    end.
    然后在dll一按钮中写如上所有create和showmodal方法,都出错,怎么改正呢?
      

  5.   

    wave_f(小浪花):大侠你要什么啊!基本的代码都在上面了!
      

  6.   

    CMain in 'CMain.pas' {fmMain},    //这就是主dll窗体,我让它显示在主应用程序的panel上!()  P_date in 'P_date.pas' {Frm_zipson};//这是dll模块里包含的另外一个窗体单元,我想在cmain窗体中某一按钮点击时创建并显示它!可有问题,老出现内存错误!
      

  7.   

    感觉是Form1 := TfmMain.CreateParented(ParentHandle);
    这里改 Form1 := TfmMain.CreateParented(Application);
      

  8.   

    谢谢,不过不行的,我的ParentHandle是传入的是主应用程序上panel的句柄!我要的就是让form1显示在主应用程序的panel上!所以不能改,而且改了,框架就乱了!谢谢,请继续