Changeset 297


Ignore:
Timestamp:
Jun 27, 2006, 2:17:35 AM (19 years ago)
Author:
root
Message:

DriveProc: disable menu items if drive not ready
DriveProc: correct my stupid
IDM_EDITANYARCHIVER: sanitize code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r260 r297  
    1919  06 Jun 05 SHL Rework MainWMCommand for VAC3.65 compat
    2020  13 Aug 05 SHL Renames and comments
     21  08 Dec 05 SHL DriveProc: disable menu items if drive not ready
     22  17 Dec 05 SHL DriveProc: correct my stupid
     23  29 May 06 SHL IDM_EDITANYARCHIVER: sanitize code
    2124
    2225***********************************************************************/
     
    19261929{
    19271930  USHORT id;
    1928   static CHAR dv[4];
     1931  CHAR szDrv[CCHMAXPATH];
     1932
    19291933  static BOOL emphasized = FALSE;
    1930   static HWND hwndMenu = (HWND) 0;
     1934  static HWND hwndMenu = NULLHANDLE;
    19311935  static USHORT helpid = 0;
    19321936
     
    19972001    hwndMenu = (HWND) 0;
    19982002    id = WinQueryWindowUShort(hwnd, QWS_ID);
    1999     *dv = 0;
     2003    *szDrv = 0;
    20002004    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    20012005                                       id + 50),
    2002                        sizeof(dv),
    2003                        dv);
    2004     if (isalpha(*dv))
     2006                       sizeof(szDrv),
     2007                       szDrv);
     2008    if (isalpha(*szDrv))
    20052009    {
    20062010      hwndMenu = WinLoadMenu(HWND_DESKTOP,
     
    20092013      if (hwndMenu)
    20102014      {
    2011         if (!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOTE))
     2015        BOOL rdy;
     2016        CHAR chDrv = *szDrv;
     2017        UINT iDrv;
     2018        strcpy(szDrv + 2, "\\");
     2019        MakeValidDir(szDrv);
     2020        // Disable menus if MakeValidDir changes drive letter
     2021        rdy = toupper(*szDrv) == toupper(chDrv);
     2022        iDrv = toupper(*szDrv) - 'A';
     2023        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    20122024          WinEnableMenuItem(hwndMenu,
    20132025                            IDM_DETACH,
    20142026                            FALSE);
    2015         if (driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE)
     2027        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE)
    20162028        {
    2017           WinEnableMenuItem(hwndMenu,
    2018                             IDM_MKDIR,
    2019                             FALSE);
    2020           WinEnableMenuItem(hwndMenu,
    2021                             IDM_FORMAT,
    2022                             FALSE);
    2023           WinEnableMenuItem(hwndMenu,
    2024                             IDM_OPTIMIZE,
    2025                             FALSE);
    2026           WinEnableMenuItem(hwndMenu,
    2027                             IDM_UNDELETE,
    2028                             FALSE);
    2029         }
    2030         if (!(driveflags[toupper(*dv) - 'A'] & DRIVE_REMOVABLE))
     2029          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     2030          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     2031          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     2032          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     2033        }
     2034        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE)
    20312035        {
    2032           WinEnableMenuItem(hwndMenu,
    2033                             IDM_EJECT,
    2034                             FALSE);
    2035           WinEnableMenuItem(hwndMenu,
    2036                             IDM_LOCK,
    2037                             FALSE);
    2038           WinEnableMenuItem(hwndMenu,
    2039                             IDM_UNLOCK,
    2040                             FALSE);
    2041         }
    2042         /*
    2043            if(!(driveflags[toupper(*dv) - 'A'] & DRIVE_CDROM)) {
    2044            WinEnableMenuItem(hwndMenu,
    2045            IDM_CLOSETRAY,
    2046           FALSE);
    2047            }
    2048          */
     2036          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     2037          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     2038          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     2039        }
     2040        if (!rdy)
     2041        {
     2042          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     2043          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     2044          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     2045          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     2046          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     2047        }
     2048        /* fixme to be gone?
     2049        if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     2050          WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     2051        }
     2052        */
    20492053        PopupMenu(hwnd,
    20502054                  hwnd,
     
    20622066  case WM_BUTTON3CLICK:
    20632067    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2064     *dv = 0;
     2068    *szDrv = 0;
    20652069    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    20662070                                       id + 50),
    2067                        sizeof(dv),
    2068                        dv);
    2069     if (isalpha(*dv))
    2070     {
    2071       strcat(dv, "\\");
    2072       if (!FindDirCnrByName(dv, TRUE))
     2071                       sizeof(szDrv),
     2072                       szDrv);
     2073    if (isalpha(*szDrv))
     2074    {
     2075      strcat(szDrv, "\\");
     2076      if (!FindDirCnrByName(szDrv, TRUE))
    20732077        OpenDirCnr((HWND) 0,
    20742078                   hwndMain,
    20752079                   hwndTree,
    20762080                   FALSE,
    2077                    dv);
     2081                   szDrv);
    20782082    }
    20792083    break;
     
    20852089  case UM_COMMAND:
    20862090    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2087     *dv = 0;
     2091    *szDrv = 0;
    20882092    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    20892093                                       id + 50),
    2090                        sizeof(dv),
    2091                        dv);
    2092     if (isalpha(*dv))
    2093     {
    2094       strcat(dv, "\\");
    2095       CommonDriveCmd(hwnd, dv, SHORT1FROMMP(mp1));
     2094                       sizeof(szDrv),
     2095                       szDrv);
     2096    if (isalpha(*szDrv))
     2097    {
     2098      strcat(szDrv, "\\");
     2099      CommonDriveCmd(hwnd, szDrv, SHORT1FROMMP(mp1));
    20962100    }
    20972101    return 0;
     
    20992103  case DM_DRAGOVER:
    21002104    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2101     *dv = 0;
     2105    *szDrv = 0;
    21022106    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    21032107                                       id + 50),
    2104                        sizeof(dv),
    2105                        dv);
    2106     if (isalpha(*dv) &&
    2107         !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE))
     2108                       sizeof(szDrv),
     2109                       szDrv);
     2110    if (isalpha(*szDrv) &&
     2111        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE))
    21082112    {
    21092113      if (!emphasized)
     
    21212125  case DM_DRAGLEAVE:
    21222126    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2123     *dv = 0;
     2127    *szDrv = 0;
    21242128    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    21252129                                       id + 50),
    2126                        sizeof(dv),
    2127                        dv);
    2128     if (isalpha(*dv) &&
    2129         !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE))
     2130                       sizeof(szDrv),
     2131                       szDrv);
     2132    if (isalpha(*szDrv) &&
     2133        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE))
    21302134    {
    21312135      if (emphasized)
     
    21392143  case DM_DROPHELP:
    21402144    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2141     *dv = 0;
     2145    *szDrv = 0;
    21422146    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2143                                        id + 50), sizeof(dv), dv);
    2144     if (isalpha(*dv) &&
    2145         !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE))
     2147                                       id + 50), sizeof(szDrv), szDrv);
     2148    if (isalpha(*szDrv) &&
     2149        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE))
    21462150    {
    21472151      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
     
    21522156  case DM_DROP:
    21532157    id = WinQueryWindowUShort(hwnd, QWS_ID);
    2154     *dv = 0;
     2158    *szDrv = 0;
    21552159    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    21562160                                       id + 50),
    2157                        sizeof(dv),
    2158                        dv);
    2159     if (isalpha(*dv) &&
    2160         !(driveflags[toupper(*dv) - 'A'] & DRIVE_NOTWRITEABLE))
     2161                       sizeof(szDrv),
     2162                       szDrv);
     2163    if (isalpha(*szDrv) &&
     2164        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE))
    21612165    {
    21622166
     
    21802184      if (li)
    21812185      {
    2182         strcpy(li -> targetpath, dv);
     2186        strcpy(li -> targetpath, szDrv);
    21832187        strcat(li -> targetpath, "\\");
    21842188        if (li -> list &&
     
    52965300
    52975301  case IDM_EDITANYARCHIVER:
    5298     {
    5299       DIRCNRDATA arc;
    5300 
    5301       memset(&arc, 0, sizeof(DIRCNRDATA));
    5302       EditArchiverData(hwnd, &arc);
    5303     }
     5302    EditArchiverData(hwnd);
    53045303    break;
    53055304
Note: See TracChangeset for help on using the changeset viewer.