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.
    
  • 相关阅读:
    Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView
    Maven 本地打war包
    数据库性能优化一
    SessionStateMode之Redis共享session
    SessionStateMode之SQL Server共享session
    iframe跨域
    Jenkins发布MVC应用程序
    Docker入门之一Docker在Window下安装
    Window下SVN服务器搭建以及客户端使用
    Window下Jenkins的安装
  • 原文地址:https://www.cnblogs.com/del/p/1621872.html
Copyright © 2011-2022 走看看