如何调用ocx控件 如何调用zhFileOcx.ocx,里面有很多函数,例如OnConnect(ByVal bConn As Boolean, ByVal nFileID As Long)。我写代码怎么样来调用ocx里OnConnect函数,要怎么写?大家帮帮忙!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://dev.csdn.net/develop/article/21/21917.shtm 现在请跟着我做:点击Tools菜单->Environment Options->Type Library页,我们应该发现一项:Ignore special CoClass Flags When Importing,选中它,然后再选中Can Create那一项,那么现在,我们再尝试去导入那个可怜的ActiveX控件吧(这里要注意,如果你已经导入过一次,那么请把产生的那两个文件 .dcr 和 .pas文件删除,否则将不会刷新)。这次如果还是不能在ActiveX栏中发现那个控件的话,那么只有致电Microsoft或是Borland,问问看什么时候它们能结成亲家,呵呵! //vbPublic Sub OnConnect(ByVal bConn As Boolean, ByVal nFileID As Long) Text1.Text = "hello world"End SubPrivate Sub Command1_Click() MsgBox "ok" End Sub////delphiunit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, Project1_TLB, StdCtrls, Buttons;type TForm1 = class(TForm) UserControl11: TUserControl1; BitBtn1: TBitBtn; procedure BitBtn1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);beginself.UserControl11.OnConnect( true,1 );end;end. OnConnect 好像是一个事件而不是一个函数吧 当你为这个事件写了函数以后,譬如:procedure TForm1.ZhFileOcx1Connect(ASender: TObject; bConn: WordBool; nFileID: Integer);begin //here is codeend;ZhFileOcx1Connect和普通的函数是一样的,赋给OnConnect之后它会在Connect时自动触发这个函数,如果要手动使用这个函数,和使用普通函数的方法是一样的。只是注意一下里面的参数必须匹配。WordBool也是一个布尔型,占两个字节,当成Boolean处理就可以了。 vb中的事件默认为privatePrivate Sub Command1_Click()也可以修改成Public Sub Command1_Click()这样的话就可以这样调用self.UserControl11.Command1_Click; 各位,为什么我的OCX跟不进去,断点是有效的,就是不到断点 TCP通信时,发送缓冲区用结构体表示,结构体中定义的变量能否不固定大小. 许久不做delphi 开发,弱弱问个问题 大家现在搞delphi 开发用哪个版本 BDS2006可执行文件鼠标停留时的提示显示? 如何替换ListView中某行的某列 软考通过。散分!! 如何接管IE浏览器的脚本解析 字符串被截的问题 TQuery返回的字段类型信息如何区分numeric还是float? 用delphi连接oracle,任何条件都不能查到结果,快急死了! 哪位朋友有“DELPHI控件大全”之类的电子书? sql top 问题 Delphi中,BDE Administrator 的使用问题
Public Sub OnConnect(ByVal bConn As Boolean, ByVal nFileID As Long)
Text1.Text = "hello world"
End SubPrivate Sub Command1_Click()
MsgBox "ok"
End Sub////delphiunit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, Project1_TLB, StdCtrls, Buttons;type
TForm1 = class(TForm)
UserControl11: TUserControl1;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
begin
self.UserControl11.OnConnect( true,1 );
end;end.
procedure TForm1.ZhFileOcx1Connect(ASender: TObject; bConn: WordBool;
nFileID: Integer);
begin
//here is code
end;ZhFileOcx1Connect和普通的函数是一样的,赋给OnConnect之后它会在Connect时自动触发这个函数,如果要手动使用这个函数,和使用普通函数的方法是一样的。只是注意一下里面的参数必须匹配。WordBool也是一个布尔型,占两个字节,当成Boolean处理就可以了。
Private Sub Command1_Click()
也可以修改成
Public Sub Command1_Click()
这样的话就可以这样调用
self.UserControl11.Command1_Click;