Delphi: TGraphicControl支持PaintTo方法
Delphi之TWinControl支持PaintTo方法,可以方便的Paint有句柄控件,而此方法,TGraphicControl没有。
这使得有时需要Paint无句柄控件诸如TLabel时颇为费事,能否扩充它?
可以。使用class helper for技术,通过其Parent,仍然调用TWinControl支持PaintTo方法,中转一下。
直上代码吧,以做备忘:
TGraphicControlHelper = class helper for TGraphicControl
procedure PaintTo(Canvas: TCanvas; X, Y: Integer);
end;
实现:
{ TGraphicControlHelper }
procedure TGraphicControlHelper.PaintTo(Canvas: TCanvas; X, Y: Integer);
var
bmp: TBitmap;
sr: TRect;
begin
if Self.Parent = nil then Exit;
bmp := TBitmap.Create;
try
bmp.SetSize(Parent.Width, Parent.Height);
Self.Parent.PaintTo(bmp.Canvas.Handle, X, Y);
sr := Self.BoundsRect;
Windows.OffsetRect(sr, , );
Canvas.CopyRect(Self.ClientRect, bmp.Canvas, sr);
finally
bmp.Free;
end;
end;
完美支持
Delphi: TGraphicControl支持PaintTo方法的更多相关文章
- Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息
Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息 http://www.cnblogs.com/zhwx/archive/2012/08/28/266055 ...
- delphi操作文本文件的方法简介
delphi操作文本文件的方法简介减小字体 增大字体 作者佚名来源不详发布时间2008-5-31 10:31:16发布人xuedelphi1 文件类型和标准过程 Delphi同Object ...
- DELPHI开始支持LINUX DOCKER
DELPHI开始支持LINUX DOCKER 本方翻译自Marco Cantu的文章. 在过去的几年中,将服务器端解决方案(实际上是任何类型的应用程序)部署到轻量级容器而不是物理机器或虚拟机已经变得越 ...
- 现有语言不支持XXX方法
史上最强大的IDE也会有bug的时候哈,今天遇到这个问题特别郁闷,百度了下,果然也有人遇到过这个问题 解决方法: 1.调用的时候参数和接口声明的参数不一致(检查修改) 2.继承接口中残留一个废弃的方法 ...
- Delphi XE5 支持的Android 版本
Delphi XE5 已经支持Android应用开发. 那XE5支持Android的哪些版本呢?Delphi编译的APP能部署到Gingerbread (2.3.3-2.3.7), Ice Crea ...
- [delphi]indy idhttp post方法
网易 博客 LOFTCam-用心创造滤镜 LOFTER-最美图片社交APP 送20张免费照片冲印 > 注册登录 加关注 techiepc的博客 万事如意 首页 日志 LOFTER 相册 音乐 ...
- PHPnow开启PHP扩展里openssl支持的方法
PHPnow 是 Win32 下绿色的 Apache + PHP + MySQL 环境套件包.简易安装.快速搭建支持虚拟主机的 PHP 环境.更多介绍<PHP服务套件 PHPnow1.5.6&g ...
- Delphi的移动文件方法(转)/删除文件:/文件的复制
RenameFile,DeleteFile,MoveFile Delphi的移动文件方法 uses ShellApi; procedure ShellFileOperation(fromFile: ...
- jquery 1.9版本后不在支持browser 方法的解决方案
今天对jquery 进行升级,导致项目出错,原来在1.9版本之后 jquery 不支持browser 方法了. 官方建议的又不好用,所以我所jquery 原来的代码摘除来,又扩展回去. //解决jq ...
随机推荐
- js页面停留时间
//在线阅读时间 function onlineRead(minutes){ var o= new Object(); o.courseId=courseId; o.userId=userId; o. ...
- ABAP-多线程处理
*&---------------------------------------------------------------------* *& Report ZRICO_TES ...
- 原生java读取存储为xml格式的数据,并存储到java bean里
一.举例读取的文件为:X-bond可交易债券信息_20180917.xml <?xml version="1.0" encoding="UTF-8"?&g ...
- 使用ubuntu远程连接windows, Connect to a Windows PC from Ubuntu via Remote Desktop Connection
from: https://www.digitalcitizen.life/connecting-windows-remote-desktop-ubuntu NOTE: This tutorial w ...
- UNITY 优化之带Animator的Go.SetActive耗时问题,在手机上,这个问题似乎并不存在,因为优化了后手机上运行帧率并未明显提升
UNITY 优化之带Animator的Go.SetActive耗时问题,在手机上,这个问题似乎并不存在,因为优化了后手机上运行帧率并未明显提升 经确认,这个问题在手机上依然存在,不过占的比例非常小.因 ...
- C# 递归获取 文件夹的 所有文件
public void Director(string dir, List<string> list) { DirectoryInfo d = new DirectoryInfo(dir) ...
- CDH6离线安装
CentOS7下完全离线安装CDH6集群 CDH Linux 大数据 shareSHARE 245 浏览量 分享到微博 分享到 Twitter 分享到 QQ 本文是在CentOS7.5下进行C ...
- Docker网络及命令
Docker常用命令 docker version #查看版本 docker search centos #搜索可用docker镜像 docker images 查看当前docker所有镜像 dock ...
- Incompatible shapes during the half way training---Invalid argument: Incompatible shapes: [1,63,4] vs. [1,64,4]
这是tensorflow model 中我使用它的faster--cnn,但是就是训练过程中,代码执行到一半 一般是step=40~120的时候就报错了: INFO:tensorflow:global ...
- hdu1573-X问题-(扩展欧几里得定理+中国剩余定理)
X问题 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...