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.

276 lines
9.9 KiB

  1. //
  2. // aboutdlg.cpp: about dialog box
  3. //
  4. #include "stdafx.h"
  5. #define TRC_GROUP TRC_GROUP_UI
  6. #define TRC_FILE "aboutdlg"
  7. #include <atrcapi.h>
  8. #include "aboutdlg.h"
  9. #include "sh.h"
  10. #include "aver.h"
  11. CAboutDlg* CAboutDlg::_pAboutDlgInstance = NULL;
  12. CAboutDlg::CAboutDlg( HWND hwndOwner, HINSTANCE hInst, DCINT cipherStrength, PDCTCHAR szControlVer) :
  13. CDlgBase( hwndOwner, hInst, UI_IDD_ABOUT)
  14. {
  15. DC_BEGIN_FN("CAboutDlg");
  16. TRC_ASSERT((NULL == CAboutDlg::_pAboutDlgInstance),
  17. (TB,_T("Clobbering existing dlg instance pointer\n")));
  18. _cipherStrength = cipherStrength;
  19. DC_TSTRNCPY(_szControlVer, szControlVer, sizeof(_szControlVer)/sizeof(DCTCHAR));
  20. CAboutDlg::_pAboutDlgInstance = this;
  21. DC_END_FN();
  22. }
  23. CAboutDlg::~CAboutDlg()
  24. {
  25. CAboutDlg::_pAboutDlgInstance = NULL;
  26. }
  27. DCINT CAboutDlg::DoModal()
  28. {
  29. DCINT retVal = 0;
  30. DC_BEGIN_FN("DoModal");
  31. retVal = DialogBox(_hInstance, MAKEINTRESOURCE(_dlgResId),
  32. _hwndOwner, StaticDialogBoxProc);
  33. TRC_ASSERT((retVal != 0 && retVal != -1), (TB, _T("DialogBoxParam failed\n")));
  34. DC_END_FN();
  35. return retVal;
  36. }
  37. INT_PTR CALLBACK CAboutDlg::StaticDialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  38. {
  39. //
  40. // Delegate to appropriate instance (only works for single instance dialogs)
  41. //
  42. DC_BEGIN_FN("StaticDialogBoxProc");
  43. DCINT retVal = 0;
  44. TRC_ASSERT(_pAboutDlgInstance, (TB, _T("About dialog has NULL static instance ptr\n")));
  45. if(_pAboutDlgInstance)
  46. {
  47. retVal = _pAboutDlgInstance->DialogBoxProc( hwndDlg, uMsg, wParam, lParam);
  48. }
  49. DC_END_FN();
  50. return retVal;
  51. }
  52. /****************************************************************************/
  53. /* Name: DialogBoxProc */
  54. /* */
  55. /* Purpose: Handles About Box dialog */
  56. /* */
  57. /* Returns: TRUE if message dealt with */
  58. /* FALSE otherwise */
  59. /* */
  60. /* Params: See window documentation */
  61. /* */
  62. /****************************************************************************/
  63. INT_PTR CALLBACK CAboutDlg::DialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  64. {
  65. USES_CONVERSION;
  66. DCTCHAR buildNumberStr[SH_BUILDNUMBER_STRING_MAX_LENGTH];
  67. DCTCHAR fullBuildNumberStr[SH_BUILDNUMBER_STRING_MAX_LENGTH +
  68. SH_INTEGER_STRING_MAX_LENGTH];
  69. DCTCHAR versionNumberStr[SH_VERSION_STRING_MAX_LENGTH];
  70. DCTCHAR fullVersionNumberStr[SH_VERSION_STRING_MAX_LENGTH +
  71. SH_INTEGER_STRING_MAX_LENGTH];
  72. DCTCHAR cipherStrengthStr[SH_DISPLAY_STRING_MAX_LENGTH];
  73. INT_PTR rc = FALSE;
  74. DCUINT intRC ;
  75. DCTCHAR VersionBuildstr[SH_BUILDNUMBER_STRING_MAX_LENGTH + SH_VERSION_STRING_MAX_LENGTH +
  76. 2 * SH_INTEGER_STRING_MAX_LENGTH];
  77. DC_BEGIN_FN("DialogBoxProc");
  78. TRC_DBG((TB, _T("AboutBox dialog")));
  79. switch (uMsg)
  80. {
  81. case WM_INITDIALOG:
  82. {
  83. _hwndDlg = hwndDlg;
  84. /****************************************************************/
  85. /* Center the dialog */
  86. /****************************************************************/
  87. //Center the about dialog on the screen
  88. CenterWindow(NULL);
  89. SetDialogAppIcon(hwndDlg);
  90. //
  91. // First load the shell version number
  92. //
  93. intRC = LoadString( _hInstance,
  94. UI_IDS_SHELL_VERSION,
  95. versionNumberStr,
  96. SH_VERSION_STRING_MAX_LENGTH );
  97. #ifndef OS_WINCE
  98. LPTSTR szShellVersion = A2T(VER_PRODUCTVERSION_STRING);
  99. #else
  100. LPTSTR szShellVersion = _T("SAMPLE v1.0");
  101. #endif
  102. if (0 == intRC)
  103. {
  104. //Problem with resources
  105. TRC_SYSTEM_ERROR("LoadString");
  106. TRC_ERR((TB, _T("Failed to load string ID:%u"), UI_IDS_SHELL_VERSION));
  107. }
  108. else
  109. {
  110. //Get the version number
  111. if(szShellVersion)
  112. {
  113. DC_TSPRINTF(fullVersionNumberStr, versionNumberStr,
  114. szShellVersion);
  115. }
  116. else
  117. {
  118. DC_TSTRCPY(fullVersionNumberStr, _T(""));
  119. }
  120. TRC_DBG((TB, _T("versionNumberStr = %s"), versionNumberStr));
  121. }
  122. intRC = LoadString( _hInstance,
  123. UI_IDS_BUILDNUMBER,
  124. buildNumberStr,
  125. SH_BUILDNUMBER_STRING_MAX_LENGTH );
  126. if (0 == intRC)
  127. {
  128. //Problem with resources
  129. TRC_SYSTEM_ERROR("LoadString");
  130. TRC_ERR((TB, _T("Failed to load string ID:%u"), UI_IDS_BUILDNUMBER));
  131. }
  132. else
  133. {
  134. /************************************************************/
  135. /* Get the build number */
  136. /************************************************************/
  137. DC_TSPRINTF(fullBuildNumberStr, buildNumberStr, DCVER_BUILD_NUMBER);
  138. TRC_DBG((TB, _T("buildNumberStr = %s"), buildNumberStr));
  139. /************************************************************/
  140. /* concatenate the version number and build number to one */
  141. /* string */
  142. /************************************************************/
  143. DC_TSTRCPY(VersionBuildstr, fullVersionNumberStr);
  144. DC_TSTRCAT(VersionBuildstr, fullBuildNumberStr);
  145. /************************************************************/
  146. /* Set the textual description. */
  147. /************************************************************/
  148. if(hwndDlg)
  149. {
  150. SetDlgItemText(hwndDlg,
  151. UI_ID_VERSIONBUILD_STRING,
  152. VersionBuildstr);
  153. }
  154. }
  155. //
  156. // Now the control version
  157. //
  158. intRC = LoadString( _hInstance,
  159. UI_IDS_CONTROL_VERSION,
  160. versionNumberStr,
  161. SH_VERSION_STRING_MAX_LENGTH );
  162. if (0 == intRC)
  163. {
  164. /***********************************************************/
  165. /* Some problem with the resources. */
  166. /***********************************************************/
  167. TRC_SYSTEM_ERROR("LoadString");
  168. TRC_ERR((TB, _T("Failed to load string ID:%u"), UI_IDS_CONTROL_VERSION));
  169. }
  170. else
  171. {
  172. /************************************************************/
  173. /* Get the version number */
  174. /************************************************************/
  175. DC_TSPRINTF(fullVersionNumberStr, versionNumberStr, _szControlVer);
  176. TRC_DBG((TB, _T("versionNumberStr = %s"), versionNumberStr));
  177. }
  178. if(hwndDlg)
  179. {
  180. SetDlgItemText(hwndDlg,
  181. UI_ID_CONTROL_VERSION,
  182. fullVersionNumberStr);
  183. }
  184. //
  185. // Now set the cipher strength
  186. //
  187. intRC = LoadString( _hInstance,
  188. UI_IDS_CIPHER_STRENGTH,
  189. cipherStrengthStr,
  190. SH_DISPLAY_STRING_MAX_LENGTH );
  191. DCTCHAR fullCipherStr[SH_DISPLAY_STRING_MAX_LENGTH];
  192. if (0 == intRC)
  193. {
  194. /***********************************************************/
  195. /* Some problem with the resources. */
  196. /***********************************************************/
  197. TRC_SYSTEM_ERROR("LoadString");
  198. TRC_ERR((TB, _T("Failed to load string ID:%u"), UI_IDS_CIPHER_STRENGTH));
  199. }
  200. else
  201. {
  202. /************************************************************/
  203. /* Set the cipher strength number */
  204. /************************************************************/
  205. DC_TSPRINTF(fullCipherStr, cipherStrengthStr, _cipherStrength);
  206. TRC_DBG((TB, _T("cipher string = %s"), fullCipherStr));
  207. }
  208. if(hwndDlg)
  209. {
  210. SetDlgItemText(hwndDlg,
  211. UI_ID_CIPHER_STRENGTH,
  212. fullCipherStr);
  213. }
  214. rc = TRUE;
  215. }
  216. break;
  217. default:
  218. {
  219. rc = CDlgBase::DialogBoxProc(hwndDlg,
  220. uMsg,
  221. wParam,
  222. lParam);
  223. }
  224. break;
  225. }
  226. DC_END_FN();
  227. return(rc);
  228. } /* UIAboutDialogBox */