PageRenderTime 578ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/win32/uxtheme.d

http://github.com/wilkie/djehuty
D | 1582 lines | 615 code | 133 blank | 834 comment | 0 complexity | ed3c216765e4345fe3fdfffd56cba131 MD5 | raw 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. module binding.win32.uxtheme;
  12. import binding.win32.windef;
  13. import binding.win32.winnt;
  14. import binding.win32.wingdi;
  15. // XXX: CommCtrl.h
  16. alias HANDLE HIMAGELIST;
  17. //---------------------------------------------------------------------------
  18. //
  19. // uxtheme.h - theming API header file.
  20. //
  21. // Copyright (c) Microsoft Corporation. All rights reserved.
  22. //
  23. //---------------------------------------------------------------------------
  24. alias HANDLE HTHEME; // handle to a section of theme data for class
  25. const auto MAX_THEMECOLOR = 64;
  26. const auto MAX_THEMESIZE = 64;
  27. //---------------------------------------------------------------------------
  28. // NOTE: PartId's and StateId's used in the theme API are defined in the
  29. // hdr file <vssym32.h> using the TM_PART and TM_STATE macros. For
  30. // example, "TM_PART(BP, PUSHBUTTON)" defines the PartId "BP_PUSHBUTTON".
  31. //---------------------------------------------------------------------------
  32. // OpenThemeData() - Open the theme data for the specified HWND and
  33. // semi-colon separated list of class names.
  34. //
  35. // OpenThemeData() will try each class name, one at
  36. // a time, and use the first matching theme info
  37. // found. If a match is found, a theme handle
  38. // to the data is returned. If no match is found,
  39. // a "NULL" handle is returned.
  40. //
  41. // When the window is destroyed or a WM_THEMECHANGED
  42. // msg is received, "CloseThemeData()" should be
  43. // called to close the theme handle.
  44. //
  45. // hwnd - window handle of the control/window to be themed
  46. //
  47. // pszClassList - class name (or list of names) to match to theme data
  48. // section. if the list contains more than one name,
  49. // the names are tested one at a time for a match.
  50. // If a match is found, OpenThemeData() returns a
  51. // theme handle associated with the matching class.
  52. // This param is a list (instead of just a single
  53. // class name) to provide the class an opportunity
  54. // to get the "best" match between the class and
  55. // the current theme. For example, a button might
  56. // pass L"OkButton, Button" if its ID=ID_OK. If
  57. // the current theme has an entry for OkButton,
  58. // that will be used. Otherwise, we fall back on
  59. // the normal Button entry.
  60. //---------------------------------------------------------------------------
  61. HTHEME OpenThemeData(
  62. HWND hwnd,
  63. LPCWSTR pszClassList
  64. );
  65. const auto OTD_FORCE_RECT_SIZING = 0x00000001; // make all parts size to rect
  66. const auto OTD_NONCLIENT = 0x00000002; // set if hTheme to be used for nonclient area
  67. const auto OTD_VALIDBITS = (OTD_FORCE_RECT_SIZING | OTD_NONCLIENT);
  68. //---------------------------------------------------------------------------
  69. // OpenThemeDataEx - Open the theme data for the specified HWND and
  70. // semi-colon separated list of class names.
  71. //
  72. // OpenThemeData() will try each class name, one at
  73. // a time, and use the first matching theme info
  74. // found. If a match is found, a theme handle
  75. // to the data is returned. If no match is found,
  76. // a "NULL" handle is returned.
  77. //
  78. // When the window is destroyed or a WM_THEMECHANGED
  79. // msg is received, "CloseThemeData()" should be
  80. // called to close the theme handle.
  81. //
  82. // hwnd - window handle of the control/window to be themed
  83. //
  84. // pszClassList - class name (or list of names) to match to theme data
  85. // section. if the list contains more than one name,
  86. // the names are tested one at a time for a match.
  87. // If a match is found, OpenThemeData() returns a
  88. // theme handle associated with the matching class.
  89. // This param is a list (instead of just a single
  90. // class name) to provide the class an opportunity
  91. // to get the "best" match between the class and
  92. // the current theme. For example, a button might
  93. // pass L"OkButton, Button" if its ID=ID_OK. If
  94. // the current theme has an entry for OkButton,
  95. // that will be used. Otherwise, we fall back on
  96. // the normal Button entry.
  97. //
  98. // dwFlags - allows certain overrides of std features
  99. // (see OTD_XXX defines above)
  100. //---------------------------------------------------------------------------
  101. HTHEME OpenThemeDataEx(
  102. HWND hwnd,
  103. LPCWSTR pszClassList,
  104. DWORD dwFlags
  105. );
  106. //---------------------------------------------------------------------------
  107. // CloseThemeData() - closes the theme data handle. This should be done
  108. // when the window being themed is destroyed or
  109. // whenever a WM_THEMECHANGED msg is received
  110. // (followed by an attempt to create a new Theme data
  111. // handle).
  112. //
  113. // hTheme - open theme data handle (returned from prior call
  114. // to OpenThemeData() API).
  115. //---------------------------------------------------------------------------
  116. HRESULT CloseThemeData(
  117. HTHEME hTheme
  118. );
  119. //---------------------------------------------------------------------------
  120. // functions for basic drawing support
  121. //---------------------------------------------------------------------------
  122. // The following methods are the theme-aware drawing services.
  123. // Controls/Windows are defined in drawable "parts" by their author: a
  124. // parent part and 0 or more child parts. Each of the parts can be
  125. // described in "states" (ex: disabled, hot, pressed).
  126. //---------------------------------------------------------------------------
  127. // For the list of all themed classes and the definition of all
  128. // parts and states, see the file "tmschmea.h".
  129. //---------------------------------------------------------------------------
  130. // Each of the below methods takes a "iPartId" param to specify the
  131. // part and a "iStateId" to specify the state of the part.
  132. // "iStateId=0" refers to the root part. "iPartId" = "0" refers to
  133. // the root class.
  134. //-----------------------------------------------------------------------
  135. // Note: draw operations are always scaled to fit (and not to exceed)
  136. // the specified "Rect".
  137. //-----------------------------------------------------------------------
  138. //------------------------------------------------------------------------
  139. // DrawThemeBackground()
  140. // - draws the theme-specified border and fill for
  141. // the "iPartId" and "iStateId". This could be
  142. // based on a bitmap file, a border and fill, or
  143. // other image description.
  144. //
  145. // hTheme - theme data handle
  146. // hdc - HDC to draw into
  147. // iPartId - part number to draw
  148. // iStateId - state number (of the part) to draw
  149. // pRect - defines the size/location of the part
  150. // pClipRect - optional clipping rect (don't draw outside it)
  151. //------------------------------------------------------------------------
  152. HRESULT DrawThemeBackground(
  153. HTHEME hTheme,
  154. HDC hdc,
  155. int iPartId,
  156. int iStateId,
  157. LPCRECT pRect,
  158. LPCRECT pClipRect
  159. );
  160. //------------------------------------------------------------------------
  161. //---- bits used in dwFlags of DTBGOPTS ----
  162. const auto DTBG_CLIPRECT = 0x00000001; // rcClip has been specified
  163. const auto DTBG_DRAWSOLID = 0x00000002; // DEPRECATED: draw transparent/alpha images as solid
  164. const auto DTBG_OMITBORDER = 0x00000004; // don't draw border of part
  165. const auto DTBG_OMITCONTENT = 0x00000008; // don't draw content area of part
  166. const auto DTBG_COMPUTINGREGION = 0x00000010; // TRUE if calling to compute region
  167. const auto DTBG_MIRRORDC = 0x00000020; // assume the hdc is mirrorred and
  168. // flip images as appropriate (currently
  169. // only supported for bgtype=imagefile)
  170. const auto DTBG_NOMIRROR = 0x00000040; // don't mirror the output, overrides everything else
  171. const auto DTBG_VALIDBITS = (DTBG_CLIPRECT |
  172. DTBG_DRAWSOLID |
  173. DTBG_OMITBORDER |
  174. DTBG_OMITCONTENT |
  175. DTBG_COMPUTINGREGION |
  176. DTBG_MIRRORDC |
  177. DTBG_NOMIRROR);
  178. struct DTBGOPTS {
  179. DWORD dwSize; // size of the struct
  180. DWORD dwFlags; // which options have been specified
  181. RECT rcClip; // clipping rectangle
  182. }
  183. typedef DTBGOPTS* PDTBGOPTS;
  184. //------------------------------------------------------------------------
  185. // DrawThemeBackgroundEx()
  186. // - draws the theme-specified border and fill for
  187. // the "iPartId" and "iStateId". This could be
  188. // based on a bitmap file, a border and fill, or
  189. // other image description. NOTE: This will be
  190. // merged back into DrawThemeBackground() after
  191. // BETA 2.
  192. //
  193. // hTheme - theme data handle
  194. // hdc - HDC to draw into
  195. // iPartId - part number to draw
  196. // iStateId - state number (of the part) to draw
  197. // pRect - defines the size/location of the part
  198. // pOptions - ptr to optional params
  199. //------------------------------------------------------------------------
  200. HRESULT DrawThemeBackgroundEx(
  201. HTHEME hTheme,
  202. HDC hdc,
  203. int iPartId,
  204. int iStateId,
  205. LPCRECT pRect,
  206. DTBGOPTS *pOptions
  207. );
  208. //---------------------------------------------------------------------------
  209. //----- DrawThemeText() flags ----
  210. const auto DTT_GRAYED = 0x00000001; // draw a grayed-out string (this is deprecated)
  211. const auto DTT_FLAGS2VALIDBITS = (DTT_GRAYED);
  212. //-------------------------------------------------------------------------
  213. // DrawThemeText() - draws the text using the theme-specified
  214. // color and font for the "iPartId" and
  215. // "iStateId".
  216. //
  217. // hTheme - theme data handle
  218. // hdc - HDC to draw into
  219. // iPartId - part number to draw
  220. // iStateId - state number (of the part) to draw
  221. // pszText - actual text to draw
  222. // dwCharCount - number of chars to draw (-1 for all)
  223. // dwTextFlags - same as DrawText() "uFormat" param
  224. // dwTextFlags2 - additional drawing options
  225. // pRect - defines the size/location of the part
  226. //-------------------------------------------------------------------------
  227. HRESULT DrawThemeText(
  228. HTHEME hTheme,
  229. HDC hdc,
  230. int iPartId,
  231. int iStateId,
  232. LPCWSTR pszText,
  233. int cchText,
  234. DWORD dwTextFlags,
  235. DWORD dwTextFlags2,
  236. LPCRECT pRect
  237. );
  238. //---------------------------------------------------------------------------
  239. //
  240. // DrawThemeTextEx
  241. //
  242. // Callback function used by DrawTextWithGlow instead of DrawTextW
  243. typedef int function(HDC hdc, LPWSTR pszText, int cchText, LPRECT prc, UINT dwFlags, LPARAM lParam) DTT_CALLBACK_PROC;
  244. //---- bits used in dwFlags of DTTOPTS ----
  245. const auto DTT_TEXTCOLOR = (1UL << 0); // crText has been specified
  246. const auto DTT_BORDERCOLOR = (1UL << 1); // crBorder has been specified
  247. const auto DTT_SHADOWCOLOR = (1UL << 2); // crShadow has been specified
  248. const auto DTT_SHADOWTYPE = (1UL << 3); // iTextShadowType has been specified
  249. const auto DTT_SHADOWOFFSET = (1UL << 4); // ptShadowOffset has been specified
  250. const auto DTT_BORDERSIZE = (1UL << 5); // iBorderSize has been specified
  251. const auto DTT_FONTPROP = (1UL << 6); // iFontPropId has been specified
  252. const auto DTT_COLORPROP = (1UL << 7); // iColorPropId has been specified
  253. const auto DTT_STATEID = (1UL << 8); // IStateId has been specified
  254. const auto DTT_CALCRECT = (1UL << 9); // Use pRect as and in/out parameter
  255. const auto DTT_APPLYOVERLAY = (1UL << 10); // fApplyOverlay has been specified
  256. const auto DTT_GLOWSIZE = (1UL << 11); // iGlowSize has been specified
  257. const auto DTT_CALLBACK = (1UL << 12); // pfnDrawTextCallback has been specified
  258. const auto DTT_COMPOSITED = (1UL << 13); // Draws text with antialiased alpha (needs a DIB section)
  259. const auto DTT_VALIDBITS = (DTT_TEXTCOLOR |
  260. DTT_BORDERCOLOR |
  261. DTT_SHADOWCOLOR |
  262. DTT_SHADOWTYPE |
  263. DTT_SHADOWOFFSET |
  264. DTT_BORDERSIZE |
  265. DTT_FONTPROP |
  266. DTT_COLORPROP |
  267. DTT_STATEID |
  268. DTT_CALCRECT |
  269. DTT_APPLYOVERLAY |
  270. DTT_GLOWSIZE |
  271. DTT_COMPOSITED);
  272. struct DTTOPTS {
  273. DWORD dwSize; // size of the struct
  274. DWORD dwFlags; // which options have been specified
  275. COLORREF crText; // color to use for text fill
  276. COLORREF crBorder; // color to use for text outline
  277. COLORREF crShadow; // color to use for text shadow
  278. int iTextShadowType; // TST_SINGLE or TST_CONTINUOUS
  279. POINT ptShadowOffset; // where shadow is drawn (relative to text)
  280. int iBorderSize; // Border radius around text
  281. int iFontPropId; // Font property to use for the text instead of TMT_FONT
  282. int iColorPropId; // Color property to use for the text instead of TMT_TEXTCOLOR
  283. int iStateId; // Alternate state id
  284. BOOL fApplyOverlay; // Overlay text on top of any text effect?
  285. int iGlowSize; // Glow radious around text
  286. DTT_CALLBACK_PROC pfnDrawTextCallback; // Callback for DrawText
  287. LPARAM lParam; // Parameter for callback
  288. }
  289. typedef DTTOPTS* PDTTOPTS;
  290. HRESULT DrawThemeTextEx(
  291. HTHEME hTheme,
  292. HDC hdc,
  293. int iPartId,
  294. int iStateId,
  295. LPCWSTR pszText,
  296. int cchText,
  297. DWORD dwTextFlags,
  298. LPRECT pRect,
  299. DTTOPTS *pOptions
  300. );
  301. //-------------------------------------------------------------------------
  302. // GetThemeBackgroundContentRect()
  303. // - gets the size of the content for the theme-defined
  304. // background. This is usually the area inside
  305. // the borders or Margins.
  306. //
  307. // hTheme - theme data handle
  308. // hdc - (optional) device content to be used for drawing
  309. // iPartId - part number to draw
  310. // iStateId - state number (of the part) to draw
  311. // pBoundingRect - the outer RECT of the part being drawn
  312. // pContentRect - RECT to receive the content area
  313. //-------------------------------------------------------------------------
  314. HRESULT GetThemeBackgroundContentRect(
  315. HTHEME hTheme,
  316. HDC hdc,
  317. int iPartId,
  318. int iStateId,
  319. LPCRECT pBoundingRect,
  320. LPRECT pContentRect
  321. );
  322. //-------------------------------------------------------------------------
  323. // GetThemeBackgroundExtent() - calculates the size/location of the theme-
  324. // specified background based on the
  325. // "pContentRect".
  326. //
  327. // hTheme - theme data handle
  328. // hdc - (optional) device content to be used for drawing
  329. // iPartId - part number to draw
  330. // iStateId - state number (of the part) to draw
  331. // pContentRect - RECT that defines the content area
  332. // pBoundingRect - RECT to receive the overall size/location of part
  333. //-------------------------------------------------------------------------
  334. HRESULT GetThemeBackgroundExtent(
  335. HTHEME hTheme,
  336. HDC hdc,
  337. int iPartId,
  338. int iStateId,
  339. LPCRECT pContentRect,
  340. LPRECT pExtentRect
  341. );
  342. //-------------------------------------------------------------------------
  343. // GetThemeBackgroundRegion()
  344. // - computes the region for a regular or partially
  345. // transparent theme-specified background that is
  346. // bound by the specified "pRect".
  347. // If the rectangle is empty, sets the HRGN to NULL
  348. // and return S_FALSE.
  349. //
  350. // hTheme - theme data handle
  351. // hdc - optional HDC to draw into (DPI scaling)
  352. // iPartId - part number to draw
  353. // iStateId - state number (of the part)
  354. // pRect - the RECT used to draw the part
  355. // pRegion - receives handle to calculated region
  356. //-------------------------------------------------------------------------
  357. HRESULT GetThemeBackgroundRegion(
  358. HTHEME hTheme,
  359. HDC hdc,
  360. int iPartId,
  361. int iStateId,
  362. LPCRECT pRect,
  363. HRGN *pRegion
  364. );
  365. enum THEMESIZE {
  366. TS_MIN, // minimum size
  367. TS_TRUE, // size without stretching
  368. TS_DRAW // size that theme mgr will use to draw part
  369. }
  370. //-------------------------------------------------------------------------
  371. // GetThemePartSize() - returns the specified size of the theme part
  372. //
  373. // hTheme - theme data handle
  374. // hdc - HDC to select font into & measure against
  375. // iPartId - part number to retrieve size for
  376. // iStateId - state number (of the part)
  377. // prc - (optional) rect for part drawing destination
  378. // eSize - the type of size to be retreived
  379. // psz - receives the specified size of the part
  380. //-------------------------------------------------------------------------
  381. HRESULT GetThemePartSize(
  382. HTHEME hTheme,
  383. HDC hdc,
  384. int iPartId,
  385. int iStateId,
  386. LPCRECT prc,
  387. THEMESIZE eSize,
  388. SIZE *psz
  389. );
  390. //-------------------------------------------------------------------------
  391. // GetThemeTextExtent() - calculates the size/location of the specified
  392. // text when rendered in the Theme Font.
  393. //
  394. // hTheme - theme data handle
  395. // hdc - HDC to select font & measure into
  396. // iPartId - part number to draw
  397. // iStateId - state number (of the part)
  398. // pszText - the text to be measured
  399. // dwCharCount - number of chars to draw (-1 for all)
  400. // dwTextFlags - same as DrawText() "uFormat" param
  401. // pszBoundingRect - optional: to control layout of text
  402. // pszExtentRect - receives the RECT for text size/location
  403. //-------------------------------------------------------------------------
  404. HRESULT
  405. GetThemeTextExtent(
  406. HTHEME hTheme,
  407. HDC hdc,
  408. int iPartId,
  409. int iStateId,
  410. LPCWSTR pszText,
  411. int cchCharCount,
  412. DWORD dwTextFlags,
  413. LPCRECT pBoundingRect,
  414. LPRECT pExtentRect
  415. );
  416. //-------------------------------------------------------------------------
  417. // GetThemeTextMetrics()
  418. // - returns info about the theme-specified font
  419. // for the part/state passed in.
  420. //
  421. // hTheme - theme data handle
  422. // hdc - optional: HDC for screen context
  423. // iPartId - part number to draw
  424. // iStateId - state number (of the part)
  425. // ptm - receives the font info
  426. //-------------------------------------------------------------------------
  427. HRESULT GetThemeTextMetrics(
  428. HTHEME hTheme,
  429. HDC hdc,
  430. int iPartId,
  431. int iStateId,
  432. TEXTMETRICW *ptm
  433. );
  434. //-------------------------------------------------------------------------
  435. //----- HitTestThemeBackground, HitTestThemeBackgroundRegion flags ----
  436. // Theme background segment hit test flag (default). possible return values are:
  437. // HTCLIENT: hit test succeeded in the middle background segment
  438. // HTTOP, HTLEFT, HTTOPLEFT, etc: // hit test succeeded in the the respective theme background segment.
  439. const auto HTTB_BACKGROUNDSEG = 0x00000000;
  440. // Fixed border hit test option. possible return values are:
  441. // HTCLIENT: hit test succeeded in the middle background segment
  442. // HTBORDER: hit test succeeded in any other background segment
  443. const auto HTTB_FIXEDBORDER = 0x00000002; // Return code may be either HTCLIENT or HTBORDER.
  444. // Caption hit test option. Possible return values are:
  445. // HTCAPTION: hit test succeeded in the top, top left, or top right background segments
  446. // HTNOWHERE or another return code, depending on absence or presence of accompanying flags, resp.
  447. const auto HTTB_CAPTION = 0x00000004;
  448. // Resizing border hit test flags. Possible return values are:
  449. // HTCLIENT: hit test succeeded in middle background segment
  450. // HTTOP, HTTOPLEFT, HTLEFT, HTRIGHT, etc: hit test succeeded in the respective system resizing zone
  451. // HTBORDER: hit test failed in middle segment and resizing zones, but succeeded in a background border segment
  452. const auto HTTB_RESIZINGBORDER_LEFT = 0x00000010; // Hit test left resizing border,
  453. const auto HTTB_RESIZINGBORDER_TOP = 0x00000020; // Hit test top resizing border
  454. const auto HTTB_RESIZINGBORDER_RIGHT = 0x00000040; // Hit test right resizing border
  455. const auto HTTB_RESIZINGBORDER_BOTTOM = 0x00000080; // Hit test bottom resizing border
  456. const auto HTTB_RESIZINGBORDER = (HTTB_RESIZINGBORDER_LEFT |
  457. HTTB_RESIZINGBORDER_TOP |
  458. HTTB_RESIZINGBORDER_RIGHT |
  459. HTTB_RESIZINGBORDER_BOTTOM);
  460. // Resizing border is specified as a template, not just window edges.
  461. // This option is mutually exclusive with HTTB_SYSTEMSIZINGWIDTH; HTTB_SIZINGTEMPLATE takes precedence
  462. const auto HTTB_SIZINGTEMPLATE = 0x00000100;
  463. // Use system resizing border width rather than theme content margins.
  464. // This option is mutually exclusive with HTTB_SIZINGTEMPLATE, which takes precedence.
  465. const auto HTTB_SYSTEMSIZINGMARGINS = 0x00000200;
  466. //-------------------------------------------------------------------------
  467. // HitTestThemeBackground()
  468. // - returns a HitTestCode (a subset of the values
  469. // returned by WM_NCHITTEST) for the point "ptTest"
  470. // within the theme-specified background
  471. // (bound by pRect). "pRect" and "ptTest" should
  472. // both be in the same coordinate system
  473. // (client, screen, etc).
  474. //
  475. // hTheme - theme data handle
  476. // hdc - HDC to draw into
  477. // iPartId - part number to test against
  478. // iStateId - state number (of the part)
  479. // pRect - the RECT used to draw the part
  480. // hrgn - optional region to use; must be in same coordinates as
  481. // - pRect and pTest.
  482. // ptTest - the hit point to be tested
  483. // dwOptions - HTTB_xxx constants
  484. // pwHitTestCode - receives the returned hit test code - one of:
  485. //
  486. // HTNOWHERE, HTLEFT, HTTOPLEFT, HTBOTTOMLEFT,
  487. // HTRIGHT, HTTOPRIGHT, HTBOTTOMRIGHT,
  488. // HTTOP, HTBOTTOM, HTCLIENT
  489. //-------------------------------------------------------------------------
  490. HRESULT HitTestThemeBackground(
  491. HTHEME hTheme,
  492. HDC hdc,
  493. int iPartId,
  494. int iStateId,
  495. DWORD dwOptions,
  496. LPCRECT pRect,
  497. HRGN hrgn,
  498. POINT ptTest,
  499. WORD *pwHitTestCode
  500. );
  501. //------------------------------------------------------------------------
  502. // DrawThemeEdge() - Similar to the DrawEdge() API, but uses part colors
  503. // and is high-DPI aware
  504. // hTheme - theme data handle
  505. // hdc - HDC to draw into
  506. // iPartId - part number to draw
  507. // iStateId - state number of part
  508. // pDestRect - the RECT used to draw the line(s)
  509. // uEdge - Same as DrawEdge() API
  510. // uFlags - Same as DrawEdge() API
  511. // pContentRect - Receives the interior rect if (uFlags & BF_ADJUST)
  512. //------------------------------------------------------------------------
  513. HRESULT DrawThemeEdge(
  514. HTHEME hTheme,
  515. HDC hdc,
  516. int iPartId,
  517. int iStateId,
  518. LPCRECT pDestRect,
  519. UINT uEdge,
  520. UINT uFlags,
  521. LPRECT pContentRect
  522. );
  523. //------------------------------------------------------------------------
  524. // DrawThemeIcon() - draws an image within an imagelist based on
  525. // a (possible) theme-defined effect.
  526. //
  527. // hTheme - theme data handle
  528. // hdc - HDC to draw into
  529. // iPartId - part number to draw
  530. // iStateId - state number of part
  531. // pRect - the RECT to draw the image within
  532. // himl - handle to IMAGELIST
  533. // iImageIndex - index into IMAGELIST (which icon to draw)
  534. //------------------------------------------------------------------------
  535. HRESULT DrawThemeIcon(
  536. HTHEME hTheme,
  537. HDC hdc,
  538. int iPartId,
  539. int iStateId,
  540. LPCRECT pRect,
  541. HIMAGELIST himl,
  542. int iImageIndex
  543. );
  544. //---------------------------------------------------------------------------
  545. // IsThemePartDefined() - returns TRUE if the theme has defined parameters
  546. // for the specified "iPartId" and "iStateId".
  547. //
  548. // hTheme - theme data handle
  549. // iPartId - part number to find definition for
  550. // iStateId - state number of part
  551. //---------------------------------------------------------------------------
  552. BOOL IsThemePartDefined(
  553. HTHEME hTheme,
  554. int iPartId,
  555. int iStateId
  556. );
  557. //---------------------------------------------------------------------------
  558. // IsThemeBackgroundPartiallyTransparent()
  559. // - returns TRUE if the theme specified background for
  560. // the part/state has transparent pieces or
  561. // alpha-blended pieces.
  562. //
  563. // hTheme - theme data handle
  564. // iPartId - part number
  565. // iStateId - state number of part
  566. //---------------------------------------------------------------------------
  567. BOOL IsThemeBackgroundPartiallyTransparent(
  568. HTHEME hTheme,
  569. int iPartId,
  570. int iStateId
  571. );
  572. //---------------------------------------------------------------------------
  573. // lower-level theme information services
  574. //---------------------------------------------------------------------------
  575. // The following methods are getter routines for each of the Theme Data types.
  576. // Controls/Windows are defined in drawable "parts" by their author: a
  577. // parent part and 0 or more child parts. Each of the parts can be
  578. // described in "states" (ex: disabled, hot, pressed).
  579. //---------------------------------------------------------------------------
  580. // Each of the below methods takes a "iPartId" param to specify the
  581. // part and a "iStateId" to specify the state of the part.
  582. // "iStateId=0" refers to the root part. "iPartId" = "0" refers to
  583. // the root class.
  584. //-----------------------------------------------------------------------
  585. // Each method also take a "iPropId" param because multiple instances of
  586. // the same primitive type can be defined in the theme schema.
  587. //-----------------------------------------------------------------------
  588. //-----------------------------------------------------------------------
  589. // GetThemeColor() - Get the value for the specified COLOR property
  590. //
  591. // hTheme - theme data handle
  592. // iPartId - part number
  593. // iStateId - state number of part
  594. // iPropId - the property number to get the value for
  595. // pColor - receives the value of the property
  596. //-----------------------------------------------------------------------
  597. HRESULT GetThemeColor(
  598. HTHEME hTheme,
  599. int iPartId,
  600. int iStateId,
  601. int iPropId,
  602. COLORREF *pColor
  603. );
  604. //-----------------------------------------------------------------------
  605. // GetThemeMetric() - Get the value for the specified metric/size
  606. // property
  607. //
  608. // hTheme - theme data handle
  609. // hdc - (optional) hdc to be drawn into (DPI scaling)
  610. // iPartId - part number
  611. // iStateId - state number of part
  612. // iPropId - the property number to get the value for
  613. // piVal - receives the value of the property
  614. //-----------------------------------------------------------------------
  615. HRESULT GetThemeMetric(
  616. HTHEME hTheme,
  617. HDC hdc,
  618. int iPartId,
  619. int iStateId,
  620. int iPropId,
  621. int *piVal
  622. );
  623. //-----------------------------------------------------------------------
  624. // GetThemeString() - Get the value for the specified string property
  625. //
  626. // hTheme - theme data handle
  627. // iPartId - part number
  628. // iStateId - state number of part
  629. // iPropId - the property number to get the value for
  630. // pszBuff - receives the string property value
  631. // cchMaxBuffChars - max. number of chars allowed in pszBuff
  632. //-----------------------------------------------------------------------
  633. HRESULT GetThemeString(
  634. HTHEME hTheme,
  635. int iPartId,
  636. int iStateId,
  637. int iPropId,
  638. LPWSTR pszBuff,
  639. int cchMaxBuffChars
  640. );
  641. //-----------------------------------------------------------------------
  642. // GetThemeBool() - Get the value for the specified BOOL property
  643. //
  644. // hTheme - theme data handle
  645. // iPartId - part number
  646. // iStateId - state number of part
  647. // iPropId - the property number to get the value for
  648. // pfVal - receives the value of the property
  649. //-----------------------------------------------------------------------
  650. HRESULT GetThemeBool(
  651. HTHEME hTheme,
  652. int iPartId,
  653. int iStateId,
  654. int iPropId,
  655. BOOL *pfVal
  656. );
  657. //-----------------------------------------------------------------------
  658. // GetThemeInt() - Get the value for the specified int property
  659. //
  660. // hTheme - theme data handle
  661. // iPartId - part number
  662. // iStateId - state number of part
  663. // iPropId - the property number to get the value for
  664. // piVal - receives the value of the property
  665. //-----------------------------------------------------------------------
  666. HRESULT GetThemeInt(
  667. HTHEME hTheme,
  668. int iPartId,
  669. int iStateId,
  670. int iPropId,
  671. int *piVal
  672. );
  673. //-----------------------------------------------------------------------
  674. // GetThemeEnumValue() - Get the value for the specified ENUM property
  675. //
  676. // hTheme - theme data handle
  677. // iPartId - part number
  678. // iStateId - state number of part
  679. // iPropId - the property number to get the value for
  680. // piVal - receives the value of the enum (cast to int*)
  681. //-----------------------------------------------------------------------
  682. HRESULT GetThemeEnumValue(
  683. HTHEME hTheme,
  684. int iPartId,
  685. int iStateId,
  686. int iPropId,
  687. int *piVal
  688. );
  689. //-----------------------------------------------------------------------
  690. // GetThemePosition() - Get the value for the specified position
  691. // property
  692. //
  693. // hTheme - theme data handle
  694. // iPartId - part number
  695. // iStateId - state number of part
  696. // iPropId - the property number to get the value for
  697. // pPoint - receives the value of the position property
  698. //-----------------------------------------------------------------------
  699. HRESULT GetThemePosition(
  700. HTHEME hTheme,
  701. int iPartId,
  702. int iStateId,
  703. int iPropId,
  704. POINT *pPoint
  705. );
  706. //-----------------------------------------------------------------------
  707. // GetThemeFont() - Get the value for the specified font property
  708. //
  709. // hTheme - theme data handle
  710. // hdc - (optional) hdc to be drawn to (DPI scaling)
  711. // iPartId - part number
  712. // iStateId - state number of part
  713. // iPropId - the property number to get the value for
  714. // pFont - receives the value of the LOGFONT property
  715. // (scaled for the current logical screen dpi)
  716. //-----------------------------------------------------------------------
  717. HRESULT GetThemeFont(
  718. HTHEME hTheme,
  719. HDC hdc,
  720. int iPartId,
  721. int iStateId,
  722. int iPropId,
  723. LOGFONTW *pFont
  724. );
  725. //-----------------------------------------------------------------------
  726. // GetThemeRect() - Get the value for the specified RECT property
  727. //
  728. // hTheme - theme data handle
  729. // iPartId - part number
  730. // iStateId - state number of part
  731. // iPropId - the property number to get the value for
  732. // pRect - receives the value of the RECT property
  733. //-----------------------------------------------------------------------
  734. HRESULT GetThemeRect(
  735. HTHEME hTheme,
  736. int iPartId,
  737. int iStateId,
  738. int iPropId,
  739. LPRECT pRect
  740. );
  741. struct MARGINS {
  742. int cxLeftWidth; // width of left border that retains its size
  743. int cxRightWidth; // width of right border that retains its size
  744. int cyTopHeight; // height of top border that retains its size
  745. int cyBottomHeight; // height of bottom border that retains its size
  746. }
  747. typedef MARGINS* PMARGINS;
  748. //-----------------------------------------------------------------------
  749. // GetThemeMargins() - Get the value for the specified MARGINS property
  750. //
  751. // hTheme - theme data handle
  752. // hdc - (optional) hdc to be used for drawing
  753. // iPartId - part number
  754. // iStateId - state number of part
  755. // iPropId - the property number to get the value for
  756. // prc - RECT for area to be drawn into
  757. // pMargins - receives the value of the MARGINS property
  758. //-----------------------------------------------------------------------
  759. HRESULT GetThemeMargins(
  760. HTHEME hTheme,
  761. HDC hdc,
  762. int iPartId,
  763. int iStateId,
  764. int iPropId,
  765. LPCRECT prc,
  766. MARGINS *pMargins
  767. );
  768. const auto MAX_INTLIST_COUNT = 402;
  769. struct INTLIST {
  770. int iValueCount; // number of values in iValues
  771. int[MAX_INTLIST_COUNT] iValues;
  772. }
  773. typedef INTLIST* PINTLIST;
  774. //-----------------------------------------------------------------------
  775. // GetThemeIntList() - Get the value for the specified INTLIST struct
  776. //
  777. // hTheme - theme data handle
  778. // iPartId - part number
  779. // iStateId - state number of part
  780. // iPropId - the property number to get the value for
  781. // pIntList - receives the value of the INTLIST property
  782. //-----------------------------------------------------------------------
  783. HRESULT GetThemeIntList(
  784. HTHEME hTheme,
  785. int iPartId,
  786. int iStateId,
  787. int iPropId,
  788. INTLIST *pIntList
  789. );
  790. enum PROPERTYORIGIN {
  791. PO_STATE, // property was found in the state section
  792. PO_PART, // property was found in the part section
  793. PO_CLASS, // property was found in the class section
  794. PO_GLOBAL, // property was found in [globals] section
  795. PO_NOTFOUND // property was not found
  796. }
  797. //-----------------------------------------------------------------------
  798. // GetThemePropertyOrigin()
  799. // - searches for the specified theme property
  800. // and sets "pOrigin" to indicate where it was
  801. // found (or not found)
  802. //
  803. // hTheme - theme data handle
  804. // iPartId - part number
  805. // iStateId - state number of part
  806. // iPropId - the property number to search for
  807. // pOrigin - receives the value of the property origin
  808. //-----------------------------------------------------------------------
  809. HRESULT GetThemePropertyOrigin(
  810. HTHEME hTheme,
  811. int iPartId,
  812. int iStateId,
  813. int iPropId,
  814. PROPERTYORIGIN *pOrigin
  815. );
  816. //---------------------------------------------------------------------------
  817. // SetWindowTheme()
  818. // - redirects an existing Window to use a different
  819. // section of the current theme information than its
  820. // class normally asks for.
  821. //
  822. // hwnd - the handle of the window (cannot be NULL)
  823. //
  824. // pszSubAppName - app (group) name to use in place of the calling
  825. // app's name. If NULL, the actual calling app
  826. // name will be used.
  827. //
  828. // pszSubIdList - semicolon separated list of class Id names to
  829. // use in place of actual list passed by the
  830. // window's class. if NULL, the id list from the
  831. // calling class is used.
  832. //---------------------------------------------------------------------------
  833. // The Theme Manager will remember the "pszSubAppName" and the
  834. // "pszSubIdList" associations thru the lifetime of the window (even
  835. // if themes are subsequently changed). The window is sent a
  836. // "WM_THEMECHANGED" msg at the end of this call, so that the new
  837. // theme can be found and applied.
  838. //---------------------------------------------------------------------------
  839. // When "pszSubAppName" or "pszSubIdList" are NULL, the Theme Manager
  840. // removes the previously remember association. To turn off theme-ing for
  841. // the specified window, you can pass an empty string (L"") so it
  842. // won't match any section entries.
  843. //---------------------------------------------------------------------------
  844. HRESULT SetWindowTheme(
  845. HWND hwnd,
  846. LPCWSTR pszSubAppName,
  847. LPCWSTR pszSubIdList
  848. );
  849. enum WINDOWTHEMEATTRIBUTETYPE {
  850. WTA_NONCLIENT = 1
  851. }
  852. struct WTA_OPTIONS {
  853. DWORD dwFlags; // values for each style option specified in the bitmask
  854. DWORD dwMask; // bitmask for flags that are changing
  855. // valid options are: WTNCA_NODRAWCAPTION, WTNCA_NODRAWICON, WTNCA_NOSYSMENU
  856. }
  857. typedef WTA_OPTIONS* PWTA_OPTIONS;
  858. const auto WTNCA_NODRAWCAPTION = 0x00000001; // don't draw the window caption
  859. const auto WTNCA_NODRAWICON = 0x00000002; // don't draw the system icon
  860. const auto WTNCA_NOSYSMENU = 0x00000004; // don't expose the system menu icon functionality
  861. const auto WTNCA_NOMIRRORHELP = 0x00000008; // don't mirror the question mark, even in RTL layout
  862. const auto WTNCA_VALIDBITS = (WTNCA_NODRAWCAPTION |
  863. WTNCA_NODRAWICON |
  864. WTNCA_NOSYSMENU |
  865. WTNCA_NOMIRRORHELP);
  866. HRESULT SetWindowThemeAttribute(
  867. HWND hwnd,
  868. WINDOWTHEMEATTRIBUTETYPE eAttribute,
  869. PVOID pvAttribute,
  870. DWORD cbAttribute
  871. );
  872. HRESULT SetWindowThemeNonClientAttributes(HWND hwnd, DWORD dwMask, DWORD dwAttributes) {
  873. WTA_OPTIONS wta;
  874. wta.dwFlags = dwAttributes;
  875. wta.dwMask = dwMask;
  876. return SetWindowThemeAttribute(hwnd, WTA_NONCLIENT, cast(void*)&(wta), wta.sizeof);
  877. }
  878. //---------------------------------------------------------------------------
  879. // GetThemeFilename() - Get the value for the specified FILENAME property.
  880. //
  881. // hTheme - theme data handle
  882. // iPartId - part number
  883. // iStateId - state number of part
  884. // iPropId - the property number to search for
  885. // pszThemeFileName - output buffer to receive the filename
  886. // cchMaxBuffChars - the size of the return buffer, in chars
  887. //---------------------------------------------------------------------------
  888. HRESULT GetThemeFilename(
  889. HTHEME hTheme,
  890. int iPartId,
  891. int iStateId,
  892. int iPropId,
  893. LPWSTR pszThemeFileName,
  894. int cchMaxBuffChars
  895. );
  896. //---------------------------------------------------------------------------
  897. // GetThemeSysColor() - Get the value of the specified System color.
  898. //
  899. // hTheme - the theme data handle. if non-NULL, will return
  900. // color from [SysMetrics] section of theme.
  901. // if NULL, will return the global system color.
  902. //
  903. // iColorId - the system color index defined in winuser.h
  904. //---------------------------------------------------------------------------
  905. COLORREF GetThemeSysColor(
  906. HTHEME hTheme,
  907. int iColorId
  908. );
  909. //---------------------------------------------------------------------------
  910. // GetThemeSysColorBrush()
  911. // - Get the brush for the specified System color.
  912. //
  913. // hTheme - the theme data handle. if non-NULL, will return
  914. // brush matching color from [SysMetrics] section of
  915. // theme. if NULL, will return the brush matching
  916. // global system color.
  917. //
  918. // iColorId - the system color index defined in winuser.h
  919. //---------------------------------------------------------------------------
  920. HBRUSH GetThemeSysColorBrush(
  921. HTHEME hTheme,
  922. int iColorId
  923. );
  924. //---------------------------------------------------------------------------
  925. // GetThemeSysBool() - Get the boolean value of specified System metric.
  926. //
  927. // hTheme - the theme data handle. if non-NULL, will return
  928. // BOOL from [SysMetrics] section of theme.
  929. // if NULL, will return the specified system boolean.
  930. //
  931. // iBoolId - the TMT_XXX BOOL number (first BOOL
  932. // is TMT_FLATMENUS)
  933. //---------------------------------------------------------------------------
  934. BOOL GetThemeSysBool(
  935. HTHEME hTheme,
  936. int iBoolId
  937. );
  938. //---------------------------------------------------------------------------
  939. // GetThemeSysSize() - Get the value of the specified System size metric.
  940. // (scaled for the current logical screen dpi)
  941. //
  942. // hTheme - the theme data handle. if non-NULL, will return
  943. // size from [SysMetrics] section of theme.
  944. // if NULL, will return the global system metric.
  945. //
  946. // iSizeId - the following values are supported when
  947. // hTheme is non-NULL:
  948. //
  949. // SM_CXBORDER (border width)
  950. // SM_CXVSCROLL (scrollbar width)
  951. // SM_CYHSCROLL (scrollbar height)
  952. // SM_CXSIZE (caption width)
  953. // SM_CYSIZE (caption height)
  954. // SM_CXSMSIZE (small caption width)
  955. // SM_CYSMSIZE (small caption height)
  956. // SM_CXMENUSIZE (menubar width)
  957. // SM_CYMENUSIZE (menubar height)
  958. // SM_CXPADDEDBORDER (padded border width)
  959. //
  960. // when hTheme is NULL, iSizeId is passed directly
  961. // to the GetSystemMetrics() function
  962. //---------------------------------------------------------------------------
  963. int GetThemeSysSize(
  964. HTHEME hTheme,
  965. int iSizeId
  966. );
  967. //---------------------------------------------------------------------------
  968. // GetThemeSysFont() - Get the LOGFONT for the specified System font.
  969. //
  970. // hTheme - the theme data handle. if non-NULL, will return
  971. // font from [SysMetrics] section of theme.
  972. // if NULL, will return the specified system font.
  973. //
  974. // iFontId - the TMT_XXX font number (first font
  975. // is TMT_CAPTIONFONT)
  976. //
  977. // plf - ptr to LOGFONT to receive the font value.
  978. // (scaled for the current logical screen dpi)
  979. //---------------------------------------------------------------------------
  980. HRESULT GetThemeSysFont(
  981. HTHEME hTheme,
  982. int iFontId,
  983. LOGFONTW *plf
  984. );
  985. //---------------------------------------------------------------------------
  986. // GetThemeSysString() - Get the value of specified System string metric.
  987. //
  988. // hTheme - the theme data handle (required)
  989. //
  990. // iStringId - must be one of the following values:
  991. //
  992. // TMT_CSSNAME
  993. // TMT_XMLNAME
  994. //
  995. // pszStringBuff - the buffer to receive the string value
  996. //
  997. // cchMaxStringChars - max. number of chars that pszStringBuff can hold
  998. //---------------------------------------------------------------------------
  999. HRESULT GetThemeSysString(
  1000. HTHEME hTheme,
  1001. int iStringId,
  1002. LPWSTR pszStringBuff,
  1003. int cchMaxStringChars
  1004. );
  1005. //---------------------------------------------------------------------------
  1006. // GetThemeSysInt() - Get the value of specified System int.
  1007. //
  1008. // hTheme - the theme data handle (required)
  1009. //
  1010. // iIntId - must be one of the following values:
  1011. //
  1012. // TMT_DPIX
  1013. // TMT_DPIY
  1014. // TMT_MINCOLORDEPTH
  1015. //
  1016. // piValue - ptr to int to receive value
  1017. //---------------------------------------------------------------------------
  1018. HRESULT GetThemeSysInt(
  1019. HTHEME hTheme,
  1020. int iIntId,
  1021. int *piValue
  1022. );
  1023. //---------------------------------------------------------------------------
  1024. // IsThemeActive() - can be used to test if a system theme is active
  1025. // for the current user session.
  1026. //
  1027. // use the API "IsAppThemed()" to test if a theme is
  1028. // active for the calling process.
  1029. //---------------------------------------------------------------------------
  1030. BOOL IsThemeActive();
  1031. //---------------------------------------------------------------------------
  1032. // IsAppThemed() - returns TRUE if a theme is active and available to
  1033. // the current process
  1034. //---------------------------------------------------------------------------
  1035. BOOL IsAppThemed();
  1036. //---------------------------------------------------------------------------
  1037. // GetWindowTheme() - if window is themed, returns its most recent
  1038. // HTHEME from OpenThemeData() - otherwise, returns
  1039. // NULL.
  1040. //
  1041. // hwnd - the window to get the HTHEME of
  1042. //---------------------------------------------------------------------------
  1043. HTHEME GetWindowTheme(
  1044. HWND hwnd
  1045. );
  1046. const auto ETDT_DISABLE = 0x00000001;
  1047. const auto ETDT_ENABLE = 0x00000002;
  1048. const auto ETDT_USETABTEXTURE = 0x00000004;
  1049. const auto ETDT_USEAEROWIZARDTABTEXTURE = 0x00000008;
  1050. const auto ETDT_ENABLETAB = (ETDT_ENABLE |
  1051. ETDT_USETABTEXTURE);
  1052. const auto ETDT_ENABLEAEROWIZARDTAB = (ETDT_ENABLE |
  1053. ETDT_USEAEROWIZARDTABTEXTURE);
  1054. const auto ETDT_VALIDBITS = (ETDT_DISABLE |
  1055. ETDT_ENABLE |
  1056. ETDT_USETABTEXTURE |
  1057. ETDT_USEAEROWIZARDTABTEXTURE);
  1058. //---------------------------------------------------------------------------
  1059. // EnableThemeDialogTexture()
  1060. //
  1061. // - Enables/disables dialog background theme. This method can be used to
  1062. // tailor dialog compatibility with child windows and controls that
  1063. // may or may not coordinate the rendering of their client area backgrounds
  1064. // with that of their parent dialog in a manner that supports seamless
  1065. // background texturing.
  1066. //
  1067. // hdlg - the window handle of the target dialog
  1068. // dwFlags - ETDT_ENABLE to enable the theme-defined dialog background texturing,
  1069. // ETDT_DISABLE to disable background texturing,
  1070. // ETDT_ENABLETAB to enable the theme-defined background
  1071. // texturing using the Tab texture
  1072. //---------------------------------------------------------------------------
  1073. HRESULT EnableThemeDialogTexture(
  1074. HWND hwnd,
  1075. DWORD dwFlags
  1076. );
  1077. //---------------------------------------------------------------------------
  1078. // IsThemeDialogTextureEnabled()
  1079. //
  1080. // - Reports whether the dialog supports background texturing.
  1081. //
  1082. // hdlg - the window handle of the target dialog
  1083. //---------------------------------------------------------------------------
  1084. BOOL IsThemeDialogTextureEnabled(
  1085. HWND hwnd
  1086. );
  1087. //---------------------------------------------------------------------------
  1088. //---- flags to control theming within an app ----
  1089. const auto STAP_ALLOW_NONCLIENT = (1UL << 0);
  1090. const auto STAP_ALLOW_CONTROLS = (1UL << 1);
  1091. const auto STAP_ALLOW_WEBCONTENT = (1UL << 2);
  1092. const auto STAP_VALIDBITS = (STAP_ALLOW_NONCLIENT |
  1093. STAP_ALLOW_CONTROLS |
  1094. STAP_ALLOW_WEBCONTENT);
  1095. //---------------------------------------------------------------------------
  1096. // GetThemeAppProperties()
  1097. // - returns the app property flags that control theming
  1098. //---------------------------------------------------------------------------
  1099. DWORD GetThemeAppProperties();
  1100. //---------------------------------------------------------------------------
  1101. // SetThemeAppProperties()
  1102. // - sets the flags that control theming within the app
  1103. //
  1104. // dwFlags - the flag values to be set
  1105. //---------------------------------------------------------------------------
  1106. void SetThemeAppProperties(
  1107. DWORD dwFlags
  1108. );
  1109. //---------------------------------------------------------------------------
  1110. // GetCurrentThemeName()
  1111. // - Get the name of the current theme in-use.
  1112. // Optionally, return the ColorScheme name and the
  1113. // Size name of the theme.
  1114. //
  1115. // pszThemeFileName - receives the theme path & filename
  1116. // cchMaxNameChars - max chars allowed in pszNameBuff
  1117. //
  1118. // pszColorBuff - (optional) receives the canonical color scheme name
  1119. // (not the display name)
  1120. // cchMaxColorChars - max chars allowed in pszColorBuff
  1121. //
  1122. // pszSizeBuff - (optional) receives the canonical size name
  1123. // (not the display name)
  1124. // cchMaxSizeChars - max chars allowed in pszSizeBuff
  1125. //---------------------------------------------------------------------------
  1126. HRESULT GetCurrentThemeName(
  1127. LPWSTR pszThemeFileName,
  1128. int cchMaxNameChars,
  1129. LPWSTR pszColorBuff,
  1130. int cchMaxColorChars,
  1131. LPWSTR pszSizeBuff,
  1132. int cchMaxSizeChars
  1133. );
  1134. const auto SZ_THDOCPROP_DISPLAYNAME = "DisplayName\0"w;
  1135. const auto SZ_THDOCPROP_CANONICALNAME = "ThemeName\0"w;
  1136. const auto SZ_THDOCPROP_TOOLTIP = "ToolTip\0"w;
  1137. const auto SZ_THDOCPROP_AUTHOR = "author\0"w;
  1138. HRESULT GetThemeDocumentationProperty(
  1139. LPCWSTR pszThemeName,
  1140. LPCWSTR pszPropertyName,
  1141. LPWSTR pszValueBuff,
  1142. int cchMaxValChars
  1143. );
  1144. //---------------------------------------------------------------------------
  1145. // Theme API Error Handling
  1146. //
  1147. // All functions in the Theme API not returning an HRESULT (THEMEAPI_)
  1148. // use the WIN32 function "SetLastError()" to record any call failures.
  1149. //
  1150. // To retreive the error code of the last failure on the
  1151. // current thread for these type of API's, use the WIN32 function
  1152. // "GetLastError()".
  1153. //
  1154. // All Theme API error codes (HRESULT's and GetLastError() values)
  1155. // should be normal win32 errors which can be formatted into
  1156. // strings using the Win32 API FormatMessage().
  1157. //---------------------------------------------------------------------------
  1158. //---------------------------------------------------------------------------
  1159. // DrawThemeParentBackground()
  1160. // - used by partially-transparent or alpha-blended
  1161. // child controls to draw the part of their parent
  1162. // that they appear in front of.
  1163. //
  1164. // hwnd - handle of the child control
  1165. //
  1166. // hdc - hdc of the child control
  1167. //
  1168. // prc - (optional) rect that defines the area to be
  1169. // drawn (CHILD coordinates)
  1170. //---------------------------------------------------------------------------
  1171. HRESULT DrawThemeParentBackground(
  1172. HWND hwnd,
  1173. HDC hdc,
  1174. RECT* prc
  1175. );
  1176. const auto DTPB_WINDOWDC = 0x00000001;
  1177. const auto DTPB_USECTLCOLORSTATIC = 0x00000002;
  1178. const auto DTPB_USEERASEBKGND = 0x00000004;
  1179. //---------------------------------------------------------------------------
  1180. // DrawThemeParentBackgroundEx()
  1181. // - used by partially-transparent or alpha-blended
  1182. // child controls to draw the part of their parent
  1183. // that they appear in front of.
  1184. // Sends a WM_ERASEBKGND message followed by a WM_PRINTCLIENT.
  1185. //
  1186. // hwnd - handle of the child control
  1187. //
  1188. // hdc - hdc of the child control
  1189. //
  1190. // dwFlags - if 0, only returns S_OK if the parent handled
  1191. // WM_PRINTCLIENT.
  1192. // - if DTPB_WINDOWDC is set, hdc is assumed to be a window DC,
  1193. // not a client DC.
  1194. // - if DTPB_USEERASEBKGND is set, the function will return S_OK
  1195. // without sending a WM_CTLCOLORSTATIC message if the parent
  1196. // actually painted on WM_ERASEBKGND.
  1197. // - if DTPB_CTLCOLORSTATIC is set, the function will send
  1198. // a WM_CTLCOLORSTATIC message to the parent and use the
  1199. // brush if one is provided, else COLOR_BTNFACE.
  1200. //
  1201. // prc - (optional) rect that defines the area to be
  1202. // drawn (CHILD coordinates)
  1203. //
  1204. // Return value - S_OK if something was painted, S_FALSE if not.
  1205. //---------------------------------------------------------------------------
  1206. HRESULT DrawThemeParentBackgroundEx(
  1207. HWND hwnd,
  1208. HDC hdc,
  1209. DWORD dwFlags,
  1210. RECT* prc
  1211. );
  1212. //---------------------------------------------------------------------------
  1213. // EnableTheming() - enables or disables themeing for the current user
  1214. // in the current and future sessions.
  1215. //
  1216. // fEnable - if FALSE, disable theming & turn themes off.
  1217. // - if TRUE, enable themeing and, if user previously
  1218. // had a theme active, make it active now.
  1219. //---------------------------------------------------------------------------
  1220. HRESULT EnableTheming(
  1221. BOOL fEnable
  1222. );
  1223. const auto GBF_DIRECT = 0x00000001; // direct dereferencing.
  1224. const auto GBF_COPY = 0x00000002; // create a copy of the bitmap
  1225. const auto GBF_VALIDBITS = (GBF_DIRECT |
  1226. GBF_COPY);
  1227. HRESULT GetThemeBitmap(
  1228. HTHEME hTheme,
  1229. int iPartId,
  1230. int iStateId,
  1231. int iPropId,
  1232. ULONG dwFlags,
  1233. HBITMAP* phBitmap
  1234. );
  1235. //-----------------------------------------------------------------------
  1236. // GetThemeStream() - Get the value for the specified STREAM property
  1237. //
  1238. // hTheme - theme data handle
  1239. // iPartId - part number
  1240. // iStateId - state number of part
  1241. // iPropId - the property number to get the value for
  1242. // ppvStream - if non-null receives the value of the STREAM property (not to be freed)
  1243. // pcbStream - if non-null receives the size of the STREAM property
  1244. // hInst - NULL when iPropId==TMT_STREAM, HINSTANCE of a loaded msstyles
  1245. // file when iPropId==TMT_DISKSTREAM (use GetCurrentThemeName
  1246. // and LoadLibraryEx(LOAD_LIBRARY_AS_DATAFILE)
  1247. //-----------------------------------------------------------------------
  1248. HRESULT GetThemeStream(
  1249. HTHEME hTheme,
  1250. int iPartId,
  1251. int iStateId,
  1252. int iPropId,
  1253. VOID **ppvStream,
  1254. DWORD *pcbStream,
  1255. HINSTANCE hInst
  1256. );
  1257. //------------------------------------------------------------------------
  1258. // BufferedPaintInit() - Initialize the Buffered Paint API.
  1259. // Should be called prior to BeginBufferedPaint,
  1260. // and should have a matching BufferedPaintUnInit.
  1261. //------------------------------------------------------------------------
  1262. HRESULT BufferedPaintInit(
  1263. );
  1264. //------------------------------------------------------------------------
  1265. // BufferedPaintUnInit() - Uninitialize the Buffered Paint API.
  1266. // Should be called once for each call to BufferedPaintInit,
  1267. // when calls to BeginBufferedPaint are no longer needed.
  1268. //------------------------------------------------------------------------
  1269. HRESULT BufferedPaintUnInit(
  1270. );
  1271. //------------------------------------------------------------------------
  1272. // BeginBufferedPaint() - Begins a buffered paint operation.
  1273. //
  1274. // hdcTarget - Target DC on which the buffer will be painted
  1275. // rcTarget - Rectangle specifying the area of the target DC to paint to
  1276. // dwFormat - Format of the buffer (see BP_BUFFERFORMAT)
  1277. // pPaintParams - Paint operation parameters (see BP_PAINTPARAMS)
  1278. // phBufferedPaint - Pointer to receive handle to new buffered paint context
  1279. //------------------------------------------------------------------------
  1280. // HPAINTBUFFER
  1281. alias HANDLE HPAINTBUFFER; // handle to a buffered paint context
  1282. // BP_BUFFERFORMAT
  1283. enum BP_BUFFERFORMAT {
  1284. BPBF_COMPATIBLEBITMAP, // Compatible bitmap
  1285. BPBF_DIB, // Device-independent bitmap
  1286. BPBF_TOPDOWNDIB, // Top-down device-independent bitmap
  1287. BPBF_TOPDOWNMONODIB // Top-down monochrome device-independent bitmap
  1288. }
  1289. const auto BPBF_COMPOSITED = BP_BUFFERFORMAT.BPBF_TOPDOWNDIB;
  1290. // BP_ANIMATIONSTYLE
  1291. enum BP_ANIMATIONSTYLE {
  1292. BPAS_NONE, // No animation
  1293. BPAS_LINEAR, // Linear fade animation
  1294. BPAS_CUBIC, // Cubic fade animation
  1295. BPAS_SINE // Sinusoid fade animation
  1296. }
  1297. // BP_ANIMATIONPARAMS
  1298. struct BP_ANIMATIONPARAMS {
  1299. DWORD cbSize;
  1300. DWORD dwFlags; // BPAF_ flags
  1301. BP_ANIMATIONSTYLE style;
  1302. DWORD dwDuration;
  1303. }
  1304. typedef BP_ANIMATIONPARAMS* PBP_ANIMATIONPARAMS;
  1305. const auto BPPF_ERASE = 0x0001; // Empty the buffer during BeginBufferedPaint()
  1306. const auto BPPF_NOCLIP = 0x0002; // Don't apply the target DC's clip region to the double buffer
  1307. const auto BPPF_NONCLIENT = 0x0004; // Using a non-client DC
  1308. // BP_PAINTPARAMS
  1309. struct BP_PAINTPARAMS {
  1310. DWORD cbSize;
  1311. DWORD dwFlags; // BPPF_ flags
  1312. const RECT * prcExclude;
  1313. const BLENDFUNCTION * pBlendFunction;
  1314. }
  1315. typedef BP_PAINTPARAMS* PBP_PAINTPARAMS;
  1316. HPAINTBUFFER BeginBufferedPaint(
  1317. HDC hdcTarget,
  1318. RECT* prcTarget,
  1319. BP_BUFFERFORMAT dwFormat,
  1320. BP_PAINTPARAMS *pPaintParams,
  1321. HDC *phdc
  1322. );
  1323. //------------------------------------------------------------------------
  1324. // EndBufferedPaint() - Ends a buffered paint operation.
  1325. //
  1326. // hBufferedPaint - handle to buffered paint context
  1327. // fUpdateTarget - update target DC
  1328. //------------------------------------------------------------------------
  1329. HRESULT EndBufferedPaint(
  1330. HPAINTBUFFER hBufferedPaint,
  1331. BOOL fUpdateTarget
  1332. );
  1333. //------------------------------------------------------------------------
  1334. // GetBufferedPaintTargetRect() - Returns the target rectangle specified during BeginBufferedPaint
  1335. //
  1336. // hBufferedPaint - handle to buffered paint context
  1337. // prc - pointer to receive target rectangle
  1338. //------------------------------------------------------------------------
  1339. HRESULT GetBufferedPaintTargetRect(
  1340. HPAINTBUFFER hBufferedPaint,
  1341. RECT *prc
  1342. );
  1343. //------------------------------------------------------------------------
  1344. // GetBufferedPaintTargetDC() - Returns the target DC specified during BeginBufferedPaint
  1345. //
  1346. // hBufferedPaint - handle to buffered paint context
  1347. //------------------------------------------------------------------------
  1348. HDC GetBufferedPaintTargetDC(
  1349. HPAINTBUFFER hBufferedPaint
  1350. );
  1351. //------------------------------------------------------------------------
  1352. // GetBufferedPaintDC() - Returns the same paint DC returned by BeginBufferedPaint
  1353. //
  1354. // hBufferedPaint - handle to buffered paint context
  1355. //------------------------------------------------------------------------
  1356. HDC GetBufferedPaintDC(
  1357. HPAINTBUFFER hBufferedPaint
  1358. );
  1359. //------------------------------------------------------------------------
  1360. // GetBufferedPaintBits() - Obtains a pointer to the buffer bitmap, if the buffer is a DIB
  1361. //
  1362. // hBufferedPaint - handle to buffered paint context
  1363. // ppbBuffer - pointer to receive pointer to buffer bitmap pixels
  1364. // pcxRow - pointer to receive width of buffer bitmap, in pixels;
  1365. // this value may not necessarily be equal to the buffer width
  1366. //------------------------------------------------------------------------
  1367. HRESULT GetBufferedPaintBits(
  1368. HPAINTBUFFER hBufferedPaint,
  1369. RGBQUAD **ppbBuffer,
  1370. int *pcxRow
  1371. );
  1372. //------------------------------------------------------------------------
  1373. // BufferedPaintClear() - Clears given rectangle to ARGB = {0, 0, 0, 0}
  1374. //
  1375. // hBufferedPaint - handle to buffered paint context
  1376. // prc - rectangle to clear; NULL specifies entire buffer
  1377. //------------------------------------------------------------------------
  1378. HRESULT BufferedPaintClear(
  1379. HPAINTBUFFER hBufferedPaint,
  1380. RECT *prc
  1381. );
  1382. //------------------------------------------------------------------------
  1383. // BufferedPaintSetAlpha() - Set alpha to given value in given rectangle
  1384. //
  1385. // hBufferedPaint - handle to buffered paint context
  1386. // prc - rectangle to set alpha in; NULL specifies entire buffer
  1387. // alpha - alpha value to set in the given rectangle
  1388. //------------------------------------------------------------------------
  1389. HRESULT BufferedPaintSetAlpha(
  1390. HPAINTBUFFER hBufferedPaint,
  1391. RECT *prc,
  1392. BYTE alpha
  1393. );
  1394. // Macro for setting the buffer to opaque (alpha = 255)
  1395. HRESULT BufferedPaintMakeOpaque(HPAINTBUFFER hBufferedPaint, RECT* prc) {
  1396. return BufferedPaintSetAlpha(hBufferedPaint, prc, 255);
  1397. }
  1398. //------------------------------------------------------------------------
  1399. // BufferedPaintStopAllAnimations() - Stop all buffer animations for the given window
  1400. //
  1401. // hwnd - window on which to stop all animations
  1402. //------------------------------------------------------------------------
  1403. HRESULT BufferedPaintStopAllAnimations(
  1404. HWND hwnd
  1405. );
  1406. alias HANDLE HANIMATIONBUFFER; // handle to a buffered paint animation
  1407. HANIMATIONBUFFER BeginBufferedAnimation(
  1408. HWND hwnd,
  1409. HDC hdcTarget,
  1410. RECT* prcTarget,
  1411. BP_BUFFERFORMAT dwFormat,
  1412. BP_PAINTPARAMS *pPaintParams,
  1413. BP_ANIMATIONPARAMS *pAnimationParams,
  1414. HDC *phdcFrom,
  1415. HDC *phdcTo
  1416. );
  1417. HRESULT EndBufferedAnimation(
  1418. HANIMATIONBUFFER hbpAnimation,
  1419. BOOL fUpdateTarget
  1420. );
  1421. BOOL BufferedPaintRenderAnimation(
  1422. HWND hwnd,
  1423. HDC hdcTarget
  1424. );
  1425. //----------------------------------------------------------------------------
  1426. // Tells if the DWM is running, and composition effects are possible for this
  1427. // process (themes are active).
  1428. // Roughly equivalent to "DwmIsCompositionEnabled() && IsAppthemed()"
  1429. //----------------------------------------------------------------------------
  1430. BOOL IsCompositionActive();
  1431. //------------------------------------------------------------------------
  1432. // GetThemeTransitionDuration()
  1433. // - Gets the duration for the specified transition
  1434. //
  1435. // hTheme - theme data handle
  1436. // iPartId - part number
  1437. // iStateIdFrom - starting state number of part
  1438. // iStateIdTo - ending state number of part
  1439. // iPropId - property id
  1440. // pdwDuration - receives the transition duration
  1441. //------------------------------------------------------------------------
  1442. HRESULT GetThemeTransitionDuration(
  1443. HTHEME hTheme,
  1444. int iPartId,
  1445. int iStateIdFrom,
  1446. int iStateIdTo,
  1447. int iPropId,
  1448. DWORD *pdwDuration
  1449. );