在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
本例效果图: //在GDI+中,绘制矩形是通过TGPGraphics类的DrawRectangle方法实现的 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} uses GDIPOBJ, GDIPAPI; procedure TForm1.FormPaint(Sender: TObject); const w = 100; h = 50; var g: TGPGraphics; p: TGPPen; x,y: Single; //32位单精度浮点型变量 begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(0, 2); g.Clear(MakeColor(255,255,255)); x := 20; y := 20; p.SetColor(aclRed); //设置画笔颜色为红色 g.DrawRectangle(p, x, y, w, h); //画一个矩形 p.SetColor(aclGold); //设置画笔颜色为黄色 x := x + w / 2; {70} y := y + h /2; {45} g.DrawRectangle(p, MakeRect(x, y, w, h)); //画另一个矩形 g.Free; p.Free; end; end. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论