⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycomponent.h

📁 C++Builder高级应用开发指南随书源码
💻 H
字号:
//---------------------------------------------------------------------------

#ifndef MyComponentH
#define MyComponentH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <dsgnintf.hpp>
//---------------------------------------------------------------------------
typedef void __fastcall (__closure * TCountChangedEvent)
    (TObject * Sender, int & Count);
    
class TMyGraphic: public TPersistent
{
private:
    int FTest;
public:
    __fastcall TMyGraphic();
__published:
    __property int Test={read=FTest,write=FTest};
};

class PACKAGE TMyComponent : public TWinControl
{
private:
    TMyGraphic * FGraphics;
    int FCount;
    bool IsMouseEnter;
    TCountChangedEvent FCountChanged;
    int FPointArray[5];
    int __fastcall GetCount();
    void __fastcall SetCount(int ACount);
    int __fastcall GetPointArray(int Index);
    void __fastcall SetPointArray(int Index, int Value);
    void __fastcall DoPaint(TWMPaint & Mess);
    void __fastcall OnMouseEnter(TMessage &Mess);
    void __fastcall OnMouseLeave(TMessage & Mess);
protected:
    BEGIN_MESSAGE_MAP
        VCL_MESSAGE_HANDLER(WM_PAINT, TWMPaint, DoPaint)
        VCL_MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, OnMouseEnter)
        VCL_MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, OnMouseLeave)
    END_MESSAGE_MAP(TWinControl)
public:
    __fastcall TMyComponent(TComponent* Owner);
    __fastcall ~TMyComponent();
    __property int PointArray[int Index]={read=GetPointArray,write=SetPointArray};
__published:
    __property BevelInner;
    __property BevelOuter;
    __property BevelKind;
    __property BevelWidth;

    __property OnClick;
    
    __property int Count = {read=GetCount, write=SetCount, default=5};
    __property TCountChangedEvent OnCountChanged = {read=FCountChanged,
        write=FCountChanged,nodefault};
    __property TMyGraphic * Graphics={read=FGraphics,write=FGraphics};
};
//---------------------------------------------------------------------------

class PACKAGE TMyPropertyEditor:public TPropertyEditor
{
public:
    void __fastcall SetValue(String Value);
    String __fastcall GetValue();
    TPropertyAttributes __fastcall GetAttributes();
    void __fastcall Edit();
    __fastcall TMyPropertyEditor(const _di_IFormDesigner ADesigner, int APropCount);
    __fastcall ~TMyPropertyEditor();
};
//---------------------------------------------------------------------------

class PACKAGE TMyComponentEditor:public TComponentEditor
{
public:
    int __fastcall GetVerbCount();
    String __fastcall GetVerb(int Index);
    void __fastcall ExecuteVerb(int Index);
    void __fastcall Edit();
};
//---------------------------------------------------------------------------
#endif
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -