⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getdevicecapsu.pas

📁 Delphi Win32核心API参考光盘源码 本书包含了常用的Windows API函数
💻 PAS
字号:
unit GetDeviceCapsU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Math;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  with ListBox1.Items do
  begin
    {display the driver version}
    Add('Display Driver Version: '+IntToSTr(GetDeviceCaps(Canvas.Handle,
        DRIVERVERSION)));

    {display the technology}
    case GetDeviceCaps(Canvas.Handle, TECHNOLOGY) of
      DT_PLOTTER:    Add('Driver Type: Vector Plotter');
      DT_RASDISPLAY: Add('Driver Type: Raster Display');
      DT_RASPRINTER: Add('Driver Type: Raster Printer');
      DT_RASCAMERA:  Add('Driver Type: Raster Camera');
      DT_CHARSTREAM: Add('Driver Type: Character Stream');
      DT_METAFILE:   Add('Driver Type: Metafile');
      DT_DISPFILE:   Add('Driver Type: Display File');
    end;

    {display the screen size}
    Add('Screen Size: '+IntToStr(GetDeviceCaps(Canvas.Handle, HORZSIZE))+' X '+
        IntToStr(GetDeviceCaps(Canvas.Handle, VERTSIZE))+' millimeters');
    Add('Screen Resolution: '+IntToStr(GetDeviceCaps(Canvas.Handle, HORZRES))+
        ' X '+IntToStr(GetDeviceCaps(Canvas.Handle, VERTRES))+' pixels');

    {display the pixels per logical inch}
    Add('Pixels/Logical Inch - Horizontal: '+IntToStr(GetDeviceCaps(
        Canvas.Handle, LOGPIXELSX)));
    Add('Pixels/Logical Inch - Vertical: '+IntToStr(GetDeviceCaps(
        Canvas.Handle, LOGPIXELSY)));

    {display the color depth and number of common graphical objects}
    Add('Bits/Pixel: '+IntToStr(GetDeviceCaps(Canvas.Handle, BITSPIXEL)));
    Add('Brushes: '+IntToStr(GetDeviceCaps(Canvas.Handle, NUMBRUSHES)));
    Add('Pens: '+IntToStr(GetDeviceCaps(Canvas.Handle, NUMPENS)));
    Add('Fonts: '+IntToStr(GetDeviceCaps(Canvas.Handle, NUMFONTS)));

    {display the number of entries in the color table}
    if GetDeviceCaps(Canvas.Handle, NUMCOLORS)>-1 then
      Add('Entries in color table: '+IntToStr(GetDeviceCaps(
          Canvas.Handle, NUMCOLORS)));

    {display pixel dimensions}
    Add('Pixel Width: '+IntToStr(GetDeviceCaps(Canvas.Handle, ASPECTX)));
    Add('Pixel Height: '+IntToStr(GetDeviceCaps(Canvas.Handle, ASPECTY)));
    Add('Pixel Diagonal: '+IntToStr(GetDeviceCaps(Canvas.Handle, ASPECTXY)));

    {indicate if the device can clip to a rectangle}
    if GetDeviceCaps(Canvas.Handle, CLIPCAPS)=1 then
      Add('Device can clip to a rectangle')
    else
      Add('Device can not clip to a rectangle');

    {display the palette size, reserved colors, and color depth}
    Add('Palette Size: '+IntToStr(GetDeviceCaps(Canvas.Handle, SIZEPALETTE)));
    Add('Number of Reserved Colors: '+IntToStr(GetDeviceCaps(
        Canvas.Handle, NUMRESERVED)));
    Add('Color Resolution: '+IntToStr(Trunc(IntPower(2, GetDeviceCaps(
        Canvas.Handle, COLORRES))))+' colors');

    {display the raster capabilities}
    Add('Raster Capabilities -');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_BANDING)=RC_BANDING then
          Add('     Requires Banding');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_BITBLT)=RC_BITBLT then
          Add('     Can Transer Bitmaps');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_BITMAP64)=RC_BITMAP64 then
          Add('     Supports Bitmaps > 64K');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_DI_BITMAP)=RC_DI_BITMAP then
          Add('     Supports SetDIBits and GetDIBits');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_DIBTODEV)=RC_DIBTODEV then
          Add('     Supports SetDIBitsToDevice');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_FLOODFILL)=RC_FLOODFILL then
          Add('     Can Perform Floodfills');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_GDI20_OUTPUT)=RC_GDI20_OUTPUT then
          Add('     Supports Windows 2.0 Features');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_PALETTE)=RC_PALETTE then
          Add('     Palette Based');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_SCALING)=RC_SCALING then
          Add('     Supports Scaling');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_STRETCHBLT)=RC_STRETCHBLT then
          Add('     Supports StretchBlt');
    if (GetDeviceCaps(Canvas.Handle, RASTERCAPS) and
        RC_STRETCHDIB)=RC_STRETCHDIB then
          Add('     Supports StretchDIBits');

    {display curve capabilities}
    Add('Curve Capabilities -');
    if GetDeviceCaps(Canvas.Handle, CURVECAPS)=CC_NONE then
      Add('     Device Does Not Support Curves')
    else
    begin
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_CIRCLES)=CC_CIRCLES then
            Add('     Supports Cirles');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_PIE)=CC_PIE then
            Add('     Supports Pie Wedges');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_CHORD)=CC_CHORD then
            Add('     Supports Chords');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_ELLIPSES)=CC_ELLIPSES then
            Add('     Supports Ellipses');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_WIDE)=CC_WIDE then
            Add('     Supports Wide Borders');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_STYLED)=CC_STYLED then
            Add('     Supports Styled Borders');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_WIDESTYLED)=CC_WIDESTYLED then
            Add('     Supports Wide And Styled Borders');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_INTERIORS)=CC_INTERIORS then
            Add('     Supports Interiors');
      if (GetDeviceCaps(Canvas.Handle, CURVECAPS) and
          CC_ROUNDRECT)=CC_ROUNDRECT then
            Add('     Supports Rounded Rectangles');
    end;

    {display line capabilities}
    Add('Line Capabilities -');
    if GetDeviceCaps(Canvas.Handle, LINECAPS)=LC_NONE then
      Add('     Device Does Not Support Lines')
    else
    begin
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_POLYLINE)=LC_POLYLINE then
            Add('     Supports Polylines');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_MARKER)=LC_MARKER then
            Add('     Supports Markers');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_POLYMARKER)=LC_POLYMARKER then
            Add('     Supports Multiple Markers');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_WIDE)=LC_WIDE then
            Add('     Supports Wide Lines');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_STYLED)=LC_STYLED then
            Add('     Supports Styled Lines');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_WIDESTYLED)=LC_WIDESTYLED then
            Add('     Supports Wide And Styled Lines');
      if (GetDeviceCaps(Canvas.Handle, LINECAPS) and
          LC_INTERIORS)=LC_INTERIORS then
            Add('     Supports Interiors');
    end;

    {display polygonal capabilities}
    Add('Polygonal Capabilities -');
    if GetDeviceCaps(Canvas.Handle, POLYGONALCAPS)=PC_NONE then
      Add('     Device Does Not Support Polygons')
    else
    begin
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_POLYGON)=PC_POLYGON then
            Add('     Supports Alternate Fill Polygons');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_RECTANGLE)=PC_RECTANGLE then
            Add('     Supports Rectangles');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_WINDPOLYGON)=PC_WINDPOLYGON then
            Add('     Supports Winding Fill Polygons');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_SCANLINE)=PC_SCANLINE then
            Add('     Supports Single Scanlines');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_WIDE)=PC_WIDE then
            Add('     Supports Wide Borders');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_STYLED)=PC_STYLED then
            Add('     Supports Styled Borders');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_WIDESTYLED)=PC_WIDESTYLED then
            Add('     Supports Wide And Styled Borders');
      if (GetDeviceCaps(Canvas.Handle, POLYGONALCAPS) and
          PC_INTERIORS)=PC_INTERIORS then
            Add('     Supports Interiors');
    end;

    {display text capabilities}
    Add('Text Capabilities -');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_OP_CHARACTER)=TC_OP_CHARACTER then
          Add('     Capable of Character Output Precision');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_OP_STROKE)=TC_OP_STROKE then
          Add('     Capable of Stroke Output Precision');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_CP_STROKE)=TC_CP_STROKE then
          Add('     Capable of Stroke Clip Precision');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_CR_90)=TC_CR_90 then
          Add('     Supports 90 Degree Character Rotation');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_CR_ANY)=TC_CR_ANY then
          Add('     Supports Character Rotation to Any Angle');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SF_X_YINDEP)=TC_SF_X_YINDEP then
          Add('     X And Y Scale Independent');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SA_DOUBLE)=TC_SA_DOUBLE then
          Add('     Supports Doubled Character Scaling');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SA_INTEGER)=TC_SA_INTEGER then
          Add('     Supports Integer Multiples Only When Scaling');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SA_CONTIN)=TC_SA_CONTIN then
          Add('     Supports Any Multiples For Exact Character Scaling');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_EA_DOUBLE)=TC_EA_DOUBLE then
          Add('     Supports Double Weight Characters');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_IA_ABLE)=TC_IA_ABLE then
          Add('     Supports Italics');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_UA_ABLE)=TC_UA_ABLE then
          Add('     Supports Underlines');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SO_ABLE)=TC_SO_ABLE then
          Add('     Supports Strikeouts');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_RA_ABLE)=TC_RA_ABLE then
          Add('     Supports Raster Fonts');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_VA_ABLE)=TC_VA_ABLE then
          Add('     Supports Vector Fonts');
    if (GetDeviceCaps(Canvas.Handle, TEXTCAPS) and
        TC_SCROLLBLT)=TC_SCROLLBLT then
          Add('     Cannot Scroll Using Blts');
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -