zoukankan      html  css  js  c++  java
  • 一毫米等于多少像素? GetDeviceCaps

    这不是个确定的值, 它和设备的分辨率相关.

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;
    
    type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    var
      mmW,mmH: Integer;
      pixW,pixH: Integer;
      pm: Double;
    begin
      {以毫米为单位获取屏幕尺寸}
      mmW := GetDeviceCaps(Canvas.Handle, HORZSIZE);
      mmH := GetDeviceCaps(Canvas.Handle, VERTSIZE);
      ShowMessageFmt('屏幕宽: %d 毫米; 屏幕高: %d 毫米', [mmW, mmH]);
      {屏幕宽: 320 毫米; 屏幕高: 240 毫米}
    
    
      {以像素为单位获取屏幕尺寸}
      pixW := GetDeviceCaps(Canvas.Handle, HORZRES);
      pixH := GetDeviceCaps(Canvas.Handle, VERTRES);
      ShowMessageFmt('屏幕宽: %d 像素; 屏幕高: %d 像素', [pixW, pixH]);
      {屏幕宽: 1024 像素; 屏幕高: 768 像素}
    
    
      {当前状态下, 1 毫米等于多少像素?}
      ShowMessage(FloatToStr(pixW / mmW)); {3.2}
      ShowMessage(FloatToStr(pixH / mmH)); {3.2}
    
      {一步获取}
      pm := GetDeviceCaps(Canvas.Handle, HORZRES) / GetDeviceCaps(Canvas.Handle, HORZSIZE);
      ShowMessage(FloatToStr(pm)); {3.2}
    end;
    
    end.
    
  • 相关阅读:
    List<Map>遍历相加
    jqgrid属性
    idea Could not autowire. No beans of 'xxxx' type found
    【笔记】抓取百度贴吧
    python url中文转码
    python lxml 库
    Python 基础 (笔记)
    HTML 背景
    HTML Iframe
    HTML 响应式 Web 设计
  • 原文地址:https://www.cnblogs.com/del/p/1213123.html
Copyright © 2011-2022 走看看