用C++Builder写的主程序,用Delphi写DLL,然后从Dll中引出一个函数,其功能是把一个窗体嵌入到
主程序的TPageControl中,但显示不出来。
  Delphi DLL
  ....
  function ShowClientServerInfo(AParent:TWinControl):HWND;stdcall;
  begin
    if frmClientServerInfo = nil then
      frmClientServerInfo := TfrmClientServerInfo.Create(nil);
    frmClientServerInfo.Parent := AParent;
    frmClientServerInfo.Show();
    frmClientServerInfo.Update();
    Result := frmClientServerInfo.Handle;
  end;
 C++ builder 
      调用代码:
         PageControl1->ActivePage = TabSheet10;
         DM->ShowClientServerInfo(TabSheet10);
//函数的调用包装
void __fastcall TDM::ShowClientServerInfo(TWinControl* AParent)
{
   typedef THandle (WINAPI *DelphiProc)(TWinControl*AParent);
   HINSTANCE hinstDLL = LoadLibrary("beauty.dll");
   char *ProcName = "ShowClientServerInfo";
   if (hinstDLL)
   {
       DelphiProc Proc= (DelphiProc)GetProcAddress(hinstDLL,ProcName);
       if (Proc)
       {
          Proc(AParent);
          //FreeLibrary(hinstDLL);
          return ;
       }
       else
       {
          FreeLibrary(hinstDLL);
          ShowMessage("ShowClientServerInfo No found in beauty.dll");
          return ;
       }
   }
}

解决方案 »

  1.   

    建議你把問題分離,首先使用D測試是否可以SHOW出來,如果可以就是CBUILD的問題了,否則就是DLL問題/
      

  2.   

    这个问题有个折中的解决办法。
    好象Dll里的Form设置的Parent为TForm就能看见了,其他TControl都看不到。
    类似下面方法可行,弄个BorderStyle=bsNone的窗体作为中介frmTemp,在TabSheet10上建立窗体frmTemp,然后将Dll窗体建立在frmTemp上,就能够看到了。
    Delphi中的Dll参数传递用这样形式更好。function ShowClientServerInfo(pIn:Pointer):HWND;export;stdcall;
    begin
        if frmClientServerInfo =nil then
            frmClientServerInfo :=TfrmClientServerInfo.Create(nil);
        frmClientServerInfo .Parent:=TWinControl(pIn);
        frmClientServerInfo .Show;
        Result:=frmClientServerInfo .Handle;
    end;
    .......................................
    PageControl1->ActivePage = TabSheet10;
    frmTemp->Create(Owner);
    frmTemp->Parent=TabSheet10;DM->ShowClientServerInfo(frmTemp);
      

  3.   

    to  gzmhero(hihihi) 谢谢你的回答,但我试一下,没有效果的
      

  4.   

    很奇怪你们的项目要这样搞。全部用C++Builder又没有什么限制的。
      

  5.   

    To  lextm(LeLe) 项目很奇怪是吧,原因如下:
      是修改前人写的一个程序(C++builder 写的),但我C++builder 用的不熟,所以才如此