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.

453 lines
11 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. CONFSETT.C
  5. Abstract:
  6. Setting Confirmation screen
  7. Author:
  8. Bob Watson (a-robw)
  9. Revision History:
  10. 17 Feb 94 Written
  11. --*/
  12. //
  13. // Windows Include Files
  14. //
  15. #include <windows.h>
  16. #include <stdio.h>
  17. #include <malloc.h>
  18. #include <tchar.h> // unicode macros
  19. //
  20. // app include files
  21. //
  22. #include "otnboot.h"
  23. #include "otnbtdlg.h"
  24. static
  25. VOID
  26. SetConfirmDiskString (
  27. IN HWND hwndDlg
  28. )
  29. /*++
  30. Routine Description:
  31. Formats and outputs information for display in confirmation dialog box
  32. Arguments:
  33. IN HWND hwndDlg
  34. handle to dialog box that will display the information.
  35. Return Value:
  36. None
  37. --*/
  38. {
  39. LPTSTR szTextString;
  40. szTextString = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE);
  41. if (szTextString != NULL) {
  42. #ifdef JAPAN
  43. // fixed kkntbug #12382
  44. // NCAdmin:"[] Make Japanese startup disks" is not functioning.
  45. if (bJpnDisk)
  46. _stprintf (szTextString,
  47. GetStringResource (FMT_LOAD_NET_CLIENT1),
  48. GetStringResource (
  49. (pAppInfo->mtBootDriveType == F3_1Pt44_512) ?
  50. CSZ_35_HD : CSZ_525_HD),
  51. pAppInfo->szBootFilesPath);
  52. else
  53. #endif
  54. _stprintf (szTextString,
  55. GetStringResource (FMT_LOAD_NET_CLIENT),
  56. GetStringResource (
  57. (pAppInfo->mtBootDriveType == F3_1Pt44_512) ?
  58. CSZ_35_HD : CSZ_525_HD),
  59. pAppInfo->szBootFilesPath);
  60. SetDlgItemText (hwndDlg, NCDU_CONFIRM_DISK_FORMAT, szTextString);
  61. FREE_IF_ALLOC (szTextString);
  62. }
  63. }
  64. static
  65. VOID
  66. SetConfirmTargetString (
  67. IN HWND hwndDlg
  68. )
  69. /*++
  70. Routine Description:
  71. Formats and outputs information for display in confirmation dialog box
  72. Arguments:
  73. IN HWND hwndDlg
  74. handle to dialog box that will display the information.
  75. Return Value:
  76. None
  77. --*/
  78. {
  79. LPTSTR szTextString;
  80. LPTSTR szTempString;
  81. szTextString = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE);
  82. szTempString = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE);
  83. if ((szTextString != NULL) && (szTempString != NULL)) {
  84. _stprintf (szTextString,
  85. GetStringResource (FMT_CONFIRM_TARGET),
  86. pAppInfo->piFloppyProtocol.szName,
  87. pAppInfo->niNetCard.szName);
  88. if (_tcsnicmp(pAppInfo->piFloppyProtocol.szName, cszTCP, lstrlen(cszTCP)) == 0) {
  89. if (pAppInfo->bUseDhcp) {
  90. lstrcat (szTextString, GetStringResource(FMT_USING_DHCP));
  91. } else {
  92. // display TCP/IP information.
  93. _stprintf (szTempString,
  94. GetStringResource (FMT_CONFIRM_FLOPPY_IP),
  95. pAppInfo->tiTcpIpInfo.IpAddr[0],
  96. pAppInfo->tiTcpIpInfo.IpAddr[1],
  97. pAppInfo->tiTcpIpInfo.IpAddr[2],
  98. pAppInfo->tiTcpIpInfo.IpAddr[3],
  99. pAppInfo->tiTcpIpInfo.SubNetMask[0],
  100. pAppInfo->tiTcpIpInfo.SubNetMask[1],
  101. pAppInfo->tiTcpIpInfo.SubNetMask[2],
  102. pAppInfo->tiTcpIpInfo.SubNetMask[3],
  103. pAppInfo->tiTcpIpInfo.DefaultGateway[0],
  104. pAppInfo->tiTcpIpInfo.DefaultGateway[1],
  105. pAppInfo->tiTcpIpInfo.DefaultGateway[2],
  106. pAppInfo->tiTcpIpInfo.DefaultGateway[3]);
  107. lstrcat (szTextString, szTempString);
  108. }
  109. }
  110. _stprintf (szTempString,
  111. GetStringResource (FMT_INSTALL_TARGET_CLIENT),
  112. pAppInfo->piTargetProtocol.szName);
  113. lstrcat (szTextString, szTempString);
  114. SetDlgItemText (hwndDlg, NCDU_CONFIRM_TARGET_NET, szTextString);
  115. }
  116. FREE_IF_ALLOC (szTextString);
  117. FREE_IF_ALLOC (szTempString);
  118. }
  119. static
  120. VOID
  121. SetConfirmProtocolString (
  122. IN HWND hwndDlg
  123. )
  124. /*++
  125. Routine Description:
  126. Formats and outputs information for display in confirmation dialog box
  127. Arguments:
  128. IN HWND hwndDlg
  129. handle to dialog box that will display the information.
  130. Return Value:
  131. None
  132. --*/
  133. {
  134. LPTSTR szTextString;
  135. szTextString = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE);
  136. if (szTextString != NULL) {
  137. if (pAppInfo->szUsername[0] != 0) {
  138. _stprintf (szTextString,
  139. GetStringResource (FMT_LOGON_USERNAME),
  140. pAppInfo->szUsername,
  141. pAppInfo->szDomain);
  142. } else {
  143. _stprintf (szTextString,
  144. GetStringResource (FMT_PROMPT_USERNAME),
  145. pAppInfo->szDomain);
  146. }
  147. SetDlgItemText (hwndDlg, NCDU_CONFIRM_PROTOCOL, szTextString);
  148. FREE_IF_ALLOC (szTextString);
  149. }
  150. }
  151. static
  152. BOOL
  153. ConfirmSettingsDlg_WM_INITDIALOG (
  154. IN HWND hwndDlg,
  155. IN WPARAM wParam,
  156. IN LPARAM lParam
  157. )
  158. /*++
  159. Routine Description:
  160. Dialog Box initialization routine:
  161. calls routines that format the currently selected options
  162. for display in the static text fields of the dialog box
  163. Arguments:
  164. IN HWND hwndDlg
  165. Handle to dialog box window
  166. IN WPARAM wParam
  167. Not Used
  168. IN LPARAM lParam
  169. Not Used
  170. Return Value:
  171. FALSE because focus is set in this routin to the OK button
  172. --*/
  173. {
  174. // prepare menu and locate window
  175. RemoveMaximizeFromSysMenu (hwndDlg);
  176. PositionWindow (hwndDlg);
  177. //build display strings
  178. SetConfirmDiskString(hwndDlg);
  179. SetConfirmTargetString(hwndDlg);
  180. SetConfirmProtocolString(hwndDlg);
  181. // clear old Dialog and register current
  182. PostMessage (GetParent(hwndDlg), NCDU_CLEAR_DLG, (WPARAM)hwndDlg, IDOK);
  183. PostMessage (GetParent(hwndDlg), NCDU_REGISTER_DLG,
  184. NCDU_CONFIRM_BOOTDISK_DLG, (LPARAM)hwndDlg);
  185. // set cursor & focus
  186. SetCursor (LoadCursor(NULL, IDC_ARROW));
  187. SetFocus (GetDlgItem(hwndDlg, IDOK));
  188. return FALSE;
  189. }
  190. static
  191. BOOL
  192. ConfirmSettingsDlg_IDOK (
  193. IN HWND hwndDlg
  194. )
  195. /*++
  196. Routine Description:
  197. Called when user selects the OK button in the dialog box.
  198. Validates the destination path is a bootable floppy and
  199. presents message box to user if it's not.
  200. if all tests are succeessful, then the copy file dialog is
  201. called next. If not, the user is returned to this dialog box
  202. (mainly so they can press the cancel button and return to
  203. a previous screen and make corrections.)
  204. Arguments:
  205. IN HWND hwndDlg
  206. handle to dialog box window
  207. Return Value:
  208. TRUE, always.
  209. --*/
  210. {
  211. int nMbResult;
  212. MEDIA_TYPE mtDest;
  213. // make sure the target media is present
  214. if (!MediaPresent (pAppInfo->szBootFilesPath, TRUE)) {
  215. // media is NOT present so display message and return to dialog message
  216. DisplayMessageBox (
  217. hwndDlg,
  218. NCDU_NO_MEDIA,
  219. 0,
  220. MB_OK_TASK_EXCL);
  221. return TRUE; // message processed and return to dialog
  222. }
  223. // check destination boot disk one last time before copying files
  224. if (!IsBootDisk (pAppInfo->szBootFilesPath)) {
  225. nMbResult = DisplayMessageBox (
  226. hwndDlg,
  227. NCDU_DRIVE_NOT_BOOTDISK,
  228. 0,
  229. MB_OKCANCEL_TASK_EXCL);
  230. if (nMbResult == IDOK) {
  231. // the message prompts them to insert a bootable disk
  232. // then press OK. see if they did...
  233. if (!IsBootDisk (pAppInfo->szBootFilesPath)) {
  234. // they still have a "regular" disk so add a message
  235. // to the exit list
  236. AddMessageToExitList (pAppInfo, NCDU_COPY_TO_FLOPPY);
  237. } // else they put in the correct disk so continue
  238. } else {
  239. return TRUE; // return now so they can change floppys
  240. }
  241. }
  242. // check destination drive against boot type
  243. mtDest = GetDriveTypeFromPath (pAppInfo->szBootFilesPath);
  244. if (mtDest == Unknown) {
  245. AddMessageToExitList (pAppInfo, NCDU_CONFIRM_FLOPPY);
  246. } else if (mtDest != pAppInfo->mtBootDriveType) {
  247. AddMessageToExitList (pAppInfo, NCDU_COPY_TO_FLOPPY);
  248. }
  249. if (pAppInfo->itInstall == OverTheNetInstall) {
  250. AddMessageToExitList (pAppInfo, NCDU_USERNAME_ACCESS);
  251. AddMessageToExitList (pAppInfo, NCDU_MAKE_COMP_NAME);
  252. if (GetBootDiskDosVersion (pAppInfo->szBootFilesPath) < 5) {
  253. AddMessageToExitList (pAppInfo, NCDU_INSUF_MEM_AT_BOOT);
  254. }
  255. }
  256. PostMessage (GetParent(hwndDlg), NCDU_SHOW_COPYING_DLG, 0, 0);
  257. SetCursor(LoadCursor(NULL, IDC_WAIT));
  258. return TRUE;
  259. }
  260. static
  261. BOOL
  262. ConfirmSettingsDlg_WM_COMMAND (
  263. IN HWND hwndDlg,
  264. IN WPARAM wParam,
  265. IN LPARAM lParam
  266. )
  267. /*++
  268. Routine Description:
  269. WM_COMMAND message dispatching routine.
  270. Dispatches IDCANCEL and IDOK button messages, sends all others
  271. to the DefDlgProc.
  272. Arguments:
  273. IN HWND hwndDlg
  274. Handle to dialog box window
  275. IN WPARAM wParam
  276. windows message wParam arg
  277. IN LPARAM lParam
  278. windows message lParam arg
  279. Return Value:
  280. TRUE if message is not dispatched (i.e. not processed)
  281. othewise the value returned by the called routine.
  282. --*/
  283. {
  284. switch (LOWORD(wParam)) {
  285. case IDCANCEL:
  286. switch (HIWORD(wParam)) {
  287. case BN_CLICKED:
  288. PostMessage (GetParent(hwndDlg), NCDU_SHOW_SERVER_CFG_DLG, 0, 0);
  289. SetCursor(LoadCursor(NULL, IDC_WAIT));
  290. return TRUE;
  291. default:
  292. return FALSE;
  293. }
  294. case IDOK:
  295. switch (HIWORD(wParam)) {
  296. case BN_CLICKED:
  297. return ConfirmSettingsDlg_IDOK (hwndDlg);
  298. default:
  299. return FALSE;
  300. }
  301. default:
  302. return FALSE;
  303. }
  304. }
  305. INT_PTR CALLBACK
  306. ConfirmSettingsDlgProc (
  307. IN HWND hwndDlg,
  308. IN UINT message,
  309. IN WPARAM wParam,
  310. IN LPARAM lParam
  311. )
  312. /*++
  313. Routine Description:
  314. main dialog proc for this dialog box.
  315. Processes the following messages:
  316. WM_INITDIALOG: dialog box initialization
  317. WM_COMMAND: command button/item selected
  318. WM_PAINT: for painting icon when minimized
  319. WM_MOVE: for saving the new location of the window
  320. WM_SYSCOMMAND: for processing menu messages
  321. Arguments:
  322. IN HWND hwndDlg
  323. handle to dialog box window
  324. IN UINT message
  325. message id
  326. IN WPARAM wParam
  327. message wParam arg
  328. IN LPARAM lParam
  329. message lParam arg
  330. Return Value:
  331. FALSE if message not processed by this module, otherwise the
  332. value returned by the message processing routine.
  333. --*/
  334. {
  335. switch (message) {
  336. case WM_INITDIALOG: return (ConfirmSettingsDlg_WM_INITDIALOG (hwndDlg, wParam, lParam));
  337. case WM_COMMAND: return (ConfirmSettingsDlg_WM_COMMAND (hwndDlg, wParam, lParam));
  338. case WM_PAINT: return (Dlg_WM_PAINT (hwndDlg, wParam, lParam));
  339. case WM_MOVE: return (Dlg_WM_MOVE (hwndDlg, wParam, lParam));
  340. case WM_SYSCOMMAND: return (Dlg_WM_SYSCOMMAND (hwndDlg, wParam, lParam));
  341. default: return FALSE;
  342. }
  343. }