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.

197 lines
6.2 KiB

  1. //
  2. // cachewrndlg.cpp: cachewrn dialog box
  3. // bitmap cache error dialog box
  4. //
  5. #include "stdafx.h"
  6. #define TRC_GROUP TRC_GROUP_UI
  7. #define TRC_FILE "cachewrndlg"
  8. #include <atrcapi.h>
  9. #include "cachewrndlg.h"
  10. #include "sh.h"
  11. CCacheWrnDlg* CCacheWrnDlg::_pCacheWrnDlgInstance = NULL;
  12. CCacheWrnDlg::CCacheWrnDlg( HWND hwndOwner, HINSTANCE hInst) :
  13. CDlgBase( hwndOwner, hInst, UI_IDD_BITMAPCACHEERROR)
  14. {
  15. DC_BEGIN_FN("CCacheWrnDlg");
  16. TRC_ASSERT((NULL == CCacheWrnDlg::_pCacheWrnDlgInstance),
  17. (TB,_T("Clobbering existing dlg instance pointer\n")));
  18. CCacheWrnDlg::_pCacheWrnDlgInstance = this;
  19. DC_END_FN();
  20. }
  21. CCacheWrnDlg::~CCacheWrnDlg()
  22. {
  23. CCacheWrnDlg::_pCacheWrnDlgInstance = NULL;
  24. }
  25. DCINT CCacheWrnDlg::DoModal()
  26. {
  27. DCINT retVal = 0;
  28. DC_BEGIN_FN("DoModal");
  29. retVal = DialogBox(_hInstance, MAKEINTRESOURCE(_dlgResId),
  30. _hwndOwner, StaticDialogBoxProc);
  31. TRC_ASSERT((retVal != 0 && retVal != -1), (TB, _T("DialogBoxParam failed\n")));
  32. DC_END_FN();
  33. return retVal;
  34. }
  35. INT_PTR CALLBACK CCacheWrnDlg::StaticDialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  36. {
  37. //
  38. // Delegate to appropriate instance (only works for single instance dialogs)
  39. //
  40. DC_BEGIN_FN("StaticDialogBoxProc");
  41. DCINT retVal = 0;
  42. TRC_ASSERT(_pCacheWrnDlgInstance, (TB, _T("CacheWrn dialog has NULL static instance ptr\n")));
  43. if(_pCacheWrnDlgInstance)
  44. {
  45. retVal = _pCacheWrnDlgInstance->DialogBoxProc( hwndDlg, uMsg, wParam, lParam);
  46. }
  47. DC_END_FN();
  48. return retVal;
  49. }
  50. /****************************************************************************/
  51. /* Name: DialogBoxProc */
  52. /* */
  53. /* Purpose: Handles CacheWrn Box dialog (Random Failure dialog) */
  54. /* */
  55. /* Returns: TRUE if message dealt with */
  56. /* FALSE otherwise */
  57. /* */
  58. /* Params: See window documentation */
  59. /* */
  60. /****************************************************************************/
  61. INT_PTR CALLBACK CCacheWrnDlg::DialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  62. {
  63. INT_PTR rc = FALSE;
  64. DC_BEGIN_FN("UIBitmapCacheErrorDialogProc");
  65. #if ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  66. DC_IGNORE_PARAMETER(lParam);
  67. /************************************************************************/
  68. /* Handle dialog messages */
  69. /************************************************************************/
  70. switch(uMsg)
  71. {
  72. case WM_INITDIALOG:
  73. {
  74. _hwndDlg = hwndDlg;
  75. HWND hStatic = NULL;
  76. SetDialogAppIcon(hwndDlg);
  77. #ifndef OS_WINCE
  78. // load warning icon to _hWarningIcon
  79. _hWarningIcon = LoadIcon(NULL, IDI_EXCLAMATION);
  80. // Get the window position for the warning icon
  81. if (hwndDlg != NULL) {
  82. hStatic = GetDlgItem(hwndDlg, UI_IDC_WARNING_ICON_HOLDER);
  83. if (hStatic != NULL) {
  84. GetWindowRect(hStatic, &(_warningIconRect));
  85. MapWindowPoints(NULL, hwndDlg, (LPPOINT)&(_warningIconRect), 2);
  86. DestroyWindow(hStatic);
  87. }
  88. }
  89. #endif
  90. rc = TRUE;
  91. }
  92. break;
  93. case WM_PAINT:
  94. {
  95. PAINTSTRUCT ps;
  96. HDC hDC = NULL;
  97. if (hwndDlg != NULL) {
  98. hDC = BeginPaint(hwndDlg, &ps);
  99. // draw the warning icon for our dialog
  100. if (hDC != NULL && _hWarningIcon != NULL) {
  101. DrawIcon(hDC, _warningIconRect.left, _warningIconRect.top,
  102. _hWarningIcon);
  103. }
  104. EndPaint(hwndDlg, &ps);
  105. }
  106. rc = TRUE;
  107. }
  108. break;
  109. case WM_COMMAND:
  110. {
  111. switch(DC_GET_WM_COMMAND_ID(wParam))
  112. {
  113. case IDOK:
  114. {
  115. /********************************************************/
  116. /* Closes the dialog */
  117. /********************************************************/
  118. TRC_NRM((TB, _T("Close dialog")));
  119. if(hwndDlg != NULL)
  120. {
  121. EndDialog(hwndDlg, IDOK);
  122. }
  123. rc = TRUE;
  124. }
  125. break;
  126. default:
  127. {
  128. /********************************************************/
  129. /* Do Nothing */
  130. /********************************************************/
  131. }
  132. break;
  133. }
  134. }
  135. break;
  136. case WM_CLOSE:
  137. {
  138. /****************************************************************/
  139. /* Closes the dialog */
  140. /****************************************************************/
  141. TRC_NRM((TB, _T("Close dialog")));
  142. if(IsWindow(hwndDlg))
  143. {
  144. EndDialog(hwndDlg, IDCANCEL);
  145. }
  146. rc = TRUE;
  147. }
  148. break;
  149. default:
  150. {
  151. /****************************************************************/
  152. /* Do Nothing */
  153. /****************************************************************/
  154. }
  155. }
  156. #endif // ((!defined(OS_WINCE)) || (defined(ENABLE_BMP_CACHING_FOR_WINCE)))
  157. DC_END_FN();
  158. return(rc);
  159. }