我在主程序中调用了DLL,这个DLL中有窗体对象,现在我在动态调用该DLL并显示DLL里面的窗体时什么都不显示,但是代码却执行了。为什么?到底是为什么?怎么解决?

解决方案 »

  1.   

    参考:library MyDll;uses
      SysUtils,
      Classes,
      Main in 'Main.pas' {Form1};{$R *.res}procedure ShowForm;
    begin
      Form1:=TForm1.Create(nil);
      Form1.ShowModal;
      Form1.Free;
    end;exports
      ShowForm;beginend.program MyApp;{$APPTYPE CONSOLE}uses
      Windows;type
      TShowForm = procedure;var
      hModule: Cardinal;
      ShowForm: TShowForm;
    begin
      hModule:=LoadLibrary('MyDll.dll');
      if hModule<>0 then
      begin
        ShowForm:=GetProcAddress(hModule, 'ShowForm');
        if Assigned(ShowForm) then
          ShowForm;
        FreeLibrary(hModule);
      end;
    end.
      

  2.   

    这块是一样的,我需要对DLL窗体进行dock和非dock操作。在交替操作时出现上述问题
      

  3.   

    在主程序工程和dll工程中分别动态连接包vcl60,否则内存中存在两分TFrom,从而正常阻塞消息传递