请问大家能做一个TComboBox [StdCtrls] 继承的控件吗,我做好后出现了rtl60.bpl错误,我是用BCB6+WIN2000,大家中秋快乐

hzdsxu 2003-09-11 01:47:49
你能不能试下用以下这个类做个控件,让后加入OnMouseMove,OnMouseUp,OnMouseDown 事件,我试了N次不成功,老是rtl60.bpl错误,放不到窗口上去。谢谢,如果成功请告诉我啊。
TComboBox [StdCtrls]

我的做法如下:在.h文件里加入三行鼠标消息的公布。
class PACKAGE TComboBox1 : public TComboBox
{
private:
protected:
public:
__fastcall TComboBox1(TComponent* Owner);
__published:
__property OnMouseMove;
__property OnMouseDown;
__property OnMouseUp;
};

//.cpp文件
#include <vcl.h>

#pragma hdrstop

#include "ComboBox1.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TComboBox1 *)
{
new TComboBox1(NULL);
}
//---------------------------------------------------------------------------
__fastcall TComboBox1::TComboBox1(TComponent* Owner)
: TComboBox(Owner)
{
}
//---------------------------------------------------------------------------
namespace Combobox1
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TComboBox1)};
RegisterComponents("Data Controls", classes, 0);
}
}
...全文
52 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ch_builder 2004-03-26
  • 打赏
  • 举报
回复
rtl60.bpl是CB运行时所需要的动态链,检查一下是不是你的CB中没有或是这个文件出现错误了,更替下试一下,要是打包时,不包含这个文件是一定不行的,我们的文件在别人的机器上是运行不了的:)
GodBirdFlying 2004-03-25
  • 打赏
  • 举报
回复
路过看看
顺便up
hzdsxu 2003-09-12
  • 打赏
  • 举报
回复
这三个鼠标事件去掉,还是要出错,
woainihaha 2003-09-11
  • 打赏
  • 举报
回复
TComboBox是一个组合型容器类控件,而通常的MouseDown或MouseUp以及MouseMove事件是目标唯一性事件(即通常情况下,其事件对应的主体唯一),在这类控件中通常封装MouseDown或MouseUp以及MouseMove事件一是实用性不大,二是不可能为每一个TComboBox的Control创建事件.如TComboBox默认的主Mouse事件的对象为一Button(下拉按纽),而你所需要的事件是Edit的事件.
比如最直接的Button(下拉按纽)的Mouse事件如下:
....
class PACKAGE TMComboBox : public TComboBox
{
private:
TMouseEvent FOnMouseDown;
TMouseEvent FOnMouseUp;

protected:
__declspec(dynamic) void __fastcall MouseDown(TMouseButton Button,Classes::TShiftState Shift,int X,int Y);
__declspec(dynamic) void __fastcall MouseUp(TMouseButton Button,Classes::TShiftState Shift,int X,int Y);

public:
__fastcall TMComboBox(TComponent* Owner);
__published:
__property TMouseEvent OnMouseDown = { read = FOnMouseDown, write = FOnMouseDown };
__property TMouseEvent OnMouseUp = { read = FOnMouseUp, write = FOnMouseUp };

};

void __fastcall TMComboBox::MouseDown(TMouseButton Button, Classes::TShiftState Shift, int X, int Y)
{
if (FOnMouseDown) FOnMouseDown(this,Button,Shift, X, Y);
}
//---------------------------------------------------------------------------

void __fastcall TMComboBox::MouseUp(TMouseButton Button, Classes::TShiftState Shift, int X, int Y)
{
if (FOnMouseDown) FOnMouseUp(this,Button,Shift, X, Y);
}

//---------------------------------------------------------------------------

703

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder ActiveX/COM/DCOM
社区管理员
  • ActiveX/COM/DCOM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧