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.

191 lines
5.2 KiB

  1. /*
  2. * prsht.c - Hacky property sheet code
  3. */
  4. #include "tweakui.h"
  5. /***************************************************************************
  6. *
  7. * @doc INTERNAL
  8. *
  9. * @func Prsht_SkipDlgString |
  10. *
  11. * Skip a thing-that-might-be-a-string in a dialog template.
  12. *
  13. * It could be 0xFFFF, meaning that the next word is all.
  14. * Or it's a unicode string.
  15. *
  16. * Note that everything stays word-aligned, so we don't need
  17. * to worry about UNALIGNEDness.
  18. *
  19. ***************************************************************************/
  20. LPWORD PASCAL
  21. Prsht_SkipDlgString(LPWORD pw)
  22. {
  23. if (*pw == 0xFFFF) {
  24. pw += 2;
  25. } else {
  26. while (*pw++) { /* Skip over the UNICODE string */
  27. }
  28. }
  29. return pw;
  30. }
  31. /***************************************************************************
  32. *
  33. * @doc INTERNAL
  34. *
  35. * @func Prsht_PropertySheetCallback |
  36. *
  37. * We also want to force single-line tabs. We must do it
  38. * here so that the margins are set up correctly. (If we
  39. * wait until WM_INITDIALOG, then when we change to
  40. * single-line tabs, we get messed-up margins.)
  41. *
  42. * We need single-line tabs because multi-line tabs cause
  43. * our property sheet to be too large to fit on an 640x480
  44. * screen.
  45. *
  46. * Do this only if we are running on a 640 x 480 display.
  47. *
  48. ***************************************************************************/
  49. typedef struct DLGFINISH {
  50. WORD cdit;
  51. short x;
  52. short y;
  53. short cx;
  54. short cy;
  55. } DLGFINISH, *PDLGFINISH;
  56. typedef struct DLGTEMPLATEEX {
  57. WORD wDlgVer;
  58. WORD wSignature;
  59. DWORD dwHelpID;
  60. DWORD dwExStyle;
  61. DWORD style;
  62. WORD cDlgItems;
  63. short x;
  64. short y;
  65. short cx;
  66. short cy;
  67. } DLGTEMPLATEEX, *PDLGTEMPLATEEX;
  68. typedef struct DLGITEMTEMPLATEEX {
  69. DWORD dwHelpID;
  70. DWORD dwExStyle;
  71. DWORD style;
  72. short x;
  73. short y;
  74. short cx;
  75. short cy;
  76. DWORD dwID;
  77. } DLGITEMTEMPLATEEX, *PDLGITEMTEMPLATEEX;
  78. typedef struct DLGITEMCOORDS {
  79. short x;
  80. short y;
  81. short cx;
  82. short cy;
  83. } DLGITEMCOORDS, *PDLGITEMCOORDS;
  84. WCHAR c_wszTabClass[] = WC_TABCONTROLW;
  85. int CALLBACK
  86. Prsht_PropertySheetCallback(HWND hwnd, UINT pscb, LPARAM lp)
  87. {
  88. LPDLGTEMPLATE pdt;
  89. UINT idit;
  90. LPWORD pw;
  91. BOOL fEx;
  92. DWORD dwStyle;
  93. PDLGFINISH pdf;
  94. hwnd;
  95. switch (pscb) {
  96. case PSCB_PRECREATE:
  97. if (GetSystemMetrics(SM_CYSCREEN) <= 480) {
  98. pdt = (LPDLGTEMPLATE)lp;
  99. if (pdt->style == 0xFFFF0001) {
  100. PDLGTEMPLATEEX pdtex= (PDLGTEMPLATEEX)lp;
  101. fEx = 1;
  102. dwStyle = pdtex->style;
  103. pdf = (PDLGFINISH)&pdtex->cDlgItems;
  104. pw = (LPWORD)(pdtex+1);
  105. } else {
  106. fEx = 0;
  107. dwStyle = pdt->style;
  108. pdf = (PDLGFINISH)&pdt->cdit;
  109. pw = (LPWORD)(pdt+1);
  110. }
  111. /*
  112. * After the DLGTEMPLATE(EX) come three strings:
  113. * the menu, the class, and the title.
  114. */
  115. pw = Prsht_SkipDlgString(pw); /* Menu */
  116. pw = Prsht_SkipDlgString(pw); /* Class */
  117. pw = Prsht_SkipDlgString(pw); /* Title */
  118. /*
  119. * Then the optional font.
  120. */
  121. if (dwStyle & DS_SETFONT) {
  122. pw++; /* Font size */
  123. if (fEx) {
  124. pw++; /* Font weight */
  125. pw++; /* Font style and charset */
  126. }
  127. pw = Prsht_SkipDlgString(pw); /* Font name */
  128. }
  129. /*
  130. * Now walk the item list looking for the tab control.
  131. */
  132. for (idit = 0; idit < pdf->cdit; idit++) {
  133. /* Round up to next dword; all aligned and happy again */
  134. LPDLGITEMTEMPLATE pdit = (LPDLGITEMTEMPLATE)(((DWORD_PTR)pw + 3) & ~3);
  135. PDLGITEMTEMPLATEEX pditex = (PDLGITEMTEMPLATEEX)pdit;
  136. PDLGITEMCOORDS pdic;
  137. if (fEx) {
  138. pw = (LPWORD)(pditex+1);
  139. } else {
  140. pw = (LPWORD)(pdit+1);
  141. }
  142. /* Immediately after the pdit is the class name */
  143. if (memcmp(pw, c_wszTabClass, cbX(c_wszTabClass)) == 0) {
  144. LPDWORD pdwStyle;
  145. /* Found it! Nuke the multiline style */
  146. if (fEx) {
  147. pdwStyle = &pditex->style;
  148. pdic = (PDLGITEMCOORDS)&pditex->x;
  149. } else {
  150. pdwStyle = &pdit->style;
  151. pdic = (PDLGITEMCOORDS)&pdit->x;
  152. }
  153. *pdwStyle &= ~TCS_MULTILINE;
  154. break;
  155. }
  156. /* Oh well, on to the next one */
  157. pw = Prsht_SkipDlgString(pw); /* Class */
  158. pw = Prsht_SkipDlgString(pw); /* Title */
  159. pw = (LPWORD)((LPBYTE)pw + 2 + *pw); /* Goo */
  160. }
  161. }
  162. break;
  163. }
  164. return 0;
  165. }