在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
unit FrmMappingMode; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TFrmMM = class(TForm) procedure FormPaint(Sender: TObject); procedure FormResize(Sender: TObject); private { Private declarations } public { Public declarations } end; var FrmMM: TFrmMM; implementation {$R *.dfm} procedure TFrmMM.FormPaint(Sender: TObject); var halfH,halfW : integer; begin halfH := clientHeight div 2; halfW := ClientWidth div 2; Canvas.Rectangle(1,1,100,200); // SetMapMode(canvas.Handle, MM_LOMETRIC); //逻辑单位:0.1 mm // SetMapMode(canvas.Handle, MM_LOENGLISH); //逻辑单位:0.1 inch SetMapMode(canvas.Handle, MM_ISOTROPIC); // 1 = 1 自定义 { SetWindowExtEx,SetViewportExtEx 函数只对 MM_ANISOTROPIC 和 MM_ISOTROPIC映射模式有用,其它模式下它会被忽略} SetWindowExtEx(canvas.Handle,500,-500,nil); SetViewportExtEx(canvas.Handle,ClientWidth,ClientHeight,nil); // SetViewportExtEx(canvas.Handle,200,200,nil); SetViewportOrgEx(Canvas.Handle, ClientWidth div 2, ClientHeight div 2, nil); Canvas.Rectangle(0,0,50,50); //横线 Canvas.MoveTo(-halfW,0); Canvas.LineTo(halfW,0); //竖线 Canvas.MoveTo(0,-halfH); Canvas.LineTo(0,halfH); end; procedure TFrmMM.FormResize(Sender: TObject); begin Invalidate; end; end.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论