• Delphi映射模式实验


    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.
    

      

  • 相关阅读:
    django LDAP
    Python egg
    皮皮书屋
    Linux运维
    bash shell 快捷键汇总
    linux ldconfig
    Linux set env export declare unset
    OpenStack
    【LeetCode】258. Add Digits
    一个"Median Maintenance"问题
  • 原文地址:https://www.cnblogs.com/wucg/p/4224435.html
Copyright © 2020-2023  润新知