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.

198 lines
4.6 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. // MsgDlg.cpp : Defines the initialization routines for the DLL.
  3. //
  4. #include "precomp.h"
  5. #include "MsgDlg.h"
  6. #include "wbemError.h"
  7. #include "resource.h"
  8. #include "commctrl.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. //------------------------------------------------------------
  15. POLARITY int DisplayUserMessage(HWND hWnd,
  16. HINSTANCE inst,
  17. UINT caption,
  18. UINT clientMsg,
  19. ERROR_SRC src,
  20. HRESULT sc,
  21. UINT uType)
  22. {
  23. //EXTASSERT(inst);
  24. //EXTASSERT(caption);
  25. TCHAR tCaption[100] = {0};
  26. TCHAR tClientMsg[256] = {0};
  27. DWORD resError = 0;
  28. if(LoadString(inst, caption, tCaption, 100) == 0)
  29. {
  30. return 0;
  31. }
  32. if(clientMsg == BASED_ON_SRC)
  33. {
  34. HINSTANCE UtilInst = GetModuleHandle(_T("MMFUtil.dll"));
  35. WCHAR resName[16] = {0};
  36. // FMT: "S<src>E<sc>"
  37. wsprintf(resName, L"S%dE%x", src, sc);
  38. if(_wcsicmp(resName,L"S1E8004100e") == 0)
  39. {
  40. LoadString(UtilInst,S1E8004100e,tClientMsg,256);
  41. }
  42. else if(_wcsicmp(resName,L"S1E80080005") == 0)
  43. {
  44. LoadString(UtilInst,S1E80080005,tClientMsg,256);
  45. }
  46. else if(_wcsicmp(resName,L"S4E80041003") == 0)
  47. {
  48. LoadString(UtilInst,S4E80041003,tClientMsg,256);
  49. }
  50. }
  51. else // use the one passed in.
  52. {
  53. LoadString(inst, clientMsg, tClientMsg, 256);
  54. }
  55. return DisplayUserMessage(hWnd, tCaption,
  56. (wcslen(tClientMsg) > 0 ? tClientMsg : NULL),
  57. src, sc, uType);
  58. }
  59. //------------------------------------------------------------
  60. POLARITY int DisplayUserMessage(HWND hWnd,
  61. LPCTSTR lpCaption,
  62. LPCTSTR lpClientMsg,
  63. ERROR_SRC src,
  64. HRESULT sc,
  65. UINT uType)
  66. {
  67. #define MAX_MSG 512
  68. TCHAR errMsg[MAX_MSG] = {0};
  69. UINT sevIcon = 0;
  70. if(ErrorStringEx(sc, errMsg, MAX_MSG,
  71. &sevIcon))
  72. {
  73. // if no icon explicitly selected...
  74. if(!(uType & MB_ICONMASK))
  75. {
  76. // use the recommendation.
  77. uType |= sevIcon;
  78. }
  79. // append the clientmsg if there is one.
  80. if(lpClientMsg)
  81. {
  82. _tcscat(errMsg, _T("\n\n"));
  83. _tcscat(errMsg, lpClientMsg);
  84. }
  85. // do it.
  86. return MessageBox(hWnd, errMsg,
  87. lpCaption, uType);
  88. }
  89. else
  90. {
  91. // failed.
  92. return 0;
  93. }
  94. return 0;
  95. }
  96. //---------------------------------------------------------
  97. typedef struct {
  98. LPCTSTR lpCaption;
  99. LPCTSTR lpClientMsg;
  100. UINT uAnim;
  101. HWND *boxHwnd;
  102. } ANIMCONFIG;
  103. INT_PTR CALLBACK AnimDlgProc(HWND hwndDlg,
  104. UINT uMsg,
  105. WPARAM wParam,
  106. LPARAM lParam)
  107. {
  108. INT_PTR retval = FALSE;
  109. switch(uMsg)
  110. {
  111. case WM_INITDIALOG:
  112. {//BEGIN
  113. //lParam = ANIMCONFIG *
  114. ANIMCONFIG *cfg = (ANIMCONFIG *)lParam;
  115. *(cfg->boxHwnd) = hwndDlg;
  116. // save this pointer for the WM_DESTROY.
  117. SetWindowLongPtr(hwndDlg, DWLP_USER, (LPARAM)cfg->boxHwnd);
  118. HWND hAnim = GetDlgItem(hwndDlg, IDC_ANIMATE);
  119. HWND hMsg = GetDlgItem(hwndDlg, IDC_MSG);
  120. Animate_Open(hAnim, MAKEINTRESOURCE(cfg->uAnim));
  121. SetWindowText(hwndDlg, cfg->lpCaption);
  122. SetWindowText(hMsg, cfg->lpClientMsg);
  123. retval = TRUE;
  124. }//END
  125. break;
  126. case WM_USER + 20: //WM_ASYNC_CIMOM_CONNECTED
  127. // the client has completed 'whatever' and I should
  128. // claim victory and go away now.
  129. EndDialog(hwndDlg, IDOK);
  130. break;
  131. case WM_COMMAND:
  132. // they're only one button.
  133. if(HIWORD(wParam) == BN_CLICKED)
  134. {
  135. // I'm going away now so anybody that has a ptr to my
  136. // hwnd (which I gave out in my WM_INITDIALOG) shouldn't
  137. // use it anymore.
  138. HWND *me = (HWND *)GetWindowLongPtr(hwndDlg, DWLP_USER);
  139. *me = 0;
  140. EndDialog(hwndDlg, IDCANCEL);
  141. }
  142. retval = TRUE; // I processed it.
  143. break;
  144. case WM_DESTROY:
  145. {// BEGIN
  146. // I'm going away now so anybody that has a ptr to my
  147. // hwnd (which I gave out in my WM_INITDIALOG) shouldn't
  148. // use it anymore.
  149. HWND *me = (HWND *)GetWindowLongPtr(hwndDlg, DWLP_USER);
  150. *me = 0;
  151. retval = TRUE; // I processed it.
  152. } //END
  153. break;
  154. default:
  155. retval = FALSE; // I did NOT process this msg.
  156. break;
  157. } //endswitch uMsg
  158. return retval;
  159. }
  160. //---------------------------------------------------------
  161. POLARITY INT_PTR DisplayAVIBox(HWND hWnd,
  162. LPCTSTR lpCaption,
  163. LPCTSTR lpClientMsg,
  164. HWND *boxHwnd)
  165. {
  166. ANIMCONFIG cfg = {lpCaption, lpClientMsg, IDR_AVIWAIT, boxHwnd};
  167. return DialogBoxParam(_Module.GetModuleInstance(),
  168. MAKEINTRESOURCE(IDD_ANIMATE),
  169. hWnd, AnimDlgProc,
  170. (LPARAM)&cfg);
  171. }