Source code of Windows XP (NT5)
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.

79 lines
2.1 KiB

  1. // UsrCtl32.cpp : Defines the entry point for the DLL application.
  2. //
  3. #include "ctlspriv.h"
  4. #pragma hdrstop
  5. #include "UsrCtl32.h"
  6. #define AWS_MASK (BS_TYPEMASK | BS_RIGHT | BS_RIGHTBUTTON | \
  7. WS_HSCROLL | WS_VSCROLL | SS_TYPEMASK)
  8. VOID AlterWindowStyle(HWND hwnd, DWORD mask, DWORD flags)
  9. {
  10. ULONG ulStyle;
  11. if (mask & ~AWS_MASK)
  12. {
  13. TraceMsg(TF_STANDARD, "AlterWindowStyle: bad mask %x", mask);
  14. return;
  15. }
  16. ulStyle = GetWindowStyle(hwnd);
  17. mask &= AWS_MASK;
  18. ulStyle = (ulStyle & (~mask)) | (flags & mask);
  19. SetWindowLong(hwnd, GWL_STYLE, ulStyle);
  20. }
  21. LONG TestWF(HWND hwnd, DWORD flag)
  22. {
  23. LPDWORD pdwWW;
  24. // GWLP_WOWWORDS returns a pointer to the WW struct in the hwnd.
  25. // We're interest in the first four DWORDS: state, state2,
  26. // ExStyle (exposed, although not all bits, by GetWindowExStyle),
  27. // and style (exposed by GetWindowStyle).
  28. //
  29. // The parameter flag, contains information on how to pick the field
  30. // we want and how to build the WS_xxx or WS_EX_xxx we want to
  31. // check for.
  32. //
  33. // See UsrCtl32.h for more details on how this is done.
  34. //
  35. pdwWW = (LPDWORD)GetWindowLongPtr(hwnd, GWLP_WOWWORDS);
  36. if ( pdwWW )
  37. {
  38. INT iField; // the field we want
  39. INT iShift; // how many bytes to shift flag
  40. LONG ulMask; // WS_xxx or WS_EX_xxx flag
  41. iField = ( HIBYTE(flag) & 0xFC ) >> 2;
  42. iShift = HIBYTE(flag) & 0x03;
  43. ulMask = LOBYTE(flag) << (iShift << 3);
  44. ASSERT( 0 <= iField && iField < 4 );
  45. return pdwWW[iField] & ulMask;
  46. };
  47. return 0;
  48. }
  49. UINT GetACPCharSet()
  50. {
  51. static UINT charset = (UINT)~0;
  52. CHARSETINFO csInfo;
  53. if (charset != (UINT)~0) {
  54. return charset;
  55. }
  56. // Sundown: In the TCI_SRCCODEPAGE case, the GetACP() return value is zero-extended.
  57. if (!TranslateCharsetInfo((DWORD*)UIntToPtr( GetACP() ), &csInfo, TCI_SRCCODEPAGE)) {
  58. return DEFAULT_CHARSET;
  59. }
  60. charset = csInfo.ciCharset;
  61. UserAssert(charset != (UINT)~0);
  62. return csInfo.ciCharset;
  63. }