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.

194 lines
4.3 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. expldlg.c
  5. Abstract:
  6. explain dialog box functions
  7. Revision History
  8. Bob Watson (bobw) mar-97 Created
  9. --*/
  10. #include <windows.h>
  11. #include <tchar.h>
  12. #include <pdh.h>
  13. #include "pdhidef.h"
  14. #include "pdhdlgs.h"
  15. #include "expldlg.h"
  16. #include "pdhui.h"
  17. //
  18. // Constants used in this module
  19. //
  20. WCHAR PdhiszTitleString[MAX_PATH+1];
  21. STATIC_BOOL
  22. ExplainTextDlg_WM_INITDIALOG (
  23. IN HWND hDlg,
  24. IN WPARAM wParam,
  25. IN LPARAM lParam
  26. )
  27. {
  28. RECT ParentRect;
  29. RECT rectDeskTop;
  30. RECT rectDlg;
  31. BOOL bResult = FALSE;
  32. UNREFERENCED_PARAMETER (lParam);
  33. UNREFERENCED_PARAMETER (wParam);
  34. bResult = GetWindowRect(GetDesktopWindow(), & rectDeskTop)
  35. && GetWindowRect(hDlg, & rectDlg);
  36. GetWindowTextW (hDlg, PdhiszTitleString, MAX_PATH);
  37. if (GetWindowRect (GetParent(hDlg), & ParentRect)) {
  38. int x = ParentRect.left;
  39. int y = ParentRect.bottom + 1;
  40. if (bResult) {
  41. if ( y + (rectDlg.bottom - rectDlg.top)
  42. > (rectDeskTop.bottom - rectDeskTop.top)) {
  43. // Explain dialog will be off-screen at the bottom, so
  44. // reposition it to top of AddCounter dialog
  45. //
  46. y = ParentRect.top - (rectDlg.bottom - rectDlg.top) - 1;
  47. if (y < 0) {
  48. // Explain dialog will be off-screen at the top, use
  49. // original calculation
  50. //
  51. y = ParentRect.bottom + 1;
  52. }
  53. }
  54. }
  55. SetWindowPos (hDlg, HWND_TOP, x, y, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  56. } else {
  57. ShowWindow (hDlg, SW_SHOW);
  58. }
  59. return FALSE;
  60. }
  61. STATIC_BOOL
  62. ExplainTextDlg_WM_COMMAND (
  63. IN HWND hDlg,
  64. IN WPARAM wParam,
  65. IN LPARAM lParam
  66. )
  67. {
  68. WORD wNotifyMsg;
  69. UNREFERENCED_PARAMETER (lParam);
  70. UNREFERENCED_PARAMETER (hDlg);
  71. wNotifyMsg = HIWORD(wParam);
  72. switch (LOWORD(wParam)) { // select on the control ID
  73. default:
  74. return FALSE;
  75. }
  76. }
  77. STATIC_BOOL
  78. ExplainTextDlg_WM_SYSCOMMAND (
  79. IN HWND hDlg,
  80. IN WPARAM wParam,
  81. IN LPARAM lParam
  82. )
  83. {
  84. UNREFERENCED_PARAMETER (lParam);
  85. switch (wParam) {
  86. case SC_CLOSE:
  87. PostMessageW (GetParent(hDlg), EDM_EXPLAIN_DLG_CLOSING, 0, 0);
  88. EndDialog (hDlg, IDOK);
  89. return TRUE;
  90. default:
  91. return FALSE;
  92. }
  93. }
  94. STATIC_BOOL
  95. ExplainTextDlg_WM_CLOSE (
  96. IN HWND hDlg,
  97. IN WPARAM wParam,
  98. IN LPARAM lParam
  99. )
  100. {
  101. UNREFERENCED_PARAMETER (lParam);
  102. UNREFERENCED_PARAMETER (wParam);
  103. UNREFERENCED_PARAMETER (hDlg);
  104. return TRUE;
  105. }
  106. STATIC_BOOL
  107. ExplainTextDlg_WM_DESTROY (
  108. IN HWND hDlg,
  109. IN WPARAM wParam,
  110. IN LPARAM lParam
  111. )
  112. {
  113. UNREFERENCED_PARAMETER (lParam);
  114. UNREFERENCED_PARAMETER (wParam);
  115. UNREFERENCED_PARAMETER (hDlg);
  116. return TRUE;
  117. }
  118. BOOL
  119. ExplainTextDlgProc (
  120. IN HWND hDlg,
  121. IN UINT message,
  122. IN WPARAM wParam,
  123. IN LPARAM lParam
  124. )
  125. {
  126. WCHAR szCaption[MAX_PATH*2];
  127. switch (message) {
  128. case WM_INITDIALOG:
  129. return ExplainTextDlg_WM_INITDIALOG (hDlg, wParam, lParam);
  130. case WM_COMMAND:
  131. return ExplainTextDlg_WM_COMMAND (hDlg, wParam, lParam);
  132. case WM_SYSCOMMAND:
  133. return ExplainTextDlg_WM_SYSCOMMAND (hDlg, wParam, lParam);
  134. case WM_CLOSE:
  135. return ExplainTextDlg_WM_CLOSE (hDlg, wParam, lParam);
  136. case WM_DESTROY:
  137. return ExplainTextDlg_WM_DESTROY (hDlg, wParam, lParam);
  138. case EDM_UPDATE_EXPLAIN_TEXT:
  139. if (lParam != 0) {
  140. SetWindowTextW (GetDlgItem(hDlg, IDC_EXPLAIN_TEXT), (LPCWSTR)lParam);
  141. } else {
  142. SetWindowTextW (GetDlgItem(hDlg, IDC_EXPLAIN_TEXT), cszEmptyString);
  143. }
  144. return TRUE;
  145. case EDM_UPDATE_TITLE_TEXT:
  146. lstrcpyW (szCaption, PdhiszTitleString);
  147. if (lParam != 0) {
  148. if (*(LPWSTR)lParam != 0) {
  149. lstrcatW (szCaption, cszSpacer);
  150. lstrcatW (szCaption, (LPCWSTR)lParam);
  151. }
  152. }
  153. SetWindowTextW (hDlg, (LPCWSTR)szCaption);
  154. return TRUE;
  155. default:
  156. return FALSE;
  157. }
  158. }