用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 ;
}
}
}
主程序的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 ;
}
}
}
解决方案 »
- PChar转String问题
- 其它电脑访问A机时,提示"网络登入服务尚未启动, 把A机退出域提示"指定的服务并未以已安装的服务存在. 点解?
- 查找字段的问题
- 要运行D8写的.Net程序的机器上应该装些什么?
- 讨论:perform(),sendmessage(),postmessage()区别
- Oracle与C编程底层软件。哪个比较有前途???
- 如果使用DELPHI实现打印预缆?
- 关于在table1中保存图片的问题
- 谁有ICS 的 FTP SERVER 的说明文档?
- 一段可以冒充QQ上线,下线的源代码,支持最新版0710B
- 在DELPHI程序中,要如何才能取到ACCESS数据库字段的标题呢?
- 请教:关于两窗体间传递消息的问题
好象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);
是修改前人写的一个程序(C++builder 写的),但我C++builder 用的不熟,所以才如此