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.

1053 lines
38 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* WINFILE.C - */
  4. /* */
  5. /* Windows File System Application */
  6. /* */
  7. /****************************************************************************/
  8. #define NO_WF_GLOBALS
  9. #include "winfile.h"
  10. #include "winnet.h"
  11. #include "lfn.h"
  12. #include "stdlib.h"
  13. /*--------------------------------------------------------------------------*/
  14. /* */
  15. /* Global Variables - */
  16. /* */
  17. /*--------------------------------------------------------------------------*/
  18. BOOL bNetAdmin = FALSE;
  19. BOOL bMinOnRun = FALSE;
  20. BOOL bStatusBar = TRUE;
  21. BOOL bConfirmDelete = TRUE;
  22. BOOL bConfirmSubDel = TRUE;
  23. BOOL bConfirmReplace = TRUE;
  24. BOOL bConfirmMouse = TRUE;
  25. BOOL bConfirmFormat = TRUE;
  26. BOOL bSearchSubs = TRUE;
  27. BOOL bUserAbort = FALSE;
  28. BOOL bConnect = FALSE;
  29. BOOL bDisconnect = FALSE;
  30. BOOL bFileSysChanging = FALSE;
  31. BOOL fShowSourceBitmaps = TRUE;
  32. BOOL bMultiple; // used to indicate multiple selection
  33. BOOL bFSCTimerSet = FALSE;
  34. BOOL bStoleTreeData = FALSE;
  35. BOOL bSaveSettings = TRUE;
  36. CHAR chFirstDrive; /* 'A' or 'a' */
  37. CHAR szExtensions[] = "Extensions";
  38. CHAR szFrameClass[] = "WOS_Frame";
  39. CHAR szTreeClass[] = "WOS_Tree";
  40. CHAR szDrivesClass[] = "WOS_Drives";
  41. CHAR szTreeControlClass[] = "DirTree";
  42. CHAR szDirClass[] = "WOS_Dir";
  43. CHAR szSearchClass[] = "WOS_Search";
  44. CHAR szMinOnRun[] = "MinOnRun";
  45. CHAR szStatusBar[] = "StatusBar";
  46. CHAR szSaveSettings[] = "Save Settings";
  47. CHAR szConfirmDelete[] = "ConfirmDelete";
  48. CHAR szConfirmSubDel[] = "ConfirmSubDel";
  49. CHAR szConfirmReplace[] = "ConfirmReplace";
  50. CHAR szConfirmMouse[] = "ConfirmMouse";
  51. CHAR szConfirmFormat[] = "ConfirmFormat";
  52. CHAR szDirKeyFormat[] = "dir%d";
  53. CHAR szWindow[] = "Window";
  54. CHAR szFace[] = "Face";
  55. CHAR szSize[] = "Size";
  56. CHAR szLowerCase[] = "LowerCase";
  57. CHAR szAddons[] = "AddOns";
  58. CHAR szUndelete[] = "UNDELETE.DLL";
  59. CHAR szDefPrograms[] = "EXE COM BAT PIF";
  60. CHAR szINIFile[] = "WINOBJ.INI";
  61. CHAR szWindows[] = "Windows";
  62. CHAR szPrevious[] = "Previous";
  63. CHAR szSettings[] = "Settings";
  64. CHAR szInternational[] = "Intl";
  65. CHAR szStarDotStar[] = "*.*";
  66. CHAR szNULL[] = "";
  67. CHAR szBlank[] = " ";
  68. CHAR szEllipses[] = "...";
  69. CHAR szReservedMarker[] = "FAT16 ";
  70. CHAR szNetwork[] = "Network";
  71. CHAR szDirsRead[32];
  72. CHAR szCurrentFileSpec[14] = "*.*";
  73. CHAR szShortDate[11] = "MM/dd/yy";
  74. CHAR szTime[2] = ":";
  75. CHAR sz1159[9] = "AM";
  76. CHAR sz2359[9] = "PM";
  77. CHAR szComma[2] = ",";
  78. CHAR szListbox[] = "ListBox"; // window style
  79. CHAR szTheINIFile[64+12+3];
  80. CHAR szTitle[128];
  81. CHAR szMessage[MAXMESSAGELEN+1];
  82. CHAR szSearch[MAXPATHLEN+1];
  83. CHAR szStatusTree[80];
  84. CHAR szStatusDir[80];
  85. CHAR szOriginalDirPath[64+12+3]; /* OEM string!!!!!! */
  86. CHAR szBytes[10];
  87. CHAR szSBytes[10];
  88. EFCB VolumeEFCB ={
  89. 0xFF,
  90. 0, 0, 0, 0, 0,
  91. ATTR_VOLUME,
  92. 0,
  93. '?','?','?','?','?','?','?','?','?','?','?',
  94. 0, 0, 0, 0, 0,
  95. '?','?','?','?','?','?','?','?','?','?','?',
  96. 0, 0, 0, 0, 0, 0, 0, 0, 0
  97. };
  98. INT cDrives;
  99. INT dxDrive;
  100. INT dyDrive;
  101. INT dxDriveBitmap;
  102. INT dyDriveBitmap;
  103. INT dxEllipses;
  104. INT dxFolder;
  105. INT dyFolder;
  106. INT dyBorder; /* System Border Width/Height */
  107. INT dyBorderx2; /* System Border Width/Height * 2 */
  108. INT dyStatus; /* Status Bar height */
  109. INT dxStatusField;
  110. INT dxText; /* System Font Width 'M' */
  111. INT dyText; /* System Font Height */
  112. //INT dxFileName;
  113. INT dyFileName;
  114. INT iCurrentDrive; /* Logical # of the current drive */
  115. INT iFormatDrive; /* Logical # of the drive to format */
  116. INT nFloppies; /* Number of Removable Drives */
  117. INT rgiDrive[26];
  118. INT rgiDriveType[26];
  119. VOLINFO *(apVolInfo[26]);
  120. INT rgiDrivesOffset[26];
  121. INT iSelHilite = -1;
  122. INT iTime = 0; /* Default to 12-hour time */
  123. INT iTLZero = TRUE; /* Default to leading zeros */
  124. INT cDisableFSC = 0; /* has fsc been disabled? */
  125. INT iReadLevel = 0; // global. if !0 someone is reading a tree
  126. INT dxFrame;
  127. INT dxClickRect;
  128. INT dyClickRect;
  129. BOOL bCancelTree;
  130. HANDLE hAccel = NULL;
  131. HANDLE hAppInstance;
  132. HBITMAP hbmBitmaps = NULL;
  133. HDC hdcMem = NULL;
  134. INT iCurDrag = 0;
  135. HICON hicoTree = NULL;
  136. HICON hicoTreeDir = NULL;
  137. HICON hicoDir = NULL;
  138. HWND hdlgProgress;
  139. HWND hwndFrame = NULL;
  140. HWND hwndMDIClient = NULL;
  141. HWND hwndSearch = NULL;
  142. HWND hwndDragging = NULL;
  143. LPSTR szPrograms;
  144. LPSTR szDocuments;
  145. WORD wTextAttribs = TA_LOWERCASE;
  146. WORD wSuperDlgMode;
  147. WORD wFATSector = (WORD)0xFFFF;
  148. WORD wFATMode = 0;
  149. WORD wDOSversion;
  150. UINT wHelpMessage;
  151. UINT wBrowseMessage;
  152. WORD xTreeMax = 0; // current width of widest tree window
  153. WORD wNewView = VIEW_NAMEONLY;
  154. WORD wNewSort = IDD_NAME;
  155. DWORD dwNewAttribs = ATTR_DEFAULT;
  156. LONG lFreeSpace = -1L;
  157. LONG lTotalSpace = -1L;
  158. HFONT hFont;
  159. HFONT hFontStatus;
  160. CHAR szWinObjHelp[] = "WINOBJ.HLP";
  161. INT iNumExtensions = 0;
  162. EXTENSION extensions[MAX_EXTENSIONS];
  163. FM_UNDELETE_PROC lpfpUndelete = NULL;
  164. BOOL EnablePropertiesMenu (HWND,PSTR);
  165. HHOOK hhkMessageFilter = NULL;
  166. WORD wMenuID = 0;
  167. HMENU hMenu = 0;
  168. WORD wMenuFlags = 0;
  169. DWORD dwContext = 0L;
  170. HANDLE hModUndelete = NULL;
  171. /*--------------------------------------------------------------------------*/
  172. /* */
  173. /* WinMain() - */
  174. /* */
  175. /*--------------------------------------------------------------------------*/
  176. MMain(
  177. hInst,
  178. hPrevInst,
  179. lpCmdLine,
  180. nCmdShow
  181. )
  182. //{
  183. MSG msg;
  184. FBREAK(BF_START);
  185. ENTER("MMain");
  186. PRINT(BF_PARMTRACE, "lpCmdLine=%s", lpCmdLine);
  187. PRINT(BF_PARMTRACE, "nCmdShow=%ld", IntToPtr(nCmdShow));
  188. if (!InitFileManager(hInst, hPrevInst, lpCmdLine, nCmdShow)) {
  189. FreeFileManager();
  190. return FALSE;
  191. }
  192. while (GetMessage(&msg, NULL, 0, 0)) {
  193. // since we use RETURN as an accelerator we have to manually
  194. // restore ourselves when we see VK_RETURN and we are minimized
  195. if (msg.message == WM_SYSKEYDOWN && msg.wParam == VK_RETURN && IsIconic(hwndFrame)) {
  196. ShowWindow(hwndFrame, SW_NORMAL);
  197. } else {
  198. if (!TranslateMDISysAccel(hwndMDIClient, &msg) &&
  199. (!hwndFrame || !TranslateAccelerator(hwndFrame, hAccel, &msg))) {
  200. TranslateMessage(&msg);
  201. DispatchMessage(&msg);
  202. }
  203. }
  204. }
  205. FreeFileManager();
  206. LEAVE("MMain");
  207. return (int)msg.wParam;
  208. }
  209. VOID
  210. NoRunInLongDir(
  211. HWND hwndActive,
  212. HMENU hMenu
  213. )
  214. {
  215. char szTemp[MAXPATHLEN];
  216. WORD wMenuFlags;
  217. // cannot run in a long directory
  218. SendMessage(hwndActive, FS_GETDIRECTORY, MAXPATHLEN, (LPARAM)szTemp);
  219. StripBackslash(szTemp);
  220. //wMenuFlags = IsLFN(szTemp) ? MF_BYCOMMAND | MF_GRAYED
  221. // : MF_BYCOMMAND | MF_ENABLED;
  222. wMenuFlags = MF_BYCOMMAND | MF_ENABLED;
  223. EnableMenuItem(hMenu, IDM_RUN, wMenuFlags);
  224. }
  225. /*--------------------------------------------------------------------------*/
  226. /* */
  227. /* FrameWndProc() - */
  228. /* */
  229. /*--------------------------------------------------------------------------*/
  230. INT_PTR
  231. APIENTRY
  232. FrameWndProc(
  233. HWND hWnd,
  234. UINT wMsg,
  235. WPARAM wParam,
  236. LPARAM lParam
  237. )
  238. {
  239. RECT rc;
  240. HMENU hMenu = NULL;
  241. STKCHK();
  242. switch (wMsg) {
  243. case WM_CREATE:
  244. TRACE(BF_WM_CREATE, "FrameWndProc - WM_CREATE");
  245. {
  246. CLIENTCREATESTRUCT ccs;
  247. /* Store the Frame's hwnd. */
  248. hwndFrame = hWnd;
  249. // ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), IDM_WINDOW);
  250. // the extensions haven't been loaded yet so the window
  251. // menu is in the position of the first extensions menu
  252. ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), IDM_EXTENSIONS);
  253. ccs.idFirstChild = IDM_CHILDSTART;
  254. // create the MDI client at aproximate size to make sure
  255. // "run minimized" works
  256. GetClientRect(hwndFrame, &rc);
  257. hwndMDIClient = CreateWindow("MDIClient", NULL,
  258. WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_BORDER,
  259. // -dyBorder, -dyBorder,
  260. // rc.right + dyBorder,
  261. // rc.bottom - dyBorder - (bStatusBar ? dyStatus + dyBorder : 0),
  262. 0, 0, rc.right, rc.bottom,
  263. hWnd, (HMENU)1, hAppInstance, (LPSTR)&ccs);
  264. if (!hwndMDIClient) {
  265. MSG("FrameWndProc", "WM_CREATE failed!");
  266. return -1L;
  267. }
  268. break;
  269. }
  270. case WM_INITMENUPOPUP:
  271. MSG("FrameWndProc", "WM_INITMENUPOPUP");
  272. {
  273. BOOL bMaxed;
  274. WORD wSort;
  275. WORD wView;
  276. WORD wMenuFlags;
  277. HWND hwndActive;
  278. HWND hwndTree, hwndDir;
  279. BOOL bLFN;
  280. hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L);
  281. if (hwndActive && GetWindowLong(hwndActive, GWL_STYLE) & WS_MAXIMIZE)
  282. bMaxed = 1;
  283. else
  284. bMaxed = 0;
  285. hwndTree = HasTreeWindow(hwndActive);
  286. hwndDir = HasDirWindow(hwndActive);
  287. wSort = (WORD)GetWindowLong(hwndActive, GWL_SORT);
  288. wView = (WORD)GetWindowLong(hwndActive, GWL_VIEW);
  289. hMenu = (HMENU)wParam;
  290. wMenuFlags = MF_BYCOMMAND | MF_ENABLED;
  291. // bLFN = IsLFNSelected();
  292. bLFN = FALSE; // For now, ignore the case.
  293. switch (LOWORD(lParam)-bMaxed) {
  294. case IDM_FILE:
  295. MSG("FrameWndProc", "IDM_FILE");
  296. {
  297. LPSTR pSel;
  298. BOOL fDir;
  299. if (!hwndDir)
  300. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  301. // EnableMenuItem(hMenu, IDM_PRINT, wMenuFlags);
  302. EnableMenuItem(hMenu, IDM_SELALL, wMenuFlags);
  303. EnableMenuItem(hMenu, IDM_DESELALL, wMenuFlags);
  304. if (hwndActive == hwndSearch || hwndDir)
  305. wMenuFlags = MF_BYCOMMAND;
  306. else
  307. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  308. // EnableMenuItem(hMenu, IDM_ATTRIBS, wMenuFlags);
  309. EnableMenuItem(hMenu, IDM_SELECT, wMenuFlags);
  310. pSel = (LPSTR)SendMessage(hwndActive, FS_GETSELECTION, 1, (LPARAM)&fDir);
  311. // can't print an lfn thing or a directory.
  312. wMenuFlags = (WORD)((bLFN || fDir)
  313. ? MF_BYCOMMAND | MF_DISABLED | MF_GRAYED
  314. : MF_BYCOMMAND | MF_ENABLED);
  315. EnableMenuItem(hMenu, IDM_PRINT, wMenuFlags);
  316. // can't open an LFN file but can open an LFN dir
  317. wMenuFlags = (WORD)((bLFN && !fDir)
  318. ? MF_BYCOMMAND | MF_DISABLED | MF_GRAYED
  319. : MF_BYCOMMAND | MF_ENABLED);
  320. EnableMenuItem(hMenu, IDM_OPEN, wMenuFlags);
  321. // See if we can enable the Properties... menu
  322. if (EnablePropertiesMenu (hwndActive,pSel))
  323. wMenuFlags = MF_BYCOMMAND;
  324. else
  325. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  326. EnableMenuItem (hMenu, IDM_ATTRIBS, wMenuFlags);
  327. LocalFree((HANDLE)pSel);
  328. NoRunInLongDir(hwndActive, hMenu);
  329. break;
  330. }
  331. case IDM_DISK:
  332. MSG("FrameWndProc", "IDM_DISK");
  333. // be sure not to allow disconnect while any trees
  334. // are still being read (iReadLevel != 0)
  335. if (bDisconnect) {
  336. INT i;
  337. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  338. if (!iReadLevel) {
  339. for (i=0; i < cDrives; i++) {
  340. wParam = rgiDrive[i];
  341. if ((!IsCDRomDrive((INT)wParam)) && (IsNetDrive((INT)wParam))) {
  342. wMenuFlags = MF_BYCOMMAND | MF_ENABLED;
  343. break;
  344. }
  345. }
  346. }
  347. EnableMenuItem(hMenu, IDM_DISCONNECT, wMenuFlags);
  348. } else {
  349. if (iReadLevel)
  350. EnableMenuItem(hMenu, IDM_CONNECTIONS, MF_BYCOMMAND | MF_GRAYED);
  351. else
  352. EnableMenuItem(hMenu, IDM_CONNECTIONS, MF_BYCOMMAND | MF_ENABLED);
  353. }
  354. break;
  355. case IDM_TREE:
  356. MSG("FrameWndProc", "IDM_TREE");
  357. if (!hwndTree || iReadLevel)
  358. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  359. EnableMenuItem(hMenu, IDM_EXPONE, wMenuFlags);
  360. EnableMenuItem(hMenu, IDM_EXPSUB, wMenuFlags);
  361. EnableMenuItem(hMenu, IDM_EXPALL, wMenuFlags);
  362. EnableMenuItem(hMenu, IDM_COLLAPSE, wMenuFlags);
  363. EnableMenuItem(hMenu, IDM_ADDPLUSES, wMenuFlags);
  364. if (hwndTree)
  365. CheckMenuItem(hMenu, IDM_ADDPLUSES, GetWindowLong(hwndActive, GWL_VIEW) & VIEW_PLUSES ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  366. break;
  367. case IDM_VIEW:
  368. MSG("FrameWndProc", "IDM_VIEW");
  369. EnableMenuItem(hMenu, IDM_VNAME, wMenuFlags);
  370. EnableMenuItem(hMenu, IDM_VDETAILS, wMenuFlags);
  371. EnableMenuItem(hMenu, IDM_VOTHER, wMenuFlags);
  372. if (hwndActive == hwndSearch || IsIconic(hwndActive))
  373. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  374. else {
  375. CheckMenuItem(hMenu, IDM_BOTH, hwndTree && hwndDir ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  376. CheckMenuItem(hMenu, IDM_DIRONLY, !hwndTree && hwndDir ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  377. CheckMenuItem(hMenu, IDM_TREEONLY, hwndTree && !hwndDir ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  378. }
  379. EnableMenuItem(hMenu, IDM_BOTH, wMenuFlags);
  380. EnableMenuItem(hMenu, IDM_TREEONLY, wMenuFlags);
  381. EnableMenuItem(hMenu, IDM_DIRONLY, wMenuFlags);
  382. EnableMenuItem(hMenu, IDM_SPLIT, wMenuFlags);
  383. EnableMenuItem(hMenu, IDM_VINCLUDE, wMenuFlags);
  384. wView &= VIEW_EVERYTHING;
  385. CheckMenuItem(hMenu, IDM_VNAME, (wView == VIEW_NAMEONLY) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  386. CheckMenuItem(hMenu, IDM_VDETAILS,(wView == VIEW_EVERYTHING) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  387. CheckMenuItem(hMenu, IDM_VOTHER, (wView != VIEW_NAMEONLY && wView != VIEW_EVERYTHING) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  388. CheckMenuItem(hMenu, IDM_BYNAME, (wSort == IDD_NAME) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  389. CheckMenuItem(hMenu, IDM_BYTYPE, (wSort == IDD_TYPE) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  390. CheckMenuItem(hMenu, IDM_BYSIZE, (wSort == IDD_SIZE) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  391. CheckMenuItem(hMenu, IDM_BYDATE, (wSort == IDD_DATE) ? MF_CHECKED | MF_BYCOMMAND : MF_UNCHECKED | MF_BYCOMMAND);
  392. if (hwndDir)
  393. wMenuFlags = MF_BYCOMMAND | MF_ENABLED;
  394. else
  395. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  396. EnableMenuItem(hMenu, IDM_BYNAME, wMenuFlags);
  397. EnableMenuItem(hMenu, IDM_BYTYPE, wMenuFlags);
  398. EnableMenuItem(hMenu, IDM_BYSIZE, wMenuFlags);
  399. EnableMenuItem(hMenu, IDM_BYDATE, wMenuFlags);
  400. break;
  401. case IDM_OPTIONS:
  402. MSG("FrameWndProc", "IDM_OPTIONS");
  403. if (iReadLevel)
  404. wMenuFlags = MF_BYCOMMAND | MF_GRAYED;
  405. EnableMenuItem(hMenu, IDM_ADDPLUSES, wMenuFlags);
  406. EnableMenuItem(hMenu, IDM_EXPANDTREE, wMenuFlags);
  407. break;
  408. default:
  409. MSG("FrameWndProc", "default WM_COMMAND");
  410. {
  411. INT pos = (INT)LOWORD(lParam) - bMaxed;
  412. INT index;
  413. if ((pos >= IDM_EXTENSIONS) && (pos < (iNumExtensions + IDM_EXTENSIONS))) {
  414. // HIWORD(lParam) is the menu handle
  415. // LOWORD(lParam) is menu item delta. DLL should
  416. // add this to it's menu id if it want's to
  417. // change the menu.
  418. index = pos - IDM_EXTENSIONS;
  419. (extensions[index].ExtProc)(hwndFrame, FMEVENT_INITMENU, (LPARAM)(hMenu));
  420. }
  421. break;
  422. }
  423. }
  424. break;
  425. }
  426. case WM_PAINT:
  427. MSG("FrameWndProc", "WM_PAINT");
  428. {
  429. HDC hdc;
  430. RECT rcTemp;
  431. HBRUSH hBrush;
  432. PAINTSTRUCT ps;
  433. BOOL bEGA;
  434. HFONT hFontOld;
  435. hdc = BeginPaint(hWnd, &ps);
  436. if (!IsIconic(hWnd) && bStatusBar) {
  437. GetClientRect(hWnd, &rc);
  438. hFontOld = SelectObject(hdc, hFontStatus);
  439. // status area, leave room for the top border
  440. rc.top = rc.bottom - dyStatus + dyBorder;
  441. bEGA = GetNearestColor(hdc, GetSysColor(COLOR_BTNHIGHLIGHT)) ==
  442. GetNearestColor(hdc, GetSysColor(COLOR_BTNFACE));
  443. if (!bEGA) {
  444. // displays with button shadows
  445. // draw the frame
  446. if (hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE))) {
  447. // top bottom
  448. rcTemp = rc;
  449. rcTemp.bottom = rcTemp.top + dyBorderx2;
  450. FillRect(hdc, &rcTemp, hBrush);
  451. rcTemp = rc;
  452. rcTemp.top = rcTemp.bottom - dyBorderx2;
  453. FillRect(hdc, &rcTemp, hBrush);
  454. // left right
  455. rcTemp = rc;
  456. rcTemp.right = 8 * dyBorder;
  457. FillRect(hdc, &rcTemp, hBrush);
  458. rcTemp = rc;
  459. rcTemp.left = dxStatusField * 2 - 8 * dyBorder;
  460. FillRect(hdc, &rcTemp, hBrush);
  461. // middle
  462. rcTemp = rc;
  463. rcTemp.left = dxStatusField - 4 * dyBorder;
  464. rcTemp.right = dxStatusField + 4 * dyBorder;
  465. FillRect(hdc, &rcTemp, hBrush);
  466. DeleteObject(hBrush);
  467. }
  468. // shadow
  469. if (hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW))) {
  470. // left
  471. rcTemp.left = 8 * dyBorder;
  472. rcTemp.right = dxStatusField - 4 * dyBorder;
  473. rcTemp.top = rc.top + dyBorderx2;
  474. rcTemp.bottom = rcTemp.top + dyBorder;
  475. FillRect(hdc, &rcTemp, hBrush);
  476. // right
  477. rcTemp.left = dxStatusField + 4 * dyBorder;
  478. rcTemp.right = dxStatusField * 2 - 8 * dyBorder;
  479. FillRect(hdc, &rcTemp, hBrush);
  480. // left side 1
  481. rcTemp = rc;
  482. rcTemp.left = 8 * dyBorder;
  483. rcTemp.right = rcTemp.left + dyBorder;
  484. rcTemp.top += dyBorderx2;
  485. rcTemp.bottom -= dyBorderx2;
  486. FillRect(hdc, &rcTemp, hBrush);
  487. // left side 2
  488. rcTemp.left = dxStatusField + 4 * dyBorder;
  489. rcTemp.right = rcTemp.left + dyBorder;
  490. FillRect(hdc, &rcTemp, hBrush);
  491. DeleteObject(hBrush);
  492. }
  493. // the hilight
  494. // hilight
  495. if (hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNHIGHLIGHT))) {
  496. // left
  497. rcTemp.left = 8 * dyBorder;
  498. rcTemp.right = dxStatusField - 4 * dyBorder;
  499. rcTemp.top = rc.bottom - 3 * dyBorder;
  500. rcTemp.bottom = rcTemp.top + dyBorder;
  501. FillRect(hdc, &rcTemp, hBrush);
  502. // right
  503. rcTemp.left = dxStatusField + 4 * dyBorder;
  504. rcTemp.right = dxStatusField * 2 - 8 * dyBorder;
  505. FillRect(hdc, &rcTemp, hBrush);
  506. // left side 1
  507. rcTemp = rc;
  508. rcTemp.left = dxStatusField - 5 * dyBorder;
  509. rcTemp.right = rcTemp.left + dyBorder;
  510. rcTemp.top += dyBorderx2;
  511. rcTemp.bottom -= dyBorderx2;
  512. FillRect(hdc, &rcTemp, hBrush);
  513. // left side 2
  514. rcTemp.left = 2 * dxStatusField - 9 * dyBorder;
  515. rcTemp.right = rcTemp.left + dyBorder;
  516. FillRect(hdc, &rcTemp, hBrush);
  517. DeleteObject(hBrush);
  518. }
  519. }
  520. // solid black line across top (above the status rc)
  521. if (hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNTEXT))) {
  522. rcTemp = rc;
  523. rcTemp.bottom = rcTemp.top;
  524. rcTemp.top -= dyBorder;
  525. FillRect(hdc, &rcTemp, hBrush);
  526. DeleteObject(hBrush);
  527. }
  528. // set the text and background colors
  529. SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
  530. SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
  531. // now the text, with a gray background
  532. rcTemp.top = rc.top + 3 * dyBorder;
  533. rcTemp.bottom = rc.bottom - 3 * dyBorder;
  534. rcTemp.left = 9 * dyBorder;
  535. rcTemp.right = dxStatusField - 5 * dyBorder;
  536. ExtTextOut(hdc, rcTemp.left + dyBorderx2, rcTemp.top,
  537. ETO_OPAQUE | ETO_CLIPPED, bEGA ? &rc : &rcTemp, szStatusTree, lstrlen(szStatusTree), NULL);
  538. rcTemp.left = dxStatusField + 5 * dyBorder;
  539. rcTemp.right = dxStatusField * 2 - 9 * dyBorder;
  540. ExtTextOut(hdc, rcTemp.left + dyBorderx2, rcTemp.top,
  541. bEGA ? ETO_CLIPPED : ETO_OPAQUE | ETO_CLIPPED, &rcTemp, szStatusDir, lstrlen(szStatusDir), NULL);
  542. if (hFontOld)
  543. SelectObject(hdc, hFontOld);
  544. }
  545. EndPaint(hWnd, &ps);
  546. break;
  547. }
  548. case WM_DESTROY:
  549. MSG("FrameWndProc", "WM_DESTROY");
  550. //FileCDR(NULL);
  551. if (!WinHelp(hwndFrame, szWinObjHelp, HELP_QUIT, 0L)) {
  552. MyMessageBox(hwndFrame, IDS_WINFILE, IDS_WINHELPERR, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL);
  553. }
  554. hwndFrame = NULL;
  555. PostQuitMessage(0);
  556. break;
  557. case WM_SIZE:
  558. MSG("FrameWndProc", "WM_SIZE");
  559. if (wParam != SIZEICONIC) {
  560. INT dx, dy;
  561. // make things look good by putting WS_BORDER on the
  562. // client, then adjust the thing so it gets clipped
  563. dx = LOWORD(lParam) + 2 * dyBorder;
  564. dy = HIWORD(lParam) + 2 * dyBorder;
  565. if (bStatusBar)
  566. dy -= dyStatus;
  567. MoveWindow(hwndMDIClient, -dyBorder, -dyBorder, dx, dy, TRUE);
  568. if (bStatusBar) {
  569. GetClientRect(hwndFrame, &rc);
  570. rc.top = rc.bottom - dyStatus;
  571. InvalidateRect(hWnd, &rc, TRUE);
  572. }
  573. }
  574. break;
  575. case WM_TIMER:
  576. MSG("FrameWndProc", "WM_TIMER");
  577. // this came from a FSC that wasn't generated by us
  578. bFSCTimerSet = FALSE;
  579. KillTimer(hWnd, 1);
  580. EnableFSC();
  581. break;
  582. case WM_FILESYSCHANGE:
  583. MSG("FrameWndProc", "WM_FILESYSCHANGE");
  584. {
  585. LPSTR lpTo;
  586. // if its a rename (including those trapped by kernel)
  587. // find the destination
  588. if (wParam == FSC_RENAME || wParam == 0x8056) {
  589. if (wParam == 0x8056)
  590. lpTo = (LPSTR)LOWORD(lParam);
  591. else
  592. lpTo = (LPSTR)lParam;
  593. while (*lpTo++)
  594. ;
  595. } else
  596. lpTo = NULL;
  597. ChangeFileSystem((WORD)wParam, (LPSTR)lParam, lpTo);
  598. break;
  599. }
  600. case WM_SYSCOLORCHANGE:
  601. case WM_WININICHANGE:
  602. MSG("FrameWndProc", "WM_SYSCOLORCHANGE/WININICHANGE");
  603. if (!lParam || !lstrcmpi((LPSTR)lParam, szInternational)) {
  604. HWND hwnd;
  605. GetInternational();
  606. for (hwnd = GetWindow(hwndMDIClient,GW_CHILD);
  607. hwnd;
  608. hwnd = GetWindow(hwnd,GW_HWNDNEXT)) {
  609. if (!GetWindow(hwnd, GW_OWNER))
  610. InvalidateRect(hwnd, NULL, TRUE);
  611. }
  612. }
  613. if (!lParam || !lstrcmpi((LPSTR)lParam, "colors")) { // win.ini section [colors]
  614. HWND hwnd;
  615. DeleteBitmaps();
  616. LoadBitmaps();
  617. InitDriveBitmaps(); // reset the drive bitmaps
  618. // we need to recread the drives windows to change
  619. // the bitmaps
  620. for (hwnd = GetWindow(hwndMDIClient,GW_CHILD);
  621. hwnd;
  622. hwnd = GetWindow(hwnd,GW_HWNDNEXT)) {
  623. if (!GetWindow(hwnd, GW_OWNER))
  624. SendMessage(hwnd, FS_CHANGEDRIVES, 0, 0L);
  625. }
  626. }
  627. break;
  628. case FM_GETFOCUS:
  629. case FM_GETDRIVEINFO:
  630. case FM_GETSELCOUNT:
  631. case FM_GETSELCOUNTLFN:
  632. case FM_GETFILESEL:
  633. case FM_GETFILESELLFN:
  634. case FM_REFRESH_WINDOWS:
  635. case FM_RELOAD_EXTENSIONS:
  636. return ExtensionMsgProc(wMsg, wParam, lParam);
  637. break;
  638. case WM_MENUSELECT:
  639. MSG("FrameWndProc", "WM_MENUSELECT");
  640. if (GET_WM_MENUSELECT_HMENU(wParam, lParam)) {
  641. // Save the menu the user selected
  642. wMenuID = GET_WM_MENUSELECT_CMD(wParam, lParam);
  643. wMenuFlags = GET_WM_MENUSELECT_FLAGS(wParam, lParam);
  644. hMenu = GET_WM_MENUSELECT_HMENU(wParam, lParam);
  645. if (wMenuID >= IDM_CHILDSTART && wMenuID < IDM_HELPINDEX)
  646. wMenuID = IDM_CHILDSTART;
  647. }
  648. break;
  649. case WM_ENDSESSION:
  650. if (wParam) {
  651. #ifdef ORGCODE
  652. /* Yeah, I know I shouldn't have to save this, but I don't
  653. * trust anybody
  654. */
  655. BOOL bSaveExit = bExitWindows;
  656. bExitWindows = FALSE;
  657. /* Simulate an exit command to clean up, but don't display
  658. * the "are you sure you want to exit", since somebody should
  659. * have already taken care of that, and hitting Cancel has no
  660. * effect anyway.
  661. */
  662. AppCommandProc(IDM_EXIT, 0L);
  663. bExitWindows = bSaveExit;
  664. #else
  665. AppCommandProc(IDM_EXIT);
  666. #endif
  667. }
  668. break;
  669. case WM_CLOSE:
  670. MSG("FrameWndProc", "WM_ENDSESSION/WM_CLOSE");
  671. if (iReadLevel) {
  672. bCancelTree = 2;
  673. break;
  674. }
  675. wParam = IDM_EXIT;
  676. /*** FALL THRU ***/
  677. case WM_COMMAND:
  678. if (AppCommandProc(GET_WM_COMMAND_ID(wParam, lParam)))
  679. break;
  680. if (GET_WM_COMMAND_ID(wParam, lParam) == IDM_EXIT) {
  681. FreeExtensions();
  682. if (hModUndelete >= (HANDLE)32)
  683. FreeLibrary(hModUndelete);
  684. DestroyWindow(hWnd);
  685. break;
  686. }
  687. /*** FALL THRU ***/
  688. default:
  689. if (wMsg == wHelpMessage) {
  690. if (GET_WM_COMMAND_ID(wParam, lParam) == MSGF_MENU) {
  691. // Get outta menu mode if help for a menu item
  692. if (wMenuID && hMenu) {
  693. WORD m = wMenuID; // save
  694. HMENU hM = hMenu;
  695. WORD mf = wMenuFlags;
  696. SendMessage(hWnd, WM_CANCELMODE, 0, 0L);
  697. wMenuID = m; // restore
  698. hMenu = hM;
  699. wMenuFlags = mf;
  700. }
  701. if (!(wMenuFlags & MF_POPUP)) {
  702. if (wMenuFlags & MF_SYSMENU)
  703. dwContext = IDH_SYSMENU;
  704. else
  705. dwContext = wMenuID + IDH_HELPFIRST;
  706. WFHelp(hWnd);
  707. }
  708. } else if (GET_WM_COMMAND_ID(wParam, lParam) == MSGF_DIALOGBOX) {
  709. // context range for message boxes
  710. if (dwContext >= IDH_MBFIRST && dwContext <= IDH_MBLAST)
  711. WFHelp(hWnd);
  712. else
  713. // let dialog box deal with it
  714. PostMessage(GetRealParent(GET_WM_COMMAND_HWND(wParam, lParam)), wHelpMessage, 0, 0L);
  715. }
  716. } else {
  717. DEFMSG("FrameWndProc", (WORD)wMsg);
  718. return DefFrameProc(hWnd, hwndMDIClient, wMsg, wParam, lParam);
  719. }
  720. }
  721. return 0L;
  722. }
  723. LRESULT
  724. APIENTRY
  725. MessageFilter(
  726. INT nCode,
  727. WPARAM wParam,
  728. LPARAM lParam
  729. )
  730. {
  731. LPMSG lpMsg = (LPMSG) lParam;
  732. if (nCode == MSGF_MENU) {
  733. if (lpMsg->message == WM_KEYDOWN && lpMsg->wParam == VK_F1) {
  734. // Window of menu we want help for is in loword of lParam.
  735. PostMessage(hwndFrame, wHelpMessage, MSGF_MENU, MAKELONG((WORD)lpMsg->hwnd,0));
  736. return 1;
  737. }
  738. } else if (nCode == MSGF_DIALOGBOX) {
  739. if (lpMsg->message == WM_KEYDOWN && lpMsg->wParam == VK_F1) {
  740. // Dialog box we want help for is in loword of lParam
  741. PostMessage(hwndFrame, wHelpMessage, MSGF_DIALOGBOX, MAKELONG(lpMsg->hwnd, 0));
  742. return 1;
  743. }
  744. }
  745. return (INT)DefHookProc(nCode, wParam, (LPARAM)lpMsg, &hhkMessageFilter);
  746. }
  747. /*============================================================================
  748. ;
  749. ; EnablePropertiesMenu
  750. ;
  751. ; The following function checks to see if we can enable the Properties...
  752. ; item in the File menu. The Properties... menu should be disabled if:
  753. ;
  754. ; 1) The root directory is selected in the current tree window.
  755. ; 2) ONLY the .. directory is selected in the current directory window.
  756. ; 3) Nothing is selected in the window having the focus.
  757. ;
  758. ; Parameters:
  759. ;
  760. ; hwndActive - Currently active window, contains a listbox in LASTFOCUS
  761. ; pSel - Currently selected item.
  762. ;
  763. ; Return Value: This function returns TRUE if the Properties... menu item
  764. ; should be enabled.
  765. ;
  766. ============================================================================*/
  767. BOOL
  768. EnablePropertiesMenu (
  769. HWND hwndActive,
  770. PSTR pSel
  771. )
  772. {
  773. HANDLE hDTA; /* Handle to list box DTA data */
  774. WORD wHighlight; /* Number of highlighted entries in listbox */
  775. LPMYDTA lpmydta; /* Pointer to listbox DTA data */
  776. BOOL bRet; /* Return value */
  777. HWND hwndLB;
  778. bRet = FALSE;
  779. /* Can't get properties on root directory */
  780. if ((lstrlen (pSel) == 3 && pSel[2] == '\\'))
  781. return (FALSE);
  782. if (hwndActive == hwndSearch)
  783. hwndLB = (HWND)GetWindowLongPtr(hwndActive, GWLP_LASTFOCUSSEARCH);
  784. else
  785. hwndLB = (HWND)GetWindowLongPtr(hwndActive, GWLP_LASTFOCUS);
  786. if (!hwndLB)
  787. return (TRUE);
  788. wHighlight = (WORD) SendMessage (hwndLB,LB_GETSELCOUNT,0,0L);
  789. if (hwndActive == hwndSearch)
  790. return (wHighlight >= 1);
  791. /* Lock down DTA data */
  792. if (!(hDTA = (HANDLE)GetWindowLongPtr (GetParent(hwndLB),GWLP_HDTA)))
  793. return (TRUE);
  794. if (!(lpmydta = (LPMYDTA) LocalLock (hDTA)))
  795. return (TRUE);
  796. if (wHighlight <= 0)
  797. goto ReturnFalse;
  798. if (wHighlight > 1)
  799. goto ReturnTrue;
  800. /* If exactly one element is highlighted, make sure it is not .. */
  801. if (!(BOOL) SendMessage (hwndLB,LB_GETSEL,0,0L))
  802. goto ReturnTrue;
  803. /* Get the DTA index. */
  804. SendMessage (hwndLB,LB_GETTEXT,0,(LPARAM) &lpmydta);
  805. if (!lpmydta)
  806. goto ReturnFalse;
  807. if ((lpmydta->my_dwAttrs & ATTR_DIR) &&
  808. (lpmydta->my_dwAttrs & ATTR_PARENT))
  809. goto ReturnFalse;
  810. ReturnTrue:
  811. bRet = TRUE;
  812. ReturnFalse:
  813. LocalUnlock (hDTA);
  814. return (bRet);
  815. }
  816. LONG
  817. lmul(
  818. WORD w1,
  819. WORD w2
  820. )
  821. {
  822. return (LONG)w1 * (LONG)w2;
  823. }