本例效果图:
代码文件:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DIB, StdCtrls;
type
TForm1 = class(TForm)
DXPaintBox1: TDXPaintBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
c1 = clRed;
c2 = clYellow;
var
w,h: Integer;
procedure TForm1.Button1Click(Sender: TObject);
begin
w := DXPaintBox1.ClientWidth;
h := DXPaintBox1.ClientHeight;
DXPaintBox1.DIB.SetSize(w, h, 24);
DXPaintBox1.DIB.Fill(c1);
DXPaintBox1.DIB.Canvas.Brush.Style := bsClear;
DXPaintBox1.DIB.Canvas.Font.Color := c2;
DXPaintBox1.DIB.Canvas.Font.Name := 'Arial Black';
DXPaintBox1.DIB.Canvas.Font.Size := 36;
DXPaintBox1.DIB.Canvas.Font.Style := [fsBold];
DXPaintBox1.DIB.Canvas.TextOut(20, 10, 'DelphiX');
DXPaintBox1.Repaint;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DXPaintBox1.DIB.DrawMorphed(DXPaintBox1.DIB, 0, 0, w, h, 0, 0, c2);
DXPaintBox1.Repaint;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
DXPaintBox1.DIB.DrawMorphed(DXPaintBox1.DIB, 0, 0, w, h, 0, 0, c1);
DXPaintBox1.Repaint;
end;
end.