📄 vcl简单示例.txt
字号:
//--------------------------- LinkImage.h -----------------------------------
#ifndef LinkImageH
#define LinkImageH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
class PACKAGE TLinkImage : public TImage
{
private:
TPicture * FHoverPic;
TPicture * FLinkPic;
TNotifyEvent Fabc;
void __fastcall SetPicture(Graphics::TPicture * value);
void __fastcall SetHoverPic(Graphics::TPicture * value);
void __fastcall abcd(TNotifyEvent value);
protected:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(CM_MOUSEENTER, Messages::TMessage, MouseEnter)
VCL_MESSAGE_HANDLER(CM_MOUSELEAVE, Messages::TMessage, MouseLeave)
END_MESSAGE_MAP(TImage)
void __fastcall MouseEnter(Messages::TMessage & Message);
void __fastcall MouseLeave(Messages::TMessage & Message);
virtual void __fastcall CreateWnd(void);
public:
__fastcall TLinkImage(TComponent* Owner);
__fastcall ~TLinkImage();
DYNAMIC void __fastcall Click(void);
__published:
__property Graphics::TPicture * LinkPic = { read=FLinkPic, write=SetPicture };
__property Graphics::TPicture * HoverPic = { read=FHoverPic, write=SetHoverPic };
__property Picture = {read=FPicture, write=SetPicture};
__property TNotifyEvent abc = { read=Fabc, write=abcd };
};
//---------------------------------------------------------------------------
#endif
//=======================================================================================================================
//---------------------------------LinkImage.cpp-----------------------------
#include <vcl.h>
#pragma hdrstop
#include "LinkImage.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(TLinkImage *)
{
new TLinkImage(NULL);
}
//---------------------------------------------------------------------------
__fastcall TLinkImage::TLinkImage(TComponent* Owner)
: TImage(Owner)
{
FHoverPic = new TPicture();
FLinkPic = new TPicture();
}
//---------------------------------------------------------------------------
namespace Linkimage
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TLinkImage)};
RegisterComponents("ExtPackage", classes, 0);
}
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::SetPicture(Graphics::TPicture * value)
{
//TODO: Add your source code here
Picture->Assign(value);
FLinkPic->Assign(value);
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::SetHoverPic(Graphics::TPicture * value)
{
//TODO: Add your source code here
FHoverPic->Assign(value);
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::MouseEnter(Messages::TMessage & Message)
{
//TODO: Add your source ode here
Picture->Assign(FHoverPic);
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::MouseLeave(Messages::TMessage & Message)
{
//TODO: Add your source code here
Picture->Assign(FLinkPic);
}
//---------------------------------------------------------------------------
__fastcall TLinkImage::~TLinkImage()
{
//TODO: Add your source code here
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::CreateWnd(void)
{
// CreateWnd();
}
//---------------------------------------------------------------------------
void __fastcall TLinkImage::Click(void)
{
//TODO: Add your source code here
TImage::Click();
}
void __fastcall TLinkImage::abcd(TNotifyEvent value)
{
//TODO: Add your source code here
ShowMessage("abcd");
Fabc = value;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -