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.

1792 lines
67 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. NetUtils.C
  5. Abstract:
  6. File copy and sharing dialog
  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. #include <stdlib.h> // string to number conversions
  20. #include <lmcons.h> // lanman API constants
  21. //
  22. // app include files
  23. //
  24. #include "otnboot.h"
  25. #include "otnbtdlg.h"
  26. //
  27. // local windows messages
  28. //
  29. #define NCDU_SHARE_DIR (WM_USER +101)
  30. #define NCDU_VALIDATE_AND_END (WM_USER +103)
  31. #define NCDU_BROWSE_DIST_PATH (WM_USER +104)
  32. #define NCDU_BROWSE_DEST_PATH (WM_USER +105)
  33. //
  34. // static variables
  35. //
  36. //
  37. static int nNextDialog; // select dialog to follow this on OK
  38. static BOOL bShareNotCopy; // select default button mode
  39. //
  40. // these variables are used to remember the contents of the edit controls
  41. // that are disabled and/or blanked
  42. //
  43. static TCHAR szShareName1[MAX_PATH];
  44. static TCHAR szDestPath[MAX_PATH];
  45. static TCHAR szShareName2[MAX_PATH];
  46. static TCHAR szServerName[MAX_PATH];
  47. static TCHAR szShareName3[MAX_PATH];
  48. static
  49. UINT
  50. GetRealToolSourcePath (
  51. IN LPCTSTR szInPath,
  52. OUT LPTSTR szOutPath
  53. )
  54. /*++
  55. Routine Description:
  56. checks the path in to see if it's a tool tree, if not, then it checks
  57. to see if it's a client tree with a tool tree in it and returns
  58. the name of the tool path found (if any) or an error message ID and
  59. an empty string if a tool path cannot be found
  60. Arguments:
  61. IN LPCTSTR szInPath,
  62. Initial path to check
  63. OUT LPTSTR szOutPath
  64. resulting tool path or empty string if no path found
  65. Return Value:
  66. 0 if success
  67. NCDU error message string ID if error or tree not found
  68. --*/
  69. {
  70. UINT nResult;
  71. UINT nFirstResult;
  72. LPTSTR szNewPath;
  73. if (szOutPath == NULL) {
  74. return NCDU_UNABLE_READ_DIR;
  75. }
  76. if ((nResult = ValidSrvToolsPath(szInPath)) == 0) {
  77. // then the "in" path was a server tools path
  78. lstrcpy (szOutPath, szInPath);
  79. nResult = 0;
  80. } else {
  81. nFirstResult = nResult; // save for later
  82. // the "in" path is NOT a server tools path, so see if it's
  83. // a client tree
  84. if ((nResult = ValidSharePath(szInPath)) == 0) {
  85. // then this is a valid net client tree so see
  86. // if there's a srvtools dir 'underneath' it.
  87. szNewPath = (LPTSTR)GlobalAlloc(GPTR, MAX_PATH_BYTES);
  88. if (szNewPath != NULL) {
  89. // build new path
  90. lstrcpy (szNewPath, szInPath);
  91. if (szNewPath[lstrlen(szNewPath)-1] != cBackslash) {
  92. lstrcat(szNewPath, cszBackslash);
  93. }
  94. lstrcat (szNewPath, cszSrvtoolsDir);
  95. // now test the new path
  96. if ((nResult = ValidSrvToolsPath(szNewPath)) == 0) {
  97. // that worked so return it
  98. lstrcpy (szOutPath, szNewPath);
  99. nResult = 0; // success
  100. } else {
  101. // this isn't a tools dir either so give up
  102. // and return nResult from first call (from
  103. // the original path)
  104. nResult = nFirstResult;
  105. *szOutPath = 0;
  106. }
  107. //release temporary memory buffer
  108. FREE_IF_ALLOC (szNewPath);
  109. } else {
  110. nResult = NCDU_ERROR_NOMEMORY;
  111. *szOutPath = 0;
  112. }
  113. } else {
  114. // return error from first call (szInPath)
  115. nResult = nFirstResult;
  116. *szOutPath = 0;
  117. }
  118. }
  119. return nResult;
  120. }
  121. static
  122. LPCTSTR
  123. GetDefaultDestPath (
  124. VOID
  125. )
  126. /*++
  127. Routine Description:
  128. Creates a valid path to use as the default destination to copy the
  129. client files to from the CD. The routine finds the first valid
  130. local drive, then on that drive, finds the first permutation of
  131. "Clients\\srvtools" or "Clients\\srvtool[0-9]" that isn't currently on that drive.
  132. Arguments:
  133. None
  134. Return Value:
  135. Pointer to the read only string containing the resulting path or
  136. an empty string if a valid path could not be concocted.
  137. --*/
  138. {
  139. static TCHAR szPathBuffer[MAX_PATH];
  140. BOOL bFound;
  141. UINT nDriveType;
  142. DWORD dwFileAttrib;
  143. LPTSTR szUniqueChar;
  144. // start by finding a valid disk drive
  145. szPathBuffer[0] = cC;
  146. szPathBuffer[1] = cColon;
  147. szPathBuffer[2] = cBackslash;
  148. szPathBuffer[3] = 0;
  149. bFound = FALSE;
  150. while (!bFound) {
  151. nDriveType = GetDriveType (szPathBuffer);
  152. if (nDriveType == DRIVE_FIXED) {
  153. bFound = TRUE;
  154. } else {
  155. // increment drive letter
  156. szPathBuffer[0]++;
  157. if (szPathBuffer[0] > cZ) break;
  158. }
  159. }
  160. if (!bFound) {
  161. // unable to find a suitable drive so bail out.
  162. szPathBuffer[0] = 0;
  163. } else {
  164. // found a suitable drive so add a directory
  165. lstrcat (szPathBuffer, cszToolsDir);
  166. szUniqueChar = &szPathBuffer[lstrlen(szPathBuffer)-1];
  167. *(szUniqueChar + 1) = 0; // add extra null char
  168. bFound = FALSE;
  169. while (!bFound) {
  170. // the path is "found" when it references a non-
  171. // existent directory
  172. dwFileAttrib = QuietGetFileAttributes (szPathBuffer);
  173. if (dwFileAttrib == 0xFFFFFFFF) {
  174. bFound = TRUE;
  175. } else {
  176. if (*szUniqueChar == cs) {
  177. *szUniqueChar = c0;
  178. } else {
  179. if (*szUniqueChar < c9) {
  180. *szUniqueChar += 1; // increment digit
  181. } else {
  182. // used up all the letters with out finding an
  183. // unused dir so return an empty string
  184. szPathBuffer[0] = 0;
  185. break;
  186. }
  187. }
  188. }
  189. }
  190. }
  191. return (LPCTSTR)&szPathBuffer[0];
  192. }
  193. static
  194. LPCTSTR
  195. GetDefaultShareName (
  196. IN LPCTSTR szServer
  197. )
  198. /*++
  199. Routine Description:
  200. Creates a share name to be used as a default share. If an unused
  201. name can be created, then it is returned, if all names are used,
  202. then an empty string is returned.
  203. Arguments:
  204. IN LPCTSTR szServer pointer to the buffer containing the name of
  205. the server on which to look up the share name.
  206. if this parameter is NULL, then the local
  207. machine is used.
  208. Return Value:
  209. the pointer to a read-only buffer containing either the name of an
  210. unused share point or an empty string if such a name cannot be
  211. created.
  212. --*/
  213. {
  214. static TCHAR szNameBuffer[MAX_PATH];
  215. LPTSTR szLocalPath;
  216. LPTSTR szShareName;
  217. LPTSTR szShareIndex;
  218. TCHAR cOrigIndexChar;
  219. DWORD dwBufLen;
  220. DWORD dwFileAttrib;
  221. BOOL bFound;
  222. // allocate a local buffer for building dir path in
  223. szLocalPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  224. if (szLocalPath == NULL) {
  225. // unable to allocate mem for local path buffer so return an
  226. // empty string and leave
  227. szNameBuffer[0] = 0;
  228. } else {
  229. // build a UNC path in the local buffer to test for the
  230. // existence of the share point
  231. *szLocalPath = 0;
  232. lstrcpy (szLocalPath, cszDoubleBackslash);
  233. if (szServer == NULL) {
  234. // then look up local computer name
  235. dwBufLen = MAX_COMPUTERNAME_LENGTH+1;
  236. GetComputerName (&szLocalPath[2], &dwBufLen);
  237. } else {
  238. // use server sent in path
  239. lstrcat (szLocalPath, szServer);
  240. }
  241. lstrcat (szLocalPath, cszBackslash);
  242. // save pointer to sharepoint name in UNC string
  243. szShareName = &szLocalPath[lstrlen(szLocalPath)];
  244. lstrcpy (szShareName, GetStringResource (CSZ_SETUP_ADM));
  245. // limit name to 8 characters
  246. if (lstrlen(szShareName) > 8) {
  247. szShareName[8] = 0;
  248. }
  249. // for uniqueness, count the last digit from 0 - 9
  250. if (lstrlen(szShareName) >= 7) {
  251. // overwrite the last character
  252. szShareIndex = &szShareName[7];
  253. cOrigIndexChar = *szShareIndex;
  254. } else {
  255. szShareIndex = &szShareName[lstrlen(szShareName)];
  256. cOrigIndexChar = 0;
  257. }
  258. *(szShareIndex + 1) = 0; // add extra terminating null char
  259. bFound = FALSE;
  260. while (!bFound) {
  261. dwFileAttrib = QuietGetFileAttributes (szLocalPath);
  262. if (dwFileAttrib == 0xFFFFFFFF) {
  263. bFound = TRUE;
  264. } else {
  265. // this share point already exists, so try the
  266. // next one in the sequence
  267. if (*szShareIndex == cOrigIndexChar) {
  268. // this is the first retry
  269. *szShareIndex = c0;
  270. } else {
  271. if (*szShareIndex < c9) {
  272. *szShareIndex += 1; // increment character
  273. } else {
  274. // all attempted names are in use so bail out with
  275. // an empty buffer
  276. break;
  277. }
  278. }
  279. }
  280. }
  281. if (bFound) {
  282. // copy server name to output buffer
  283. lstrcpy (szNameBuffer, szShareName);
  284. } else {
  285. // a valid unused share name wasn't found, so return empty buffer
  286. szNameBuffer[0] = 0;
  287. }
  288. FREE_IF_ALLOC (szLocalPath);
  289. }
  290. return (LPCTSTR)&szNameBuffer[0];
  291. }
  292. static
  293. DWORD
  294. UpdateDiskSpace (
  295. IN HWND hwndDlg
  296. )
  297. /*++
  298. Routine Description:
  299. Computes and display the total estimated disk space required
  300. to copy the network utilities as read from the .INF
  301. Arguments:
  302. IN HWND hwndDlg
  303. Return Value:
  304. total bytes required (sum of all selected items)
  305. --*/
  306. {
  307. DWORD dwBytesReqd = 0;
  308. LPTSTR szFileInfo;
  309. LPTSTR szInfName;
  310. szFileInfo = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  311. szInfName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  312. if ((szFileInfo != NULL) && (szInfName != NULL)) {
  313. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szFileInfo, MAX_PATH);
  314. GetRealToolSourcePath (szFileInfo, szInfName);
  315. if (szInfName[lstrlen(szInfName)-1] != cBackslash) lstrcat(szInfName, cszBackslash);
  316. lstrcat (szInfName, cszSrvToolsInf);
  317. QuietGetPrivateProfileString (cszSizes, csz_ToolsTree_, cszEmptyString,
  318. szFileInfo, MAX_PATH, szInfName);
  319. dwBytesReqd = GetSizeFromInfString (szFileInfo);
  320. // reuse InfName buffer for output string
  321. // add 500,000 to bytes rquired in order to round M's up. (div
  322. // will simply truncate)
  323. _stprintf (szInfName, GetStringResource (FMT_M_BYTES),
  324. ((dwBytesReqd+500000)/1000000));
  325. SetDlgItemText (hwndDlg, NCDU_DISK_SPACE_REQD, szInfName);
  326. }
  327. FREE_IF_ALLOC(szFileInfo);
  328. FREE_IF_ALLOC(szInfName);
  329. return dwBytesReqd;
  330. }
  331. static
  332. VOID
  333. UpdateDialogMode (
  334. IN HWND hwndDlg
  335. )
  336. /*++
  337. Routine Description:
  338. Called to size the dialog box based on the currently selected
  339. mode. If the "Use existing share" mode is selected, then
  340. only the top half of the dialog box is visible, if the
  341. "copy" mode is selected then the entire dialog box is
  342. visible. All concealed controls are disabled for proper
  343. tab sequencing.
  344. Arguments:
  345. IN HWND hwndDlg
  346. Return Value:
  347. None
  348. --*/
  349. {
  350. BOOL bUseExistingPath;
  351. BOOL bShareFiles;
  352. BOOL bCopyAndShare;
  353. BOOL bUseExistingShare;
  354. BOOL bEnablePath;
  355. // save any share/path information in case the fields have to be cleared
  356. EnableWindow (GetDlgItem (hwndDlg, NCDU_FILES_ALREADY_SHARED), TRUE);
  357. if ( SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH, WM_GETTEXTLENGTH, 0, 0) > 0) {
  358. GetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath, MAX_PATH);
  359. }
  360. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1, WM_GETTEXTLENGTH, 0, 0) > 0) {
  361. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1, MAX_PATH);
  362. }
  363. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2, WM_GETTEXTLENGTH, 0, 0) > 0) {
  364. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2, MAX_PATH);
  365. }
  366. if ( SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME, WM_GETTEXTLENGTH, 0, 0) > 0) {
  367. GetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szServerName, MAX_PATH);
  368. }
  369. if ( SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3, WM_GETTEXTLENGTH, 0, 0) > 0) {
  370. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szShareName3, MAX_PATH);
  371. }
  372. // buttons are mutually exclusive so only one of these can (should) be
  373. // true at a time
  374. bUseExistingPath =
  375. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_USE_DIST_PATH) == CHECKED);
  376. bShareFiles =
  377. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_USE_EXISTING_SHARE) == CHECKED);
  378. bCopyAndShare =
  379. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_COPY_AND_MAKE_SHARE) == CHECKED);
  380. bUseExistingShare =
  381. (BOOL)(IsDlgButtonChecked(hwndDlg, NCDU_FILES_ALREADY_SHARED) == CHECKED);
  382. bEnablePath = !bUseExistingShare;
  383. // set the dialog to be approrpriate for the current button
  384. // set the path edit controls
  385. EnableWindow (GetDlgItem (hwndDlg, NCDU_TOP_PATH_TITLE), bEnablePath);
  386. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH), bEnablePath);
  387. EnableWindow (GetDlgItem (hwndDlg, NCDU_BROWSE_DIST), bEnablePath);
  388. // set the "Share Files" controls
  389. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_FILES_TEXT), bShareFiles);
  390. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1_TITLE), bShareFiles);
  391. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1), bShareFiles);
  392. if (bShareFiles) {
  393. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1);
  394. } else {
  395. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, cszEmptyString);
  396. }
  397. // set the "Copy Files..." controls
  398. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISK_SPACE_REQD), bCopyAndShare);
  399. EnableWindow (GetDlgItem (hwndDlg, NCDU_DISK_SPACE_REQD_LABEL), bCopyAndShare);
  400. EnableWindow (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH_LABEL), bCopyAndShare);
  401. EnableWindow (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH), bCopyAndShare);
  402. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2_TITLE), bCopyAndShare);
  403. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2), bCopyAndShare);
  404. if (bCopyAndShare) {
  405. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath);
  406. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2);
  407. } else {
  408. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, cszEmptyString);
  409. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, cszEmptyString);
  410. }
  411. // set "Use Existing Share..." controls
  412. EnableWindow (GetDlgItem (hwndDlg, NCDU_SERVER_NAME_TITLE), bUseExistingShare);
  413. EnableWindow (GetDlgItem (hwndDlg, NCDU_SERVER_NAME), bUseExistingShare);
  414. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3_TITLE), bUseExistingShare);
  415. EnableWindow (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3), bUseExistingShare);
  416. if (bUseExistingShare) {
  417. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szServerName);
  418. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szShareName3);
  419. } else {
  420. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, cszEmptyString);
  421. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, cszEmptyString);
  422. }
  423. // redraw button box
  424. UpdateWindow (hwndDlg);
  425. }
  426. static
  427. BOOL
  428. CopyFilesFromDistToDest (
  429. IN HWND hwndDlg
  430. )
  431. /*++
  432. Routine Description:
  433. copies the selected clients listed under the distribution directory
  434. to the destination directory.
  435. Arguments:
  436. IN HWND hwndDlg
  437. handle to dialog box window
  438. Return Value:
  439. TRUE if all went ok
  440. FALSE if the operation was aborted or ended in error.
  441. --*/
  442. {
  443. LPTSTR szSourceDir;
  444. LPTSTR szDestDir;
  445. DWORD dwBytesReqd = 0;
  446. LPTSTR szFileInfo;
  447. DWORD dwCopyFlags = CD_FLAGS_COPY_SUB_DIR + CD_FLAGS_LONG_NAMES;
  448. LPTSTR szClientName;
  449. LPTSTR szInfName;
  450. LPTSTR szDisplayString;
  451. int nCopyResult;
  452. CF_DLG_DATA cfData;
  453. szSourceDir = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  454. szDestDir = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  455. szFileInfo = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  456. szClientName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  457. szInfName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  458. if ((szSourceDir != NULL) &&
  459. (szDestDir != NULL) &&
  460. (szFileInfo != NULL) &&
  461. (szClientName != NULL) &&
  462. (szInfName != NULL)) {
  463. // copy the files in the netutils dir to the specified path
  464. lstrcpy (szInfName, pAppInfo->szDistPath);
  465. if (szInfName[lstrlen(szInfName)-1] != cBackslash) lstrcat(szInfName, cszBackslash);
  466. lstrcat (szInfName, cszSrvToolsInf);
  467. // make source & dest pathnames
  468. lstrcpy (szSourceDir, pAppInfo->szDistPath);
  469. if (szSourceDir[lstrlen(szSourceDir)-1] == cBackslash) szSourceDir[lstrlen(szSourceDir)-1] = 0;
  470. // remove trailing backslash
  471. lstrcpy (szDestDir, pAppInfo->szDestPath);
  472. if (szDestDir[lstrlen(szDestDir)-1] == cBackslash) szDestDir[lstrlen(szDestDir)-1] = 0;
  473. // copy files
  474. lstrcpy (szClientName, GetStringResource (CSZ_COPYING_NET_UTILS));
  475. cfData.szDisplayName = szClientName;
  476. cfData.szSourceDir = szSourceDir;
  477. cfData.szDestDir = szDestDir;
  478. cfData.dwCopyFlags = CD_FLAGS_COPY_SUB_DIR | CD_FLAGS_LONG_NAMES;
  479. QuietGetPrivateProfileString (cszSizes, csz_ToolsTree_, cszEmptyString,
  480. szFileInfo, MAX_PATH, szInfName);
  481. // add to total
  482. cfData.dwTotalSize = GetSizeFromInfString (szFileInfo);
  483. cfData.dwFilesCopied = 0;
  484. cfData.dwDirsCreated = 0;
  485. nCopyResult = (int)DialogBoxParam (
  486. (HANDLE)GetWindowLongPtr(GetParent(hwndDlg), GWLP_HINSTANCE),
  487. MAKEINTRESOURCE(NCDU_COPYING_FILES_DLG),
  488. hwndDlg,
  489. CopyFileDlgProc,
  490. (LPARAM)&cfData);
  491. if (nCopyResult == IDOK) {
  492. szDisplayString = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  493. if (szDisplayString == NULL) {
  494. // unable to allocate string buffer so try default message
  495. DisplayMessageBox (
  496. hwndDlg,
  497. NCDU_COPY_COMPLETE,
  498. 0,
  499. MB_OK_TASK_INFO);
  500. } else {
  501. _stprintf (szDisplayString,
  502. GetStringResource (FMT_COPY_COMPLETE_STATS),
  503. cfData.dwDirsCreated, cfData.dwFilesCopied);
  504. MessageBox (
  505. hwndDlg, szDisplayString,
  506. GetStringResource (SZ_APP_TITLE),
  507. MB_OK_TASK_INFO);
  508. FREE_IF_ALLOC (szDisplayString);
  509. }
  510. }
  511. } else {
  512. nCopyResult = IDCANCEL;
  513. }
  514. FREE_IF_ALLOC (szSourceDir);
  515. FREE_IF_ALLOC (szDestDir);
  516. FREE_IF_ALLOC (szFileInfo);
  517. FREE_IF_ALLOC (szClientName);
  518. FREE_IF_ALLOC (szInfName);
  519. return (nCopyResult == IDOK ? TRUE : FALSE);
  520. }
  521. static
  522. BOOL
  523. CopyNetUtilsDlg_WM_INITDIALOG (
  524. IN HWND hwndDlg,
  525. IN WPARAM wParam,
  526. IN LPARAM lParam
  527. )
  528. /*++
  529. Routine Description:
  530. Processes the WM_INITDIALOG windows message. Loads the controls
  531. with the values from the application data structure and
  532. initializes the display mode (i.e. the dlg box size)
  533. Arguments:
  534. IN HWND hwndDlg
  535. Handle to the dialog box window
  536. IN WPARAM wParam
  537. Not Used
  538. IN LPARAM lParam
  539. Not Used
  540. Return Value:
  541. FALSE
  542. --*/
  543. {
  544. LPTSTR szDlgDistPath;
  545. DWORD dwShareType;
  546. RemoveMaximizeFromSysMenu (hwndDlg);
  547. PositionWindow (hwndDlg);
  548. szDlgDistPath = GlobalAlloc(GPTR, MAX_PATH_BYTES);
  549. if (szDlgDistPath == NULL) {
  550. EndDialog (hwndDlg, IDCANCEL);
  551. return FALSE;
  552. }
  553. //
  554. // Determine next message for EndDialog Return based on
  555. // installation to perform
  556. //
  557. nNextDialog = NCDU_SHOW_SW_CONFIG_DLG;
  558. // get source path for client files
  559. if (*pAppInfo->szDistShowPath == 0) {
  560. // load default values if an existing source dir doesn't exist
  561. if (GetDistributionPath (hwndDlg, FDT_TOOLS_TREE,
  562. szDlgDistPath, MAX_PATH, &dwShareType) == ERROR_FILE_NOT_FOUND) {
  563. // tool tree not found so try client tree
  564. GetDistributionPath (hwndDlg, FDT_CLIENT_TREE,
  565. szDlgDistPath, MAX_PATH, &dwShareType);
  566. }
  567. //then initialize with a default value
  568. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  569. } else {
  570. // on entry into the dialog box only shared TOOL dirs are allowed
  571. // if the user wants to use the root client dir rather than the
  572. // actual tool dir later, that's OK, but here it's got to be the
  573. // real thing!
  574. if (ValidSrvToolsPath (pAppInfo->szDistShowPath) == 0) {
  575. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  576. // a valid path is already loaded
  577. if (IsUncPath(pAppInfo->szDistShowPath)) {
  578. dwShareType = NCDU_LOCAL_SHARE_PATH;
  579. } else {
  580. dwShareType = NCDU_HARD_DRIVE_PATH;
  581. }
  582. } else {
  583. // lookup a default path to use
  584. if (GetDistributionPath (hwndDlg, FDT_TOOLS_TREE,
  585. szDlgDistPath, MAX_PATH, &dwShareType) == ERROR_FILE_NOT_FOUND) {
  586. // tool tree not found so try client tree
  587. GetDistributionPath (hwndDlg, FDT_CLIENT_TREE,
  588. szDlgDistPath, MAX_PATH, &dwShareType);
  589. }
  590. //then initialize with a default value
  591. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  592. }
  593. }
  594. // load fields using data from data structure
  595. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, pAppInfo->szDistShowPath);
  596. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, pAppInfo->szDestPath);
  597. // set edit box text limits
  598. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  599. EM_LIMITTEXT, (WPARAM)(MAX_PATH-1), (LPARAM)0);
  600. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  601. EM_LIMITTEXT, (WPARAM)(MAX_PATH-1), (LPARAM)0);
  602. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  603. EM_LIMITTEXT, (WPARAM)(MAX_COMPUTERNAME_LENGTH), (LPARAM)0);
  604. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  605. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  606. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  607. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  608. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  609. EM_LIMITTEXT, (WPARAM)(MAX_SHARENAME-1), (LPARAM)0);
  610. // initialize field variables
  611. lstrcpy (szShareName1, GetDefaultShareName(NULL));
  612. lstrcpy (szShareName2, GetDefaultShareName(NULL));
  613. lstrcpy (szDestPath, GetDefaultDestPath());
  614. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szShareName1);
  615. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDestPath);
  616. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2, szShareName2);
  617. // set dialog state to appropriate value
  618. bShareNotCopy = (dwShareType == NCDU_CDROM_PATH ? FALSE : TRUE);
  619. switch (dwShareType) {
  620. case NCDU_NO_CLIENT_PATH_FOUND:
  621. // no path found
  622. CheckRadioButton (hwndDlg,
  623. NCDU_USE_DIST_PATH,
  624. NCDU_FILES_ALREADY_SHARED,
  625. NCDU_USE_EXISTING_SHARE);
  626. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  627. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  628. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  629. break;
  630. case NCDU_HARD_DRIVE_PATH:
  631. // path found on hard drive so default is to share
  632. CheckRadioButton (hwndDlg,
  633. NCDU_USE_DIST_PATH,
  634. NCDU_FILES_ALREADY_SHARED,
  635. NCDU_USE_EXISTING_SHARE);
  636. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  637. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  638. SetFocus (GetDlgItem(hwndDlg, NCDU_SHARE_NAME_1));
  639. break;
  640. case NCDU_CDROM_PATH:
  641. // path found on CD-ROM so default is to copy & share
  642. CheckRadioButton (hwndDlg,
  643. NCDU_USE_DIST_PATH,
  644. NCDU_FILES_ALREADY_SHARED,
  645. NCDU_COPY_AND_MAKE_SHARE);
  646. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  647. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  648. SetFocus (GetDlgItem(hwndDlg, NCDU_DESTINATION_PATH));
  649. break;
  650. case NCDU_PATH_FROM_REGISTRY:
  651. case NCDU_LOCAL_SHARE_PATH:
  652. // path already shared
  653. CheckRadioButton (hwndDlg,
  654. NCDU_USE_DIST_PATH,
  655. NCDU_FILES_ALREADY_SHARED,
  656. NCDU_FILES_ALREADY_SHARED);
  657. if (GetServerFromUnc (pAppInfo->szDistShowPath, szDlgDistPath)) {
  658. _tcsupr(szDlgDistPath);
  659. lstrcpy (szServerName, szDlgDistPath);
  660. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, szDlgDistPath);
  661. if (GetShareFromUnc (pAppInfo->szDistShowPath, szDlgDistPath)) {
  662. lstrcpy (szShareName3, szDlgDistPath);
  663. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3, szDlgDistPath);
  664. } else {
  665. // unable to look up share point so go back to dist path
  666. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, cszEmptyString);
  667. CheckRadioButton (hwndDlg,
  668. NCDU_USE_DIST_PATH,
  669. NCDU_FILES_ALREADY_SHARED,
  670. NCDU_USE_EXISTING_SHARE);
  671. }
  672. } else {
  673. // unable to look up server, so go back to dist path
  674. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME, cszEmptyString);
  675. CheckRadioButton (hwndDlg,
  676. NCDU_USE_DIST_PATH,
  677. NCDU_FILES_ALREADY_SHARED,
  678. NCDU_USE_EXISTING_SHARE);
  679. }
  680. SetFocus (GetDlgItem (hwndDlg, IDOK));
  681. break;
  682. }
  683. UpdateDiskSpace(hwndDlg);
  684. UpdateDialogMode (hwndDlg);
  685. PostMessage (GetParent(hwndDlg), NCDU_CLEAR_DLG, (WPARAM)hwndDlg, IDOK);
  686. PostMessage (GetParent(hwndDlg), NCDU_REGISTER_DLG,
  687. NCDU_COPY_NET_UTILS_DLG, (LPARAM)hwndDlg);
  688. SetCursor(LoadCursor(NULL, IDC_ARROW));
  689. FREE_IF_ALLOC (szDlgDistPath);
  690. return FALSE;
  691. }
  692. static
  693. BOOL
  694. CopyNetUtilsDlg_NCDU_SHARE_DIR (
  695. IN HWND hwndDlg,
  696. IN WPARAM wParam, // not used
  697. IN LPARAM lParam // pointer to SPS_DATA block
  698. )
  699. /*++
  700. Routine Description:
  701. Shares the Distribution dir path.
  702. Uses the share name entered in the display. If
  703. successful this message terminates the dialog box, otherwise
  704. an error message will be displayed.
  705. Arguments:
  706. IN HWND hwndDlg
  707. Handle to dialog box window
  708. IN WPARAM wParam
  709. Not Used
  710. IN LPARAM lParam
  711. pointer to SPS_DATA block
  712. Return Value:
  713. TRUE if dir shared
  714. FALSE if not (GetLastError for info)
  715. --*/
  716. {
  717. PSPS_DATA pspData;
  718. LPWSTR szTempMachineName = NULL;
  719. int nDlgBoxStatus;
  720. pspData = (PSPS_DATA)lParam;
  721. if (*pspData->szServer != cBackslash) {
  722. szTempMachineName = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  723. if (szTempMachineName != NULL) {
  724. lstrcpy (szTempMachineName, cszDoubleBackslash);
  725. lstrcat (szTempMachineName, pspData->szServer);
  726. pspData->szServer = szTempMachineName;
  727. }
  728. }
  729. nDlgBoxStatus = (int)DialogBoxParam (
  730. (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),
  731. MAKEINTRESOURCE (NCDU_DLG_SHARING_PATH),
  732. hwndDlg,
  733. SharePathDlgProc,
  734. lParam);
  735. FREE_IF_ALLOC (szTempMachineName);
  736. return (nDlgBoxStatus == IDOK ? TRUE : FALSE);
  737. }
  738. static
  739. BOOL
  740. CopyNetUtilsDlg_IDOK (
  741. IN HWND hwndDlg,
  742. IN WPARAM wParam,
  743. IN LPARAM lParam
  744. )
  745. /*++
  746. Routine Description:
  747. Processes the IDOK button depending on the mode selected. If the
  748. copy files mode is selected, then the source, destination and
  749. clients are validated and the files are copied. If the share
  750. distribution mode is selected, then the directory path is
  751. shared on the local machine.
  752. The validation consists of the following:
  753. FILES_ALREADY_SHARED: (bottom button)
  754. Get Server Name
  755. must be non blank
  756. must be name of machine on network
  757. Get Sharepoint Name
  758. must be non-blank
  759. must exist on above server
  760. signal if > DOS compatible name length
  761. \\server\share must be a valid server tools directory tree
  762. Use the distribution path: (any of the top buttons)
  763. Check Destination path
  764. must be non-blank
  765. must be a valid server tools directory tree
  766. SHARE DISTRIBUTION_PATH:
  767. Get share name
  768. must be non-blank
  769. if blank, then dest path must already be shared
  770. or a UNC path
  771. must not be in use
  772. signal if > DOS compatible name length
  773. Signal if name is in currently in use
  774. user may either use current name or change
  775. COPY AND SHARE:
  776. Get Destination Path
  777. must be non-blank
  778. Get share name
  779. must be non-blank
  780. must not be in use
  781. signal if > DOS compatible name length
  782. Signal if name is in currently in use
  783. Check disk space on destination machine
  784. Copy files from distribution to destination dir's
  785. If copy went OK, then update dlg fields and share
  786. Arguments:
  787. IN HWND hwndDlg
  788. Return Value:
  789. TRUE if the message is processed by this routine
  790. FALSE if not
  791. --*/
  792. {
  793. LPTSTR szDlgDistPath;
  794. LPTSTR szDlgDestPath;
  795. LPTSTR szPathBuff;
  796. LPTSTR szMsgBuff;
  797. LPTSTR szSharePath;
  798. TCHAR szDlgShareName[MAX_SHARENAME];
  799. TCHAR szServerName[MAX_COMPUTERNAME_LENGTH+1];
  800. UINT nDirMsg;
  801. BOOL bShareDest;
  802. DWORD dwBytesToCopy;
  803. DWORD dwShareType;
  804. SPS_DATA spData;
  805. LPTSTR szShareName;
  806. int nMbResult;
  807. BOOL bFinishOff = FALSE;
  808. switch (HIWORD(wParam)) {
  809. case BN_CLICKED:
  810. SetCursor(LoadCursor(NULL, IDC_WAIT));
  811. szDlgDistPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  812. szDlgDestPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  813. szPathBuff = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  814. szMsgBuff = GlobalAlloc (GPTR, SMALL_BUFFER_SIZE * sizeof(TCHAR));
  815. szSharePath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  816. if ((szDlgDistPath != NULL) &&
  817. (szDlgDestPath != NULL) &&
  818. (szMsgBuff != NULL) &&
  819. (szSharePath != NULL) &&
  820. (szPathBuff != NULL)) {
  821. if (IsDlgButtonChecked(hwndDlg, NCDU_FILES_ALREADY_SHARED) == CHECKED) {
  822. // use server & share found in the group box
  823. // make UNC from server & share found in dialog box
  824. lstrcpy (szDlgDistPath, cszDoubleBackslash);
  825. GetDlgItemText (hwndDlg, NCDU_SERVER_NAME,
  826. &szDlgDistPath[2], MAX_COMPUTERNAME_LENGTH+1);
  827. TrimSpaces (&szDlgDistPath[2]);
  828. if (lstrlen (&szDlgDistPath[2]) == 0) {
  829. DisplayMessageBox (
  830. hwndDlg,
  831. NCDU_NO_SERVER,
  832. 0,
  833. MB_OK_TASK_EXCL);
  834. SetDlgItemText (hwndDlg, NCDU_SERVER_NAME,
  835. &szDlgDistPath[2]);
  836. SetFocus (GetDlgItem (hwndDlg, NCDU_SERVER_NAME));
  837. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  838. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  839. goto IDOK_ExitClicked;
  840. }
  841. if (ComputerPresent (szDlgDistPath)) {
  842. lstrcat (szDlgDistPath, cszBackslash);
  843. szShareName = &szDlgDistPath[lstrlen(szDlgDistPath)];
  844. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3,
  845. szShareName, MAX_SHARENAME+1);
  846. TrimSpaces(szShareName);
  847. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_3,
  848. szShareName);
  849. if (lstrlen(szShareName) > LM20_DEVLEN) {
  850. nMbResult = DisplayMessageBox (
  851. hwndDlg,
  852. NCDU_NOT_DOS_SHARE,
  853. 0,
  854. MB_OKCANCEL_TASK_EXCL_DEF2);
  855. if (nMbResult == IDCANCEL) {
  856. // they pressed cancel, so go back to the offending share and
  857. // try again
  858. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  859. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  860. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  861. goto IDOK_ExitClicked;
  862. }
  863. // if here the user want's to keep the share name so continue
  864. }
  865. if (lstrlen(szShareName) == 0) {
  866. DisplayMessageBox (
  867. hwndDlg,
  868. NCDU_NO_SHARE_NAME,
  869. 0,
  870. MB_OK_TASK_EXCL);
  871. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  872. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  873. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  874. goto IDOK_ExitClicked;
  875. }
  876. if (szDlgDistPath[lstrlen(szDlgDistPath)-1] != cBackslash)
  877. lstrcat (szDlgDistPath, cszBackslash);
  878. dwShareType = ValidSrvToolsPath (szDlgDistPath);
  879. if (dwShareType == 0) {
  880. // valid, so copy to dist path and exit
  881. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  882. bFinishOff = TRUE;
  883. } else {
  884. // unable to locate sharepoint
  885. DisplayMessageBox (
  886. hwndDlg,
  887. dwShareType,
  888. 0,
  889. MB_OK_TASK_EXCL);
  890. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_3));
  891. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_3,
  892. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  893. }
  894. } else {
  895. // unable to locate server
  896. DisplayMessageBox (
  897. hwndDlg,
  898. NCDU_SERVER_NOT_PRESENT,
  899. 0,
  900. MB_OK_TASK_EXCL);
  901. SetFocus (GetDlgItem (hwndDlg, NCDU_SERVER_NAME));
  902. SendDlgItemMessage (hwndDlg, NCDU_SERVER_NAME,
  903. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  904. }
  905. } else {
  906. // they want to use the path in the edit box so
  907. // validate distribution directory path
  908. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szDlgDistPath, MAX_PATH);
  909. TrimSpaces (szDlgDistPath);
  910. if (lstrlen(szDlgDistPath) == 0) {
  911. // no source path
  912. DisplayMessageBox (
  913. hwndDlg,
  914. NCDU_PATH_CANNOT_BE_BLANK,
  915. 0,
  916. MB_OK_TASK_EXCL);
  917. // set focus and leave so the user can correct
  918. SetFocus (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH));
  919. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  920. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  921. goto IDOK_ExitClicked;
  922. }
  923. if ((nDirMsg = GetRealToolSourcePath(
  924. szDlgDistPath, pAppInfo->szDistPath)) != 0) {
  925. // error in Distribution path
  926. DisplayMessageBox (
  927. hwndDlg,
  928. nDirMsg,
  929. 0,
  930. MB_OK_TASK_EXCL);
  931. // error in directory path so set focus to directory entry
  932. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  933. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  934. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  935. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  936. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  937. goto IDOK_ExitClicked;
  938. }
  939. // distribution path is valid so save the path
  940. // and the server and then continue
  941. lstrcpy (pAppInfo->szDistShowPath, szDlgDistPath);
  942. if (IsDlgButtonChecked(hwndDlg, NCDU_USE_EXISTING_SHARE) == CHECKED) {
  943. // then they want to share the path in the edit box
  944. GetNetPathInfo (pAppInfo->szDistPath, szServerName,
  945. szSharePath);
  946. if ((*szServerName == 0) || (*szSharePath == 0)) {
  947. // unable to get path information
  948. DisplayMessageBox (
  949. hwndDlg,
  950. NCDU_UNABLE_GET_PATH_INFO,
  951. 0,
  952. MB_OK_TASK_EXCL);
  953. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  954. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  955. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  956. goto IDOK_ExitClicked;
  957. }
  958. // share the path in the source name edit control
  959. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szDlgShareName, MAX_SHARENAME);
  960. TrimSpaces (szDlgShareName);
  961. // update edit field in case we need to come back
  962. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, szDlgShareName);
  963. if (lstrlen(szDlgShareName) > LM20_DEVLEN) {
  964. nMbResult = DisplayMessageBox (
  965. hwndDlg,
  966. NCDU_NOT_DOS_SHARE,
  967. 0,
  968. MB_OKCANCEL_TASK_EXCL_DEF2);
  969. if (nMbResult == IDCANCEL) {
  970. // they pressed cancel, so go back to the offending share and
  971. // try again
  972. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  973. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  974. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  975. goto IDOK_ExitClicked;
  976. }
  977. // if here the user want's to keep the share name so continue
  978. }
  979. if (lstrlen(szDlgShareName) == 0) {
  980. // no share name specified so display error and
  981. // exit
  982. DisplayMessageBox (
  983. hwndDlg,
  984. NCDU_NO_SHARE_NAME,
  985. 0,
  986. MB_OK_TASK_EXCL);
  987. SetFocus (GetDlgItem(hwndDlg,
  988. NCDU_SHARE_NAME_1));
  989. SendDlgItemMessage (hwndDlg,
  990. NCDU_SHARE_NAME_1,
  991. EM_SETSEL, (WPARAM)0,
  992. (LPARAM)-1);
  993. goto IDOK_ExitClicked;
  994. } else {
  995. // there is a share name so try to share the source path
  996. if (IsShareNameUsed (szServerName, szDlgShareName,
  997. &dwShareType, szPathBuff)) {
  998. if (dwShareType == NCDU_SHARE_IS_SERVER_TOOLS) {
  999. // then this is the name of a shared client
  1000. // dir tree already, so tell the user about it
  1001. _stprintf (szMsgBuff,
  1002. GetStringResource (FMT_SHARE_IS_TOOLS_DIR),
  1003. szDlgShareName, szServerName, szPathBuff);
  1004. if (MessageBox (hwndDlg, szMsgBuff,
  1005. GetStringResource (SZ_APP_TITLE),
  1006. MB_OKCANCEL_TASK_EXCL_DEF2) == IDOK) {
  1007. // use the existing path and share name
  1008. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  1009. lstrcat (pAppInfo->szDistShowPath, szServerName);
  1010. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1011. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  1012. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1013. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1014. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, pAppInfo->szDistShowPath);
  1015. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_1, cszEmptyString);
  1016. // that's it then, so exit
  1017. bFinishOff = TRUE;
  1018. } else {
  1019. // they want to try again
  1020. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  1021. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  1022. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1023. goto IDOK_ExitClicked;
  1024. }
  1025. } else {
  1026. // this is the name of some other shared
  1027. // directory so tell the user
  1028. _stprintf (szMsgBuff,
  1029. GetStringResource (FMT_SHARE_IS_ALREADY_USED),
  1030. szDlgShareName, szServerName, szPathBuff);
  1031. MessageBox (hwndDlg, szMsgBuff,
  1032. GetStringResource (SZ_APP_TITLE),
  1033. MB_OK_TASK_EXCL);
  1034. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  1035. SendDlgItemMessage (hwndDlg,
  1036. NCDU_SHARE_NAME_1,
  1037. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1038. goto IDOK_ExitClicked;
  1039. }
  1040. } else {
  1041. // share name isn't in use, so go ahead and share it
  1042. // try to share
  1043. lstrcpy (szMsgBuff, GetStringResource (FMT_SHARE_TOOLS_REMARK));
  1044. spData.szServer = szServerName;
  1045. spData.szPath = szSharePath;
  1046. spData.szShareName = szDlgShareName;
  1047. spData.szRemark = szMsgBuff;
  1048. if (CopyNetUtilsDlg_NCDU_SHARE_DIR (hwndDlg,
  1049. (WPARAM)0, (LPARAM)&spData)) {
  1050. // shared successfully so
  1051. // make new UNC for distribution path
  1052. // then exit
  1053. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  1054. lstrcat (pAppInfo->szDistShowPath, szServerName);
  1055. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1056. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  1057. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1058. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1059. pAppInfo->szDistShowPath);
  1060. bFinishOff = TRUE;
  1061. } else {
  1062. // unable to share dir, error has been
  1063. // signaled via message box already
  1064. SetFocus (GetDlgItem(hwndDlg,
  1065. NCDU_SHARE_NAME_1));
  1066. SendDlgItemMessage (hwndDlg,
  1067. NCDU_SHARE_NAME_1,
  1068. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1069. }
  1070. }
  1071. } // end if sharename has some text
  1072. } else if (IsDlgButtonChecked(hwndDlg, NCDU_COPY_AND_MAKE_SHARE) == CHECKED) {
  1073. // copy the files from the distribution path to the destination
  1074. // path then share the destination path
  1075. // check destination string
  1076. GetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDlgDestPath, MAX_PATH);
  1077. TrimSpaces (szDlgDestPath);
  1078. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH, szDlgDestPath);
  1079. if (lstrlen(szDlgDestPath) == 0) {
  1080. // destination path is empty so go back and try again
  1081. // no source path
  1082. DisplayMessageBox (
  1083. hwndDlg,
  1084. NCDU_PATH_CANNOT_BE_BLANK,
  1085. 0,
  1086. MB_OK_TASK_EXCL);
  1087. // set focus and leave so the user can correct
  1088. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1089. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1090. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1091. goto IDOK_ExitClicked;
  1092. } else {
  1093. // there's a string in the destination so
  1094. // trim and copy to global struct
  1095. lstrcpy (pAppInfo->szDestPath, szDlgDestPath);
  1096. // see if there's a share name
  1097. GetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2,
  1098. szDlgShareName, MAX_SHARENAME);
  1099. TrimSpaces (szDlgShareName);
  1100. SetDlgItemText (hwndDlg, NCDU_SHARE_NAME_2,
  1101. szDlgShareName);
  1102. if (lstrlen(szDlgShareName) > LM20_DEVLEN) {
  1103. nMbResult = DisplayMessageBox (
  1104. hwndDlg,
  1105. NCDU_NOT_DOS_SHARE,
  1106. 0,
  1107. MB_OKCANCEL_TASK_EXCL_DEF2);
  1108. if (nMbResult == IDCANCEL) {
  1109. // they pressed cancel, so go back to the offending share and
  1110. // try again
  1111. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2));
  1112. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1113. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1114. goto IDOK_ExitClicked;
  1115. }
  1116. // if here the user want's to keep the share name so continue
  1117. }
  1118. if (lstrlen(szDlgShareName) == 0) {
  1119. // no share name so display error and
  1120. // bail out
  1121. DisplayMessageBox (
  1122. hwndDlg,
  1123. NCDU_NO_SHARE_NAME,
  1124. 0,
  1125. MB_OK_TASK_EXCL);
  1126. SetFocus (GetDlgItem(hwndDlg,
  1127. NCDU_SHARE_NAME_2));
  1128. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1129. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1130. goto IDOK_ExitClicked;
  1131. } else {
  1132. GetNetPathInfo (pAppInfo->szDestPath,
  1133. szServerName,
  1134. szSharePath);
  1135. if ((*szServerName == 0) || (*szSharePath == 0)) {
  1136. // unable to get path information
  1137. DisplayMessageBox (
  1138. hwndDlg,
  1139. NCDU_UNABLE_GET_PATH_INFO,
  1140. 0,
  1141. MB_OK_TASK_EXCL);
  1142. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1143. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1144. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1145. goto IDOK_ExitClicked;
  1146. }
  1147. if (IsShareNameUsed (szServerName, szDlgShareName,
  1148. &dwShareType, szPathBuff)) {
  1149. // this is the name of some other shared
  1150. // directory so tell the user
  1151. _stprintf (szMsgBuff,
  1152. GetStringResource (FMT_SHARE_IS_ALREADY_USED),
  1153. szDlgShareName, szServerName, szPathBuff);
  1154. MessageBox (hwndDlg, szMsgBuff,
  1155. GetStringResource (SZ_APP_TITLE),
  1156. MB_OK_TASK_EXCL);
  1157. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_2));
  1158. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_2,
  1159. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1160. goto IDOK_ExitClicked;
  1161. } else {
  1162. // indicate that the destination dir
  1163. // should be shared after the files have been
  1164. // copied.
  1165. bShareDest = TRUE;
  1166. }
  1167. }
  1168. // so at this point there's a destination dir and
  1169. // a share name if one's needed. finally we need to
  1170. // see if any client's have been selected to be
  1171. // copied.
  1172. dwBytesToCopy = UpdateDiskSpace(hwndDlg);
  1173. if (dwBytesToCopy == 0) {
  1174. DisplayMessageBox (
  1175. hwndDlg,
  1176. NCDU_NO_CLIENTS_SELECTED,
  1177. 0,
  1178. MB_OK_TASK_EXCL);
  1179. SetFocus (GetDlgItem(hwndDlg, NCDU_DISTRIBUTION_PATH));
  1180. SendDlgItemMessage (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1181. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1182. goto IDOK_ExitClicked;
  1183. }
  1184. // there's clients selected, now see if they'll fit
  1185. if (ComputeFreeSpace(pAppInfo->szDestPath) < dwBytesToCopy) {
  1186. DisplayMessageBox (
  1187. hwndDlg,
  1188. NCDU_INSUFFICIENT_DISK_SPACE,
  1189. 0,
  1190. MB_OK_TASK_EXCL);
  1191. SetFocus (GetDlgItem(hwndDlg, NCDU_DESTINATION_PATH));
  1192. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1193. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1194. goto IDOK_ExitClicked;
  1195. }
  1196. // so there should be enough free space
  1197. if (CopyFilesFromDistToDest (hwndDlg)) {
  1198. // copy was successful so
  1199. // copy destination name to distribution name
  1200. lstrcpy (pAppInfo->szDistShowPath,
  1201. pAppInfo->szDestPath);
  1202. lstrcpy (pAppInfo->szDistPath,
  1203. pAppInfo->szDestPath);
  1204. *pAppInfo->szDestPath = 0;
  1205. // update dialog box fields
  1206. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1207. pAppInfo->szDistShowPath);
  1208. SetDlgItemText (hwndDlg, NCDU_DESTINATION_PATH,
  1209. pAppInfo->szDestPath);
  1210. // since the files have been successfully copied and
  1211. // and the paths have been transposed (i.e. dest is now
  1212. // dist) update the button state so that if a sharing
  1213. // error occurs, the files won't have to be copied again
  1214. CheckRadioButton (hwndDlg,
  1215. NCDU_USE_DIST_PATH,
  1216. NCDU_FILES_ALREADY_SHARED,
  1217. NCDU_USE_EXISTING_SHARE);
  1218. bShareNotCopy = TRUE;
  1219. UpdateDialogMode (hwndDlg);
  1220. //
  1221. // then share the destination dir (which is now
  1222. // in the distribution path)
  1223. if (bShareDest) {
  1224. lstrcpy (szMsgBuff, GetStringResource (FMT_SHARE_TOOLS_REMARK));
  1225. spData.szServer = szServerName; // local machine
  1226. spData.szPath = szSharePath;
  1227. spData.szShareName = szDlgShareName;
  1228. spData.szRemark = szMsgBuff;
  1229. if (CopyNetUtilsDlg_NCDU_SHARE_DIR (hwndDlg,
  1230. (WPARAM)0, (LPARAM)&spData)) {
  1231. // shared successfully so
  1232. // make new UNC for distribution path
  1233. // then exit
  1234. lstrcpy (pAppInfo->szDistShowPath, cszDoubleBackslash);
  1235. lstrcat (pAppInfo->szDistShowPath, szServerName);
  1236. lstrcat (pAppInfo->szDistShowPath, cszBackslash);
  1237. lstrcat (pAppInfo->szDistShowPath, szDlgShareName);
  1238. lstrcpy (pAppInfo->szDistPath, pAppInfo->szDistShowPath);
  1239. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH,
  1240. pAppInfo->szDistShowPath);
  1241. bFinishOff = TRUE;
  1242. } else {
  1243. // the share operation failed, but was
  1244. // already signaled.
  1245. SetFocus (GetDlgItem (hwndDlg, NCDU_SHARE_NAME_1));
  1246. SendDlgItemMessage (hwndDlg, NCDU_SHARE_NAME_1,
  1247. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1248. }
  1249. } else {
  1250. // just leave
  1251. bFinishOff = TRUE;
  1252. }
  1253. } else {
  1254. // copy was not successful, but error has
  1255. // already been signaled to the user
  1256. SetFocus (GetDlgItem (hwndDlg, NCDU_DESTINATION_PATH));
  1257. SendDlgItemMessage (hwndDlg, NCDU_DESTINATION_PATH,
  1258. EM_SETSEL, (WPARAM)0, (LPARAM)-1);
  1259. }
  1260. } // end if there's a destination directory entry
  1261. } else { // end if copy and share is checked
  1262. bFinishOff = TRUE;
  1263. }
  1264. }// end if files not already shared
  1265. } // end if memory allocation was successful
  1266. IDOK_ExitClicked:
  1267. FREE_IF_ALLOC(szDlgDistPath);
  1268. FREE_IF_ALLOC(szDlgDestPath);
  1269. FREE_IF_ALLOC(szMsgBuff);
  1270. FREE_IF_ALLOC(szPathBuff);
  1271. FREE_IF_ALLOC(szSharePath);
  1272. if (bFinishOff) {
  1273. PostMessage (hwndDlg, NCDU_VALIDATE_AND_END,
  1274. (WPARAM)FALSE, (LPARAM)0);
  1275. } else {
  1276. SetCursor (LoadCursor(NULL, IDC_ARROW));
  1277. }
  1278. return TRUE;
  1279. default:
  1280. return FALSE;
  1281. }
  1282. }
  1283. static
  1284. BOOL
  1285. CopyNetUtilsDlg_WM_COMMAND (
  1286. IN HWND hwndDlg,
  1287. IN WPARAM wParam,
  1288. IN LPARAM lParam
  1289. )
  1290. /*++
  1291. Routine Description:
  1292. Processes the WM_COMMAND windows message in response to user input.
  1293. Dispatches to the appropriate routine based on the control that
  1294. was selected.
  1295. Arguments:
  1296. IN HWND hwndDlg
  1297. Handle to dialog box window
  1298. IN WPARAM wParam
  1299. LOWORD has id of control sending the message
  1300. HIWORD has the notification code (if applicable)
  1301. IN LPARAM lParam
  1302. Not Used
  1303. Return Value:
  1304. TRUE if message not processed by this routine, otherwise the value
  1305. returned by the dispatched routine
  1306. --*/
  1307. {
  1308. switch (LOWORD(wParam)) {
  1309. case IDOK: return CopyNetUtilsDlg_IDOK (hwndDlg, wParam, lParam);
  1310. case IDCANCEL:
  1311. switch (HIWORD(wParam)) {
  1312. case BN_CLICKED:
  1313. PostMessage (GetParent(hwndDlg), NCDU_SHOW_SW_CONFIG_DLG, 0, 0);
  1314. SetCursor(LoadCursor(NULL, IDC_WAIT));
  1315. return TRUE;
  1316. default:
  1317. return FALSE;
  1318. }
  1319. case NCDU_BROWSE_DIST:
  1320. switch (HIWORD(wParam)) {
  1321. case BN_CLICKED:
  1322. PostMessage (hwndDlg, NCDU_BROWSE_DIST_PATH, 0, 0);
  1323. SetCursor(LoadCursor(NULL, IDC_WAIT));
  1324. return TRUE;
  1325. default:
  1326. return FALSE;
  1327. }
  1328. case NCDU_USE_DIST_PATH:
  1329. case NCDU_USE_EXISTING_SHARE:
  1330. case NCDU_COPY_AND_MAKE_SHARE:
  1331. case NCDU_FILES_ALREADY_SHARED:
  1332. // these buttons don't send a notification message
  1333. UpdateDiskSpace (hwndDlg);
  1334. UpdateDialogMode (hwndDlg);
  1335. return TRUE;
  1336. case NCDU_DISTRIBUTION_PATH:
  1337. switch (HIWORD(wParam)) {
  1338. case EN_KILLFOCUS:
  1339. UpdateDiskSpace (hwndDlg);
  1340. return TRUE;
  1341. default:
  1342. return FALSE;
  1343. }
  1344. case NCDU_SHARE_NET_SW_DLG_HELP:
  1345. switch (HIWORD(wParam)) {
  1346. case BN_CLICKED:
  1347. // return ShowAppHelp (hwndDlg, LOWORD(wParam));
  1348. return PostMessage (GetParent(hwndDlg), WM_HOTKEY,
  1349. (WPARAM)NCDU_HELP_HOT_KEY, 0);
  1350. default:
  1351. return FALSE;
  1352. }
  1353. default:
  1354. return FALSE;
  1355. }
  1356. }
  1357. static
  1358. BOOL
  1359. CopyNetUtilsDlg_NCDU_BROWSE_DIST_PATH (
  1360. IN HWND hwndDlg,
  1361. IN WPARAM wParam,
  1362. IN LPARAM lParam
  1363. )
  1364. /*++
  1365. Routine Description:
  1366. Displays the file /dir browser to find distribution path entry
  1367. Arguments:
  1368. IN HWND hwndDlg
  1369. Handle to dialog box window
  1370. IN WPARAM wParam
  1371. Not Used
  1372. IN LPARAM lParam
  1373. Not Used
  1374. Return Value:
  1375. TRUE
  1376. --*/
  1377. {
  1378. DB_DATA BrowseInfo;
  1379. LPTSTR szTempPath;
  1380. szTempPath = GlobalAlloc (GPTR, (MAX_PATH_BYTES + sizeof(TCHAR)));
  1381. if (szTempPath == NULL) return TRUE;
  1382. GetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szTempPath, MAX_PATH);
  1383. BrowseInfo.dwTitle = NCDU_BROWSE_TOOL_DIST_PATH;
  1384. BrowseInfo.szPath = szTempPath;
  1385. BrowseInfo.Flags = 0;
  1386. if (DialogBoxParam (
  1387. (HINSTANCE)GetWindowLongPtr(hwndDlg, GWLP_HINSTANCE),
  1388. MAKEINTRESOURCE(NCDU_DIR_BROWSER),
  1389. hwndDlg,
  1390. DirBrowseDlgProc,
  1391. (LPARAM)&BrowseInfo) == IDOK) {
  1392. SetDlgItemText (hwndDlg, NCDU_DISTRIBUTION_PATH, szTempPath);
  1393. }
  1394. SetFocus (GetDlgItem (hwndDlg, NCDU_DISTRIBUTION_PATH));
  1395. FREE_IF_ALLOC (szTempPath);
  1396. return TRUE;
  1397. }
  1398. static
  1399. BOOL
  1400. CopyNetUtilsDlg_NCDU_VALIDATE_AND_END (
  1401. IN HWND hwndDlg,
  1402. IN WPARAM wParam,
  1403. IN LPARAM lParam
  1404. )
  1405. /*++
  1406. Routine Description:
  1407. Performs all validation and field updates before exiting the
  1408. dialog to the nNextDialog. If all validations are successful
  1409. then the EndDialog is called, otherwise the function returns
  1410. to the dialog box after displaying an error message and
  1411. setting the focus to the offending control if necessary.
  1412. Arguments:
  1413. IN HWND hwndDlg
  1414. Handle to dialog box window
  1415. IN WPARAM wParam
  1416. Not Used
  1417. IN LPARAM lParam
  1418. Not Used
  1419. Return Value:
  1420. FALSE
  1421. --*/
  1422. {
  1423. BOOL bSharedOk = FALSE;
  1424. LPTSTR szDlgDistPath;
  1425. DWORD dwBufLen;
  1426. szDlgDistPath = GlobalAlloc (GPTR, MAX_PATH_BYTES);
  1427. if (szDlgDistPath == NULL) return TRUE;
  1428. // copy the app data to the local path for validation
  1429. GetRealToolSourcePath (pAppInfo->szDistShowPath, szDlgDistPath);
  1430. // just validate the dist path (look up sharepoint) an continue
  1431. if (!IsUncPath(szDlgDistPath)) {
  1432. // dos file spec
  1433. if (!OnRemoteDrive(szDlgDistPath)) {
  1434. // dir is on local machine
  1435. if (pAppInfo->itInstall == CopyNetAdminUtils) {
  1436. dwBufLen = (DWORD)GlobalSize(szDlgDistPath);
  1437. if (!LookupLocalShare(szDlgDistPath, TRUE, pAppInfo->szDistPath, &dwBufLen)) {
  1438. // not shared so display error
  1439. DisplayMessageBox (hwndDlg,
  1440. NCDU_NO_SHARE_NAME,
  1441. 0,
  1442. MB_OK_TASK_EXCL);
  1443. bSharedOk = FALSE;
  1444. } else {
  1445. lstrcpy (pAppInfo->szDistPath, szDlgDistPath);
  1446. bSharedOk = TRUE;
  1447. }
  1448. } else {
  1449. lstrcpy (pAppInfo->szDistPath, szDlgDistPath);
  1450. bSharedOk = TRUE;
  1451. }
  1452. } else {
  1453. // dir is on remote drive so translate to UNC
  1454. dwBufLen = (DWORD)GlobalSize(szDlgDistPath);
  1455. LookupRemotePath (szDlgDistPath, pAppInfo->szDistPath, &dwBufLen);
  1456. bSharedOk = TRUE;
  1457. }
  1458. } else {
  1459. // dist path is UNC name so copy it
  1460. lstrcpy (pAppInfo->szDistPath, szDlgDistPath);
  1461. bSharedOk = TRUE;
  1462. }
  1463. if (bSharedOk) {
  1464. SetCursor(LoadCursor(NULL, IDC_ARROW));
  1465. DisplayMessageBox (hwndDlg,
  1466. NCDU_NETUTILS_SHARED,
  1467. 0,
  1468. MB_OK_TASK_INFO);
  1469. //
  1470. // save the path in the registry for next time
  1471. //
  1472. SavePathToRegistry (pAppInfo->szDistPath,
  1473. cszLastToolsServer,
  1474. cszLastToolsSharepoint);
  1475. PostMessage (GetParent(hwndDlg), (int)NCDU_SHOW_SW_CONFIG_DLG, 0, 0);
  1476. SetCursor(LoadCursor(NULL, IDC_WAIT));
  1477. }
  1478. FREE_IF_ALLOC (szDlgDistPath);
  1479. return TRUE;
  1480. }
  1481. INT_PTR CALLBACK
  1482. CopyNetUtilsDlgProc (
  1483. IN HWND hwndDlg,
  1484. IN UINT message,
  1485. IN WPARAM wParam,
  1486. IN LPARAM lParam
  1487. )
  1488. /*++
  1489. Routine Description:
  1490. Main Dialog message procedure. Dispatches to the appropriate routine
  1491. to process the following windows messages:
  1492. WM_INITDIALOG: Dialog box initialization
  1493. WM_COMMAND: User Input
  1494. NCDU_SHARE_DIR: shares the specified dir to the net
  1495. all other windows messages are handled by the default dialog proc.
  1496. Arguments:
  1497. Standard WNDPROC args
  1498. Return Value:
  1499. FALSE if the message is not processed by this module, otherwise
  1500. the value returned by the dispatched routine.
  1501. --*/
  1502. {
  1503. switch (message) {
  1504. case WM_INITDIALOG: return (CopyNetUtilsDlg_WM_INITDIALOG (hwndDlg, wParam, lParam));
  1505. case WM_COMMAND: return (CopyNetUtilsDlg_WM_COMMAND (hwndDlg, wParam, lParam));
  1506. case NCDU_SHARE_DIR: return (CopyNetUtilsDlg_NCDU_SHARE_DIR (hwndDlg, wParam, lParam));
  1507. case NCDU_BROWSE_DIST_PATH:
  1508. return (CopyNetUtilsDlg_NCDU_BROWSE_DIST_PATH (hwndDlg, wParam, lParam));
  1509. case NCDU_VALIDATE_AND_END:
  1510. return (CopyNetUtilsDlg_NCDU_VALIDATE_AND_END (hwndDlg, wParam, lParam));
  1511. case WM_PAINT: return (Dlg_WM_PAINT (hwndDlg, wParam, lParam));
  1512. case WM_MOVE: return (Dlg_WM_MOVE (hwndDlg, wParam, lParam));
  1513. case WM_SYSCOMMAND: return (Dlg_WM_SYSCOMMAND (hwndDlg, wParam, lParam));
  1514. default: return FALSE;
  1515. }
  1516. }