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.

1258 lines
38 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* WFCOMMAN.C - */
  4. /* */
  5. /* Windows File System Command Proc */
  6. /* */
  7. /****************************************************************************/
  8. #include <nt.h>
  9. #include <ntrtl.h>
  10. #include <nturtl.h>
  11. #include "winfile.h"
  12. #include "object.h"
  13. #include "lfn.h"
  14. #include "wfcopy.h"
  15. #include "winnet.h"
  16. #include "wnetcaps.h" // WNetGetCaps()
  17. #define HELP_PARTIALKEY 0x0105L /* call the search engine in winhelp */
  18. HWND LocateDirWindow(LPSTR pszPath, BOOL bDirOnly);
  19. VOID AddNetMenuItems(VOID);
  20. VOID InitNetMenuItems(VOID);
  21. VOID
  22. NotifySearchFSC(
  23. PSTR pszPath,
  24. WORD wFunction
  25. )
  26. {
  27. CHAR szPath[MAXPATHLEN];
  28. if (!hwndSearch)
  29. return;
  30. SendMessage(hwndSearch, FS_GETDIRECTORY, sizeof(szPath), (LPARAM)szPath);
  31. if (DRIVEID(pszPath) == DRIVEID(szPath)) {
  32. SendMessage(hwndSearch, WM_FILESYSCHANGE, wFunction, 0L);
  33. }
  34. }
  35. /*--------------------------------------------------------------------------*/
  36. /* */
  37. /* LocateDirWindow() - */
  38. /* */
  39. // bDirOnly TRUE if pszPath does not contain a filespec
  40. /*--------------------------------------------------------------------------*/
  41. HWND
  42. LocateDirWindow(
  43. LPSTR pszPath,
  44. BOOL bDirOnly
  45. )
  46. {
  47. register HWND hwndT;
  48. HWND hwndDir;
  49. LPSTR pT2;
  50. CHAR szTemp[MAXPATHLEN];
  51. CHAR szPath[MAXPATHLEN];
  52. pT2 = pszPath;
  53. /* Only work with well-formed pathes. */
  54. if (lstrlen(pT2) < 3)
  55. return NULL;
  56. if (IsDBCSLeadByte( pT2[0] ) || pT2[1] != ':')
  57. return NULL;
  58. lstrcpy(szPath, pT2);
  59. if (!bDirOnly) // remove extension stuff
  60. StripFilespec(szPath);
  61. for (hwndT = GetWindow(hwndMDIClient, GW_CHILD);
  62. hwndT;
  63. hwndT = GetWindow(hwndT, GW_HWNDNEXT)) {
  64. if (hwndDir = HasDirWindow(hwndT)) {
  65. // Get the Window's path information, remove the extension file spec
  66. GetMDIWindowText(hwndT, szTemp, sizeof(szTemp));
  67. StripFilespec(szTemp);
  68. /* No need to worry about the window's filespec. */
  69. if (!lstrcmpi(szTemp, szPath))
  70. break;
  71. }
  72. }
  73. return hwndT;
  74. }
  75. /*--------------------------------------------------------------------------*/
  76. /* */
  77. /* EnableFSC() - */
  78. /* */
  79. /*--------------------------------------------------------------------------*/
  80. VOID
  81. APIENTRY
  82. EnableFSC()
  83. {
  84. HWND hwnd;
  85. if (--cDisableFSC)
  86. return;
  87. for (hwnd = GetWindow(hwndMDIClient,GW_CHILD);
  88. hwnd;
  89. hwnd = GetWindow(hwnd,GW_HWNDNEXT)) {
  90. // a tree or search window
  91. if (!GetWindow(hwnd, GW_OWNER) && GetWindowLong(hwnd,GWL_FSCFLAG))
  92. SendMessage(hwnd,WM_FILESYSCHANGE,FSC_REFRESH,0L);
  93. }
  94. }
  95. /*--------------------------------------------------------------------------*/
  96. /* */
  97. /* DisableFSC() - */
  98. /* */
  99. /*--------------------------------------------------------------------------*/
  100. VOID
  101. APIENTRY
  102. DisableFSC()
  103. {
  104. cDisableFSC++;
  105. }
  106. /*--------------------------------------------------------------------------*/
  107. /* */
  108. /* ChangeFileSystem() - */
  109. /* */
  110. /*--------------------------------------------------------------------------*/
  111. /* There are two sources of FileSysChange messages. They can be sent from
  112. * the 386 WinOldAp or they can be posted by WINFILE's callback function (i.e.
  113. * from Kernel). In both cases, we are free to do processing at this point.
  114. * For posted messages, we have to free the buffer passed to us as well.
  115. *
  116. * we are really in the other tasks context when we get entered here.
  117. * (this routine should be in a DLL)
  118. *
  119. * the file names are partially qualified, they have at least a drive
  120. * letter and initial directory part (c:\foo\..\bar.txt) so our
  121. * QualifyPath() calls should work.
  122. */
  123. VOID
  124. APIENTRY
  125. ChangeFileSystem(
  126. register WORD wFunction,
  127. LPSTR lpszFile,
  128. LPSTR lpszTo
  129. )
  130. {
  131. HWND hwnd, hwndTC;
  132. HWND hwndOld;
  133. CHAR szFrom[MAXPATHLEN];
  134. CHAR szTo[MAXPATHLEN];
  135. CHAR szTemp[MAXPATHLEN];
  136. CHAR szPath[MAXPATHLEN + MAXPATHLEN];
  137. ENTER("ChangeFileSystem");
  138. OemToAnsi(lpszFile,szFrom);
  139. QualifyPath(szFrom); // already partly qualified
  140. /* Handle cases where we're passed a DOS function number rather
  141. * than an FSC index (for the Kernel callback).
  142. */
  143. if (wFunction & 0x8000) {
  144. switch (wFunction & 0x7FFF) {
  145. case 0x56:
  146. wFunction = FSC_RENAME;
  147. break;
  148. case 0x3C:
  149. case 0x5A:
  150. case 0x5B:
  151. case 0x6C:
  152. wFunction = FSC_CREATE;
  153. break;
  154. case 0x41:
  155. wFunction = FSC_DELETE;
  156. break;
  157. case 0x43:
  158. wFunction = FSC_ATTRIBUTES;
  159. break;
  160. case 0x39:
  161. wFunction = FSC_MKDIR;
  162. break;
  163. case 0x3A:
  164. wFunction = FSC_RMDIR;
  165. break;
  166. }
  167. }
  168. bFileSysChanging = TRUE;
  169. // as FSC messages come in from outside winfile
  170. // we set a timer, and when that expires we
  171. // refresh everything. if another FSC comes in while
  172. // we are waiting on this timer we reset it so we
  173. // only refresh on the last operations. this lets
  174. // the timer be much shorter
  175. if (cDisableFSC == 0 || bFSCTimerSet) {
  176. if (bFSCTimerSet)
  177. KillTimer(hwndFrame, 1); // reset the timer
  178. if (SetTimer(hwndFrame, 1, 1000, NULL)) { // 1 second
  179. bFSCTimerSet = TRUE;
  180. if (cDisableFSC == 0) // only disable once
  181. DisableFSC();
  182. }
  183. }
  184. switch (wFunction) {
  185. case FSC_RENAME:
  186. OemToAnsi(lpszTo,szTo);
  187. QualifyPath(szTo); // already partly qualified
  188. NotifySearchFSC(szFrom, wFunction);
  189. /* Update the original directory window (if any). */
  190. if (hwndOld = LocateDirWindow(szFrom, FALSE))
  191. SendMessage(hwndOld, WM_FILESYSCHANGE, wFunction, (LPARAM)szFrom);
  192. NotifySearchFSC(szTo, wFunction);
  193. /* Update the new directory window (if any). */
  194. if ((hwnd = LocateDirWindow(szTo, FALSE)) && (hwnd != hwndOld))
  195. SendMessage(hwnd, WM_FILESYSCHANGE, wFunction, (LPARAM)szTo);
  196. /* Are we renaming a directory? */
  197. lstrcpy(szTemp, szTo);
  198. FixAnsiPathForDos(szTemp);
  199. if (GetFileAttributes(szTemp) & ATTR_DIR) {
  200. for (hwnd = GetWindow(hwndMDIClient, GW_CHILD);
  201. hwnd;
  202. hwnd = GetWindow(hwnd, GW_HWNDNEXT)) {
  203. if (hwndTC = HasTreeWindow(hwnd)) {
  204. // if the current selection is szFrom, we update the
  205. // selection after the rename occurs
  206. SendMessage(hwnd, FS_GETDIRECTORY, sizeof(szPath), (LPARAM)szPath);
  207. StripBackslash(szPath);
  208. // add the new name first
  209. SendMessage(hwndTC, WM_FILESYSCHANGE, FSC_MKDIR, (LPARAM)szTo);
  210. // update the selection if necessary, also
  211. // change the window text in this case to
  212. // reflect the new name
  213. if (!lstrcmpi(szPath, szFrom)) {
  214. SendMessage(hwndTC, TC_SETDIRECTORY, FALSE, (LPARAM)szTo);
  215. lstrcpy(szPath, szTo);
  216. // update the window title
  217. AddBackslash(szPath);
  218. SendMessage(hwnd, FS_GETFILESPEC, MAXPATHLEN, (LPARAM)szPath + lstrlen(szPath));
  219. // if (wTextAttribs & TA_LOWERCASE)
  220. // AnsiLower(szPath);
  221. SetMDIWindowText(hwnd, szPath);
  222. }
  223. SendMessage(hwndTC, WM_FILESYSCHANGE, FSC_RMDIR, (LPARAM)szFrom);
  224. }
  225. }
  226. }
  227. break;
  228. case FSC_RMDIR:
  229. /* Close any open directory window. */
  230. if ((hwnd = LocateDirWindow(szFrom, TRUE)) && !HasTreeWindow(hwnd))
  231. SendMessage(hwnd, WM_CLOSE, 0, 0L);
  232. /*** FALL THRU ***/
  233. case FSC_MKDIR:
  234. {
  235. HWND hwnd;
  236. HWND hwndTree;
  237. /* Update the tree. */
  238. for (hwnd = GetWindow(hwndMDIClient, GW_CHILD);
  239. hwnd;
  240. hwnd = GetWindow(hwnd, GW_HWNDNEXT)) {
  241. if (hwndTree = HasTreeWindow(hwnd)) {
  242. SendMessage(hwndTree, WM_FILESYSCHANGE, wFunction, (LPARAM)szFrom);
  243. }
  244. }
  245. }
  246. /*** FALL THRU ***/
  247. case FSC_DELETE:
  248. case FSC_CREATE:
  249. case FSC_REFRESH:
  250. case FSC_ATTRIBUTES:
  251. lFreeSpace = -1L; // cause this stuff to be refreshed
  252. if (hwnd = LocateDirWindow(szFrom, FALSE))
  253. SendMessage(hwnd, WM_FILESYSCHANGE, wFunction, (LPARAM)szFrom);
  254. NotifySearchFSC(szFrom, wFunction);
  255. break;
  256. }
  257. bFileSysChanging = FALSE;
  258. LEAVE("ChangeFileSystem");
  259. }
  260. //
  261. // HWND APIENTRY CreateTreeWindow(LPSTR szPath, int dxSplit)
  262. //
  263. // creates a tree window with all the extras
  264. //
  265. // in:
  266. // szPath fully qualified ANSI path name WITH filespec
  267. // dxSplit split position of tree and dir windows, if this is
  268. // less than the threshold a tree will not be created,
  269. // if it is more then a dir will not be created.
  270. // 0 to create a dir only
  271. // very large number for tree only
  272. // < 0 to have the split put in the middle
  273. // returns:
  274. // the hwnd of the mdi child created
  275. //
  276. HWND
  277. APIENTRY
  278. CreateTreeWindow(
  279. LPSTR szPath,
  280. INT dxSplit
  281. )
  282. {
  283. MDICREATESTRUCT MDICS;
  284. HWND hwnd;
  285. ENTER("CreateTreeWindow");
  286. PRINT(BF_PARMTRACE, "szPath=%s", szPath);
  287. PRINT(BF_PARMTRACE, "dxSplit=%ld", IntToPtr(dxSplit));
  288. // if (wTextAttribs & TA_LOWERCASE)
  289. // AnsiLower(szPath);
  290. // Create the Directory Tree window
  291. MDICS.szClass = szTreeClass;
  292. MDICS.szTitle = szPath;
  293. MDICS.hOwner = hAppInstance;
  294. MDICS.style = 0L;
  295. MDICS.x = CW_USEDEFAULT;
  296. MDICS.y = 0;
  297. MDICS.cx = CW_USEDEFAULT;
  298. MDICS.cy = 0;
  299. MDICS.lParam = MAKELONG(dxSplit, 0); // pass the split parameter
  300. // on down
  301. hwnd = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L);
  302. if (hwnd && GetWindowLong(hwnd, GWL_STYLE) & WS_MAXIMIZE)
  303. MDICS.style |= WS_MAXIMIZE;
  304. hwnd = (HWND)SendMessage(hwndMDIClient, WM_MDICREATE, 0L, (LPARAM)&MDICS);
  305. if (hwnd) {
  306. SetMDIWindowText(hwnd, szPath);
  307. #if 0
  308. HMENU hMenu;
  309. hMenu = GetSystemMenu(hwnd, FALSE);
  310. AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
  311. AppendMenu(hMenu, MF_STRING, SC_SPLIT, "Sp&lit");
  312. #endif
  313. }
  314. PRINT(BF_PARMTRACE, "OUT: hwndTree=%d", hwnd);
  315. LEAVE("CreateTreeWindow");
  316. return hwnd;
  317. }
  318. //
  319. // HWND APIENTRY CreateDirWindow(register LPSTR szPath, BOOL bStartUp)
  320. //
  321. // in:
  322. // szPath fully qualified path with no filespec
  323. // bReplaceOpen default replacement mode, shift always toggles this
  324. // hwndActive active mdi child that we are working on
  325. // on open flag
  326. // returns:
  327. // hwnd of window created or of existing dir window that we
  328. // activated or replaced if replace on open was active
  329. //
  330. HWND
  331. APIENTRY
  332. CreateDirWindow(
  333. register LPSTR szPath,
  334. BOOL bReplaceOpen,
  335. HWND hwndActive
  336. )
  337. {
  338. register HWND hwndT;
  339. CHAR szFileSpec[MAXPATHLEN];
  340. // shift toggels 'replace on open'
  341. if (GetKeyState(VK_SHIFT) < 0)
  342. bReplaceOpen = !bReplaceOpen;
  343. /* Is a window with this path already open? */
  344. if (!bReplaceOpen && (hwndT = LocateDirWindow(szPath, TRUE)) && !HasTreeWindow(hwndT)) {
  345. SendMessage(hwndMDIClient, WM_MDIACTIVATE, GET_WM_MDIACTIVATE_MPS(0, 0, hwndT));
  346. if (IsIconic(hwndT))
  347. SendMessage(hwndT, WM_SYSCOMMAND, SC_RESTORE, 0L);
  348. return hwndT;
  349. }
  350. // Are we replacing the contents of the currently active child?
  351. if (bReplaceOpen) {
  352. // update the tree if necessary, before we throw on the filespec
  353. if (hwndT = HasTreeWindow(hwndActive))
  354. SendMessage(hwndT, TC_SETDIRECTORY, FALSE, (LPARAM)szPath);
  355. SendMessage(hwndActive, FS_GETFILESPEC, sizeof(szFileSpec), (LPARAM)szFileSpec);
  356. AddBackslash(szPath); // need to add this stuff to the path
  357. lstrcat(szPath, szFileSpec);
  358. SendMessage(GetDlgItem(hwndActive, IDCW_DIR), FS_CHANGEDISPLAY, CD_PATH, (LPARAM)szPath);
  359. return hwndActive;
  360. }
  361. AddBackslash(szPath); // default to all files
  362. lstrcat(szPath, szStarDotStar);
  363. return CreateTreeWindow(szPath, 0); // dir only tree window
  364. }
  365. VOID
  366. OpenSelection(
  367. HWND hwndActive
  368. )
  369. {
  370. LPSTR p;
  371. BOOL bDir;
  372. WORD ret;
  373. HCURSOR hCursor;
  374. CHAR szTemp[MAXPATHLEN];
  375. CHAR szPath[MAXPATHLEN];
  376. HWND hwndTree, hwndDir, hwndDrives, hwndFocus;
  377. // Is the active MDI child minimized? if so restore it!
  378. if (IsIconic(hwndActive)) {
  379. SendMessage(hwndActive, WM_SYSCOMMAND, SC_RESTORE, 0L);
  380. return;
  381. }
  382. hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  383. ShowCursor(TRUE);
  384. // set the current directory
  385. SetWindowDirectory();
  386. // get the relavant parameters
  387. GetTreeWindows(hwndActive, &hwndTree, &hwndDir, &hwndDrives);
  388. if (hwndTree || hwndDir)
  389. hwndFocus = GetTreeFocus(hwndActive);
  390. else
  391. hwndFocus = NULL;
  392. if (hwndDrives && hwndFocus == hwndDrives) {
  393. // open a drive by sending a <CR>
  394. SendMessage(hwndDrives, WM_KEYDOWN, VK_RETURN, 0L);
  395. goto OpenExit;
  396. }
  397. /* Get the first selected item. */
  398. p = (LPSTR)SendMessage(hwndActive, FS_GETSELECTION, TRUE, (LPARAM)&bDir);
  399. if (!*p)
  400. goto OpenExit;
  401. GetNextFile(p, szPath, sizeof(szPath));
  402. LocalFree((HANDLE)p);
  403. if (!szPath[0])
  404. goto OpenExit;
  405. if (bDir) {
  406. if (hwndDir && hwndFocus == hwndDir) {
  407. if (hwndTree)
  408. SendMessage(hwndTree, TC_EXPANDLEVEL, FALSE, 0L);
  409. CreateDirWindow(szPath, TRUE, hwndActive);
  410. SetFocus(hwndDir); // undo some things that happen in TC_EXPANDLEVEL
  411. } else if (hwndTree) {
  412. // this came through because of
  413. // SHIFT open a dir only tree
  414. if (GetKeyState(VK_SHIFT) < 0) {
  415. CreateDirWindow(szPath, TRUE, hwndActive);
  416. } else {
  417. SendMessage(hwndTree, TC_TOGGLELEVEL, FALSE, 0L);
  418. }
  419. }
  420. } else {
  421. // Display the object information
  422. GetSelectedDirectory(0, szTemp);
  423. AddBackslash(szTemp);
  424. strcat(szTemp, szPath);
  425. DisplayObjectInformation(hwndFrame, szTemp);
  426. }
  427. OpenExit:
  428. ShowCursor(FALSE);
  429. SetCursor(hCursor);
  430. }
  431. /*--------------------------------------------------------------------------*/
  432. /* */
  433. /* AppCommandProc() - */
  434. /* */
  435. /*--------------------------------------------------------------------------*/
  436. BOOL
  437. APIENTRY
  438. AppCommandProc(
  439. register WORD id
  440. )
  441. {
  442. WORD wFlags;
  443. BOOL bMaxed;
  444. HMENU hMenu;
  445. register HWND hwndActive;
  446. BOOL bTemp;
  447. HWND hwndT;
  448. CHAR szPath[MAXPATHLEN];
  449. INT ret;
  450. hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L);
  451. if (hwndActive && GetWindowLong(hwndActive, GWL_STYLE) & WS_MAXIMIZE)
  452. bMaxed = 1;
  453. else
  454. bMaxed = 0;
  455. dwContext = IDH_HELPFIRST + id;
  456. switch (id) {
  457. case IDM_SPLIT:
  458. MSG("AppCommandProc", "IDM_SPLIT");
  459. SendMessage(hwndActive, WM_SYSCOMMAND, SC_SPLIT, 0L);
  460. break;
  461. case IDM_TREEONLY:
  462. case IDM_DIRONLY:
  463. case IDM_BOTH:
  464. MSG("AppCommandProc", "IDM_TREEONLY/IDM_DIRONLY/IDM_BOTH");
  465. {
  466. RECT rc;
  467. INT x;
  468. if (hwndActive != hwndSearch) {
  469. GetClientRect(hwndActive, &rc);
  470. if (id == IDM_DIRONLY)
  471. x = 0;
  472. else if (id == IDM_TREEONLY)
  473. x = rc.right;
  474. else
  475. x = rc.right / 2;
  476. if (ResizeSplit(hwndActive, x))
  477. SendMessage(hwndActive, WM_SIZE, SIZENOMDICRAP, MAKELONG(rc.right, rc.bottom));
  478. }
  479. break;
  480. }
  481. case IDM_OPEN:
  482. MSG("AppCommandProc", "IDM_OPEN");
  483. if (GetKeyState(VK_MENU) < 0)
  484. PostMessage(hwndFrame, WM_COMMAND, GET_WM_COMMAND_MPS(IDM_ATTRIBS, 0, 0));
  485. else
  486. OpenSelection(hwndActive);
  487. break;
  488. case IDM_ASSOCIATE:
  489. MSG("AppCommandProc", "IDM_ASSOCIATE");
  490. DialogBox(hAppInstance, MAKEINTRESOURCE(ASSOCIATEDLG), hwndFrame, AssociateDlgProc);
  491. break;
  492. case IDM_SEARCH:
  493. MSG("AppCommandProc", "IDM_SEARCH");
  494. DialogBox(hAppInstance, MAKEINTRESOURCE(SEARCHDLG), hwndFrame, SearchDlgProc);
  495. break;
  496. case IDM_RUN:
  497. MSG("AppCommandProc", "IDM_RUN");
  498. DialogBox(hAppInstance, MAKEINTRESOURCE(RUNDLG), hwndFrame, RunDlgProc);
  499. break;
  500. case IDM_SELECT:
  501. MSG("AppCommandProc", "IDM_SELECT");
  502. // push the focus to the dir half so when they are done
  503. // with the selection they can manipulate without undoing the
  504. // selection.
  505. if (hwndT = HasDirWindow(hwndActive))
  506. SetFocus(hwndT);
  507. DialogBox(hAppInstance, MAKEINTRESOURCE(SELECTDLG), hwndFrame, SelectDlgProc);
  508. break;
  509. case IDM_MOVE:
  510. case IDM_COPY:
  511. case IDM_RENAME:
  512. MSG("AppCommandProc", "IDM_MOVE/IDM_COPY/IDM_RENAME");
  513. wSuperDlgMode = id;
  514. DialogBox(hAppInstance, MAKEINTRESOURCE(MOVECOPYDLG), hwndFrame, SuperDlgProc);
  515. break;
  516. case IDM_PRINT:
  517. MSG("AppCommandProc", "IDM_PRINT");
  518. wSuperDlgMode = id;
  519. DialogBox(hAppInstance, MAKEINTRESOURCE(MYPRINTDLG), hwndFrame, SuperDlgProc);
  520. break;
  521. case IDM_DELETE:
  522. MSG("AppCommandProc", "IDM_DELETE");
  523. wSuperDlgMode = id;
  524. DialogBox(hAppInstance, MAKEINTRESOURCE(DELETEDLG), hwndFrame, SuperDlgProc);
  525. break;
  526. case IDM_UNDELETE:
  527. MSG("AppCommandProc", "IDM_UNDELETE");
  528. if (lpfpUndelete) {
  529. SendMessage(hwndActive, FS_GETDIRECTORY, sizeof(szPath), (LPARAM)szPath);
  530. StripBackslash(szPath);
  531. if ((*lpfpUndelete)(hwndActive, (LPSTR)szPath) == IDOK)
  532. RefreshWindow(hwndActive);
  533. }
  534. break;
  535. case IDM_ATTRIBS:
  536. MSG("AppCommandProc", "IDM_ATTRIBS");
  537. {
  538. LPSTR pSel, p;
  539. INT count;
  540. // should do the multiple or single file properties
  541. pSel = GetSelection(FALSE);
  542. if (!pSel)
  543. break;
  544. count = 0;
  545. p = pSel;
  546. while (p = GetNextFile(p, szPath, sizeof(szPath)))
  547. count++;
  548. LocalFree((HANDLE)pSel);
  549. if (count == 0)
  550. break; // nothing selected
  551. if (count > 1)
  552. DialogBox(hAppInstance, MAKEINTRESOURCE(MULTIPLEATTRIBSDLG), hwndFrame, AttribsDlgProc);
  553. else
  554. DialogBox(hAppInstance, MAKEINTRESOURCE(ATTRIBSDLG), hwndFrame, AttribsDlgProc);
  555. break;
  556. }
  557. case IDM_MAKEDIR:
  558. MSG("AppCommandProc", "IDM_MAKEDIR");
  559. DialogBox(hAppInstance, MAKEINTRESOURCE(MAKEDIRDLG), hwndFrame, MakeDirDlgProc);
  560. break;
  561. case IDM_SELALL:
  562. case IDM_DESELALL:
  563. MSG("AppCommandProc", "IDM_SELALL/IDM_DESELALL");
  564. // FIX31: this code could be replace with calls to
  565. // DSSetSelection()
  566. {
  567. INT iSave;
  568. HWND hwndLB;
  569. LPMYDTA lpmydta;
  570. hwndActive = HasDirWindow(hwndActive);
  571. if (!hwndActive)
  572. break;
  573. hwndLB = GetDlgItem(hwndActive, IDCW_LISTBOX);
  574. if (!hwndLB)
  575. break;
  576. SendMessage(hwndLB, WM_SETREDRAW, FALSE, 0L);
  577. iSave = (INT)SendMessage(hwndLB, LB_GETCURSEL, 0, 0L);
  578. SendMessage(hwndLB, LB_SETSEL, (id == IDM_SELALL), -1L);
  579. if (id == IDM_DESELALL)
  580. SendMessage(hwndLB, LB_SETSEL, TRUE, (LONG)iSave);
  581. else if (GetParent(hwndActive) != hwndSearch) {
  582. /* Is the first item the [..] directory? */
  583. SendMessage(hwndLB, LB_GETTEXT, 0, (LPARAM)&lpmydta);
  584. if (lpmydta->my_dwAttrs & ATTR_PARENT)
  585. SendMessage(hwndLB, LB_SETSEL, 0, 0L);
  586. }
  587. SendMessage(hwndLB, WM_SETREDRAW, TRUE, 0L);
  588. InvalidateRect(hwndLB, NULL, FALSE);
  589. /* Emulate a SELCHANGE notification. */
  590. SendMessage(hwndActive, WM_COMMAND, GET_WM_COMMAND_MPS(0, hwndActive, LBN_SELCHANGE));
  591. }
  592. break;
  593. case IDM_EXIT:
  594. MSG("AppCommandProc", "IDM_EXIT");
  595. if (iReadLevel) {
  596. bCancelTree = 2;
  597. //break;
  598. }
  599. SheChangeDir(szOriginalDirPath);
  600. if (bSaveSettings)
  601. SaveWindows(hwndFrame);
  602. return FALSE;
  603. break;
  604. case IDM_LABEL:
  605. MSG("AppCommandProc", "IDM_LABEL");
  606. DialogBox(hAppInstance, MAKEINTRESOURCE(DISKLABELDLG), hwndFrame, DiskLabelDlgProc);
  607. break;
  608. case IDM_DISKCOPY:
  609. MSG("AppCommandProc", "IDM_DISKCOPY");
  610. if (nFloppies == 1) {
  611. iCurrentDrive = iFormatDrive = rgiDrive[0];
  612. } else {
  613. wSuperDlgMode = id;
  614. ret = (int)DialogBox(hAppInstance, MAKEINTRESOURCE(CHOOSEDRIVEDLG), hwndFrame, ChooseDriveDlgProc);
  615. if (ret < 1)
  616. break;
  617. }
  618. if (bConfirmFormat) {
  619. LoadString(hAppInstance, IDS_DISKCOPYCONFIRMTITLE, szTitle, sizeof(szTitle));
  620. LoadString(hAppInstance, IDS_DISKCOPYCONFIRM, szMessage, sizeof(szMessage));
  621. if (MessageBox(hwndFrame, szMessage, szTitle, MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON1) != IDYES)
  622. break;
  623. }
  624. if (CopyDiskette(hwndFrame, (WORD)iCurrentDrive, (WORD)iFormatDrive) <= 0) {
  625. if (!bUserAbort) {
  626. LoadString(hAppInstance, IDS_COPYDISKERR, szTitle, sizeof(szTitle));
  627. LoadString(hAppInstance, IDS_COPYDISKERRMSG, szMessage, sizeof(szMessage));
  628. MessageBox(hwndFrame, szMessage, szTitle, MB_OK | MB_ICONSTOP);
  629. }
  630. }
  631. break;
  632. case IDM_FORMAT:
  633. MSG("AppCommandProc", "IDM_FORMAT");
  634. FormatDiskette(hwndFrame);
  635. break;
  636. case IDM_SYSDISK:
  637. MSG("AppCommandProc", "IDM_SYSDISK");
  638. /*** FIX30: This ASSUMEs that A: is the first floppy drive in the system! ***/
  639. if (nFloppies == 1) {
  640. iFormatDrive = rgiDrive[0];
  641. LoadString(hAppInstance, IDS_SYSDISK, szTitle, sizeof(szTitle));
  642. LoadString(hAppInstance, IDS_SYSDISKRUSURE, szPath, sizeof(szPath));
  643. wsprintf(szMessage, szPath, 'A'+iFormatDrive);
  644. if (MessageBox(hwndFrame, szMessage, szTitle, MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
  645. break;
  646. } else {
  647. wSuperDlgMode = id;
  648. if (DialogBox(hAppInstance, MAKEINTRESOURCE(CHOOSEDRIVEDLG), hwndFrame, ChooseDriveDlgProc) < 1)
  649. break;
  650. }
  651. bUserAbort = FALSE;
  652. /* Display the Format dialog. */
  653. hdlgProgress = CreateDialog(hAppInstance, MAKEINTRESOURCE(SYSDISKPROGRESSDLG), hwndFrame, ProgressDlgProc);
  654. if (!hdlgProgress)
  655. goto SysDiskExit;
  656. EnableWindow(hwndFrame, FALSE);
  657. LoadString(hAppInstance, IDS_SYSDISKERR, szTitle, sizeof(szTitle));
  658. if (MakeSystemDiskette((WORD)iFormatDrive, FALSE)) {
  659. if (!bUserAbort) {
  660. LoadString(hAppInstance, IDS_SYSDISKADDERR, szMessage, sizeof(szMessage));
  661. MessageBox(hdlgProgress, szMessage, szTitle, MB_OK | MB_ICONSTOP);
  662. }
  663. }
  664. SysDiskExit:
  665. if (hdlgProgress) {
  666. EnableWindow(hwndFrame, TRUE);
  667. DestroyWindow(hdlgProgress);
  668. hdlgProgress = NULL;
  669. }
  670. break;
  671. case IDM_CONNECTIONS:
  672. MSG("AppCommandProc", "IDM_CONNECTIONS");
  673. ret = WNetConnectionDialog(hwndFrame, RESOURCETYPE_DISK);
  674. if ( ret == WN_SUCCESS )
  675. UpdateConnections();
  676. else if ( ret == WN_NO_NETWORK || ret == WN_NOT_SUPPORTED ) {
  677. DialogBox(hAppInstance, MAKEINTRESOURCE(CONNECTDLG), hwndFrame, ConnectDlgProc);
  678. } else if ( ret != WN_CANCEL ) {
  679. WNetErrorText((WORD)ret, szMessage, (WORD)sizeof(szMessage));
  680. LoadString(hAppInstance, IDS_NETERR, szTitle, sizeof(szTitle));
  681. MessageBox(hwndFrame, szMessage, szTitle, MB_OK | MB_ICONSTOP);
  682. }
  683. break;
  684. case IDM_EXPONE:
  685. MSG("AppCommandProc", "IDM_EXPONE");
  686. if (hwndT = HasTreeWindow(hwndActive))
  687. SendMessage(hwndT, TC_EXPANDLEVEL, FALSE, 0L);
  688. break;
  689. case IDM_EXPSUB:
  690. MSG("AppCommandProc", "IDM_EXPSUB");
  691. if (hwndT = HasTreeWindow(hwndActive))
  692. SendMessage(hwndT, TC_EXPANDLEVEL, TRUE, 0L);
  693. break;
  694. case IDM_EXPALL:
  695. MSG("AppCommandProc", "IDM_EXPALL");
  696. if (hwndT = HasTreeWindow(hwndActive))
  697. SendMessage(hwndT, TC_SETDRIVE, MAKEWORD(TRUE, 0), 0L);
  698. break;
  699. case IDM_COLLAPSE:
  700. MSG("AppCommandProc", "IDM_COLLAPSE");
  701. if (hwndT = HasTreeWindow(hwndActive))
  702. SendMessage(hwndT, TC_COLLAPSELEVEL, 0, 0L);
  703. break;
  704. case IDM_VNAME:
  705. MSG("AppCommandProc", "IDM_VNAME");
  706. wFlags = (WORD)(VIEW_NAMEONLY | (GetWindowLong(hwndActive, GWL_VIEW) & VIEW_PLUSES));
  707. id = CD_VIEW;
  708. goto ChangeDisplay;
  709. case IDM_VDETAILS:
  710. MSG("AppCommandProc", "IDM_VDETAILS");
  711. wFlags = (WORD)(VIEW_EVERYTHING | (GetWindowLong(hwndActive, GWL_VIEW) & VIEW_PLUSES));
  712. id = CD_VIEW;
  713. goto ChangeDisplay;
  714. case IDM_VOTHER:
  715. MSG("AppCommandProc", "IDM_VOTHER");
  716. DialogBox(hAppInstance, MAKEINTRESOURCE(OTHERDLG), hwndFrame, OtherDlgProc);
  717. break;
  718. case IDM_BYNAME:
  719. case IDM_BYTYPE:
  720. case IDM_BYSIZE:
  721. case IDM_BYDATE:
  722. MSG("AppCommandProc", "IDM_BYNAME/IDM_BYTYPE/IDM_BYSIZE/IDM_BYDATE");
  723. wFlags = (WORD)((id - IDM_BYNAME) + IDD_NAME);
  724. id = CD_SORT;
  725. ChangeDisplay:
  726. if (hwndT = HasDirWindow(hwndActive)) {
  727. SendMessage(hwndT, FS_CHANGEDISPLAY, id, MAKELONG(wFlags, 0));
  728. } else if (hwndActive == hwndSearch) {
  729. SetWindowLong(hwndActive, GWL_VIEW, wFlags);
  730. InvalidateRect(hwndActive, NULL, TRUE);
  731. }
  732. break;
  733. case IDM_VINCLUDE:
  734. MSG("AppCommandProc", "IDM_VINCLUDE");
  735. DialogBox(hAppInstance, MAKEINTRESOURCE(INCLUDEDLG), hwndFrame, IncludeDlgProc);
  736. break;
  737. case IDM_CONFIRM:
  738. MSG("AppCommandProc", "IDM_CONFIRM");
  739. DialogBox(hAppInstance, MAKEINTRESOURCE(CONFIRMDLG), hwndFrame, ConfirmDlgProc);
  740. break;
  741. case IDM_STATUSBAR:
  742. MSG("AppCommandProc", "IDM_STATUSBAR");
  743. {
  744. RECT rc;
  745. bTemp = bStatusBar = !bStatusBar;
  746. WritePrivateProfileBool(szStatusBar, bStatusBar);
  747. GetClientRect(hwndFrame, &rc);
  748. SendMessage(hwndFrame, WM_SIZE, SIZENORMAL, MAKELONG(rc.right, rc.bottom));
  749. UpdateStatus(hwndActive);
  750. InvalidateRect(hwndFrame, NULL, TRUE);
  751. goto CHECK_OPTION;
  752. break;
  753. }
  754. case IDM_FONT:
  755. MSG("AppCommandProc", "IDM_FONT");
  756. dwContext = IDH_FONT;
  757. NewFont();
  758. break;
  759. case IDM_ADDPLUSES:
  760. MSG("AppCommandProc", "IDM_ADDPLUSES");
  761. {
  762. HWND hwnd;
  763. WORD view;
  764. if (!(hwnd = HasTreeWindow(hwndActive)))
  765. break;
  766. // toggle pluses view bit
  767. view = (WORD)(GetWindowLong(hwndActive, GWL_VIEW) ^ VIEW_PLUSES);
  768. SetWindowLong(hwndActive, GWL_VIEW, view);
  769. if (view & VIEW_PLUSES) {
  770. // need to reread the tree to do this
  771. SendMessage(hwndActive, FS_GETDIRECTORY, sizeof(szPath), (LPARAM)szPath);
  772. SendMessage(hwnd, TC_SETDRIVE, MAKEWORD(FALSE, 0), (LPARAM)szPath);
  773. } else {
  774. // repaint only
  775. InvalidateRect(hwnd, NULL, FALSE);
  776. }
  777. bTemp = view & VIEW_PLUSES;
  778. goto CHECK_OPTION;
  779. }
  780. case IDM_SAVESETTINGS:
  781. MSG("AppCommandProc", "IDM_SAVESETTINGS");
  782. bTemp = bSaveSettings = !bSaveSettings;
  783. WritePrivateProfileBool(szSaveSettings, bSaveSettings);
  784. goto CHECK_OPTION;
  785. case IDM_MINONRUN:
  786. MSG("AppCommandProc", "IDM_MINONRUN");
  787. bTemp = bMinOnRun = !bMinOnRun;
  788. WritePrivateProfileBool(szMinOnRun, bMinOnRun);
  789. CHECK_OPTION:
  790. /* Check/Uncheck the menu item. */
  791. hMenu = GetSubMenu(GetMenu(hwndFrame), IDM_OPTIONS + bMaxed);
  792. CheckMenuItem(hMenu, id, (bTemp ? MF_CHECKED : MF_UNCHECKED));
  793. break;
  794. case IDM_NEWWINDOW:
  795. MSG("AppCommandProc", "IDM_NEWWINDOW");
  796. NewTree((INT)SendMessage(hwndActive, FS_GETDRIVE, 0, 0L) - 'A', hwndActive);
  797. break;
  798. case IDM_CASCADE:
  799. MSG("AppCommandProc", "IDM_CASCADE");
  800. SendMessage(hwndMDIClient, WM_MDICASCADE, 0L, 0L);
  801. break;
  802. case IDM_TILE:
  803. MSG("AppCommandProc", "IDM_TILE");
  804. SendMessage(hwndMDIClient, WM_MDITILE,
  805. GetKeyState(VK_SHIFT) < 0 ? 0 : 1, 0L);
  806. break;
  807. case IDM_ARRANGE:
  808. MSG("AppCommandProc", "IDM_ARRANGE");
  809. SendMessage(hwndMDIClient, WM_MDIICONARRANGE, 0L, 0L);
  810. break;
  811. case IDM_REFRESH:
  812. MSG("AppCommandProc", "IDM_REFRESH");
  813. {
  814. INT i;
  815. for (i = 0; i < iNumExtensions; i++) {
  816. (extensions[i].ExtProc)(hwndFrame, FMEVENT_USER_REFRESH, 0L);
  817. }
  818. InvalidateVolTypes();
  819. RefreshWindow(hwndActive);
  820. lFreeSpace = -1L; // update free space
  821. UpdateStatus(hwndActive);
  822. AddNetMenuItems();
  823. break;
  824. }
  825. case IDM_HELPINDEX:
  826. MSG("AppCommandProc", "IDM_HELPINDEX");
  827. wFlags = HELP_INDEX;
  828. goto ACPCallHelp;
  829. case IDM_HELPKEYS:
  830. MSG("AppCommandProc", "IDM_HELPKEYS");
  831. wFlags = HELP_PARTIALKEY;
  832. goto ACPCallHelp;
  833. case IDM_HELPHELP:
  834. MSG("AppCommandProc", "IDM_HELPHELP");
  835. wFlags = HELP_HELPONHELP;
  836. goto ACPCallHelp;
  837. ACPCallHelp:
  838. SheChangeDir(szOriginalDirPath);
  839. if (!WinHelp(hwndFrame, szWinObjHelp, wFlags, (ULONG_PTR)szNULL)) {
  840. MyMessageBox(hwndFrame, IDS_WINFILE, IDS_WINHELPERR, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL);
  841. }
  842. break;
  843. case IDM_ABOUT:
  844. MSG("AppCommandProc", "IDM_ABOUT");
  845. LoadString(hAppInstance, IDS_WINFILE, szTitle, sizeof(szTitle));
  846. ShellAbout(hwndFrame, szTitle, NULL, NULL);
  847. break;
  848. case IDM_DRIVESMORE:
  849. MSG("AppCommandProc", "IDM_DRIVESMORE");
  850. DialogBox(hAppInstance, MAKEINTRESOURCE(DRIVEDLG), hwndFrame, DrivesDlgProc);
  851. break;
  852. default:
  853. DEFMSG("AppCommandProc", id);
  854. {
  855. INT i;
  856. for (i = 0; i < iNumExtensions; i++) {
  857. WORD delta = extensions[i].Delta;
  858. if ((id >= delta) && (id < (WORD)(delta + 100))) {
  859. (extensions[i].ExtProc)(hwndFrame, (WORD)(id - delta), 0L);
  860. break;
  861. }
  862. }
  863. }
  864. return FALSE;
  865. }
  866. return TRUE;
  867. }
  868. VOID
  869. AddNetMenuItems(VOID)
  870. {
  871. HMENU hMenu;
  872. hMenu = GetMenu(hwndFrame);
  873. // add only if net menuitems do not already exist
  874. if ((GetMenuState(hMenu, IDM_CONNECT, MF_BYCOMMAND) == -1) &&
  875. (GetMenuState(hMenu, IDM_CONNECTIONS, MF_BYCOMMAND) == -1)) {
  876. InitNetMenuItems();
  877. }
  878. }
  879. VOID
  880. InitNetMenuItems(VOID)
  881. {
  882. HMENU hMenu;
  883. UINT i;
  884. INT iMax;
  885. CHAR szValue[MAXPATHLEN];
  886. HWND hwndActive;
  887. hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L);
  888. if (hwndActive && GetWindowLong(hwndActive, GWL_STYLE) & WS_MAXIMIZE)
  889. iMax = 1;
  890. else
  891. iMax = 0;
  892. hMenu = GetMenu(hwndFrame);
  893. // No. Now add net items if net has been started.
  894. i = (WORD)WNetGetCaps(WNNC_DIALOG);
  895. bConnect = i & WNNC_DLG_ConnectDialog; // note, these should both
  896. bDisconnect = i & WNNC_DLG_DisconnectDialog; // be true or both false
  897. // use submenu because we are doing this by position
  898. hMenu = GetSubMenu(hMenu, IDM_DISK + iMax);
  899. if (i)
  900. InsertMenu(hMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
  901. if (bConnect && bDisconnect) {
  902. // lanman style double connect/disconnect
  903. LoadString(hAppInstance, IDS_CONNECT, szValue, sizeof(szValue));
  904. InsertMenu(hMenu, 6, MF_BYPOSITION | MF_STRING, IDM_CONNECT, szValue);
  905. LoadString(hAppInstance, IDS_DISCONNECT, szValue, sizeof(szValue));
  906. InsertMenu(hMenu, 7, MF_BYPOSITION | MF_STRING, IDM_DISCONNECT, szValue);
  907. } else if (WNetGetCaps(WNNC_CONNECTION)) {
  908. // our style
  909. LoadString(hAppInstance, IDS_CONNECTIONS, szValue, sizeof(szValue));
  910. InsertMenu(hMenu, 6, MF_BYPOSITION | MF_STRING, IDM_CONNECTIONS, szValue);
  911. }
  912. }