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

📄 tewinapi.pas

📁 这个东西的功能很强大
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{==============================================================================

  Win32 API Declarations
  Copyright (C) 2000-2003 by Evgeny Kryukov
  All rights reserved

===============================================================================}

unit TeWinAPI;

{$I TeDefine.inc}

interface

uses
  {$IFNDEF KS_COMPILER5_UP}
  Windows, CommCtrl, SyncObjs, Classes, Forms;
  {$ELSE}
  Windows, CommCtrl, SyncObjs, Classes, Forms, Multimon;
  {$ENDIF}

{!============================================================================!}

const
  kapiApiVersion = '1.1.0';
  kapiApiVersionPropText = 'LibApi Version ' + kapiApiVersion;

type
  TkapiApiVersion = type string;

var
  Sig: PChar = '- ' + kapiApiVersionPropText +
    {$IFDEF KS_DELPHI4} ' - D4 - '+ {$ENDIF}
    {$IFDEF KS_CBUILDER4} ' - CB4 - ' + {$ENDIF}
    {$IFDEF KS_DELPHI5} ' - D5 - '+ {$ENDIF}
    {$IFDEF KS_CBUILDER5} ' - CB5 - '+ {$ENDIF}
    {$IFDEF KS_DELPHI6} ' - D6 - '+ {$ENDIF}
    {$IFDEF KS_CBUILDER6} ' - CB6 - '+ {$ENDIF}
    {$IFDEF KS_DELPHI7} ' - D7 - '+ {$ENDIF}
    {$IFDEF KS_CBUILDER7} ' - CB7 - '+ {$ENDIF}
    'Copyright (C) 1998-2003 by Evgeny Kryukov -';


function IsWinNT: boolean;
function IsWinNT4: boolean;


type

  PBlendFunction = ^TBlendFunction;
  {$EXTERNALSYM _BLENDFUNCTION}
  _BLENDFUNCTION = packed record
    BlendOp: BYTE;
    BlendFlags: BYTE;
    SourceConstantAlpha: BYTE;
    AlphaFormat: BYTE;
  end;
  TBlendFunction = _BLENDFUNCTION;
  {$EXTERNALSYM BLENDFUNCTION}
  BLENDFUNCTION = _BLENDFUNCTION;

const

  {$EXTERNALSYM WS_EX_LAYERED}
  WS_EX_LAYERED = $00080000;


  {$EXTERNALSYM LWA_COLORKEY}
  LWA_COLORKEY = $00000001;
  {$EXTERNALSYM LWA_ALPHA}
  LWA_ALPHA = $00000002;

  {$EXTERNALSYM ULW_COLORKEY}
  ULW_COLORKEY = $00000001;
  {$EXTERNALSYM ULW_ALPHA}
  ULW_ALPHA = $00000002;
  {$EXTERNALSYM ULW_OPAQUE}
  ULW_OPAQUE = $00000004;

var

  SetLayeredWindowAttributes: function (hwnd: HWND; crKey: COLORREF; bAlpha: BYTE;
    dwFlags: DWORD): BOOL; stdcall;
  UpdateLayeredWindow: function (hWnd: HWND; hdcDst: HDC; pptDst: PPOINT;
    psize: PSIZE; hdcSrc: HDC; pptSrc: PPOINT; crKey: COLORREF;
    pblend: PBlendFunction; dwFlags: DWORD): BOOL; stdcall;

function IsWin2k: boolean;


const
  WM_THEMECHANGED  = $031A;

function IsWinXP: boolean;
function UseThemes: Boolean;

type
  HTHEME = THANDLE;
  {$EXTERNALSYM HTHEME}

var
  OpenThemeData: function(hwnd: HWND; pszClassList: LPCWSTR): HTHEME; stdcall;
  {$EXTERNALSYM OpenThemeData}
  CloseThemeData: function(hTheme: HTHEME): HRESULT; stdcall;
  {$EXTERNALSYM CloseThemeData}
  DrawThemeBackground: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
    const pRect: TRect; pClipRect: PRECT): HRESULT; stdcall;
  {$EXTERNALSYM DrawThemeBackground}
  DrawThemeText: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
    pszText: LPCWSTR; iCharCount: Integer; dwTextFlags, dwTextFlags2: DWORD;
    const pRect: TRect): HRESULT; stdcall;
  {$EXTERNALSYM DrawThemeText}
  GetThemeBackgroundContentRect: function(hTheme: HTHEME; hdc: HDC;
    iPartId, iStateId: Integer; const pBoundingRect: TRect;
    pContentRect: PRECT): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeBackgroundContentRect}
  GetThemeBackgroundExtent: function(hTheme: HTHEME; hdc: HDC;
    iPartId, iStateId: Integer; const pContentRect: TRect;
    var pExtentRect: TRect): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeBackgroundExtent}

const
  DTT_GRAYED = $1;
  {$EXTERNALSYM DTT_GRAYED}

type
  THEMESIZE = (
    TS_MIN,             // minimum size
    TS_TRUE,            // size without stretching
    TS_DRAW             // size that theme mgr will use to draw part
  );
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM THEMESIZE}
  {$ENDIF}
  TThemeSize = THEMESIZE;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM TTHEMESIZE}
  {$ENDIF}

var
  GetThemePartSize: function(hTheme: HTHEME; hdc: HDC;
    iPartId, iStateId: Integer; prc: PRECT; eSize: THEMESIZE;
    var psz: TSize): HRESULT; stdcall;
  {$EXTERNALSYM GetThemePartSize}
  GetThemeTextExtent: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR;
    iCharCount: Integer; dwTextFlags: DWORD; pBoundingRect: PRECT; var pExtentRect: TRect): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeTextExtent}
  GetThemeTextMetrics: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
    var ptm: TEXTMETRIC): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeTextMetrics}
  GetThemeBackgroundRegion: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pRect: TRect;
    var pRegion: HRGN): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeBackgroundRegion}

{ HitTestThemeBackground, HitTestThemeBackgroundRegion flags }
const
  HTTB_BACKGROUNDSEG         = $0000;
  {$EXTERNALSYM HTTB_BACKGROUNDSEG}
  HTTB_FIXEDBORDER           = $0002;  // Return code may be either HTCLIENT or HTBORDER.
  {$EXTERNALSYM HTTB_FIXEDBORDER}
  HTTB_CAPTION               = $0004;
  {$EXTERNALSYM HTTB_CAPTION}
  HTTB_RESIZINGBORDER_LEFT   = $0010; // Hit test left resizing border,
  {$EXTERNALSYM HTTB_RESIZINGBORDER_LEFT}
  HTTB_RESIZINGBORDER_TOP    = $0020; // Hit test top resizing border
  {$EXTERNALSYM HTTB_RESIZINGBORDER_TOP}
  HTTB_RESIZINGBORDER_RIGHT  = $0040; // Hit test right resizing border
  {$EXTERNALSYM HTTB_RESIZINGBORDER_RIGHT}
  HTTB_RESIZINGBORDER_BOTTOM = $0080; // Hit test bottom resizing border
  {$EXTERNALSYM HTTB_RESIZINGBORDER_BOTTOM}
  HTTB_RESIZINGBORDER        = (HTTB_RESIZINGBORDER_LEFT or HTTB_RESIZINGBORDER_TOP or
                                HTTB_RESIZINGBORDER_RIGHT or HTTB_RESIZINGBORDER_BOTTOM);
  {$EXTERNALSYM HTTB_RESIZINGBORDER}
  HTTB_SIZINGTEMPLATE        = $0100;
  {$EXTERNALSYM HTTB_SIZINGTEMPLATE}
  HTTB_SYSTEMSIZINGMARGINS   = $0200;
  {$EXTERNALSYM HTTB_SYSTEMSIZINGMARGINS}

var
  HitTestThemeBackground: function(hTheme: HTHEME; hdc: HDC;
    iPartId, iStateId: Integer; dwOptions: DWORD; const pRect: TRect;
    hrgn: HRGN; ptTest: TPoint; var pwHitTestCode: WORD): HRESULT; stdcall;
  {$EXTERNALSYM HitTestThemeBackground}
  DrawThemeEdge: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
    const pDestRect: TRect; uEdge, uFlags: UINT; pContentRect: PRECT): HRESULT; stdcall;
  {$EXTERNALSYM DrawThemeEdge}
  DrawThemeIcon: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
    const pRect: TRect; himl: HIMAGELIST; iImageIndex: Integer): HRESULT; stdcall;
  {$EXTERNALSYM DrawThemeIcon}
  IsThemePartDefined: function(hTheme: HTHEME; iPartId, iStateId: Integer): BOOL; stdcall;
  {$EXTERNALSYM IsThemePartDefined}
  IsThemeBackgroundPartiallyTransparent: function(hTheme: HTHEME;
    iPartId, iStateId: Integer): BOOL; stdcall;
  {$EXTERNALSYM IsThemeBackgroundPartiallyTransparent}
  GetThemeColor: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var pColor: COLORREF): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeColor}
  GetThemeMetric: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer;
    var piVal: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeMetric}
  GetThemeString: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    pszBuff: LPWSTR; cchMaxBuffChars: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeString}
  GetThemeBool: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var pfVal: BOOL): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeBool}
  GetThemeInt: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var piVal: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeInt}
  GetThemeEnumValue: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var piVal: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeEnumValue}
  GetThemePosition: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var pPoint: TPoint): HRESULT; stdcall;
  {$EXTERNALSYM GetThemePosition}
  GetThemeFont: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer;
    var pFont: LOGFONT): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeFont}
  GetThemeRect: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var pRect: TRect): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeRect}

type
  _MARGINS = record
    cxLeftWidth: Integer;      // width of left border that retains its size
    cxRightWidth: Integer;     // width of right border that retains its size
    cyTopHeight: Integer;      // height of top border that retains its size
    cyBottomHeight: Integer;   // height of bottom border that retains its size
  end;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM _MARGINS}
  {$ENDIF}
  MARGINS = _MARGINS;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM MARGINS}
  {$ENDIF}
  PMARGINS = ^MARGINS;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM PMARGINS}
  {$ENDIF}
  TMargins = MARGINS;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM TMARGINS}
  {$ENDIF}

var
  GetThemeMargins: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer; prc: PRECT;
    var pMargins: MARGINS): HRESULT; stdcall;
{$EXTERNALSYM GetThemeMargins}

const
  MAX_INTLIST_COUNT = 10;
  {$EXTERNALSYM MAX_INTLIST_COUNT}

type
  _INTLIST = record
    iValueCount: Integer;      // number of values in iValues
    iValues: array [0..MAX_INTLIST_COUNT - 1] of Integer;
  end;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM _INTLIST}
  {$ENDIF}
  INTLIST = _INTLIST;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM INTLIST}
  {$ENDIF}
  PINTLIST = ^INTLIST;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM PINTLIST}
  {$ENDIF}
  TIntList = INTLIST;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM TINTLIST}
  {$ENDIF}

var
  GetThemeIntList: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var pIntList: INTLIST): HRESULT; stdcall;
{$EXTERNALSYM GetThemeIntList}

type
  PROPERTYORIGIN = (
    PO_STATE,           // property was found in the state section
    PO_PART,            // property was found in the part section
    PO_CLASS,           // property was found in the class section
    PO_GLOBAL,          // property was found in [globals] section
    PO_NOTFOUND);       // property was not found
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM PROPERTYORIGIN}
  {$ENDIF}
  TPropertyOrigin = PROPERTYORIGIN;
  {$IFDEF KS_COMPILER6_UP}
  {$EXTERNALSYM TPROPERTYORIGIN}
  {$ENDIF}

var
  GetThemePropertyOrigin: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    var pOrigin: PROPERTYORIGIN): HRESULT; stdcall;
  {$EXTERNALSYM GetThemePropertyOrigin}
  SetWindowTheme: function(hwnd: HWND; pszSubAppName: LPCWSTR;
    pszSubIdList: LPCWSTR): HRESULT; stdcall;
  {$EXTERNALSYM SetWindowTheme}
  GetThemeFilename: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
    pszThemeFileName: LPWSTR; cchMaxBuffChars: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeFilename}
  GetThemeSysColor: function(hTheme: HTHEME; iColorId: Integer): COLORREF; stdcall;
  {$EXTERNALSYM GetThemeSysColor}
  GetThemeSysColorBrush: function(hTheme: HTHEME; iColorId: Integer): HBRUSH; stdcall;
  {$EXTERNALSYM GetThemeSysColorBrush}
  GetThemeSysBool: function(hTheme: HTHEME; iBoolId: Integer): BOOL; stdcall;
  {$EXTERNALSYM GetThemeSysBool}
  GetThemeSysSize: function(hTheme: HTHEME; iSizeId: Integer): Integer; stdcall;
  {$EXTERNALSYM GetThemeSysSize}
  GetThemeSysFont: function(hTheme: HTHEME; iFontId: Integer;
    var plf: LOGFONT): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeSysFont}
  GetThemeSysString: function(hTheme: HTHEME; iStringId: Integer;
    pszStringBuff: LPWSTR; cchMaxStringChars: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeSysString}
  GetThemeSysInt: function(hTheme: HTHEME; iIntId: Integer;
    var piValue: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeSysInt}
  IsThemeActive: function: BOOL; stdcall;
  {$EXTERNALSYM IsThemeActive}
  IsAppThemed: function: BOOL; stdcall;
  {$EXTERNALSYM IsAppThemed}
  GetWindowTheme: function(hwnd: HWND): HTHEME; stdcall;
  {$EXTERNALSYM GetWindowTheme}

const
  ETDT_DISABLE       = $00000001;
  {$EXTERNALSYM ETDT_DISABLE}
  ETDT_ENABLE        = $00000002;
  {$EXTERNALSYM ETDT_ENABLE}
  ETDT_USETABTEXTURE = $00000004;
  {$EXTERNALSYM ETDT_USETABTEXTURE}
  ETDT_ENABLETAB     = (ETDT_ENABLE or ETDT_USETABTEXTURE);
  {$EXTERNALSYM ETDT_ENABLETAB}

var
  EnableThemeDialogTexture: function(hwnd: HWND; dwFlags: DWORD): HRESULT; stdcall;
{$EXTERNALSYM EnableThemeDialogTexture}

var
  IsThemeDialogTextureEnabled: function(hwnd: HWND): BOOL; stdcall;
{$EXTERNALSYM IsThemeDialogTextureEnabled}


{ Flags to control theming within an application }
const
  STAP_ALLOW_NONCLIENT   = (1 shl 0);
  {$EXTERNALSYM STAP_ALLOW_NONCLIENT}
  STAP_ALLOW_CONTROLS    = (1 shl 1);
  {$EXTERNALSYM STAP_ALLOW_CONTROLS}
  STAP_ALLOW_WEBCONTENT  = (1 shl 2);
  {$EXTERNALSYM STAP_ALLOW_WEBCONTENT}


var
  GetThemeAppProperties: function: DWORD; stdcall;
  {$EXTERNALSYM GetThemeAppProperties}
  SetThemeAppProperties: procedure(dwFlags: DWORD); stdcall;
  {$EXTERNALSYM SetThemeAppProperties}
  GetCurrentThemeName: function(pszThemeFileName: LPWSTR;
    cchMaxNameChars: Integer; pszColorBuff: LPWSTR; cchMaxColorChars: Integer;
    pszSizeBuff: LPWSTR; cchMaxSizeChars: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetCurrentThemeName}


const
  SZ_THDOCPROP_DISPLAYNAME               = WideString('DisplayName');
  {$EXTERNALSYM SZ_THDOCPROP_DISPLAYNAME}
  SZ_THDOCPROP_CANONICALNAME             = WideString('ThemeName');
  {$EXTERNALSYM SZ_THDOCPROP_CANONICALNAME}
  SZ_THDOCPROP_TOOLTIP                   = WideString('ToolTip');
  {$EXTERNALSYM SZ_THDOCPROP_TOOLTIP}
  SZ_THDOCPROP_AUTHOR                    = WideString('author');
  {$EXTERNALSYM SZ_THDOCPROP_AUTHOR}

var
  GetThemeDocumentationProperty: function(pszThemeName, pszPropertyName: LPCWSTR;
    pszValueBuff: LPWSTR; cchMaxValChars: Integer): HRESULT; stdcall;
  {$EXTERNALSYM GetThemeDocumentationProperty}
  DrawThemeParentBackground: function(hwnd: HWND; hdc: HDC; prc: PRECT): HRESULT; stdcall;
  {$EXTERNALSYM DrawThemeParentBackground}
  EnableTheming: function(fEnable: BOOL): HRESULT; stdcall;
  {$EXTERNALSYM EnableTheming}

{ Tmschema.h }

type
  BGTYPE = Integer;
  {$EXTERNALSYM BGTYPE}
const
  BT_IMAGEFILE = 0;
  {$EXTERNALSYM BT_IMAGEFILE}
  BT_BORDERFILL = 1;
  {$EXTERNALSYM BT_BORDERFILL}
  BT_NONE = 2;
  {$EXTERNALSYM BT_NONE}

type
  IMAGELAYOUT = Integer;
  {$EXTERNALSYM IMAGELAYOUT}
const
  IL_VERTICAL = 0;
  {$EXTERNALSYM IL_VERTICAL}
  IL_HORIZONTAL = 1;
  {$EXTERNALSYM IL_HORIZONTAL}

type
  BORDERTYPE = Integer;
  {$EXTERNALSYM BORDERTYPE}
const
  BT_RECT = 0;
  {$EXTERNALSYM BT_RECT}
  BT_ROUNDRECT = 1;
  {$EXTERNALSYM BT_ROUNDRECT}
  BT_ELLIPSE = 2;
  {$EXTERNALSYM BT_ELLIPSE}

type
  FILLTYPE = Integer;
  {$EXTERNALSYM FILLTYPE}
const
  FT_SOLID = 0;
  {$EXTERNALSYM FT_SOLID}
  FT_VERTGRADIENT = 1;
  {$EXTERNALSYM FT_VERTGRADIENT}
  FT_HORZGRADIENT = 2;
  {$EXTERNALSYM FT_HORZGRADIENT}
  FT_RADIALGRADIENT = 3;
  {$EXTERNALSYM FT_RADIALGRADIENT}
  FT_TILEIMAGE = 4;
  {$EXTERNALSYM FT_TILEIMAGE}

type
  SIZINGTYPE = Integer;
  {$EXTERNALSYM SIZINGTYPE}
const
  ST_TRUESIZE = 0;
  {$EXTERNALSYM ST_TRUESIZE}
  ST_STRETCH = 1;
  {$EXTERNALSYM ST_STRETCH}
  ST_TILE = 2;
  {$EXTERNALSYM ST_TILE}

type
  HALIGN = Integer;
  {$EXTERNALSYM HALIGN}
const
  HA_LEFT = 0;
  {$EXTERNALSYM HA_LEFT}
  HA_CENTER = 1;
  {$EXTERNALSYM HA_CENTER}
  HA_RIGHT = 2;
  {$EXTERNALSYM HA_RIGHT}

type
  CONTENTALIGNMENT = Integer;
  {$EXTERNALSYM CONTENTALIGNMENT}
const
  CA_LEFT = 0;
  {$EXTERNALSYM CA_LEFT}
  CA_CENTER = 1;
  {$EXTERNALSYM CA_CENTER}
  CA_RIGHT = 2;
  {$EXTERNALSYM CA_RIGHT}

type
  VALIGN = Integer;
  {$EXTERNALSYM VALIGN}
const
  VA_TOP = 0;
  {$EXTERNALSYM VA_TOP}
  VA_CENTER = 1;
  {$EXTERNALSYM VA_CENTER}
  VA_BOTTOM = 2;
  {$EXTERNALSYM VA_BOTTOM}

type
  OFFSETTYPE = Integer;
  {$EXTERNALSYM OFFSETTYPE}
const

⌨️ 快捷键说明

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