📄 h20000127-22.htm
字号:
<html><head><script language="JavaScript"> function reset(){ for ( var i=0; i < document.Form1.elements.length; i++ ) { document.Form1.elements[i].options[0].selected=true }}function going(url){ parent.location=url; reset();}</script><style><!--A:link {text-decoration: none; color: #000000; font-family: 宋体}A:visited {text-decoration: none; color: #000000; font-family: 宋体}A:active {text-decoration: none; font-family: 宋体}A:hover {text-decoration: underline:#ffffff; color: #ff0000}body,table {font-size: 9pt; font-family: 宋体}.H1 {font-size: 9pt ; line-height:9pt; align=center}.ourfont {font-size: 9pt ; line-height:9pt; }.ourfont1 {font-size: 9pt ; line-height:9pt; }--></style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>如何在C++Builder中使用Delphi控件</title></head><body topmargin="0" leftmargin="0"><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td><p class="content4"><span class="font"><img border="0" height="3" src="../../soft/pix.gif" width="700"></span></td> </tr></tbody></table></center></div><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td bgColor="#3399ff" width="658"><p class="content4"><span class="font"> </span><a style="text-decoration: none; color: rgb(255,255,255)" href="../os/H00705-2.htm">操作系统</a><font color="#FFFFFF"><span class="font"><span> |</span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../image/H00705-14.htm">图像处理</a><font color="#FFFFFF"><span>|<span class="font"> </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../autoCAD/H00705-19.htm">辅助设计</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../data/H00705-18.htm">数 据 库</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="H00706-1.htm">高级编程</a><span class="font"><font color="#FFFFFF"><span> | </span></font></span><a style="color: rgb(255,255,255); text-decoration: none" href="../netuse/H00705-20.htm">网络应用</a><font color="#FFFFFF"><span><span class="font"> | </span></span></font><a style="color: rgb(255,255,255); text-decoration: none" href="../webpage/H00705-21.htm">网页制作</a><font color="#FFFFFF"><span><span class="font"> |</span></span></font> <a style="color: rgb(255,255,255); text-decoration: none" href="../technic/H00706-3.htm">技术交流</a> <font color="#000000"><strong> <a style="COLOR: rgb(255,255,255); TEXT-DECORATION: none" href="http://202.100.13.77/clslyb/default.asp?clsid=jiaoc">过客留言</a></strong></font></td> <td bgColor="#3399ff" width="32"><p align="center" class="content4"><a href="http://202.100.13.77/clslyb/default.asp?clsid=jiaoc"><img src="../../soft/email.gif" alt="email.gif (493 字节)" border="0" WIDTH="20" HEIGHT="19"></a></td> </tr></tbody></table></center></div><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td align="middle" bgColor="#3399ff" vAlign="top" width="130"></td> <td vAlign="top" width="20"><p class="content4"><img src="../../soft/jiao2.gif" alt="jiao2.gif (176 字节)" WIDTH="14" HEIGHT="14"></td> <td vAlign="top" width="550"><p class="content4" align="center"><span class="font"></span></td> </tr></tbody></table></center></div><div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="700"><tbody> <tr> <td bgColor="#000000" height="1" width="130"><p class="content4"><span class="font"></span></td> <td height="1" width="20"><p class="content4"><span class="font"></span></td> <td bgColor="#000000" height="1" width="200"><p class="content4"><span class="font"></span></td> <td bgColor="#000000" height="1" width="200"><p class="content4"><span class="font"></span></td> <td height="1" width="10"><p class="content4"><span class="font"></span></td> <td bgColor="#000000" height="1" width="140"><p class="content4"><span class="font"></span></td> </tr> <tr> <td align="middle" bgColor="#3399FF" vAlign="top" width="130"><p class="content4" align="center"><span class="font"><br> </span></p> <p class="content4" align="center"><strong><a style="text-decoration: none; color: rgb(255,255,255)" href="../os/H00705-2.htm">操作系统</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="../image/H00705-14.htm">图像处理</a></strong><br> <font color="#ff0000"><b><br> </b></font><strong><a style="color: rgb(255,255,255); text-decoration: none" href="../autoCAD/H00705-19.htm">辅助设计</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="../data/H00705-18.htm">数 据 库</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="H00706-1.htm">高级编程</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="../netuse/H00705-20.htm">网络应用</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="../webpage/H00705-21.htm">网页制作</a></strong><br> <br> <strong><a style="color: rgb(255,255,255); text-decoration: none" href="../technic/H00706-3.htm">技术交流</a></strong></p> <div align="center"><center><table border="0" cellPadding="0" cellSpacing="0" width="100%"><tbody></tbody> </table> </center></div><table border="0" cellPadding="0" cellSpacing="0" width="100%"><tbody></tbody> </table> </td> <td align="middle" vAlign="top" width="20"><p align="left" class="content4"><span class="font"><span><br> </span></span></td> <td colSpan="2" vAlign="top" width="400"> <p> <font SIZE="2"></p> <p>如何在C++Builder中使用Delphi控件</p> <p>上海铁道大学 施江杰</p> <p> </p> <p>----Delphi的出现将一大批程序员带入了Windows下的可视化编程,为一些C&C++的死党程序员所羡慕、感叹。</p> <p>直到C++Builder的出现这些Programer才用到了梦寐以求的编程工具,也将一些不得已"投敌"到Delphi下的程</p> <p>序员又拉回到C++的怀抱。她正真将Windows下的可视化编程和面向对象编程语言有机的融合在一起。但是由</p> <p>于C++Builder面市时间较短固而可用的控件不多,而且控件的使用也只针对某一版本,相互之间的可互用性</p> <p>不好,除非你有SourceCode;对于Delphi就更不用说了,C++Builder根本不能用,当然如果你有SourceCode</p> <p>那么你可以转写成C++Builder的控件,不过你还得经过n遍的Complie…m遍的Step&Go…最后※☆▲#\↓。</p> <p>----Delphi拥有强大的控件群,如何使用这些控件一直苦恼着我们这些C++Builder的追随者,我通过一些项</p> <p>目的实践掌握了一些如何在C++Builder中使用Delphi控件的方法。</p> <p>----我的使C++Builder使用DelphiVCL类库的方法基于Windows中较通用的DLL方式。在实际应用中找到了将</p> <p>VCL控件转化为DLL库,在C++Builder动态调用DLL。此法适用于非可视VCL控件。</p> <p>----假令在Delphi中有一Sample控件,有属性Actived、Pro1、Pro2,欲将这个控件转到C++Builder中使用。</p> <p>一:Delphi中DLL的制作</p> <p>在Delphi中新建一DLL项目SampleDLL,时在此项目中Create一个新的类TTtempcomp基类为TComponent即也为</p> <p>一个控件,在其中加入一个constructorCreate1,但不作任何动作;在DLL中加入要导出的属性的Function</p> <p>(Actived、Pro1、Pro2)&Create、Destroy的框架,Exports中加入导出的Function、Procdure名称;在DLL</p> <p>的主过程中对TTempcomp的实例temp1进行Create1,另外保存出口和设置ExitProc;在OpenSample的函数中加</p> <p>入HwCtrl:=Sample1.Create(temp1)对Sample进行实例化,对CloseSample和其它属性加入相应的语句;</p> <p>二:C++Builder中DLL的使用</p> <p>将Delphi中生成的DLL用implib生成LIB文件加入C++Builder的工程文件;</p> <p>在头文件中加入 </p> <p>extern "C" __declspec(dllimport) bool _stdcall OpenSample(void); </p> <p>extern "C" __declspec(dllimport) void _stdcall CloseSample(void); </p> <p>extern "C" __declspec(dllimport) bool _stdcall Actived (void); </p> <p>extern "C" __declspec(dllimport) int _stdcall Pro1 (void); </p> <p>extern "C" __declspec(dllimport) int _stdcall Pro2 (void); </p> <p>在OpenSample后你就可以使用Delphi中的属性Actived、Pro1、Pro2 </p> <p>三:参考DLL Source如下: </p> <p>library SampleDLL;</p> <p>uses</p> <p>SysUtils, Classes, Sample; </p> <p>TYPE </p> <p>TTempcomp = class(TComponent)</p> <p>private</p> <p>public</p> <p>constructor Create1;</p> <p>published</p> <p>end;</p> <p>var </p> <p>Sample1 :Sample;</p> <p>SaveExit :Pointer;</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -