c++builder自定义控件
c++builder自定义控件
http://docwiki.embarcadero.com/CodeExamples/XE8/en/RegisterComponents_%28C%2B%2B%29
void __fastcall SetFocusControl(TWinControl* Value);
void __fastcall CMDialogChar(TWMKey& Message);
void __fastcall CMTextChanged(TMessage& Message); protected:
virtual void __fastcall Notification(TComponent* AComponent, TOperation Operation);
virtual void __fastcall Paint(void); public:
__fastcall virtual TDemoLabel(TComponent* AOwner); __published:
__property Caption ;
__property Color ;
__property TWinControl* FocusControl = {read=FFocusControl, write=SetFocusControl, nodefault};
__property Font ;
__property ParentColor ;
__property ParentFont ;
public:
__fastcall virtual ~TDemoLabel(void) { } BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(CM_DIALOGCHAR, TWMKey, CMDialogChar);
MESSAGE_HANDLER(CM_TEXTCHANGED, TMessage, CMTextChanged);
END_MESSAGE_MAP(TGraphicControl);
}; void __fastcall PACKAGE Register()
{
TComponentClass classes[] = {__classid(TDemoLabel)};
RegisterComponents("Samples", classes, );
RegisterComponents("MySystem", classes, );
} __fastcall TDemoLabel::TDemoLabel(TComponent *AOwner):
TGraphicControl(AOwner)
{
FComponentStyle >> csInheritable;
Width=;
Height=;
} void __fastcall TDemoLabel::Notification(TComponent *AComponent, TOperation Operation)
{
TGraphicControl::Notification(AComponent, Operation);
if ((Operation == opRemove) && (AComponent == FFocusControl))
FFocusControl = ;
} void __fastcall TDemoLabel::SetFocusControl(TWinControl *Value)
{
FFocusControl = Value; // Calling FreeNotification ensures that this component
// will receive an opRemove when Value is either removed
// from its owner or destroyed. Value->FreeNotification(Value);
} void __fastcall TDemoLabel::Paint()
{
TRect Rect = ClientRect;
Canvas->Font = Font;
Canvas->Brush->Color = Color;
Canvas->FillRect(Rect);
DrawText(
Canvas->Handle,
Caption.t_str(),
Caption.Length(),
&Rect,
DT_EXPANDTABS | DT_WORDBREAK | DT_LEFT);
} void __fastcall TDemoLabel::CMDialogChar(TCMDialogKey &Message)
{
if (FFocusControl != NULL &&
Enabled == true &&
IsAccel(Message.CharCode, Caption))
if (FFocusControl->CanFocus()){
FFocusControl->SetFocus();
Message.Result = ;
}
} void __fastcall TDemoLabel::CMTextChanged(TMessage &Message)
{
Invalidate();
}
c++builder自定义控件的更多相关文章
- [翻译]使用Swift在Xcode中创建自定义控件
使用Swift在Xcode中创建自定义控件 原文 IBDesignable and IBInspectable With IBDesignable and IBInspectable, develop ...
- android拍照选择图片上传服务器自定义控件
做android项目的时候总免不了遇到图片上传功能,虽然就是调用android系统的拍照和相册选择功能,但是总面部了把一大推代码写在activity里,看上去一大推代码头都昏了.不如把这些功能都集成一 ...
- PropertyGrid自定义控件
PropertyGrid是一个很强大的控件,使用该控件做属性设置面板的一个好处就是你只需要专注于代码而无需关注UI的呈现,PropertyGrid会默认根据变量类型选择合适的控件显示.但是这也带来了一 ...
- duilib进阶教程 -- XML嵌套及自定义控件 (4)
代码下载:http://download.csdn.net/detail/qq316293804/6433937 之前入门教程里已经讲过了自定义控件,这里借着迅雷播放器再次举个例子. 1.我们先给迅雷 ...
- 【转】iOS笔记-自定义控件(OC)
原文网址:http://www.jianshu.com/p/f23862eb7b8a 导读: iOS开发中,很多时候系统提供的控件并不能很好的满足我们的需求,因此,自定义控件便成为搭建UI界面中必不可 ...
- Android 自定义控件之 日期选择控件
效果如下: 调用的代码: @OnClick(R.id.btn0) public void btn0() { final AlertDialog dialog = new AlertDialog.Bui ...
- android自定义控件一站式入门
自定义控件 Android系统提供了一系列UI相关的类来帮助我们构造app的界面,以及完成交互的处理. 一般的,所有可以在窗口中被展示的UI对象类型,最终都是继承自View的类,这包括展示最终内容的非 ...
- 23种设计模式--建造者模式-Builder Pattern
一.建造模式的介绍 建造者模式就是将零件组装成一个整体,用官方一点的话来讲就是将一个复杂的构建与其表示相分离,使得同样的构建过程可以创建不同的表示.生活中比如说组装电脑,汽车等等这些都是建 ...
- ASP.NET MVC学习之母版页和自定义控件的使用
一.母板页_Layout.cshtml类似于传统WebForm中的.master文件,起到页面整体框架重用的目地1.母板页代码预览 <!DOCTYPE html> <html> ...
随机推荐
- 每天一个linux命令:【转载】rmdir命令
今天学习一下linux中命令: rmdir命令.rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的.(注意,rm - r dir命令可代替rmdir,但是有很大危险性.)删 ...
- LeetCode 755. Pour Water
原题链接在这里:https://leetcode.com/problems/pour-water/description/ 题目: We are given an elevation map, hei ...
- Mac 中的sublime text3 如何安装插件
Mac中sublime text安装插件的步骤: 在sublime text中顶部标签栏中View–>Show Console,或者按快捷键control+`打开. 在下面输入框中粘贴进以下代码 ...
- JavaWeb框架之Struts2 ---- 系列学习
JavaWeb框架_Struts2_(七)----->文件的上传和下载 JavaWeb框架_Struts2_(六)----->Struts2的输入校验 JavaWeb框架_Struts2_ ...
- 【转】一步一步教你在Ubuntu12.04搭建gstreamer开发环境
原文网址:http://blog.csdn.net/xsl1990/article/details/8333062 闲得蛋疼 无聊寂寞冷 随便写写弄弄 看到网上蛮多搭建gstreamer开 ...
- (转)Android自定义属性时format选项( <attr format="reference" name="background" /> )
Android自定义属性时format选项可以取用的值 1. reference:参考某一资源ID. (1)属性定义: [html] view plaincopyprint? <declar ...
- (转)Android studio 使用心得(五)—代码混淆和破解apk
这篇文章等是跟大家分享一在Android studio 进行代码混淆配置.之前大家在eclipse上也弄过代码混淆配置,其实一样,大家可以把之前在eclipse上的配置文件直接拿过来用.不管是.cfg ...
- PHP使用RabbitMQ
基本概念 Broker:简单来说就是消息队列服务器实体. Exchange:消息交换机,它指定消息按什么规则,路由到哪个队列. Queue:消息队列载体,每个消息都会被投入到一个或多个队列. Bind ...
- centos7 yum 安装mysql
介绍在CentOS7上yum安装数据库服务器MySQL Community Server 5.7的方法. 准备 CentOS7默认安装了和MySQL有兼容性的MariaDB数据库,在我们安装MySQL ...
- Java 设计模式 之 中介者模式(Mediator)
中介者的功能非常简单,就是封装对象之间的交互. 如果一个对象的操作会引起其他相关对象的变化,或者是某个操作需要引起其他对象的后续或连带操作,而这个对象又不希望自己来处理这些关系,那么久可以找中介者,把 ...