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.
    
  • 相关阅读:
    C++模板的声明与实现分离 编译错误详解
    C语言中数据类型的隐式转换
    UNIX 高手的 10 个习惯
    linux 信号量
    引用与数组
    Linux 的变量命名规则
    .bash_profile和.bashrc的区别(如何设置生效
    URAL 1053 Pinocchio
    URAL 1040 Airline Company
    URAL 1045 Funny Game
  • 原文地址:https://www.cnblogs.com/del/p/1621872.html
Copyright © 2011-2022 走看看