Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.7 KiB

  1. //-------------------------------------------------------------------------//
  2. // Module Name: scrollp.cpp
  3. //
  4. // Copyright (c) 1985 - 1999, Microsoft Corporation
  5. //
  6. // win32k->uxtheme port routines for scrollbar
  7. //
  8. // History:
  9. // 03-21-00 ScottHan Created
  10. //-------------------------------------------------------------------------//
  11. #include "stdafx.h"
  12. #include "scrollp.h"
  13. extern HBRUSH _UxGrayBrush(VOID);
  14. extern void _UxFreeGDIResources();
  15. enum {
  16. WF_STATE1 = 0,
  17. WF_STATE2,
  18. WF_EXSTYLE,
  19. WF_STYLE,
  20. };
  21. //-------------------------------------------------------------------------//
  22. ULONG _ExpandWF( ULONG ulRaw, ULONG* pulField )
  23. {
  24. ULONG ulField = ( HIBYTE(ulRaw) & 0xFC ) >> 2;
  25. ULONG ulShift = HIBYTE(ulRaw) & 0x03;
  26. ULONG ulResult = LOBYTE(ulRaw) << (ulShift << 3);
  27. if( pulField )
  28. *pulField = ulField;
  29. return ulResult;
  30. }
  31. //-------------------------------------------------------------------------//
  32. // From usrctl32.h/.cpp
  33. void SetWindowState(
  34. HWND hwnd,
  35. UINT flags)
  36. {
  37. ULONG ulField;
  38. ULONG ulVal = _ExpandWF( flags, &ulField );
  39. if( WF_EXSTYLE == ulField || WF_STYLE == ulField)
  40. {
  41. ULONG dwBits = 0;
  42. ULONG dwGwl = (WF_EXSTYLE == ulField) ? GWL_EXSTYLE :
  43. (WF_STYLE == ulField) ? GWL_STYLE : 0;
  44. UserAssert(dwGwl);
  45. dwBits = GetWindowLong( hwnd, dwGwl );
  46. if( (dwBits & ulVal) != ulVal )
  47. SetWindowLong(hwnd, dwGwl, dwBits | ulVal );
  48. }
  49. }
  50. //-------------------------------------------------------------------------//
  51. // From usrctl32.h/.cpp
  52. void ClearWindowState(
  53. HWND hwnd,
  54. UINT flags)
  55. {
  56. ULONG ulField;
  57. ULONG ulVal = _ExpandWF( flags, &ulField );
  58. if( WF_EXSTYLE == ulField || WF_STYLE == ulField)
  59. {
  60. ULONG dwBits = 0;
  61. ULONG dwGwl = (WF_EXSTYLE == ulField) ? GWL_EXSTYLE :
  62. (WF_STYLE == ulField) ? GWL_STYLE : 0;
  63. UserAssert(dwGwl);
  64. dwBits = GetWindowLong( hwnd, dwGwl );
  65. if( (dwBits & ulVal) != ulVal )
  66. SetWindowLong(hwnd, dwGwl, dwBits &= ~ulVal );
  67. }
  68. }
  69. //-------------------------------------------------------------------------//
  70. // window bitfield discriminator (in lobyte of internal flags)
  71. #define WF_SEL_STATE 0x00
  72. #define WF_SEL_STATE2 0x04
  73. #define WF_SEL_STYLE_EX 0x08
  74. #define WF_SEL_STYLE 0x0C
  75. #ifdef _WIN64
  76. #undef GWL_WOWWORDS
  77. #endif /* _WIN64 */
  78. #define GWLP_WOWWORDS (-1)
  79. #define GCL_WOWWORDS (-27)
  80. #define GCL_WOWMENUNAME (-29)
  81. #ifdef _WIN64
  82. #undef GCL_WOWWORDS
  83. #endif /* _WIN64 */
  84. #define GCLP_WOWWORDS (-27)
  85. LONG TestWF(HWND hwnd, DWORD flag)
  86. {
  87. LPDWORD pdwWW;
  88. // GWLP_WOWWORDS returns a pointer to the WW struct in the hwnd.
  89. // We're interest in the first four DWORDS: state, state2,
  90. // ExStyle (exposed, although not all bits, by GetWindowExStyle),
  91. // and style (exposed by GetWindowStyle).
  92. //
  93. // The parameter flag, contains information on how to pick the field
  94. // we want and how to build the WS_xxx or WS_EX_xxx we want to
  95. // check for.
  96. //
  97. // See UsrCtl32.h for more details on how this is done.
  98. //
  99. pdwWW = (LPDWORD)GetWindowLongPtr(hwnd, GWLP_WOWWORDS);
  100. if ( pdwWW )
  101. {
  102. INT iField; // the field we want
  103. INT iShift; // how many bytes to shift flag
  104. LONG ulMask; // WS_xxx or WS_EX_xxx flag
  105. iField = ( HIBYTE(flag) & 0xFC ) >> 2;
  106. iShift = HIBYTE(flag) & 0x03;
  107. ulMask = LOBYTE(flag) << (iShift << 3);
  108. UserAssert( 0 <= iField && iField < 4 );
  109. return pdwWW[iField] & ulMask;
  110. };
  111. return 0;
  112. }