Changeset 1444 for trunk/dll/mainwnd.c
- Timestamp:
- Jul 23, 2009, 1:24:23 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/mainwnd.c
r1442 r1444 92 92 listings in tree 93 93 13 Jul 09 GKY Fixed under allocation of memory in the paint code for the drivebar bitmap buttons 94 22 Jul 09 GKY Drivebar enhancements add refresh removable, rescan all drives, drive button 95 loads drive root directory in directory container or expands drive tree 96 and rescans drive in tree container depending on container focus, greyed out 97 inappropriate menu context choices 98 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning 94 99 95 100 ***********************************************************************/ … … 171 176 #include "wrappers.h" // xfree 172 177 #include "fortify.h" 173 #include "filldir.h" // StubbyScanCount174 178 #include "excputil.h" // xbeginthread 175 179 … … 256 260 HWND hwndB = (HWND) mp1; 257 261 USHORT id; 262 CHAR s[90]= {0}; 258 263 259 264 id = WinQueryWindowUShort(hwndB, QWS_ID); 260 *dv = 0; 261 *dv = id - IDM_DRIVEA + 'A'; 262 strcpy(dv + 1, ":"); 263 d = toupper(*dv); 264 if (isalpha(d) && d > 'B' && 265 !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | 266 DRIVE_SLOW)) && 267 (!hwndBubble || 268 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 269 !WinQueryCapture(HWND_DESKTOP)) { 270 271 FSALLOCATE fsa; 272 CHAR s[90], szQty[38]; 273 ULONG ulPctFree; 274 ULONGLONG ullFreeQty; 275 276 if (!DosQueryFSInfo((d - 'A') + 1, 277 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) { 278 ullFreeQty = (ULONGLONG) fsa.cUnitAvail * 279 (fsa.cSectorUnit * fsa.cbSector); 280 ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? 281 (fsa.cUnitAvail * 100) / fsa.cUnit : 0; 282 CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' '); 283 sprintf(s, "%s %s (%lu%%) %s", dv, szQty, ulPctFree, GetPString(IDS_FREETEXT)); 284 } 285 if ((!hwndBubble || 286 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 287 !WinQueryCapture(HWND_DESKTOP)) 288 WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID); 289 } 265 switch (id) { 266 case IDM_RESCAN: 267 strcpy(s, GetPString(IDS_RESCANALLDRIVESTEXT)); 268 break; 269 270 case IDM_REFRESHREMOVABLES: 271 strcpy(s, GetPString(IDS_REFRESHREMOVABLESTEXT)); 272 break; 273 274 default: 275 *dv = 0; 276 *dv = id - IDM_DRIVEA + 'A'; 277 strcpy(dv + 1, ":"); 278 d = toupper(*dv); 279 if (isalpha(d) && d > 'B' && 280 !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID | 281 DRIVE_SLOW)) && 282 (!hwndBubble || 283 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 284 !WinQueryCapture(HWND_DESKTOP)) { 285 286 FSALLOCATE fsa; 287 CHAR szQty[38]; 288 ULONG ulPctFree; 289 ULONGLONG ullFreeQty; 290 291 if (!DosQueryFSInfo((d - 'A') + 1, 292 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) { 293 ullFreeQty = (ULONGLONG) fsa.cUnitAvail * 294 (fsa.cSectorUnit * fsa.cbSector); 295 ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ? 296 (fsa.cUnitAvail * 100) / fsa.cUnit : 0; 297 CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' '); 298 sprintf(s, "%s %s (%lu%%) %s", dv, szQty, ulPctFree, GetPString(IDS_FREETEXT)); 299 } 300 } 301 } 302 if ((!hwndBubble || 303 WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) && 304 !WinQueryCapture(HWND_DESKTOP)) 305 WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID); 290 306 } 291 307 return 0; … … 323 339 RestoreDirCnrState(hwndMain, (char *)mp1, FALSE); 324 340 WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), TRUE); 325 fNoTileUpdate = FALSE; 326 //xfree((char *)mp1, pszSrcFile, __LINE__); 327 // if (fAutoTile) 328 // TileChildren(hwndMain, TRUE); 341 fNoTileUpdate = FALSE; ; 329 342 break; 330 343 default: 331 344 Runtime_Error(pszSrcFile, __LINE__, "%u unexpected", mp2); 345 } 346 if (fInitialDriveScan) { 347 DosPostEventSem(hevInitialCnrScanComplete); 348 DosCloseEventSem(hevInitialCnrScanComplete); 349 fInitialDriveScan = FALSE; 332 350 } 333 351 return 0; … … 1835 1853 1836 1854 case WM_COMMAND: 1837 { 1838 CHAR dv[4]; 1839 1840 *dv = SHORT1FROMMP(mp1) - IDM_DRIVEA + 'A'; 1841 strcpy(dv + 1, ":\\"); 1842 if (isalpha(*dv)) { 1843 1844 HWND hwndActive; 1845 1846 dv[1] = ':'; 1847 dv[2] = '\\'; 1848 dv[3] = 0; 1849 hwndActive = TopWindow(hwnd, (HWND) 0); 1850 if (hwndActive) 1851 WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT), 1852 UM_DRIVECMD, MPFROMP(dv), MPVOID); 1855 if (fInitialDriveScan) 1856 DosWaitEventSem(hevInitialCnrScanComplete, SEM_INDEFINITE_WAIT); 1857 switch(SHORT1FROMMP(mp1)) { 1858 case IDM_RESCAN: 1859 { 1860 BOOL toggleTree = FALSE; 1861 1862 if (!hwndTree) { 1863 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); 1864 toggleTree = TRUE; 1865 } 1866 WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID); 1867 if (toggleTree) 1868 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); 1869 } 1870 break; 1871 case IDM_REFRESHREMOVABLES: 1872 { 1873 BOOL toggleTree = FALSE; 1874 1875 if (!hwndTree) { 1876 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); 1877 toggleTree = TRUE; 1878 } 1879 WinSendMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_REFRESHREMOVABLES, 0), MPVOID); 1880 if (toggleTree) 1881 WinSendMsg(hwndMain, WM_COMMAND, MPFROM2SHORT(IDM_VTREE, 0), MPVOID); 1882 } 1883 break; 1884 default: 1885 { 1886 CHAR dv[4]; 1887 1888 *dv = SHORT1FROMMP(mp1) - IDM_DRIVEA + 'A'; 1889 strcpy(dv + 1, ":\\"); 1890 if (isalpha(*dv)) { 1891 1892 HWND hwndActive; 1893 1894 dv[1] = ':'; 1895 dv[2] = '\\'; 1896 dv[3] = 0; 1897 hwndActive = TopWindow(hwnd, (HWND) 0); 1898 if (hwndActive) 1899 WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT), 1900 UM_DRIVECMD, MPFROMP(dv), MPVOID); 1901 } 1853 1902 } 1854 1903 } … … 1877 1926 switch (msg) { 1878 1927 case WM_MOUSEMOVE: 1879 if (fDrivebarHelp && 1880 (!hwndBubble || 1928 if (fDrivebarHelp && (!hwndBubble || 1881 1929 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) && 1882 1930 !WinQueryCapture(HWND_DESKTOP)) { 1883 1931 id = WinQueryWindowUShort(hwnd, QWS_ID); 1884 1932 if (helpid != id) { 1885 1933 helpid = id; 1886 1934 PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID); 1887 1935 } … … 1905 1953 1906 1954 id = WinQueryWindowUShort(hwnd, QWS_ID); 1955 if (id == IDM_REFRESHREMOVABLES || id == IDM_RESCAN) 1956 break; 1907 1957 *szDrv = 0; 1908 1958 x = id - IDM_DRIVEA; … … 1922 1972 RAMDISK_ICON : 1923 1973 (driveflags[x] & DRIVE_ZIPSTREAM) ? 1924 ZIPSTREAM_ICON : DRIVE_ICON; 1974 ZIPSTREAM_ICON : 1975 (driveflags[x] & DRIVE_LOCALHD) ? 1976 DRIVE_ICON : DONNO_ICON; 1925 1977 } 1926 1978 else … … 2000 2052 hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES); 2001 2053 if (hwndMenu) { 2002 BOOL rdy ;2054 BOOL rdy, local; 2003 2055 CHAR chDrv = *szDrv; 2004 2056 UINT iDrv; … … 2006 2058 strcat(szDrv, PCSZ_BACKSLASH); 2007 2059 MakeValidDir(szDrv); 2008 // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c 2060 // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c 2061 local = ~driveflags[iDrv] & DRIVE_REMOTE && ~driveflags[iDrv] & DRIVE_VIRTUAL && 2062 ~driveflags[iDrv] & DRIVE_RAMDISK; 2009 2063 rdy = toupper(*szDrv) == toupper(chDrv); 2010 2064 iDrv = toupper(*szDrv) - 'A'; 2011 2065 if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE) 2012 WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE); 2013 2014 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) { 2015 WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE); 2066 WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE); 2067 2068 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) 2069 WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE); 2070 2071 if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE || !local) { 2016 2072 WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE); 2017 2073 WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE); … … 2027 2083 WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE); 2028 2084 WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE); 2029 WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE); 2085 WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE); 2086 2087 if (!rdy || !local) 2030 2088 WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE); 2031 2089 } … … 2301 2359 if (!hwndB) 2302 2360 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, 2303 2361 PCSZ_WINCREATEWINDOW); 2304 2362 else { 2305 2363 WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); … … 2307 2365 } 2308 2366 } // for 2367 hwndB = WinCreateWindow(hwndT, 2368 WC_DRIVEBUTTONS, 2369 "#7001", 2370 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 2371 0, 2372 0, 2373 DRIVE_BUTTON_WIDTH, 2374 DRIVE_BUTTON_HEIGHT, 2375 hwndT, HWND_TOP, IDM_REFRESHREMOVABLES, NULL, NULL); 2376 if (!hwndB) 2377 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, 2378 PCSZ_WINCREATEWINDOW); 2379 hwndB = WinCreateWindow(hwndT, 2380 WC_DRIVEBUTTONS, 2381 "#7000", 2382 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 2383 0, 2384 0, 2385 DRIVE_BUTTON_WIDTH, 2386 DRIVE_BUTTON_HEIGHT, 2387 hwndT, HWND_TOP, IDM_RESCAN, NULL, NULL); 2388 if (!hwndB) 2389 Win_Error(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__, 2390 PCSZ_WINCREATEWINDOW); 2309 2391 } // if drivebar 2310 2392 PostMsg(WinQueryWindow(hwndT, QW_PARENT), … … 3328 3410 } 3329 3411 } 3330 //if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL)) //These were being called twice3331 // WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL); //causing dup dir names in tree3412 if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL)) 3413 WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL); 3332 3414 } 3333 3415 } … … 5726 5808 if (!add_setup(pszStatename)) 5727 5809 save_setups(); 5728 } else { 5810 } 5811 else { 5729 5812 load_tools(NULL); 5730 5813 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID); 5814 if (fInitialDriveScan) { 5815 DosPostEventSem(hevInitialCnrScanComplete); 5816 DosCloseEventSem(hevInitialCnrScanComplete); 5817 } 5731 5818 } 5732 5819 PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
Note:
See TracChangeset
for help on using the changeset viewer.