用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 ;
}
}
}
解决方案 »
- Delphi2009的指针操作十分混乱,或者应该算严重的Bug!
- 如何把一个包括3个TAB符号的字符串分成四个部分的子串?
- 300 分求 内存表 kbmMemTable 问题
- 有关jpg加入数据的问题
- 关于报表的一个简单问题
- !!!!!!!赶在五一的之前升级了,祝朋友们五一快乐 8!!!!!!!!
- 用 delphi 写数据库程序,使用什么做最简单,发布最方便?
- 如何获取Win2000里All Users所在的文件夹?
- delphi 下运行批处理命令,cmd 占用cpu80%
- 如何寫一個函數得到某月最后一天?
- 在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 用的不熟,所以才如此