zoukankan      html  css  js  c++  java
  • GdiPlus[3]: 关于 GdiPlusHelpers 单元


    本套接口只有两个单元: GdiPlus, GdiPlusHelpers; 主要的是前者, GdiPlusHelpers 的作用是通过 Helper 技术给 VCL 体系中的 TCanvas、TGraphicControl、TCustomControl、TBitmap 类补充添加 ToGPGraphics 方法, 以方便获取 IGPGraphics.

    在很多时候我们并不需要它, 这时也不需要 uses GdiPlusHelpers.

    不过这对有些对象会很方便, 譬如: uses GdiPlusHelpers 后, TPanel 也有了 ToGPGraphics 方法.

    尝试下面代码前, 先在窗体上添加 TImage、TPaintBox、TPanel 对象各一个.

    本例效果图:



    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Panel1: TPanel;
        Image1: TImage;
        PaintBox1: TPaintBox;
        procedure FormPaint(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses GdiPlus, GdiPlusHelpers;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Pen: IGPPen;
    begin
      Pen := TGPPen.Create(TGPColor.Red);
      Image1.ToGPGraphics.DrawLine(Pen, 0, 0, Image1.Width, Image1.Height);
      Image1.ToGPGraphics.DrawLine(Pen, 0, Image1.Height, Image1.Width, 0);
    
      Pen.Color := TGPColor.LimeGreen;
      PaintBox1.ToGPGraphics.DrawLine(Pen, 0, 0, PaintBox1.Width, PaintBox1.Height);
      PaintBox1.ToGPGraphics.DrawLine(Pen, 0, PaintBox1.Height, PaintBox1.Width, 0);
    
      Pen.Color := TGPColor.Blue;
      Panel1.ToGPGraphics.DrawLine(Pen, 0, 0, Panel1.ClientWidth, Panel1.Height);
      Panel1.ToGPGraphics.DrawLine(Pen, 0, Panel1.Height, Panel1.ClientWidth, 0);
    end;
    
    end.
    
  • 相关阅读:
    jemeter使用笔记
    webtest mobile + Android / Battery Historian / SoloPi
    script / go / golang
    my live house / air conditioning / dajin / dakin / FTXG50JV2CW
    OS + Centos OS 8 Thinkpad TrackPoint
    network router Gpon
    Mybatisplus 自定义sql 使用条件构造器 多表查询分页
    处理fastJson 序列化时间问题
    js 实现轮播图 超级简单 组件已封装
    Webpack-dev-server的proxy用法
  • 原文地址:https://www.cnblogs.com/del/p/1621872.html
Copyright © 2011-2022 走看看