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. POJ3682King Arthur's Birthday Celebration(数学期望||概率DP)

    King Arthur is an narcissist who intends to spare no coins to celebrate his coming K-th birthday. Th ...

  2. linux发行版本centos7.4上安装jdk,tomcat,mariadb良心教程

    准备工作: 本地安装:rpm -ivh 程序名 因为jdk,tomcat,mysql的安装过程需要从网上下载部分支持包才可以继续,所以要求提前安装下载好依赖. yum install glibc.i6 ...

  3. Codeforces 834D The Bakery 【线段树优化DP】*

    Codeforces 834D The Bakery LINK 题目大意是给你一个长度为n的序列分成k段,每一段的贡献是这一段中不同的数的个数,求最大贡献 是第一次做线段树维护DP值的题 感觉还可以, ...

  4. iOS应用截屏

    iPhone自从推出后就自带了截屏功能,简单而易用,所以应用就没什么截屏的需求了,不过有些时候我们还是会遇到这个需求.比如,我们开发了一个播放器,用openGL进行video render,此时直接截 ...

  5. 如何使用cmd

    cmd命令行 打开cmd   在windows操作系统中按住win+R键在弹出的窗口中输入cmd.     输入后按一下enter键,就进入了cmd命令行窗口. 打开磁盘文件 在命令行中输入你想要打开 ...

  6. MYSQL在当前日期的基础上加上N(年月日分秒)

    //把id为1的那条数据的开始时间改为现在  结束时间改为开始时间的1个月后 update 表明 set  begintime=now(),endtime=date_add(NOW(), interv ...

  7. GCC用法

    http://www.cnblogs.com/hibernate6/archive/2010/08/24/2522057.html

  8. PHP应用的CI/CD流程实践与学习:一、PHP运行环境的准备

    前言:一直以来想学习与实践一下敏捷开发,之前项目虽说口口声声我们项目是敏捷开发,其实很扯. 敏捷开发如果有持续集成.持续部署的支持,那样开发.测试.运维将节省不少精力. 此系列博客只为记录CI/CD的 ...

  9. JFreeChart API 说明(转)

    原地址 http://blog.csdn.net/mike_caoyong/article/details/7338160 JFreeChart目前是最好的java图形解决方案,基本能够解决目前的图形 ...

  10. python高手的自修课

    python高手的自修课 作者:相国大人 目录 0.第0课:前言与参考文献 目标读者: 具有一定python基础的编程爱好者. 本系列博文为了尽可能少说废话,凡是能够用代码表达的,都尽量直接用代码.读 ...