编写一个控件如何添加可由用户设置的属性?

johnxie132 2003-08-23 03:09:06
如题
...全文
38 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2003-08-23
  • 打赏
  • 举报
回复
没使用__property肯定是不可显示的属性
也就是定义在public:中的,可以这样用
johnxie132 2003-08-23
  • 打赏
  • 举报
回复
还有别的方法吗?我有一个控件的代码,没使用__property也有几项自定义属性
柯本 2003-08-23
  • 打赏
  • 举报
回复
class PACKAGE TSwitch : public TPanel
{
private:
bool fstatus;
bool fswtype;
MyEvent fclick;
unsigned short fregister;

DYNAMIC void __fastcall MouseDown(Controls::TMouseButton Button, Classes::TShiftState Shift, int X,
int Y);
// DYNAMIC void __fastcall KeyDown(Word &Key, Classes::TShiftState Shift);
DYNAMIC void __fastcall MouseUp(Controls::TMouseButton Button, Classes::TShiftState Shift, int X,
int Y);
void __fastcall mypaint(void);
void __fastcall setstatus(bool x)
{
fstatus=x;
mypaint();
};
void __fastcall setswtype(bool x)
{
fswtype=x;
mypaint();
};
void __fastcall Defclick(Controls::TMouseButton Button, Classes::TShiftState Shift, int X,
int Y)
{
};

protected:
public:
__fastcall TSwitch(TComponent* Owner);
__published:
__property bool status = { read = fstatus,write = setstatus,nodefault}; //自已加的
__property bool swtype = { read = fswtype,write = setswtype,nodefault};
__property unsigned short PLCregister =
{ read = fregister,write = fregister,nodefault};
__property MyEvent OnMyClick = { read = fclick,write = fclick,nodefault};

};

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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