PageRenderTime 91ms CodeModel.GetById 18ms app.highlight 63ms RepoModel.GetById 1ms app.codeStats 1ms

/binding/win32/uxtheme.d

http://github.com/wilkie/djehuty
D | 1582 lines | 615 code | 133 blank | 834 comment | 0 complexity | ed3c216765e4345fe3fdfffd56cba131 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/*
   2 * uxtheme.d
   3 *
   4 * This module binds Uxtheme.h to D. The original copyright notice
   5 * is preserved below.
   6 *
   7 * Author: Dave Wilkinson
   8 * Originated: November 25th, 2009
   9 *
  10 */
  11
  12module binding.win32.uxtheme;
  13
  14import binding.win32.windef;
  15import binding.win32.winnt;
  16import binding.win32.wingdi;
  17
  18// XXX: CommCtrl.h
  19alias HANDLE HIMAGELIST;
  20
  21//---------------------------------------------------------------------------
  22//
  23// uxtheme.h - theming API header file.
  24//
  25// Copyright (c) Microsoft Corporation. All rights reserved.
  26//
  27//---------------------------------------------------------------------------
  28
  29alias HANDLE HTHEME;          // handle to a section of theme data for class
  30
  31const auto MAX_THEMECOLOR  = 64;
  32const auto MAX_THEMESIZE   = 64;
  33
  34//---------------------------------------------------------------------------
  35// NOTE: PartId's and StateId's used in the theme API are defined in the 
  36//       hdr file <vssym32.h> using the TM_PART and TM_STATE macros.  For
  37//       example, "TM_PART(BP, PUSHBUTTON)" defines the PartId "BP_PUSHBUTTON".
  38
  39//---------------------------------------------------------------------------
  40//  OpenThemeData()     - Open the theme data for the specified HWND and 
  41//                        semi-colon separated list of class names. 
  42// 
  43//                        OpenThemeData() will try each class name, one at 
  44//                        a time, and use the first matching theme info
  45//                        found.  If a match is found, a theme handle
  46//                        to the data is returned.  If no match is found,
  47//                        a "NULL" handle is returned. 
  48//
  49//                        When the window is destroyed or a WM_THEMECHANGED
  50//                        msg is received, "CloseThemeData()" should be 
  51//                        called to close the theme handle.
  52//
  53//  hwnd                - window handle of the control/window to be themed
  54//
  55//  pszClassList        - class name (or list of names) to match to theme data
  56//                        section.  if the list contains more than one name, 
  57//                        the names are tested one at a time for a match.  
  58//                        If a match is found, OpenThemeData() returns a 
  59//                        theme handle associated with the matching class. 
  60//                        This param is a list (instead of just a single 
  61//                        class name) to provide the class an opportunity 
  62//                        to get the "best" match between the class and 
  63//                        the current theme.  For example, a button might
  64//                        pass L"OkButton, Button" if its ID=ID_OK.  If 
  65//                        the current theme has an entry for OkButton, 
  66//                        that will be used.  Otherwise, we fall back on 
  67//                        the normal Button entry.
  68//---------------------------------------------------------------------------
  69HTHEME OpenThemeData(
  70    HWND hwnd,
  71    LPCWSTR pszClassList
  72    );
  73
  74const auto OTD_FORCE_RECT_SIZING   = 0x00000001;          // make all parts size to rect
  75const auto OTD_NONCLIENT           = 0x00000002;          // set if hTheme to be used for nonclient area
  76const auto OTD_VALIDBITS           = (OTD_FORCE_RECT_SIZING | OTD_NONCLIENT);
  77
  78//---------------------------------------------------------------------------
  79//  OpenThemeDataEx     - Open the theme data for the specified HWND and 
  80//                        semi-colon separated list of class names. 
  81// 
  82//                        OpenThemeData() will try each class name, one at 
  83//                        a time, and use the first matching theme info
  84//                        found.  If a match is found, a theme handle
  85//                        to the data is returned.  If no match is found,
  86//                        a "NULL" handle is returned. 
  87//
  88//                        When the window is destroyed or a WM_THEMECHANGED
  89//                        msg is received, "CloseThemeData()" should be 
  90//                        called to close the theme handle.
  91//
  92//  hwnd                - window handle of the control/window to be themed
  93//
  94//  pszClassList        - class name (or list of names) to match to theme data
  95//                        section.  if the list contains more than one name, 
  96//                        the names are tested one at a time for a match.  
  97//                        If a match is found, OpenThemeData() returns a 
  98//                        theme handle associated with the matching class. 
  99//                        This param is a list (instead of just a single 
 100//                        class name) to provide the class an opportunity 
 101//                        to get the "best" match between the class and 
 102//                        the current theme.  For example, a button might
 103//                        pass L"OkButton, Button" if its ID=ID_OK.  If 
 104//                        the current theme has an entry for OkButton, 
 105//                        that will be used.  Otherwise, we fall back on 
 106//                        the normal Button entry.
 107//
 108//  dwFlags              - allows certain overrides of std features
 109//                         (see OTD_XXX defines above)
 110//---------------------------------------------------------------------------
 111HTHEME OpenThemeDataEx(
 112    HWND hwnd,
 113    LPCWSTR pszClassList,
 114    DWORD dwFlags
 115    );
 116
 117//---------------------------------------------------------------------------
 118//  CloseThemeData()    - closes the theme data handle.  This should be done
 119//                        when the window being themed is destroyed or
 120//                        whenever a WM_THEMECHANGED msg is received
 121//                        (followed by an attempt to create a new Theme data
 122//                        handle).
 123//
 124//  hTheme              - open theme data handle (returned from prior call
 125//                        to OpenThemeData() API).
 126//---------------------------------------------------------------------------
 127HRESULT CloseThemeData(
 128    HTHEME hTheme
 129    );
 130
 131//---------------------------------------------------------------------------
 132//    functions for basic drawing support 
 133//---------------------------------------------------------------------------
 134// The following methods are the theme-aware drawing services.
 135// Controls/Windows are defined in drawable "parts" by their author: a 
 136// parent part and 0 or more child parts.  Each of the parts can be 
 137// described in "states" (ex: disabled, hot, pressed).  
 138//---------------------------------------------------------------------------
 139// For the list of all themed classes and the definition of all
 140// parts and states, see the file "tmschmea.h".
 141//---------------------------------------------------------------------------
 142// Each of the below methods takes a "iPartId" param to specify the 
 143// part and a "iStateId" to specify the state of the part.  
 144// "iStateId=0" refers to the root part.  "iPartId" = "0" refers to 
 145// the root class.  
 146//-----------------------------------------------------------------------
 147// Note: draw operations are always scaled to fit (and not to exceed)  
 148// the specified "Rect".
 149//-----------------------------------------------------------------------
 150
 151//------------------------------------------------------------------------
 152//  DrawThemeBackground()   
 153//                      - draws the theme-specified border and fill for 
 154//                        the "iPartId" and "iStateId".  This could be 
 155//                        based on a bitmap file, a border and fill, or 
 156//                        other image description.  
 157//
 158//  hTheme              - theme data handle
 159//  hdc                 - HDC to draw into
 160//  iPartId             - part number to draw
 161//  iStateId            - state number (of the part) to draw
 162//  pRect               - defines the size/location of the part
 163//  pClipRect           - optional clipping rect (don't draw outside it)
 164//------------------------------------------------------------------------
 165HRESULT DrawThemeBackground(
 166    HTHEME hTheme,
 167    HDC hdc,
 168    int iPartId,
 169    int iStateId,
 170    LPCRECT pRect,
 171    LPCRECT pClipRect
 172    );
 173
 174//------------------------------------------------------------------------
 175//---- bits used in dwFlags of DTBGOPTS ----
 176const auto DTBG_CLIPRECT           = 0x00000001;  // rcClip has been specified
 177const auto DTBG_DRAWSOLID          = 0x00000002;  // DEPRECATED: draw transparent/alpha images as solid
 178const auto DTBG_OMITBORDER         = 0x00000004;  // don't draw border of part
 179const auto DTBG_OMITCONTENT        = 0x00000008;  // don't draw content area of part
 180const auto DTBG_COMPUTINGREGION    = 0x00000010;  // TRUE if calling to compute region
 181const auto DTBG_MIRRORDC           = 0x00000020;  // assume the hdc is mirrorred and
 182                                            // flip images as appropriate (currently
 183                                            // only supported for bgtype=imagefile)
 184const auto DTBG_NOMIRROR           = 0x00000040;  // don't mirror the output, overrides everything else
 185const auto DTBG_VALIDBITS          = (DTBG_CLIPRECT |
 186                                 DTBG_DRAWSOLID |
 187                                 DTBG_OMITBORDER |
 188                                 DTBG_OMITCONTENT |
 189                                 DTBG_COMPUTINGREGION |
 190                                 DTBG_MIRRORDC |
 191                                 DTBG_NOMIRROR);
 192
 193struct DTBGOPTS {
 194    DWORD dwSize;           // size of the struct
 195    DWORD dwFlags;          // which options have been specified
 196    RECT rcClip;            // clipping rectangle
 197}
 198
 199typedef DTBGOPTS* PDTBGOPTS;
 200
 201//------------------------------------------------------------------------
 202//  DrawThemeBackgroundEx()   
 203//                      - draws the theme-specified border and fill for 
 204//                        the "iPartId" and "iStateId".  This could be 
 205//                        based on a bitmap file, a border and fill, or 
 206//                        other image description.  NOTE: This will be
 207//                        merged back into DrawThemeBackground() after 
 208//                        BETA 2.
 209//
 210//  hTheme              - theme data handle
 211//  hdc                 - HDC to draw into
 212//  iPartId             - part number to draw
 213//  iStateId            - state number (of the part) to draw
 214//  pRect               - defines the size/location of the part
 215//  pOptions            - ptr to optional params
 216//------------------------------------------------------------------------
 217HRESULT DrawThemeBackgroundEx(
 218    HTHEME hTheme,
 219    HDC hdc,
 220    int iPartId,
 221    int iStateId,
 222    LPCRECT pRect,
 223    DTBGOPTS *pOptions
 224    );
 225
 226//---------------------------------------------------------------------------
 227//----- DrawThemeText() flags ----
 228const auto DTT_GRAYED              = 0x00000001;          // draw a grayed-out string (this is deprecated)
 229const auto DTT_FLAGS2VALIDBITS     = (DTT_GRAYED);
 230
 231//-------------------------------------------------------------------------
 232//  DrawThemeText()     - draws the text using the theme-specified
 233//                        color and font for the "iPartId" and
 234//                        "iStateId".
 235//
 236//  hTheme              - theme data handle
 237//  hdc                 - HDC to draw into
 238//  iPartId             - part number to draw
 239//  iStateId            - state number (of the part) to draw
 240//  pszText             - actual text to draw
 241//  dwCharCount         - number of chars to draw (-1 for all)
 242//  dwTextFlags         - same as DrawText() "uFormat" param
 243//  dwTextFlags2        - additional drawing options
 244//  pRect               - defines the size/location of the part
 245//-------------------------------------------------------------------------
 246HRESULT DrawThemeText(
 247    HTHEME hTheme,
 248    HDC hdc,
 249    int iPartId,
 250    int iStateId,
 251	LPCWSTR pszText,
 252    int cchText,
 253    DWORD dwTextFlags,
 254    DWORD dwTextFlags2,
 255    LPCRECT pRect
 256    );
 257
 258
 259//---------------------------------------------------------------------------
 260//
 261// DrawThemeTextEx
 262//
 263
 264// Callback function used by DrawTextWithGlow instead of DrawTextW
 265typedef int function(HDC hdc, LPWSTR pszText, int cchText, LPRECT prc, UINT dwFlags, LPARAM lParam) DTT_CALLBACK_PROC;
 266
 267//---- bits used in dwFlags of DTTOPTS ----
 268const auto DTT_TEXTCOLOR       = (1UL << 0);      // crText has been specified
 269const auto DTT_BORDERCOLOR     = (1UL << 1);      // crBorder has been specified
 270const auto DTT_SHADOWCOLOR     = (1UL << 2);      // crShadow has been specified
 271const auto DTT_SHADOWTYPE      = (1UL << 3);      // iTextShadowType has been specified
 272const auto DTT_SHADOWOFFSET    = (1UL << 4);      // ptShadowOffset has been specified
 273const auto DTT_BORDERSIZE      = (1UL << 5);      // iBorderSize has been specified
 274const auto DTT_FONTPROP        = (1UL << 6);      // iFontPropId has been specified
 275const auto DTT_COLORPROP       = (1UL << 7);      // iColorPropId has been specified
 276const auto DTT_STATEID         = (1UL << 8);      // IStateId has been specified
 277const auto DTT_CALCRECT        = (1UL << 9);      // Use pRect as and in/out parameter
 278const auto DTT_APPLYOVERLAY    = (1UL << 10);     // fApplyOverlay has been specified
 279const auto DTT_GLOWSIZE        = (1UL << 11);     // iGlowSize has been specified
 280const auto DTT_CALLBACK        = (1UL << 12);     // pfnDrawTextCallback has been specified
 281const auto DTT_COMPOSITED      = (1UL << 13);     // Draws text with antialiased alpha (needs a DIB section)
 282const auto DTT_VALIDBITS       = (DTT_TEXTCOLOR |
 283                             DTT_BORDERCOLOR |
 284							 DTT_SHADOWCOLOR |
 285                             DTT_SHADOWTYPE |
 286                             DTT_SHADOWOFFSET |
 287                             DTT_BORDERSIZE |
 288                             DTT_FONTPROP |
 289                             DTT_COLORPROP |
 290                             DTT_STATEID |
 291                             DTT_CALCRECT |
 292                             DTT_APPLYOVERLAY |
 293                             DTT_GLOWSIZE |
 294                             DTT_COMPOSITED);
 295
 296struct DTTOPTS {
 297    DWORD             dwSize;              // size of the struct
 298    DWORD             dwFlags;             // which options have been specified
 299    COLORREF          crText;              // color to use for text fill
 300    COLORREF          crBorder;            // color to use for text outline
 301    COLORREF          crShadow;            // color to use for text shadow
 302    int               iTextShadowType;     // TST_SINGLE or TST_CONTINUOUS
 303    POINT             ptShadowOffset;      // where shadow is drawn (relative to text)
 304    int               iBorderSize;         // Border radius around text
 305    int               iFontPropId;         // Font property to use for the text instead of TMT_FONT
 306    int               iColorPropId;        // Color property to use for the text instead of TMT_TEXTCOLOR
 307    int               iStateId;            // Alternate state id
 308    BOOL              fApplyOverlay;       // Overlay text on top of any text effect?
 309    int               iGlowSize;           // Glow radious around text
 310    DTT_CALLBACK_PROC pfnDrawTextCallback; // Callback for DrawText
 311    LPARAM            lParam;              // Parameter for callback
 312}
 313
 314typedef DTTOPTS* PDTTOPTS;
 315
 316HRESULT DrawThemeTextEx(
 317    HTHEME hTheme,
 318    HDC hdc,
 319    int iPartId,
 320    int iStateId,
 321	LPCWSTR pszText,
 322    int cchText,
 323    DWORD dwTextFlags,
 324    LPRECT pRect,
 325	DTTOPTS *pOptions
 326    );
 327
 328//-------------------------------------------------------------------------
 329//  GetThemeBackgroundContentRect()
 330//                      - gets the size of the content for the theme-defined
 331//                        background.  This is usually the area inside
 332//                        the borders or Margins.
 333//
 334//      hTheme          - theme data handle
 335//      hdc             - (optional) device content to be used for drawing
 336//      iPartId         - part number to draw
 337//      iStateId        - state number (of the part) to draw
 338//      pBoundingRect   - the outer RECT of the part being drawn
 339//      pContentRect    - RECT to receive the content area
 340//-------------------------------------------------------------------------
 341HRESULT GetThemeBackgroundContentRect(
 342    HTHEME hTheme,
 343    HDC hdc,
 344    int iPartId,
 345    int iStateId,
 346    LPCRECT pBoundingRect,
 347	LPRECT pContentRect
 348    );
 349
 350//-------------------------------------------------------------------------
 351//  GetThemeBackgroundExtent() - calculates the size/location of the theme-
 352//                               specified background based on the
 353//                               "pContentRect".
 354//
 355//      hTheme          - theme data handle
 356//      hdc             - (optional) device content to be used for drawing
 357//      iPartId         - part number to draw
 358//      iStateId        - state number (of the part) to draw
 359//      pContentRect    - RECT that defines the content area
 360//      pBoundingRect   - RECT to receive the overall size/location of part
 361//-------------------------------------------------------------------------
 362HRESULT GetThemeBackgroundExtent(
 363    HTHEME hTheme,
 364    HDC hdc,
 365    int iPartId,
 366    int iStateId,
 367    LPCRECT pContentRect,
 368    LPRECT pExtentRect
 369    );
 370
 371//-------------------------------------------------------------------------
 372//  GetThemeBackgroundRegion()
 373//                      - computes the region for a regular or partially
 374//                        transparent theme-specified background that is
 375//                        bound by the specified "pRect".
 376//                        If the rectangle is empty, sets the HRGN to NULL
 377//                        and return S_FALSE.
 378//
 379//  hTheme              - theme data handle
 380//  hdc                 - optional HDC to draw into (DPI scaling)
 381//  iPartId             - part number to draw
 382//  iStateId            - state number (of the part) 
 383//  pRect               - the RECT used to draw the part
 384//  pRegion             - receives handle to calculated region
 385//-------------------------------------------------------------------------
 386HRESULT GetThemeBackgroundRegion(
 387    HTHEME hTheme,
 388    HDC hdc,
 389    int iPartId,
 390    int iStateId,
 391    LPCRECT pRect,
 392	HRGN *pRegion
 393    );
 394
 395enum THEMESIZE {
 396    TS_MIN,             // minimum size
 397    TS_TRUE,            // size without stretching
 398    TS_DRAW             // size that theme mgr will use to draw part
 399}
 400
 401//-------------------------------------------------------------------------
 402//  GetThemePartSize() - returns the specified size of the theme part
 403//
 404//  hTheme              - theme data handle
 405//  hdc                 - HDC to select font into & measure against
 406//  iPartId             - part number to retrieve size for
 407//  iStateId            - state number (of the part)
 408//  prc                 - (optional) rect for part drawing destination
 409//  eSize               - the type of size to be retreived
 410//  psz                 - receives the specified size of the part
 411//-------------------------------------------------------------------------
 412HRESULT GetThemePartSize(
 413    HTHEME hTheme,
 414    HDC hdc,
 415    int iPartId,
 416    int iStateId,
 417    LPCRECT prc,
 418    THEMESIZE eSize,
 419    SIZE *psz
 420    );
 421
 422//-------------------------------------------------------------------------
 423//  GetThemeTextExtent() - calculates the size/location of the specified 
 424//                         text when rendered in the Theme Font. 
 425//
 426//  hTheme              - theme data handle
 427//  hdc                 - HDC to select font & measure into
 428//  iPartId             - part number to draw
 429//  iStateId            - state number (of the part) 
 430//  pszText             - the text to be measured
 431//  dwCharCount         - number of chars to draw (-1 for all)
 432//  dwTextFlags         - same as DrawText() "uFormat" param
 433//  pszBoundingRect     - optional: to control layout of text
 434//  pszExtentRect       - receives the RECT for text size/location
 435//-------------------------------------------------------------------------
 436HRESULT
 437GetThemeTextExtent(
 438    HTHEME hTheme,
 439    HDC hdc,
 440    int iPartId,
 441    int iStateId,
 442	LPCWSTR pszText,
 443    int cchCharCount,
 444    DWORD dwTextFlags,
 445    LPCRECT pBoundingRect,
 446    LPRECT pExtentRect
 447    );
 448
 449//-------------------------------------------------------------------------
 450//  GetThemeTextMetrics()
 451//                      - returns info about the theme-specified font
 452//                        for the part/state passed in.
 453//
 454//  hTheme              - theme data handle
 455//  hdc                 - optional: HDC for screen context
 456//  iPartId             - part number to draw
 457//  iStateId            - state number (of the part)
 458//  ptm                 - receives the font info
 459//-------------------------------------------------------------------------
 460HRESULT GetThemeTextMetrics(
 461    HTHEME hTheme,
 462    HDC hdc,
 463    int iPartId,
 464    int iStateId,
 465    TEXTMETRICW *ptm
 466    );
 467
 468//-------------------------------------------------------------------------
 469//----- HitTestThemeBackground, HitTestThemeBackgroundRegion flags ----
 470
 471//  Theme background segment hit test flag (default). possible return values are:
 472//  HTCLIENT: hit test succeeded in the middle background segment
 473//  HTTOP, HTLEFT, HTTOPLEFT, etc:  // hit test succeeded in the the respective theme background segment.
 474const auto HTTB_BACKGROUNDSEG          = 0x00000000;
 475//  Fixed border hit test option.  possible return values are:
 476//  HTCLIENT: hit test succeeded in the middle background segment
 477//  HTBORDER: hit test succeeded in any other background segment
 478const auto HTTB_FIXEDBORDER            = 0x00000002;      // Return code may be either HTCLIENT or HTBORDER.
 479//  Caption hit test option.  Possible return values are:
 480//  HTCAPTION: hit test succeeded in the top, top left, or top right background segments
 481//  HTNOWHERE or another return code, depending on absence or presence of accompanying flags, resp.
 482const auto HTTB_CAPTION                = 0x00000004;
 483//  Resizing border hit test flags.  Possible return values are:
 484//  HTCLIENT: hit test succeeded in middle background segment
 485//  HTTOP, HTTOPLEFT, HTLEFT, HTRIGHT, etc:    hit test succeeded in the respective system resizing zone
 486//  HTBORDER: hit test failed in middle segment and resizing zones, but succeeded in a background border segment
 487const auto HTTB_RESIZINGBORDER_LEFT    = 0x00000010;      // Hit test left resizing border,
 488const auto HTTB_RESIZINGBORDER_TOP     = 0x00000020;      // Hit test top resizing border
 489const auto HTTB_RESIZINGBORDER_RIGHT   = 0x00000040;      // Hit test right resizing border
 490const auto HTTB_RESIZINGBORDER_BOTTOM  = 0x00000080;      // Hit test bottom resizing border
 491const auto HTTB_RESIZINGBORDER         = (HTTB_RESIZINGBORDER_LEFT |
 492                                     HTTB_RESIZINGBORDER_TOP |
 493                                     HTTB_RESIZINGBORDER_RIGHT |
 494                                     HTTB_RESIZINGBORDER_BOTTOM);
 495
 496// Resizing border is specified as a template, not just window edges.
 497// This option is mutually exclusive with HTTB_SYSTEMSIZINGWIDTH; HTTB_SIZINGTEMPLATE takes precedence
 498const auto HTTB_SIZINGTEMPLATE         = 0x00000100;
 499// Use system resizing border width rather than theme content margins.
 500// This option is mutually exclusive with HTTB_SIZINGTEMPLATE, which takes precedence.
 501const auto HTTB_SYSTEMSIZINGMARGINS    = 0x00000200;
 502
 503//-------------------------------------------------------------------------
 504//  HitTestThemeBackground()
 505//                      - returns a HitTestCode (a subset of the values
 506//                        returned by WM_NCHITTEST) for the point "ptTest"
 507//                        within the theme-specified background
 508//                        (bound by pRect).  "pRect" and "ptTest" should
 509//                        both be in the same coordinate system
 510//                        (client, screen, etc).
 511//
 512//      hTheme          - theme data handle
 513//      hdc             - HDC to draw into
 514//      iPartId         - part number to test against
 515//      iStateId        - state number (of the part) 
 516//      pRect           - the RECT used to draw the part
 517//      hrgn            - optional region to use; must be in same coordinates as
 518//                      -    pRect and pTest.
 519//      ptTest          - the hit point to be tested
 520//      dwOptions       - HTTB_xxx constants
 521//      pwHitTestCode   - receives the returned hit test code - one of:
 522//
 523//                        HTNOWHERE, HTLEFT, HTTOPLEFT, HTBOTTOMLEFT,
 524//                        HTRIGHT, HTTOPRIGHT, HTBOTTOMRIGHT,
 525//                        HTTOP, HTBOTTOM, HTCLIENT
 526//-------------------------------------------------------------------------
 527HRESULT HitTestThemeBackground(
 528    HTHEME hTheme,
 529    HDC hdc,
 530    int iPartId,
 531    int iStateId,
 532    DWORD dwOptions,
 533    LPCRECT pRect,
 534    HRGN hrgn,
 535    POINT ptTest,
 536    WORD *pwHitTestCode
 537    );
 538
 539//------------------------------------------------------------------------
 540//  DrawThemeEdge()     - Similar to the DrawEdge() API, but uses part colors
 541//                        and is high-DPI aware
 542//  hTheme              - theme data handle
 543//  hdc                 - HDC to draw into
 544//  iPartId             - part number to draw
 545//  iStateId            - state number of part
 546//  pDestRect           - the RECT used to draw the line(s)
 547//  uEdge               - Same as DrawEdge() API
 548//  uFlags              - Same as DrawEdge() API
 549//  pContentRect        - Receives the interior rect if (uFlags & BF_ADJUST)
 550//------------------------------------------------------------------------
 551HRESULT DrawThemeEdge(
 552    HTHEME hTheme,
 553    HDC hdc,
 554    int iPartId,
 555    int iStateId,
 556    LPCRECT pDestRect,
 557    UINT uEdge,
 558    UINT uFlags,
 559    LPRECT pContentRect
 560    );
 561
 562//------------------------------------------------------------------------
 563//  DrawThemeIcon()     - draws an image within an imagelist based on
 564//                        a (possible) theme-defined effect.
 565//
 566//  hTheme              - theme data handle
 567//  hdc                 - HDC to draw into
 568//  iPartId             - part number to draw
 569//  iStateId            - state number of part
 570//  pRect               - the RECT to draw the image within
 571//  himl                - handle to IMAGELIST
 572//  iImageIndex         - index into IMAGELIST (which icon to draw)
 573//------------------------------------------------------------------------
 574HRESULT DrawThemeIcon(
 575    HTHEME hTheme,
 576    HDC hdc,
 577    int iPartId,
 578    int iStateId,
 579    LPCRECT pRect,
 580    HIMAGELIST himl,
 581    int iImageIndex
 582    );
 583
 584//---------------------------------------------------------------------------
 585//  IsThemePartDefined() - returns TRUE if the theme has defined parameters
 586//                         for the specified "iPartId" and "iStateId".
 587//
 588//  hTheme              - theme data handle
 589//  iPartId             - part number to find definition for
 590//  iStateId            - state number of part
 591//---------------------------------------------------------------------------
 592BOOL IsThemePartDefined(
 593    HTHEME hTheme,
 594    int iPartId,
 595    int iStateId
 596    );
 597
 598//---------------------------------------------------------------------------
 599//  IsThemeBackgroundPartiallyTransparent()
 600//                      - returns TRUE if the theme specified background for
 601//                        the part/state has transparent pieces or
 602//                        alpha-blended pieces.
 603//
 604//  hTheme              - theme data handle
 605//  iPartId             - part number
 606//  iStateId            - state number of part
 607//---------------------------------------------------------------------------
 608BOOL IsThemeBackgroundPartiallyTransparent(
 609    HTHEME hTheme,
 610    int iPartId,
 611    int iStateId
 612    );
 613
 614//---------------------------------------------------------------------------
 615//    lower-level theme information services
 616//---------------------------------------------------------------------------
 617// The following methods are getter routines for each of the Theme Data types.
 618// Controls/Windows are defined in drawable "parts" by their author: a
 619// parent part and 0 or more child parts.  Each of the parts can be
 620// described in "states" (ex: disabled, hot, pressed).
 621//---------------------------------------------------------------------------
 622// Each of the below methods takes a "iPartId" param to specify the
 623// part and a "iStateId" to specify the state of the part.
 624// "iStateId=0" refers to the root part.  "iPartId" = "0" refers to
 625// the root class.
 626//-----------------------------------------------------------------------
 627// Each method also take a "iPropId" param because multiple instances of
 628// the same primitive type can be defined in the theme schema.
 629//-----------------------------------------------------------------------
 630
 631//-----------------------------------------------------------------------
 632//  GetThemeColor()     - Get the value for the specified COLOR property
 633//
 634//  hTheme              - theme data handle
 635//  iPartId             - part number
 636//  iStateId            - state number of part
 637//  iPropId             - the property number to get the value for
 638//  pColor              - receives the value of the property
 639//-----------------------------------------------------------------------
 640HRESULT GetThemeColor(
 641    HTHEME hTheme,
 642    int iPartId,
 643    int iStateId,
 644    int iPropId,
 645    COLORREF *pColor
 646    );
 647
 648//-----------------------------------------------------------------------
 649//  GetThemeMetric()    - Get the value for the specified metric/size
 650//                        property
 651//
 652//  hTheme              - theme data handle
 653//  hdc                 - (optional) hdc to be drawn into (DPI scaling)
 654//  iPartId             - part number
 655//  iStateId            - state number of part
 656//  iPropId             - the property number to get the value for
 657//  piVal               - receives the value of the property
 658//-----------------------------------------------------------------------
 659HRESULT GetThemeMetric(
 660    HTHEME hTheme,
 661    HDC hdc,
 662    int iPartId,
 663    int iStateId,
 664    int iPropId,
 665    int *piVal
 666    );
 667
 668//-----------------------------------------------------------------------
 669//  GetThemeString()    - Get the value for the specified string property
 670//
 671//  hTheme              - theme data handle
 672//  iPartId             - part number
 673//  iStateId            - state number of part
 674//  iPropId             - the property number to get the value for
 675//  pszBuff             - receives the string property value
 676//  cchMaxBuffChars     - max. number of chars allowed in pszBuff
 677//-----------------------------------------------------------------------
 678HRESULT GetThemeString(
 679    HTHEME hTheme,
 680    int iPartId,
 681    int iStateId,
 682    int iPropId,
 683	LPWSTR pszBuff,
 684    int cchMaxBuffChars
 685    );
 686
 687//-----------------------------------------------------------------------
 688//  GetThemeBool()      - Get the value for the specified BOOL property
 689//
 690//  hTheme              - theme data handle
 691//  iPartId             - part number
 692//  iStateId            - state number of part
 693//  iPropId             - the property number to get the value for
 694//  pfVal               - receives the value of the property
 695//-----------------------------------------------------------------------
 696HRESULT GetThemeBool(
 697    HTHEME hTheme,
 698    int iPartId,
 699    int iStateId,
 700    int iPropId,
 701    BOOL *pfVal
 702    );
 703
 704//-----------------------------------------------------------------------
 705//  GetThemeInt()       - Get the value for the specified int property
 706//
 707//  hTheme              - theme data handle
 708//  iPartId             - part number
 709//  iStateId            - state number of part
 710//  iPropId             - the property number to get the value for
 711//  piVal               - receives the value of the property
 712//-----------------------------------------------------------------------
 713HRESULT GetThemeInt(
 714    HTHEME hTheme,
 715    int iPartId,
 716    int iStateId,
 717    int iPropId,
 718    int *piVal
 719    );
 720
 721//-----------------------------------------------------------------------
 722//  GetThemeEnumValue() - Get the value for the specified ENUM property
 723//
 724//  hTheme              - theme data handle
 725//  iPartId             - part number
 726//  iStateId            - state number of part
 727//  iPropId             - the property number to get the value for
 728//  piVal               - receives the value of the enum (cast to int*)
 729//-----------------------------------------------------------------------
 730HRESULT GetThemeEnumValue(
 731    HTHEME hTheme,
 732    int iPartId,
 733    int iStateId,
 734    int iPropId,
 735    int *piVal
 736    );
 737
 738//-----------------------------------------------------------------------
 739//  GetThemePosition()  - Get the value for the specified position
 740//                        property
 741//
 742//  hTheme              - theme data handle
 743//  iPartId             - part number
 744//  iStateId            - state number of part
 745//  iPropId             - the property number to get the value for
 746//  pPoint              - receives the value of the position property
 747//-----------------------------------------------------------------------
 748HRESULT GetThemePosition(
 749    HTHEME hTheme,
 750    int iPartId,
 751    int iStateId,
 752    int iPropId,
 753    POINT *pPoint
 754    );
 755
 756//-----------------------------------------------------------------------
 757//  GetThemeFont()      - Get the value for the specified font property
 758//
 759//  hTheme              - theme data handle
 760//  hdc                 - (optional) hdc to be drawn to (DPI scaling)
 761//  iPartId             - part number
 762//  iStateId            - state number of part
 763//  iPropId             - the property number to get the value for
 764//  pFont               - receives the value of the LOGFONT property
 765//                        (scaled for the current logical screen dpi)
 766//-----------------------------------------------------------------------
 767HRESULT GetThemeFont(
 768    HTHEME hTheme,
 769    HDC hdc,
 770    int iPartId,
 771    int iStateId,
 772    int iPropId,
 773    LOGFONTW *pFont
 774    );
 775
 776//-----------------------------------------------------------------------
 777//  GetThemeRect()      - Get the value for the specified RECT property
 778//
 779//  hTheme              - theme data handle
 780//  iPartId             - part number
 781//  iStateId            - state number of part
 782//  iPropId             - the property number to get the value for
 783//  pRect               - receives the value of the RECT property
 784//-----------------------------------------------------------------------
 785HRESULT GetThemeRect(
 786    HTHEME hTheme,
 787    int iPartId,
 788    int iStateId,
 789    int iPropId,
 790	LPRECT pRect
 791    );
 792
 793struct MARGINS {
 794    int cxLeftWidth;      // width of left border that retains its size
 795    int cxRightWidth;     // width of right border that retains its size
 796    int cyTopHeight;      // height of top border that retains its size
 797    int cyBottomHeight;   // height of bottom border that retains its size
 798}
 799
 800typedef MARGINS* PMARGINS;
 801
 802//-----------------------------------------------------------------------
 803//  GetThemeMargins()   - Get the value for the specified MARGINS property
 804//
 805//      hTheme          - theme data handle
 806//      hdc             - (optional) hdc to be used for drawing
 807//      iPartId         - part number
 808//      iStateId        - state number of part
 809//      iPropId         - the property number to get the value for
 810//      prc             - RECT for area to be drawn into
 811//      pMargins        - receives the value of the MARGINS property
 812//-----------------------------------------------------------------------
 813HRESULT GetThemeMargins(
 814    HTHEME hTheme,
 815    HDC hdc,
 816    int iPartId,
 817    int iStateId,
 818    int iPropId,
 819    LPCRECT prc,
 820    MARGINS *pMargins
 821    );
 822
 823const auto MAX_INTLIST_COUNT = 402;
 824
 825struct INTLIST {
 826    int iValueCount;      // number of values in iValues
 827    int[MAX_INTLIST_COUNT] iValues;
 828}
 829
 830typedef INTLIST* PINTLIST;
 831
 832//-----------------------------------------------------------------------
 833//  GetThemeIntList()   - Get the value for the specified INTLIST struct
 834//
 835//      hTheme          - theme data handle
 836//      iPartId         - part number
 837//      iStateId        - state number of part
 838//      iPropId         - the property number to get the value for
 839//      pIntList        - receives the value of the INTLIST property
 840//-----------------------------------------------------------------------
 841HRESULT GetThemeIntList(
 842    HTHEME hTheme,
 843    int iPartId,
 844    int iStateId,
 845    int iPropId,
 846    INTLIST *pIntList
 847    );
 848
 849enum PROPERTYORIGIN {
 850    PO_STATE,           // property was found in the state section
 851    PO_PART,            // property was found in the part section
 852    PO_CLASS,           // property was found in the class section
 853    PO_GLOBAL,          // property was found in [globals] section
 854    PO_NOTFOUND         // property was not found
 855}
 856
 857//-----------------------------------------------------------------------
 858//  GetThemePropertyOrigin()
 859//                      - searches for the specified theme property
 860//                        and sets "pOrigin" to indicate where it was
 861//                        found (or not found)
 862//
 863//  hTheme              - theme data handle
 864//  iPartId             - part number
 865//  iStateId            - state number of part
 866//  iPropId             - the property number to search for
 867//  pOrigin             - receives the value of the property origin
 868//-----------------------------------------------------------------------
 869HRESULT GetThemePropertyOrigin(
 870    HTHEME hTheme,
 871    int iPartId,
 872    int iStateId,
 873    int iPropId,
 874    PROPERTYORIGIN *pOrigin
 875    );
 876
 877//---------------------------------------------------------------------------
 878//  SetWindowTheme()
 879//                      - redirects an existing Window to use a different
 880//                        section of the current theme information than its 
 881//                        class normally asks for.
 882//
 883//  hwnd                - the handle of the window (cannot be NULL)
 884//
 885//  pszSubAppName       - app (group) name to use in place of the calling
 886//                        app's name.  If NULL, the actual calling app
 887//                        name will be used.
 888//
 889//  pszSubIdList        - semicolon separated list of class Id names to
 890//                        use in place of actual list passed by the
 891//                        window's class.  if NULL, the id list from the
 892//                        calling class is used.
 893//---------------------------------------------------------------------------
 894// The Theme Manager will remember the "pszSubAppName" and the
 895// "pszSubIdList" associations thru the lifetime of the window (even
 896// if themes are subsequently changed).  The window is sent a
 897// "WM_THEMECHANGED" msg at the end of this call, so that the new
 898// theme can be found and applied.
 899//---------------------------------------------------------------------------
 900// When "pszSubAppName" or "pszSubIdList" are NULL, the Theme Manager
 901// removes the previously remember association.  To turn off theme-ing for
 902// the specified window, you can pass an empty string (L"") so it
 903// won't match any section entries.
 904//---------------------------------------------------------------------------
 905HRESULT SetWindowTheme(
 906    HWND hwnd,
 907    LPCWSTR pszSubAppName,
 908    LPCWSTR pszSubIdList
 909    );
 910
 911enum WINDOWTHEMEATTRIBUTETYPE {
 912    WTA_NONCLIENT = 1
 913}
 914
 915struct WTA_OPTIONS {
 916    DWORD dwFlags;          // values for each style option specified in the bitmask
 917    DWORD dwMask;           // bitmask for flags that are changing
 918                            // valid options are: WTNCA_NODRAWCAPTION, WTNCA_NODRAWICON, WTNCA_NOSYSMENU
 919}
 920
 921typedef WTA_OPTIONS* PWTA_OPTIONS;
 922
 923const auto WTNCA_NODRAWCAPTION       = 0x00000001;    // don't draw the window caption
 924const auto WTNCA_NODRAWICON          = 0x00000002;    // don't draw the system icon
 925const auto WTNCA_NOSYSMENU           = 0x00000004;    // don't expose the system menu icon functionality
 926const auto WTNCA_NOMIRRORHELP        = 0x00000008;    // don't mirror the question mark, even in RTL layout
 927const auto WTNCA_VALIDBITS           = (WTNCA_NODRAWCAPTION |
 928                                   WTNCA_NODRAWICON |
 929                                   WTNCA_NOSYSMENU |
 930                                   WTNCA_NOMIRRORHELP);
 931
 932HRESULT SetWindowThemeAttribute(
 933    HWND hwnd,
 934    WINDOWTHEMEATTRIBUTETYPE eAttribute,
 935    PVOID pvAttribute,
 936    DWORD cbAttribute
 937    );
 938
 939HRESULT SetWindowThemeNonClientAttributes(HWND hwnd, DWORD dwMask, DWORD dwAttributes) {
 940    WTA_OPTIONS wta;
 941    wta.dwFlags = dwAttributes;
 942    wta.dwMask = dwMask;
 943    return SetWindowThemeAttribute(hwnd, WTA_NONCLIENT, cast(void*)&(wta), wta.sizeof);
 944}
 945
 946
 947//---------------------------------------------------------------------------
 948//  GetThemeFilename()  - Get the value for the specified FILENAME property.
 949//
 950//  hTheme              - theme data handle
 951//  iPartId             - part number
 952//  iStateId            - state number of part
 953//  iPropId             - the property number to search for
 954//  pszThemeFileName    - output buffer to receive the filename
 955//  cchMaxBuffChars     - the size of the return buffer, in chars
 956//---------------------------------------------------------------------------
 957HRESULT GetThemeFilename(
 958    HTHEME hTheme,
 959    int iPartId,
 960    int iStateId,
 961    int iPropId,
 962    LPWSTR pszThemeFileName,
 963    int cchMaxBuffChars
 964    );
 965
 966//---------------------------------------------------------------------------
 967//  GetThemeSysColor()  - Get the value of the specified System color.
 968//
 969//  hTheme              - the theme data handle.  if non-NULL, will return
 970//                        color from [SysMetrics] section of theme.
 971//                        if NULL, will return the global system color.
 972//
 973//  iColorId            - the system color index defined in winuser.h
 974//---------------------------------------------------------------------------
 975COLORREF GetThemeSysColor(
 976    HTHEME hTheme,
 977    int iColorId
 978    );
 979
 980//---------------------------------------------------------------------------
 981//  GetThemeSysColorBrush()
 982//                      - Get the brush for the specified System color.
 983//
 984//  hTheme              - the theme data handle.  if non-NULL, will return
 985//                        brush matching color from [SysMetrics] section of
 986//                        theme.  if NULL, will return the brush matching
 987//                        global system color.
 988//
 989//  iColorId            - the system color index defined in winuser.h
 990//---------------------------------------------------------------------------
 991HBRUSH GetThemeSysColorBrush(
 992    HTHEME hTheme,
 993    int iColorId
 994    );
 995
 996//---------------------------------------------------------------------------
 997//  GetThemeSysBool()   - Get the boolean value of specified System metric.
 998//
 999//  hTheme              - the theme data handle.  if non-NULL, will return
1000//                        BOOL from [SysMetrics] section of theme.
1001//                        if NULL, will return the specified system boolean.
1002//
1003//  iBoolId             - the TMT_XXX BOOL number (first BOOL
1004//                        is TMT_FLATMENUS)
1005//---------------------------------------------------------------------------
1006BOOL GetThemeSysBool(
1007    HTHEME hTheme,
1008    int iBoolId
1009    );
1010
1011//---------------------------------------------------------------------------
1012//  GetThemeSysSize()   - Get the value of the specified System size metric. 
1013//                        (scaled for the current logical screen dpi) 
1014//
1015//  hTheme              - the theme data handle.  if non-NULL, will return
1016//                        size from [SysMetrics] section of theme.
1017//                        if NULL, will return the global system metric.
1018//
1019//  iSizeId             - the following values are supported when 
1020//                        hTheme is non-NULL:
1021//
1022//                          SM_CXBORDER       (border width)
1023//                          SM_CXVSCROLL      (scrollbar width)
1024//                          SM_CYHSCROLL      (scrollbar height)
1025//                          SM_CXSIZE         (caption width)
1026//                          SM_CYSIZE         (caption height)
1027//                          SM_CXSMSIZE       (small caption width)
1028//                          SM_CYSMSIZE       (small caption height)
1029//                          SM_CXMENUSIZE     (menubar width)
1030//                          SM_CYMENUSIZE     (menubar height)
1031//                          SM_CXPADDEDBORDER (padded border width)
1032//
1033//                        when hTheme is NULL, iSizeId is passed directly
1034//                        to the GetSystemMetrics() function
1035//---------------------------------------------------------------------------
1036int GetThemeSysSize(
1037    HTHEME hTheme,
1038    int iSizeId
1039    );
1040
1041//---------------------------------------------------------------------------
1042//  GetThemeSysFont()   - Get the LOGFONT for the specified System font.
1043//
1044//  hTheme              - the theme data handle.  if non-NULL, will return
1045//                        font from [SysMetrics] section of theme.
1046//                        if NULL, will return the specified system font.
1047//
1048//  iFontId             - the TMT_XXX font number (first font
1049//                        is TMT_CAPTIONFONT)
1050//
1051//  plf                 - ptr to LOGFONT to receive the font value.
1052//                        (scaled for the current logical screen dpi)
1053//---------------------------------------------------------------------------
1054HRESULT GetThemeSysFont(
1055    HTHEME hTheme,
1056    int iFontId,
1057    LOGFONTW *plf
1058    );
1059
1060//---------------------------------------------------------------------------
1061//  GetThemeSysString() - Get the value of specified System string metric.
1062//
1063//  hTheme              - the theme data handle (required)
1064//
1065//  iStringId           - must be one of the following values:
1066//
1067//                          TMT_CSSNAME
1068//                          TMT_XMLNAME
1069//
1070//  pszStringBuff       - the buffer to receive the string value
1071//
1072//  cchMaxStringChars   - max. number of chars that pszStringBuff can hold
1073//---------------------------------------------------------------------------
1074HRESULT GetThemeSysString(
1075    HTHEME hTheme,
1076    int iStringId,
1077    LPWSTR pszStringBuff,
1078    int cchMaxStringChars
1079    );
1080
1081//---------------------------------------------------------------------------
1082//  GetThemeSysInt() - Get the value of specified System int.
1083//
1084//  hTheme              - the theme data handle (required)
1085//
1086//  iIntId              - must be one of the following values:
1087//
1088//                          TMT_DPIX
1089//                          TMT_DPIY
1090//                          TMT_MINCOLORDEPTH
1091//
1092//  piValue             - ptr to int to receive value
1093//---------------------------------------------------------------------------
1094HRESULT GetThemeSysInt(
1095    HTHEME hTheme,
1096    int iIntId,
1097    int *piValue
1098    );
1099
1100//---------------------------------------------------------------------------
1101//  IsThemeActive()     - can be used to test if a system theme is active
1102//                        for the current user session.
1103//
1104//                        use the API "IsAppThemed()" to test if a theme is
1105//                        active for the calling process.
1106//---------------------------------------------------------------------------
1107BOOL IsThemeActive();
1108
1109//---------------------------------------------------------------------------
1110//  IsAppThemed()       - returns TRUE if a theme is active and available to
1111//                        the current process
1112//---------------------------------------------------------------------------
1113BOOL IsAppThemed();
1114
1115//---------------------------------------------------------------------------
1116//  GetWindowTheme()    - if window is themed, returns its most recent
1117//                        HTHEME from OpenThemeData() - otherwise, returns
1118//                        NULL.
1119//
1120//      hwnd            - the window to get the HTHEME of
1121//---------------------------------------------------------------------------
1122HTHEME GetWindowTheme(
1123    HWND hwnd
1124    );
1125
1126const auto ETDT_DISABLE                    = 0x00000001;
1127const auto ETDT_ENABLE                     = 0x00000002;
1128const auto ETDT_USETABTEXTURE              = 0x00000004;
1129const auto ETDT_USEAEROWIZARDTABTEXTURE    = 0x00000008;
1130
1131const auto ETDT_ENABLETAB             = (ETDT_ENABLE |
1132                                     ETDT_USETABTEXTURE);
1133
1134const auto ETDT_ENABLEAEROWIZARDTAB   = (ETDT_ENABLE |
1135                                     ETDT_USEAEROWIZARDTABTEXTURE);
1136
1137const auto ETDT_VALIDBITS             = (ETDT_DISABLE |
1138                                     ETDT_ENABLE |
1139                                     ETDT_USETABTEXTURE |
1140                                     ETDT_USEAEROWIZARDTABTEXTURE);
1141
1142//---------------------------------------------------------------------------
1143//  EnableThemeDialogTexture()
1144//
1145//  - Enables/disables dialog background theme.  This method can be used to
1146//    tailor dialog compatibility with child windows and controls that
1147//    may or may not coordinate the rendering of their client area backgrounds
1148//    with that of their parent dialog in a manner that supports seamless
1149//    background texturing.
1150//
1151//      hdlg         - the window handle of the target dialog
1152//      dwFlags      - ETDT_ENABLE to enable the theme-defined dialog background texturing,
1153//                     ETDT_DISABLE to disable background texturing,
1154//                     ETDT_ENABLETAB to enable the theme-defined background
1155//                          texturing using the Tab texture
1156//---------------------------------------------------------------------------
1157HRESULT EnableThemeDialogTexture(
1158    HWND hwnd,
1159    DWORD dwFlags
1160    );
1161
1162//---------------------------------------------------------------------------
1163//  IsThemeDialogTextureEnabled()
1164//
1165//  - Reports whether the dialog supports background texturing.
1166//
1167//      hdlg   …

Large files files are truncated, but you can click here to view the full file