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自定义控件的更多相关文章

  1. [翻译]使用Swift在Xcode中创建自定义控件

    使用Swift在Xcode中创建自定义控件 原文 IBDesignable and IBInspectable With IBDesignable and IBInspectable, develop ...

  2. android拍照选择图片上传服务器自定义控件

    做android项目的时候总免不了遇到图片上传功能,虽然就是调用android系统的拍照和相册选择功能,但是总面部了把一大推代码写在activity里,看上去一大推代码头都昏了.不如把这些功能都集成一 ...

  3. PropertyGrid自定义控件

    PropertyGrid是一个很强大的控件,使用该控件做属性设置面板的一个好处就是你只需要专注于代码而无需关注UI的呈现,PropertyGrid会默认根据变量类型选择合适的控件显示.但是这也带来了一 ...

  4. duilib进阶教程 -- XML嵌套及自定义控件 (4)

    代码下载:http://download.csdn.net/detail/qq316293804/6433937 之前入门教程里已经讲过了自定义控件,这里借着迅雷播放器再次举个例子. 1.我们先给迅雷 ...

  5. 【转】iOS笔记-自定义控件(OC)

    原文网址:http://www.jianshu.com/p/f23862eb7b8a 导读: iOS开发中,很多时候系统提供的控件并不能很好的满足我们的需求,因此,自定义控件便成为搭建UI界面中必不可 ...

  6. Android 自定义控件之 日期选择控件

    效果如下: 调用的代码: @OnClick(R.id.btn0) public void btn0() { final AlertDialog dialog = new AlertDialog.Bui ...

  7. android自定义控件一站式入门

    自定义控件 Android系统提供了一系列UI相关的类来帮助我们构造app的界面,以及完成交互的处理. 一般的,所有可以在窗口中被展示的UI对象类型,最终都是继承自View的类,这包括展示最终内容的非 ...

  8. 23种设计模式--建造者模式-Builder Pattern

    一.建造模式的介绍       建造者模式就是将零件组装成一个整体,用官方一点的话来讲就是将一个复杂的构建与其表示相分离,使得同样的构建过程可以创建不同的表示.生活中比如说组装电脑,汽车等等这些都是建 ...

  9. ASP.NET MVC学习之母版页和自定义控件的使用

    一.母板页_Layout.cshtml类似于传统WebForm中的.master文件,起到页面整体框架重用的目地1.母板页代码预览 <!DOCTYPE html> <html> ...

随机推荐

  1. .NET实现CORS跨域

    1.NuGet:Install-Package Microsoft.AspNet.WebApi.Cors 2.Application_Start中增加(包含在#if DEBUG中):GlobalCon ...

  2. 使用jenkins持续集成自动化测试

    本文采用Springboot开发一个简易的添加个人资料和查询个人资料接口,并采用testng进行测试,使用jenkis进行持续继承,allure输出测试报告. 个人资料查询接口开发(集成H2数据库) ...

  3. ss client 配置

    1.1安装ss apt-get install python-pippip install shadowsocks 1.2配置ss 新建一个配置文件config.json/etc/shadowsock ...

  4. 理解 Roslyn 中的红绿树(Red-Green Trees)

    Roslyn 的 API 是非常易用的.即便如此复杂的 C# 语法,建立的复杂的 C# 语法树,还有其复杂的树遍历和修改过程,也都被其 API 包装得干净简洁. 而这背后是它的重要设计思路 —— 红绿 ...

  5. WPF/UWP 的 Grid 布局竟然有 Bug,还不止一个!了解 Grid 中那些未定义的布局规则

    只要你用 XAML 写代码,我敢打赌你一定用各种方式使(nuè)用(dài)过 Grid.不知你有没有在此过程中看到过 Grid 那些匪夷所思的布局结果呢? 本文将带你来看看 Grid 布局中的 Bu ...

  6. 如何向map和reduce脚本传递参数,加载文件和目录

    本文主要讲解三个问题:       1 使用Java编写MapReduce程序时,如何向map.reduce函数传递参数.       2 使用Streaming编写MapReduce程序(C/C++ ...

  7. php excel 读取日期问题

    在 php excel 读取 xls 格式的文件时,xls 上面显示的是正常的日期格式 但是读取出来的话,就会是一个万位整形数据,这显然不是我们想要的日期 读取出来的结果: 41807 $t = 41 ...

  8. Palindrome Degree(hash的思想题)

    个人心得:这题就是要确定是否为回文串,朴素算法会超时,所以想到用哈希,哈希从左到右和从右到左的key值一样就一定是回文串, 那么问题来了,正向还能保证一遍遍历,逆向呢,卡住我了,后面发现网上大神的秦九 ...

  9. Google、IBM和Lyft开源其大型微服务系统管理工具Istio

    Istio 的优势 集群规模可视性:在故障状况出现时,运营人员需要利用多种工具以始终关注集群运行状况并分析微服务状态图表.Istio 项目能够监控与应用程序及网络活动相关的数据,利用 Promethe ...

  10. Unite 2018 | 《崩坏3》:在Unity中实现高品质的卡通渲染(上)

    http://forum.china.unity3d.com/thread-32271-1-1.html 我们已经发布了Unite 2018 江毅冰的<发条乐师>.Hit-Point的&l ...