Changeset 1027


Ignore:
Timestamp:
Jun 20, 2008, 5:04:46 AM (17 years ago)
Author:
John Small
Message:

Ticket 227: Code cleanup and comments

Location:
trunk/dll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r1025 r1027  
    5555  22 Feb 08 JBS Ticket 230: Fix/improve various code related to state or presparam values in the INI file.
    5656  29 Feb 08 GKY Use xfree where appropriate
     57  19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
    5758
    5859***********************************************************************/
     
    7879#include "errutil.h"                    // Dos_Error...
    7980#include "strutil.h"                    // GetPString
    80 #include "notebook.h"                   // CfgDlgProc CfgMenuInit
     81#include "notebook.h"                        // CfgDlgProc CfgMenuInit
    8182#include "command.h"                    // LINKCMDS
    8283#include "fm3dll.h"
     
    9495
    9596static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    96                                           MPARAM mp2)
     97                                          MPARAM mp2)
    9798{
    9899  switch (msg) {
     
    120121      *dv = 0;
    121122      WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
    122                                         id + 50), sizeof(dv), dv);
     123                                        id + 50), sizeof(dv), dv);
    123124      d = toupper(*dv);
    124125      if (isalpha(d) && d > 'B' &&
    125           !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
    126                                    DRIVE_SLOW)) &&
    127           (!hwndBubble ||
    128            WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    129           !WinQueryCapture(HWND_DESKTOP)) {
    130 
    131         FSALLOCATE fsa;
    132         CHAR s[90], szQty[38];
    133         ULONG ulPctFree;
    134         ULONGLONG ullFreeQty;
    135 
    136         if (!DosQueryFSInfo((d - 'A') + 1,
    137                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    138           ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
    139             (fsa.cSectorUnit * fsa.cbSector);
    140           ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
    141             (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
    142           CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
    143           sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
    144         }
    145         if ((!hwndBubble ||
    146              WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    147             !WinQueryCapture(HWND_DESKTOP))
    148           WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
     126          !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
     127                                   DRIVE_SLOW)) &&
     128          (!hwndBubble ||
     129           WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     130          !WinQueryCapture(HWND_DESKTOP)) {
     131
     132        FSALLOCATE fsa;
     133        CHAR s[90], szQty[38];
     134        ULONG ulPctFree;
     135        ULONGLONG ullFreeQty;
     136
     137        if (!DosQueryFSInfo((d - 'A') + 1,
     138                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     139          ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
     140            (fsa.cSectorUnit * fsa.cbSector);
     141          ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
     142            (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
     143          CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
     144          sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
     145        }
     146        if ((!hwndBubble ||
     147             WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     148            !WinQueryCapture(HWND_DESKTOP))
     149          WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
    149150      }
    150151    }
     
    157158
    158159      if (DosQuerySysInfo(QSV_BOOT_DRIVE,
    159                           QSV_BOOT_DRIVE,
    160                           (PVOID) & bd, (ULONG) sizeof(ULONG)))
    161         bd = 3L;
     160                          QSV_BOOT_DRIVE,
     161                          (PVOID) & bd, (ULONG) sizeof(ULONG)))
     162        bd = 3L;
    162163      *s = (CHAR) bd + '@';
    163164      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    164165      if (!mp1) {
    165         s[3] = 0;
    166         WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
     166        s[3] = 0;
     167        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    167168      }
    168169      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
     
    186187      //xfree((char *)mp1, pszSrcFile, __LINE__);
    187188      if (fAutoTile)
    188         TileChildren(hwndMain, TRUE);
     189        TileChildren(hwndMain, TRUE);
    189190      break;
    190191    default:
     
    225226      DosError(FERR_DISABLEHARDERR);
    226227      WinRegisterClass(hab2,
    227                        (PSZ) WC_OBJECTWINDOW,
    228                        MainObjectWndProc, 0, sizeof(PVOID));
     228                       (PSZ) WC_OBJECTWINDOW,
     229                       MainObjectWndProc, 0, sizeof(PVOID));
    229230      MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
    230                                        WC_OBJECTWINDOW,
    231                                        (PSZ) NULL,
    232                                        0,
    233                                        0L,
    234                                        0L,
    235                                        0L,
    236                                        0L,
    237                                        0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
     231                                       WC_OBJECTWINDOW,
     232                                       (PSZ) NULL,
     233                                       0,
     234                                       0L,
     235                                       0L,
     236                                       0L,
     237                                       0L,
     238                                       0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
    238239      if (!MainObjectHwnd)
    239         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
    240                    IDS_WINCREATEWINDOW);
     240        Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
     241                   IDS_WINCREATEWINDOW);
    241242      else {
    242         WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
    243         while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
    244           WinDispatchMsg(hab2, &qmsg2);
    245         WinDestroyWindow(MainObjectHwnd);
     243        WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
     244        while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
     245          WinDispatchMsg(hab2, &qmsg2);
     246        WinDestroyWindow(MainObjectHwnd);
    246247      }
    247248      WinDestroyMsgQueue(hmq2);
     
    252253
    253254static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
    254                                         MPARAM mp2)
     255                                        MPARAM mp2)
    255256{
    256257  switch (msg) {
     
    272273    while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    273274      if (hwndC != exclude) {
    274         id = WinQueryWindowUShort(hwndC, QWS_ID);
    275         if (id)
    276           break;
     275        id = WinQueryWindowUShort(hwndC, QWS_ID);
     276        if (id)
     277          break;
    277278      }
    278279    }
     
    294295      henum = WinBeginEnumWindows(hwndMain);
    295296      while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    296         // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
    297         if (hwndC != exclude && hwndC != hwndTree) {
    298           id = WinQueryWindowUShort(hwndC, QWS_ID);
    299           if (id) {
    300             hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
    301             if (hwndClient) {
    302               hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
    303               if (hwndDir) {
    304                 if (fLookInDir) {
    305                   pci = (PCNRITEM) WinSendMsg(hwndDir,
    306                                               CM_QUERYRECORDEMPHASIS,
    307                                               MPFROMLONG(CMA_FIRST),
    308                                               MPFROMSHORT(CRA_CURSORED));
    309                   if (pci && (INT) pci != -1)
    310                     break;
    311                 }
    312                 if (WinSendMsg(hwndClient,
    313                                UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
    314                   MakeValidDir(ret);
    315                   // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
    316                   WinEndEnumWindows(henum);
    317                   return hwndC;
    318                 }
    319               }
    320             }
    321           }
    322         }
     297        // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
     298        if (hwndC != exclude && hwndC != hwndTree) {
     299          id = WinQueryWindowUShort(hwndC, QWS_ID);
     300          if (id) {
     301            hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
     302            if (hwndClient) {
     303              hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
     304              if (hwndDir) {
     305                if (fLookInDir) {
     306                  pci = (PCNRITEM) WinSendMsg(hwndDir,
     307                                              CM_QUERYRECORDEMPHASIS,
     308                                              MPFROMLONG(CMA_FIRST),
     309                                              MPFROMSHORT(CRA_CURSORED));
     310                  if (pci && (INT) pci != -1)
     311                    break;
     312                }
     313                if (WinSendMsg(hwndClient,
     314                               UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
     315                  MakeValidDir(ret);
     316                  // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
     317                  WinEndEnumWindows(henum);
     318                  return hwndC;
     319                }
     320              }
     321            }
     322          }
     323        }
    323324      }
    324325      WinEndEnumWindows(henum);
    325326      if (!pci || (INT) pci == -1) {
    326         hwndC = hwndTree;
    327         pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
    328                                                                     FID_CLIENT),
    329                                                     TREE_CNR),
    330                                     CM_QUERYRECORDEMPHASIS,
    331                                     MPFROMLONG(CMA_FIRST),
    332                                     MPFROMSHORT(CRA_CURSORED));
     327        hwndC = hwndTree;
     328        pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
     329                                                                    FID_CLIENT),
     330                                                    TREE_CNR),
     331                                    CM_QUERYRECORDEMPHASIS,
     332                                    MPFROMLONG(CMA_FIRST),
     333                                    MPFROMSHORT(CRA_CURSORED));
    333334      }
    334335      if (pci && (INT) pci != -1) {
    335         strcpy(ret, pci->pszFileName);
    336         MakeValidDir(ret);
     336        strcpy(ret, pci->pszFileName);
     337        MakeValidDir(ret);
    337338      }
    338339      else
    339         save_dir2(ret);
     340        save_dir2(ret);
    340341    }
    341342  }
     
    355356      hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    356357      if (hwndDir)
    357         ret++;
     358        ret++;
    358359    }
    359360  }
     
    373374      hwndC = WinWindowFromID(hwndF, FID_CLIENT);
    374375      if (hwndC) {
    375         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    376         if (hwndDir) {
    377           *retstr = 0;
    378           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
    379           if (*retstr && !stricmp(retstr, directory)) {
    380             if (restore)
    381               WinSetWindowPos(hwndF,
    382                               HWND_TOP,
    383                               0,
    384                               0,
    385                               0,
    386                               0,
    387                               SWP_RESTORE | SWP_SHOW |
    388                               SWP_ACTIVATE | SWP_ZORDER);
    389             break;
    390           }
    391         }
     376        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     377        if (hwndDir) {
     378          *retstr = 0;
     379          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
     380          if (*retstr && !stricmp(retstr, directory)) {
     381            if (restore)
     382              WinSetWindowPos(hwndF,
     383                              HWND_TOP,
     384                              0,
     385                              0,
     386                              0,
     387                              0,
     388                              SWP_RESTORE | SWP_SHOW |
     389                              SWP_ACTIVATE | SWP_ZORDER);
     390            break;
     391          }
     392        }
    392393      }
    393394    }
     
    456457    while (tool) {
    457458      if (!(tool->flags & T_INVISIBLE)) {
    458         swp[x].x = butx;
    459         if (fTextTools || (tool->flags & T_TEXT)) {
    460           butx += 55L;
    461           swp[x].cx = 54L;
    462           swp[x].cy = 24L;
    463           swp[x].y = 3L;
    464         }
    465         else
    466           butx += 33L;
    467         if (tool->flags & T_SEPARATOR)
    468           butx += 12;
     459        swp[x].x = butx;
     460        if (fTextTools || (tool->flags & T_TEXT)) {
     461          butx += 55L;
     462          swp[x].cx = 54L;
     463          swp[x].cy = 24L;
     464          swp[x].y = 3L;
     465        }
     466        else
     467          butx += 33L;
     468        if (tool->flags & T_SEPARATOR)
     469          butx += 12;
    469470      }
    470471      else
    471         swp[x].fl = noattrib;
     472        swp[x].fl = noattrib;
    472473      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    473474      x++;
     
    478479      swp[x].x = butx;
    479480      if (!(tool->flags & T_INVISIBLE)) {
    480         if (fTextTools || (tool->flags & T_TEXT)) {
    481           butx += 55L;
    482           swp[x].cx = 54L;
    483           swp[x].cy = 24L;
    484           swp[x].y = 3L;
    485         }
    486         else
    487           butx += 33L;
    488         if (tool->flags & T_SEPARATOR)
    489           butx += 12;
     481        if (fTextTools || (tool->flags & T_TEXT)) {
     482          butx += 55L;
     483          swp[x].cx = 54L;
     484          swp[x].cy = 24L;
     485          swp[x].y = 3L;
     486        }
     487        else
     488          butx += 33L;
     489        if (tool->flags & T_SEPARATOR)
     490          butx += 12;
    490491      }
    491492      else
    492         swp[x].fl = noattrib;
     493        swp[x].fl = noattrib;
    493494      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    494495      x++;
     
    498499    if (!fTextTools && fToolTitles) {
    499500      for (x = 2L; x < numtools + 2L; x++) {
    500         if (fTextTools || !fToolTitles)
    501           swp[x].fl = noattrib;
    502         else {
    503           tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
    504           if (tool && (tool->flags & T_TEXT))
    505             swp[x].fl = noattrib;
    506           else {
    507             swp[x].hwndInsertBehind = HWND_TOP;
    508             swp[x].y = 1L;
    509             swp[x].cy = 10L;
    510           }
    511         }
    512         swp[x].hwnd = WinWindowFromID(hwnd,
    513                                       WinQueryWindowUShort(swp[x].hwnd,
    514                                                            QWS_ID) + 25000);
     501        if (fTextTools || !fToolTitles)
     502          swp[x].fl = noattrib;
     503        else {
     504          tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
     505          if (tool && (tool->flags & T_TEXT))
     506            swp[x].fl = noattrib;
     507          else {
     508            swp[x].hwndInsertBehind = HWND_TOP;
     509            swp[x].y = 1L;
     510            swp[x].cy = 10L;
     511          }
     512        }
     513        swp[x].hwnd = WinWindowFromID(hwnd,
     514                                      WinQueryWindowUShort(swp[x].hwnd,
     515                                                           QWS_ID) + 25000);
    515516      }
    516517      WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
     
    522523
    523524static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
    524                                         MPARAM mp2)
     525                                        MPARAM mp2)
    525526{
    526527  PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
     
    560561      id = WinQueryWindowUShort(hwndParent, QWS_ID);
    561562      if (SHORT1FROMMP(mp2)) {
    562         // If getting focus 1st time - save original accelerator
    563         if (haccelSaved == NULLHANDLE) {
    564           haccelSaved = WinQueryAccelTable(hab, hwndFrame);
    565           if (haccelSaved == NULLHANDLE)
    566             Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
    567           // else
    568             // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
    569         }
    570         if (haccelSaved != NULLHANDLE) {
    571           switch (id) {
    572           case MAIN_DRIVELIST:
    573             if (haccelDriveList == NULLHANDLE) {
    574                 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
    575                 if (haccelDriveList == NULLHANDLE)
    576                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    577             }
    578             if (haccelDriveList != NULLHANDLE) {
    579               if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
    580                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    581               // else
    582                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
    583             }
    584             break;
    585           case MAIN_SETUPLIST:
    586             if (haccelSetupList == NULLHANDLE) {
    587                 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
    588                 if (haccelSetupList == NULLHANDLE)
    589                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    590             }
    591             if (haccelSetupList != NULLHANDLE) {
    592               if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
    593                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    594               // else
    595                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
    596             }
    597             break;
    598           case MAIN_CMDLIST:
    599             if (haccelCmdList == NULLHANDLE) {
    600                 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
    601                 if (haccelCmdList == NULLHANDLE)
    602                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    603             }
    604             if (haccelCmdList != NULLHANDLE) {
    605               if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
    606                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    607               // else
    608                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
    609             }
    610             break;
    611           case MAIN_USERLIST:
    612             if (haccelUserList == NULLHANDLE) {
    613                 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
    614                 if (haccelUserList == NULLHANDLE)
    615                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    616             }
    617             if (haccelUserList != NULLHANDLE) {
    618               if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
    619                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    620               // else
    621                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
    622             }
    623             break;
    624           case MAIN_BUTTONLIST:
    625             if (haccelButtonList == NULLHANDLE) {
    626                 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
    627                 if (haccelButtonList == NULLHANDLE)
    628                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    629             }
    630             if (haccelButtonList != NULLHANDLE) {
    631               if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
    632                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    633               // else
    634                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
    635             }
    636             break;
    637           } // switch
    638         }
     563        // If getting focus 1st time - save original accelerator
     564        if (haccelSaved == NULLHANDLE) {
     565          haccelSaved = WinQueryAccelTable(hab, hwndFrame);
     566          if (haccelSaved == NULLHANDLE)
     567            Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
     568          // else
     569            // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
     570        }
     571        if (haccelSaved != NULLHANDLE) {
     572          switch (id) {
     573          case MAIN_DRIVELIST:
     574            if (haccelDriveList == NULLHANDLE) {
     575                haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
     576                if (haccelDriveList == NULLHANDLE)
     577                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     578            }
     579            if (haccelDriveList != NULLHANDLE) {
     580              if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
     581                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     582              // else
     583                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
     584            }
     585            break;
     586          case MAIN_SETUPLIST:
     587            if (haccelSetupList == NULLHANDLE) {
     588                haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
     589                if (haccelSetupList == NULLHANDLE)
     590                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     591            }
     592            if (haccelSetupList != NULLHANDLE) {
     593              if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
     594                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     595              // else
     596                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
     597            }
     598            break;
     599          case MAIN_CMDLIST:
     600            if (haccelCmdList == NULLHANDLE) {
     601                haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
     602                if (haccelCmdList == NULLHANDLE)
     603                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     604            }
     605            if (haccelCmdList != NULLHANDLE) {
     606              if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
     607                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     608              // else
     609                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
     610            }
     611            break;
     612          case MAIN_USERLIST:
     613            if (haccelUserList == NULLHANDLE) {
     614                haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
     615                if (haccelUserList == NULLHANDLE)
     616                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     617            }
     618            if (haccelUserList != NULLHANDLE) {
     619              if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
     620                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     621              // else
     622                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
     623            }
     624            break;
     625          case MAIN_BUTTONLIST:
     626            if (haccelButtonList == NULLHANDLE) {
     627                haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
     628                if (haccelButtonList == NULLHANDLE)
     629                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     630            }
     631            if (haccelButtonList != NULLHANDLE) {
     632              if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
     633                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     634              // else
     635                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
     636            }
     637            break;
     638          } // switch
     639        }
    639640      }
    640641      else {
    641         // Losing focus
    642         switch (id) {
    643         case MAIN_DRIVELIST:
    644         case MAIN_SETUPLIST:
    645         case MAIN_CMDLIST:
    646         case MAIN_USERLIST:
    647         case MAIN_BUTTONLIST:
    648           if (haccelSaved != NULLHANDLE) {
    649             if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
    650               Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    651             // else
    652               // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
    653           }
    654           break;
    655         } // switch
     642        // Losing focus
     643        switch (id) {
     644        case MAIN_DRIVELIST:
     645        case MAIN_SETUPLIST:
     646        case MAIN_CMDLIST:
     647        case MAIN_USERLIST:
     648        case MAIN_BUTTONLIST:
     649          if (haccelSaved != NULLHANDLE) {
     650            if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
     651              Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     652            // else
     653              // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
     654          }
     655          break;
     656        } // switch
    656657      }
    657658    }
     
    663664
    664665      if (hwndMenu)
    665         WinDestroyWindow(hwndMenu);
     666        WinDestroyWindow(hwndMenu);
    666667      hwndMenu = (HWND) 0;
    667668      id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
    668669      switch (id) {
    669670      case MAIN_CMDLIST:
    670         WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    671                                                                 QW_PARENT),
    672                                                   QW_PARENT),
    673                                    FID_CLIENT),
    674                    WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
    675         break;
     671        WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     672                                                                QW_PARENT),
     673                                                  QW_PARENT),
     674                                   FID_CLIENT),
     675                   WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
     676        break;
    676677      case MAIN_USERLIST:
    677678      case MAIN_SETUPLIST:
    678         hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    679         if (hwndMenu)
    680           PopupMenu(hwnd,
    681                     WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    682                                                                   QW_PARENT),
    683                                                    QW_PARENT),
    684                                     FID_CLIENT), hwndMenu);
    685         break;
     679        hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     680        if (hwndMenu)
     681          PopupMenu(hwnd,
     682                    WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     683                                                                  QW_PARENT),
     684                                                   QW_PARENT),
     685                                    FID_CLIENT), hwndMenu);
     686        break;
    686687      default:
    687         ret = FALSE;
    688         break;
     688        ret = FALSE;
     689        break;
    689690      } // switch
    690691      return ret;
     
    695696      switch (SHORT1FROMMP(mp1)) {
    696697      case CBID_EDIT:
    697         id = WinQueryWindowUShort(hwnd, QWS_ID);
    698         switch (SHORT2FROMMP(mp1)) {
    699         case EN_SETFOCUS:
    700           switch (id) {
    701           case MAIN_CMDLIST:
    702             WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
    703             break;
    704           case MAIN_SETUPLIST:
    705             WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
    706             break;
    707           case MAIN_USERLIST:
    708             WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
    709             break;
    710           case MAIN_DRIVELIST:
    711             WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
    712             break;
    713           case MAIN_BUTTONLIST:
    714             WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
    715             break;
    716           default:
    717             break;
    718           }
    719           break;
    720 
    721         default:
    722           break;
    723         }
     698        id = WinQueryWindowUShort(hwnd, QWS_ID);
     699        switch (SHORT2FROMMP(mp1)) {
     700        case EN_SETFOCUS:
     701          switch (id) {
     702          case MAIN_CMDLIST:
     703            WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
     704            break;
     705          case MAIN_SETUPLIST:
     706            WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
     707            break;
     708          case MAIN_USERLIST:
     709            WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
     710            break;
     711          case MAIN_DRIVELIST:
     712            WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
     713            break;
     714          case MAIN_BUTTONLIST:
     715            WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
     716            break;
     717          default:
     718            break;
     719          }
     720          break;
     721
     722        default:
     723          break;
     724        }
    724725      }
    725726      break;
     
    734735    // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%u %s %u",id,(id == CBID_EDIT) ? "TRUE" : "FALSE",WinQueryWindowUShort(WinQueryWindow(hwnd,QW_PARENT),QWS_ID) == MAIN_USERLIST);
    735736    if (id == CBID_EDIT &&
    736         WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
    737         MAIN_USERLIST) {
     737        WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
     738        MAIN_USERLIST) {
    738739
    739740      CHAR path[CCHMAXPATH];
     
    744745      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
    745746      if (*path && !IsRoot(path))
    746         DragOne(hwnd, (HWND) 0, path, FALSE);
     747        DragOne(hwnd, (HWND) 0, path, FALSE);
    747748      return 0;
    748749    }
     
    753754    if (id == MAIN_USERLIST) {
    754755      if (!emphasized) {
    755         emphasized = TRUE;
    756         DrawTargetEmphasis(hwnd, emphasized);
     756        emphasized = TRUE;
     757        DrawTargetEmphasis(hwnd, emphasized);
    757758      }
    758759      if (AcceptOneDrop(hwnd, mp1, mp2))
    759         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     760        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    760761      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    761762    }
     
    766767    if (id == MAIN_USERLIST) {
    767768      if (emphasized) {
    768         emphasized = FALSE;
    769         DrawTargetEmphasis(hwnd, emphasized);
     769        emphasized = FALSE;
     770        DrawTargetEmphasis(hwnd, emphasized);
    770771      }
    771772    }
     
    787788
    788789      if (emphasized) {
    789         emphasized = FALSE;
    790         DrawTargetEmphasis(hwnd, emphasized);
     790        emphasized = FALSE;
     791        DrawTargetEmphasis(hwnd, emphasized);
    791792      }
    792793      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    793         MakeValidDir(szFrom);
    794         WinSetWindowText(hwnd, szFrom);
    795         PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    796                                                               QW_PARENT),
    797                                                QW_PARENT),
    798                                 FID_CLIENT),
    799                 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
    800         return 0;
     794        MakeValidDir(szFrom);
     795        WinSetWindowText(hwnd, szFrom);
     796        PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     797                                                              QW_PARENT),
     798                                               QW_PARENT),
     799                                FID_CLIENT),
     800                UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
     801        return 0;
    801802      }
    802803    }
     
    819820       (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
    820821    if ((!hwndBubble ||
    821         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    822         !WinQueryCapture(HWND_DESKTOP))
     822        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     823        !WinQueryCapture(HWND_DESKTOP))
    823824      MakeBubble(hwnd, above, help);
    824825  }
     
    841842      /* don't bring up help if window isn't active */
    842843      if (!WinIsChild(hwnd, hwndActive))
    843         return;
     844        return;
    844845    }
    845846    hwndActive = WinQueryFocus(HWND_DESKTOP);
     
    847848      /* don't bring up help if a menu is active */
    848849      if (!strcmp(ucClassname, "#4"))
    849         return;
     850        return;
    850851    }
    851852  }
    852853
    853854  hwndBubble = WinCreateWindow(HWND_DESKTOP,
    854                                WC_BUBBLE,
    855                                help,
    856                                WS_CLIPSIBLINGS | SS_TEXT |
    857                                DT_CENTER | DT_VCENTER,
    858                                0,
    859                                0,
    860                                0,
    861                                0,
    862                                HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
     855                               WC_BUBBLE,
     856                               help,
     857                               WS_CLIPSIBLINGS | SS_TEXT |
     858                               DT_CENTER | DT_VCENTER,
     859                               0,
     860                               0,
     861                               0,
     862                               0,
     863                               HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
    863864  if (!hwndBubble)
    864865    Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    865                IDS_WINCREATEWINDOW);
     866               IDS_WINCREATEWINDOW);
    866867  else {
    867868    HPS hps;
     
    883884      pp = strchr(p, '\r');
    884885      if (pp) {
    885         wp = pp;
    886         *pp = 0;
    887         pp++;
     886        wp = pp;
     887        *pp = 0;
     888        pp++;
    888889      }
    889890      GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    890891      tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
    891892      if (tptl.y)
    892         tptl.y += extra;
     893        tptl.y += extra;
    893894      else
    894         extra = aptl[TXTBOX_TOPLEFT].y / 4;
     895        extra = aptl[TXTBOX_TOPLEFT].y / 4;
    895896      tptl.y += aptl[TXTBOX_TOPLEFT].y;
    896897      if (wp)
    897         *wp = '\r';
     898        *wp = '\r';
    898899      p = pp;
    899900    }
     
    905906      sy = ptl.y + swp.cy + 4;
    906907      if (sy + tptl.y + 12 > lyScreen) {
    907         above = FALSE;
    908         sy = ptl.y - (tptl.y + 14);
     908        above = FALSE;
     909        sy = ptl.y - (tptl.y + 14);
    909910      }
    910911    }
     
    922923      sy = ptl.y + swp.cy + 4;
    923924      if (sy + tptl.y + 12 > lyScreen)
    924         sy = 0;
     925        sy = 0;
    925926    }
    926927    WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
    927                     tptl.x + 14,
    928                     tptl.y + 12,
    929                     SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
    930                     SWP_MOVE | SWP_SIZE);
     928                    tptl.x + 14,
     929                    tptl.y + 12,
     930                    SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
     931                    SWP_MOVE | SWP_SIZE);
    931932  }
    932933}
     
    954955      WinQueryPointerPos(HWND_DESKTOP, &ptl);
    955956      if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
    956           WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
    957         WinDestroyWindow(hwnd);
     957          WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
     958        WinDestroyWindow(hwnd);
    958959    }
    959960    return 0;
     
    969970      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    970971      if (hps) {
    971         WinQueryWindowPos(hwnd, &swp);
    972         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
    973         GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
    974         GpiSetBackMix(hps, BM_LEAVEALONE);
    975         GpiSetMix(hps, FM_OVERPAINT);
    976         ptl.x = ptl.y = 0;
    977         GpiMove(hps, &ptl);
    978         ptl.x = swp.cx - 1;
    979         ptl.y = swp.cy - 1;
    980         GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
    981         tlen = WinQueryWindowTextLength(hwnd);
    982         if (tlen) {
    983           s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
    984           if (s) {
    985             WinQueryWindowText(hwnd, tlen + 1, s);
    986             if (*s) {
    987               p = s;
    988               y = swp.cy - 3;
    989               extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
    990               GpiSetColor(hps, 0);
    991               GpiSetMix(hps, FM_OVERPAINT);
    992               while (p && *p) {
    993                 wp = NULL;
    994                 pp = strchr(p, '\r');
    995                 if (pp) {
    996                   wp = pp;
    997                   *pp = 0;
    998                   pp++;
    999                 }
    1000                 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    1001                 ptl.x = 7;
    1002                 y -= aptl[TXTBOX_TOPLEFT].y;
    1003                 if (p != s)
    1004                   y -= extra;
    1005                 ptl.y = y;
    1006                 GpiCharStringAt(hps, &ptl, strlen(p), p);
    1007                 if (wp)
    1008                   *wp = '\r';
    1009                 p = pp;
    1010               }
    1011             }
    1012             xfree(s, pszSrcFile, __LINE__);
    1013           }
    1014         }
    1015         if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
    1016           GpiSetColor(hps, CLR_WHITE);
    1017           ptl.x = 1;
    1018           ptl.y = 1;
    1019           GpiMove(hps, &ptl);
    1020           ptl.y = swp.cy - 2;
    1021           GpiLine(hps, &ptl);
    1022           ptl.x = swp.cx - 2;
    1023           GpiLine(hps, &ptl);
    1024           ptl.x = 2;
    1025           ptl.y = 2;
    1026           GpiMove(hps, &ptl);
    1027           ptl.y = swp.cy - 3;
    1028           GpiLine(hps, &ptl);
    1029           ptl.x = swp.cx - 3;
    1030           GpiLine(hps, &ptl);
    1031           GpiSetColor(hps, CLR_BROWN);
    1032           ptl.x = 1;
    1033           ptl.y = 1;
    1034           GpiMove(hps, &ptl);
    1035           ptl.x = swp.cx - 2;
    1036           GpiLine(hps, &ptl);
    1037           ptl.y = swp.cy - 2;
    1038           GpiLine(hps, &ptl);
    1039           ptl.x = 2;
    1040           ptl.y = 2;
    1041           GpiMove(hps, &ptl);
    1042           ptl.x = swp.cx - 3;
    1043           GpiLine(hps, &ptl);
    1044           ptl.y = swp.cy - 3;
    1045           GpiLine(hps, &ptl);
    1046         }
    1047         WinEndPaint(hps);
     972        WinQueryWindowPos(hwnd, &swp);
     973        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
     974        GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
     975        GpiSetBackMix(hps, BM_LEAVEALONE);
     976        GpiSetMix(hps, FM_OVERPAINT);
     977        ptl.x = ptl.y = 0;
     978        GpiMove(hps, &ptl);
     979        ptl.x = swp.cx - 1;
     980        ptl.y = swp.cy - 1;
     981        GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     982        tlen = WinQueryWindowTextLength(hwnd);
     983        if (tlen) {
     984          s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
     985          if (s) {
     986            WinQueryWindowText(hwnd, tlen + 1, s);
     987            if (*s) {
     988              p = s;
     989              y = swp.cy - 3;
     990              extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
     991              GpiSetColor(hps, 0);
     992              GpiSetMix(hps, FM_OVERPAINT);
     993              while (p && *p) {
     994                wp = NULL;
     995                pp = strchr(p, '\r');
     996                if (pp) {
     997                  wp = pp;
     998                  *pp = 0;
     999                  pp++;
     1000                }
     1001                GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
     1002                ptl.x = 7;
     1003                y -= aptl[TXTBOX_TOPLEFT].y;
     1004                if (p != s)
     1005                  y -= extra;
     1006                ptl.y = y;
     1007                GpiCharStringAt(hps, &ptl, strlen(p), p);
     1008                if (wp)
     1009                  *wp = '\r';
     1010                p = pp;
     1011              }
     1012            }
     1013            xfree(s, pszSrcFile, __LINE__);
     1014          }
     1015        }
     1016        if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
     1017          GpiSetColor(hps, CLR_WHITE);
     1018          ptl.x = 1;
     1019          ptl.y = 1;
     1020          GpiMove(hps, &ptl);
     1021          ptl.y = swp.cy - 2;
     1022          GpiLine(hps, &ptl);
     1023          ptl.x = swp.cx - 2;
     1024          GpiLine(hps, &ptl);
     1025          ptl.x = 2;
     1026          ptl.y = 2;
     1027          GpiMove(hps, &ptl);
     1028          ptl.y = swp.cy - 3;
     1029          GpiLine(hps, &ptl);
     1030          ptl.x = swp.cx - 3;
     1031          GpiLine(hps, &ptl);
     1032          GpiSetColor(hps, CLR_BROWN);
     1033          ptl.x = 1;
     1034          ptl.y = 1;
     1035          GpiMove(hps, &ptl);
     1036          ptl.x = swp.cx - 2;
     1037          GpiLine(hps, &ptl);
     1038          ptl.y = swp.cy - 2;
     1039          GpiLine(hps, &ptl);
     1040          ptl.x = 2;
     1041          ptl.y = 2;
     1042          GpiMove(hps, &ptl);
     1043          ptl.x = swp.cx - 3;
     1044          GpiLine(hps, &ptl);
     1045          ptl.y = swp.cy - 3;
     1046          GpiLine(hps, &ptl);
     1047        }
     1048        WinEndPaint(hps);
    10481049      }
    10491050    }
     
    10721073      switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
    10731074      case MAIN_LED:
    1074         hps = WinGetPS(hwnd);
    1075         hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
    1076         if (!fBlueLED) {
    1077           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
    1078           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
    1079         }
    1080         else {
    1081           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
    1082           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
    1083         }
    1084         if (hbmLEDoff && hbmLEDon)
    1085           WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
    1086         else {
    1087           if (hbmLEDoff)
    1088             GpiDeleteBitmap(hbmLEDoff);
    1089           if (hbmLEDon)
    1090             GpiDeleteBitmap(hbmLEDon);
    1091         }
    1092         if (hbmold &&
    1093             hbmLEDon &&
    1094             hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
    1095           GpiDeleteBitmap(hbmold);
    1096         if (hps)
    1097           WinReleasePS(hps);
    1098         break;
     1075        hps = WinGetPS(hwnd);
     1076        hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
     1077        if (!fBlueLED) {
     1078          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
     1079          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
     1080        }
     1081        else {
     1082          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
     1083          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
     1084        }
     1085        if (hbmLEDoff && hbmLEDon)
     1086          WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
     1087        else {
     1088          if (hbmLEDoff)
     1089            GpiDeleteBitmap(hbmLEDoff);
     1090          if (hbmLEDon)
     1091            GpiDeleteBitmap(hbmLEDon);
     1092        }
     1093        if (hbmold &&
     1094            hbmLEDon &&
     1095            hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
     1096          GpiDeleteBitmap(hbmold);
     1097        if (hps)
     1098          WinReleasePS(hps);
     1099        break;
    10991100      default:
    1100         SetPresParams(hwnd,
    1101                       &RGBGREY,
    1102                       &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    1103         break;
     1101        SetPresParams(hwnd,
     1102                      &RGBGREY,
     1103                      &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     1104        break;
    11041105      }
    11051106      return mr;
     
    11251126  case WM_BUTTON1CLICK:
    11261127    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1127             WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
     1128            WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
    11281129    break;
    11291130
    11301131  case WM_BUTTON2CLICK:
    11311132    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1132             WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
     1133            WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
    11331134    break;
    11341135
     
    11361137  case WM_BUTTON3CLICK:
    11371138    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1138             WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     1139            WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    11391140    break;
    11401141  }
     
    11591160    if (fToolbarHelp) {
    11601161      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    1161           && !WinQueryCapture(HWND_DESKTOP)) {
    1162         id = WinQueryWindowUShort(hwnd, QWS_ID);
    1163         tool = find_tool(id);
    1164         if (tool && tool->help && *tool->help) {
    1165 
    1166           char s[128];
    1167 
    1168           strcpy(s, tool->help);
    1169           if (tool->flags & T_DROPABLE)
    1170             strcat(s, GetPString(IDS_DROPONMETEXT));
    1171           MakeBubble(hwnd, FALSE, s);
    1172         }
     1162          && !WinQueryCapture(HWND_DESKTOP)) {
     1163        id = WinQueryWindowUShort(hwnd, QWS_ID);
     1164        tool = find_tool(id);
     1165        if (tool && tool->help && *tool->help) {
     1166
     1167          char s[128];
     1168
     1169          strcpy(s, tool->help);
     1170          if (tool->flags & T_DROPABLE)
     1171            strcat(s, GetPString(IDS_DROPONMETEXT));
     1172          MakeBubble(hwnd, FALSE, s);
     1173        }
    11731174      }
    11741175    }
     
    11791180    case IDM_HELP:
    11801181      if (hwndHelp)
    1181         WinSendMsg(hwndHelp,
    1182                    HM_DISPLAY_HELP,
    1183                    MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
     1182        WinSendMsg(hwndHelp,
     1183                   HM_DISPLAY_HELP,
     1184                   MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
    11841185      break;
    11851186
     
    11871188    case IDM_HIDETOOL:                  /* hide tool */
    11881189      if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
    1189         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1190        id = WinQueryWindowUShort(hwnd, QWS_ID);
    11901191      else
    1191         id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
    1192                                 PickToolProc, FM3ModHandle,
    1193                                 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
     1192        id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
     1193                                PickToolProc, FM3ModHandle,
     1194                                PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
    11941195      if (id) {
    1195         tool = find_tool(id);
    1196         if (tool) {
    1197           tool->flags |= T_INVISIBLE;
    1198           fToolsChanged = TRUE;
    1199         }
     1196        tool = find_tool(id);
     1197        if (tool) {
     1198          tool->flags |= T_INVISIBLE;
     1199          fToolsChanged = TRUE;
     1200        }
    12001201      }
    12011202      break;
     
    12041205      tool = toolhead;
    12051206      while (tool) {
    1206         tool->flags &= (~T_INVISIBLE);
    1207         tool = tool->next;
    1208         fToolsChanged = TRUE;
     1207        tool->flags &= (~T_INVISIBLE);
     1208        tool = tool->next;
     1209        fToolsChanged = TRUE;
    12091210      }
    12101211      break;
     
    12131214    case IDM_DELETETOOL:                /* delete button */
    12141215      if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
    1215         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1216        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12161217      else
    1217         id =
    1218           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1219                              PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
     1218        id =
     1219          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1220                             PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
    12201221      if (id)
    1221         PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
    1222                 MPFROM2SHORT(id, 0), MPVOID);
     1222        PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
     1223                MPFROM2SHORT(id, 0), MPVOID);
    12231224      return 0;
    12241225
     
    12261227    case IDM_EDITTOOL:                  /* edit button */
    12271228      if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
    1228         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1229        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12291230      else
    1230         id =
    1231           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1232                              PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
     1231        id =
     1232          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1233                             PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
    12331234      if (id) {
    1234         tool = find_tool(id);
    1235         if (tool) {
    1236           if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1237                         ADDBTN_FRAME, (PVOID) tool))
    1238             WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1239                                                                      QW_PARENT),
    1240                                                       QW_PARENT), FID_CLIENT),
    1241                        WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1242                        MPFROM2SHORT(id, 0));
    1243         }
     1235        tool = find_tool(id);
     1236        if (tool) {
     1237          if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
     1238                        ADDBTN_FRAME, (PVOID) tool))
     1239            WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1240                                                                     QW_PARENT),
     1241                                                      QW_PARENT), FID_CLIENT),
     1242                       WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1243                       MPFROM2SHORT(id, 0));
     1244        }
    12441245      }
    12451246      break;
     
    12471248    case IDM_ADDTOOL:                   /* add tool */
    12481249      id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1249                               ADDBTN_FRAME, MPVOID);
     1250                              ADDBTN_FRAME, MPVOID);
    12501251      if (id && id != (USHORT) - 1)
    1251         WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1252                                                                 QW_PARENT),
    1253                                                   QW_PARENT), FID_CLIENT),
    1254                    WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1255                    MPFROM2SHORT(id, 0));
     1252        WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1253                                                                QW_PARENT),
     1254                                                  QW_PARENT), FID_CLIENT),
     1255                   WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1256                   MPFROM2SHORT(id, 0));
    12561257      break;
    12571258
    12581259    case IDM_REORDERTOOLS:              /* reorder tools */
    12591260      WinDlgBox(HWND_DESKTOP,
    1260                 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
     1261                hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
    12611262      break;
    12621263
     
    12641265    case IDM_LOADTOOLS:
    12651266      if (WinDlgBox(HWND_DESKTOP,
    1266                     hwnd,
    1267                     ToolIODlgProc,
    1268                     FM3ModHandle,
    1269                     SVBTN_FRAME,
    1270                     (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    1271                     "TRUE" : NULL))
    1272         BuildTools(hwndToolback, TRUE);
     1267                    hwnd,
     1268                    ToolIODlgProc,
     1269                    FM3ModHandle,
     1270                    SVBTN_FRAME,
     1271                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
     1272                    "TRUE" : NULL))
     1273        BuildTools(hwndToolback, TRUE);
    12731274      break;
    12741275    }
     
    13021303      tool = find_tool(id);
    13031304      if (!tool) {
    1304         DrgFreeDraginfo(pDInfo);
    1305         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1305        DrgFreeDraginfo(pDInfo);
     1306        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13061307      }
    13071308      if (!(tool->flags & T_DROPABLE)) {
    1308         DrgFreeDraginfo(pDInfo);
    1309         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1309        DrgFreeDraginfo(pDInfo);
     1310        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13101311      }
    13111312      {
    1312         PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
    1313 
    1314         pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
    1315                                      0);        /* Index to DRAGITEM */
    1316         if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
    1317                         DRM_OS2FILE,   /* mechanisms and data */
    1318                         NULL)) {       /* formats */
    1319           if (!(tool->flags & T_EMPHASIZED)) {
    1320             tool->flags |= T_EMPHASIZED;
    1321             DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1322             DrgFreeDraginfo(pDInfo);
    1323           }
    1324           return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
    1325                                DO_MOVE));       /* Move operation valid */
    1326         }
    1327         DrgFreeDraginfo(pDInfo);
     1313        PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
     1314
     1315        pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
     1316                                     0);        /* Index to DRAGITEM */
     1317        if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
     1318                        DRM_OS2FILE,   /* mechanisms and data */
     1319                        NULL)) {       /* formats */
     1320          if (!(tool->flags & T_EMPHASIZED)) {
     1321            tool->flags |= T_EMPHASIZED;
     1322            DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1323            DrgFreeDraginfo(pDInfo);
     1324          }
     1325          return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
     1326                               DO_MOVE));       /* Move operation valid */
     1327        }
     1328        DrgFreeDraginfo(pDInfo);
    13281329      }
    13291330    }
     
    13421343    if (tool && (tool->flags & T_DROPABLE)) {
    13431344      if (tool->flags & T_EMPHASIZED) {
    1344         tool->flags &= (~T_EMPHASIZED);
    1345         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1345        tool->flags &= (~T_EMPHASIZED);
     1346        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    13461347      }
    13471348    }
     
    13561357
    13571358      if (tool->flags & T_EMPHASIZED) {
    1358         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1359         tool->flags &= (~T_EMPHASIZED);
     1359        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1360        tool->flags &= (~T_EMPHASIZED);
    13601361      }
    13611362      memset(&cdi, 0, sizeof(cdi));
     
    13641365      CheckPmDrgLimit(cdi.pDragInfo);
    13651366      if (li) {
    1366         li->type = id;
    1367         if (!li->list || !li->list[0])
    1368           FreeListInfo(li);
    1369         else {
    1370           HWND hwndActive;
    1371 
    1372           hwndActive = TopWindow(hwndMain, (HWND) 0);
    1373           if (hwndActive) {
    1374             if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
    1375               FreeListInfo(li);
    1376           }
    1377           else
    1378             FreeListInfo(li);
    1379         }
     1367        li->type = id;
     1368        if (!li->list || !li->list[0])
     1369          FreeListInfo(li);
     1370        else {
     1371          HWND hwndActive;
     1372
     1373          hwndActive = TopWindow(hwndMain, (HWND) 0);
     1374          if (hwndActive) {
     1375            if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
     1376              FreeListInfo(li);
     1377          }
     1378          else
     1379            FreeListInfo(li);
     1380        }
    13801381      }
    13811382    }
     
    14141415    if (!fTextTools) {
    14151416      if (!(tool->flags & T_MYICON)) {
    1416         hwndTool = WinCreateWindow(hwndT,
    1417                                    WC_TOOLBUTTONS,
    1418                                    s,
    1419                                    BS_NOPOINTERFOCUS |
    1420                                    BS_BITMAP | BS_PUSHBUTTON,
    1421                                    ctrlxpos,
    1422                                    14,
    1423                                    32,
    1424                                    32, hwndT, HWND_TOP, tool->id, NULL, NULL);
     1417        hwndTool = WinCreateWindow(hwndT,
     1418                                   WC_TOOLBUTTONS,
     1419                                   s,
     1420                                   BS_NOPOINTERFOCUS |
     1421                                   BS_BITMAP | BS_PUSHBUTTON,
     1422                                   ctrlxpos,
     1423                                   14,
     1424                                   32,
     1425                                   32, hwndT, HWND_TOP, tool->id, NULL, NULL);
    14251426      }
    14261427      if (!hwndTool) {
    1427         HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
    1428 
    1429         if (hbm) {
    1430           BTNCDATA btc;
    1431 
    1432           memset(&btc, 0, sizeof(btc));
    1433           btc.cb = sizeof(btc);
    1434           btc.hImage = hbm;
    1435           hwndTool = WinCreateWindow(hwndT,
    1436                                      WC_TOOLBUTTONS,
    1437                                      NullStr,
    1438                                      BS_NOPOINTERFOCUS |
    1439                                      BS_BITMAP | BS_PUSHBUTTON,
    1440                                      ctrlxpos,
    1441                                      14,
    1442                                      32,
    1443                                      32,
    1444                                      hwndT, HWND_TOP, tool->id, &btc, NULL);
    1445           if (!hwndTool)
    1446             GpiDeleteBitmap(hbm);
    1447         }
     1428        HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
     1429
     1430        if (hbm) {
     1431          BTNCDATA btc;
     1432
     1433          memset(&btc, 0, sizeof(btc));
     1434          btc.cb = sizeof(btc);
     1435          btc.hImage = hbm;
     1436          hwndTool = WinCreateWindow(hwndT,
     1437                                     WC_TOOLBUTTONS,
     1438                                     NullStr,
     1439                                     BS_NOPOINTERFOCUS |
     1440                                     BS_BITMAP | BS_PUSHBUTTON,
     1441                                     ctrlxpos,
     1442                                     14,
     1443                                     32,
     1444                                     32,
     1445                                     hwndT, HWND_TOP, tool->id, &btc, NULL);
     1446          if (!hwndTool)
     1447            GpiDeleteBitmap(hbm);
     1448        }
    14481449      }
    14491450      if (hwndTool)
    1450         tool->flags &= (~T_TEXT);
     1451        tool->flags &= (~T_TEXT);
    14511452    }
    14521453    if (!hwndTool) {
    14531454      hwndTool = WinCreateWindow(hwndT,
    1454                                 WC_TOOLBUTTONS,
    1455                                 (!tool->text && tool->id >= IDM_COMMANDSTART
    1456                                   && tool->id <
    1457                                   IDM_QUICKTOOLSTART) ? command_title(tool->
    1458                                                                       id -
    1459                                                                       IDM_COMMANDSTART)
    1460                                 : tool->text,
    1461                                 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
    1462                                 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
    1463                                 NULL);
     1455                                WC_TOOLBUTTONS,
     1456                                (!tool->text && tool->id >= IDM_COMMANDSTART
     1457                                  && tool->id <
     1458                                  IDM_QUICKTOOLSTART) ? command_title(tool->
     1459                                                                      id -
     1460                                                                      IDM_COMMANDSTART)
     1461                                : tool->text,
     1462                                BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
     1463                                2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
     1464                                NULL);
    14641465      if (!hwndTool)
    1465         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1466                    IDS_WINCREATEWINDOW);
     1466        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1467                   IDS_WINCREATEWINDOW);
    14671468      tool->flags |= T_TEXT;
    14681469    }
    14691470    if (fToolTitles && !fTextTools) {
    14701471      hwndTool = WinCreateWindow(hwndT,
    1471                                 WC_STATIC,
    1472                                 tool->text,
    1473                                 SS_TEXT | DT_LEFT | DT_VCENTER,
    1474                                 ctrlxpos,
    1475                                 1,
    1476                                 32,
    1477                                 10,
    1478                                 hwndT,
    1479                                 HWND_TOP, tool->id + 25000, NULL, NULL);
     1472                                WC_STATIC,
     1473                                tool->text,
     1474                                SS_TEXT | DT_LEFT | DT_VCENTER,
     1475                                ctrlxpos,
     1476                                1,
     1477                                32,
     1478                                10,
     1479                                hwndT,
     1480                                HWND_TOP, tool->id + 25000, NULL, NULL);
    14801481      if (!hwndTool)
    1481         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1482                    IDS_WINCREATEWINDOW);
     1482        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1483                   IDS_WINCREATEWINDOW);
    14831484      else {
    1484         SetPresParams(hwndTool,
    1485                       &RGBGREY,
    1486                       &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
     1485        SetPresParams(hwndTool,
     1486                      &RGBGREY,
     1487                      &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
    14871488      }
    14881489    }
    14891490    ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
    14901491    SetPresParams(WinWindowFromID(hwndT, tool->id),
    1491                   NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
     1492                  NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
    14921493    tool = tool->next;
    14931494  }                                     // while tool
    14941495
    14951496  hwndTool = WinCreateWindow(hwndT,
    1496                              WC_BUTTON,
    1497                              "#6010",
    1498                              BS_NOPOINTERFOCUS |
    1499                              BS_BITMAP | BS_PUSHBUTTON,
    1500                              1,
    1501                              19,
    1502                              14,
    1503                              13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
     1497                             WC_BUTTON,
     1498                             "#6010",
     1499                             BS_NOPOINTERFOCUS |
     1500                             BS_BITMAP | BS_PUSHBUTTON,
     1501                             1,
     1502                             19,
     1503                             14,
     1504                             13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
    15041505  if (!hwndTool)
    15051506    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1506                IDS_WINCREATEWINDOW);
     1507               IDS_WINCREATEWINDOW);
    15071508  hwndTool =
    15081509    WinCreateWindow(hwndT, WC_BUTTON, "#6011",
    1509                     BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
    1510                     13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
     1510                    BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
     1511                    13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
    15111512  if (!hwndTool)
    15121513    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1513                IDS_WINCREATEWINDOW);
     1514               IDS_WINCREATEWINDOW);
    15141515  if (resize)
    15151516    ResizeTools(hwndT);
     
    15171518
    15181519static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
    1519                                         MPARAM mp2)
     1520                                        MPARAM mp2)
    15201521{
    15211522  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    15341535
    15351536      if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
    1536         break;
     1537        break;
    15371538      if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
    1538         WinDestroyWindow(hwnd);
     1539        WinDestroyWindow(hwnd);
    15391540    }
    15401541    break;
     
    15481549        lbup = TRUE;
    15491550        if (WinDlgBox(HWND_DESKTOP,
    1550                       hwnd,
    1551                       CmdLine2DlgProc,
    1552                       FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
    1553           lstrip(pszCmdLine);
    1554         WinSetWindowText(hwnd, pszCmdLine);
     1551                        hwnd,
     1552                      CmdLine2DlgProc,
     1553                      FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
     1554          lstrip(pszCmdLine);
     1555        WinSetWindowText(hwnd, pszCmdLine);
    15551556        }
    15561557        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     
    15731574    case COMMAND_BUTTON:
    15741575      if (!lbup)
    1575         PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1576        PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    15761577      break;
    15771578    }
     
    15921593      bstrip(cl + len);
    15931594      if (strlen(cl) > len) {
    1594         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    1595                    UM_SETUP, MPFROMP(cl + len), MPVOID);
    1596         WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
    1597         bstrip(directory);
    1598         if (*directory && (IsRoot(directory) || !IsFile(directory))) {
    1599           if (!FM2Command(directory, cl + len)) {
    1600             hwndCnr = TopWindow(hwndMain, (HWND) 0);
    1601             if (hwndCnr) {
    1602               hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
    1603               if (hwndCnr) {
    1604                 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
    1605                 if (hwndCnr)
    1606                   list = BuildList(hwndCnr);
    1607               }
    1608             }
    1609             WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
    1610             if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
    1611               save_cmdlines(FALSE);
    1612             ExecOnList(hwndCnr,
    1613                        cl,
    1614                        WINDOWED | ((fKeepCmdLine) ?
    1615                                    SEPARATEKEEP : SEPARATE),
    1616                        directory, list, NULL, pszSrcFile, __LINE__);
    1617             xfree(list, pszSrcFile, __LINE__);
    1618             WinDestroyWindow(hwnd);
    1619             break;
    1620           }
    1621         }
     1595        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
     1596                   UM_SETUP, MPFROMP(cl + len), MPVOID);
     1597        WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
     1598        bstrip(directory);
     1599        if (*directory && (IsRoot(directory) || !IsFile(directory))) {
     1600          if (!FM2Command(directory, cl + len)) {
     1601            hwndCnr = TopWindow(hwndMain, (HWND) 0);
     1602            if (hwndCnr) {
     1603              hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
     1604              if (hwndCnr) {
     1605                hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
     1606                if (hwndCnr)
     1607                  list = BuildList(hwndCnr);
     1608              }
     1609            }
     1610            WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
     1611            if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
     1612              save_cmdlines(FALSE);
     1613            ExecOnList(hwndCnr,
     1614                       cl,
     1615                       WINDOWED | ((fKeepCmdLine) ?
     1616                                   SEPARATEKEEP : SEPARATE),
     1617                       directory, list, NULL, pszSrcFile, __LINE__);
     1618            xfree(list, pszSrcFile, __LINE__);
     1619            WinDestroyWindow(hwnd);
     1620            break;
     1621          }
     1622        }
    16221623      }
    16231624      WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     
    16281629    if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
    16291630      if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
    1630         if ((SHORT1FROMMP(mp2) & 255) == '\r')
    1631           PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
    1632         else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
    1633           WinDestroyWindow(hwnd);
    1634         else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
    1635           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1631        if ((SHORT1FROMMP(mp2) & 255) == '\r')
     1632          PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
     1633        else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
     1634          WinDestroyWindow(hwnd);
     1635        else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
     1636          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    16361637      }
    16371638    }
    16381639    else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
    1639              ((SHORT2FROMMP(mp2) == VK_UP ||
    1640                SHORT2FROMMP(mp2) == VK_DOWN) ||
    1641               (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
     1640             ((SHORT2FROMMP(mp2) == VK_UP ||
     1641               SHORT2FROMMP(mp2) == VK_DOWN) ||
     1642              (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
    16421643      return 0;
    16431644    break;
     
    16651666      rgb.bRed = (BYTE)128;
    16661667      SetPresParams(hwnd,
    1667                     &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
     1668                    &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
    16681669      SetTargetDir(hwnd, TRUE);
    16691670    }
     
    16951696  case WM_CONTROLPOINTER:
    16961697    if (!fNoFinger &&
    1697         (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
    1698         SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
     1698        (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
     1699        SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
    16991700      return MRFROMLONG(hptrFinger);
    17001701    break;
     
    17061707      *dv = 0;
    17071708      WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
    1708                         2, dv);
     1709                        2, dv);
    17091710      if (isalpha(*dv)) {
    17101711
    1711         HWND hwndActive;
    1712 
    1713         dv[1] = ':';
    1714         dv[2] = '\\';
    1715         dv[3] = 0;
    1716         hwndActive = TopWindow(hwnd, (HWND) 0);
    1717         if (hwndActive)
    1718           WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    1719                      UM_DRIVECMD, MPFROMP(dv), MPVOID);
     1712        HWND hwndActive;
     1713
     1714        dv[1] = ':';
     1715        dv[2] = '\\';
     1716        dv[3] = 0;
     1717        hwndActive = TopWindow(hwnd, (HWND) 0);
     1718        if (hwndActive)
     1719          WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     1720                     UM_DRIVECMD, MPFROMP(dv), MPVOID);
    17201721      }
    17211722    }
     
    17451746  case WM_MOUSEMOVE:
    17461747    if (fDrivebarHelp &&
    1747         (!hwndBubble ||
    1748         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1749         !WinQueryCapture(HWND_DESKTOP)) {
     1748        (!hwndBubble ||
     1749        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1750        !WinQueryCapture(HWND_DESKTOP)) {
    17501751      id = WinQueryWindowUShort(hwnd, QWS_ID);
    17511752      if (helpid != id) {
    1752         helpid = id;
    1753         PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
     1753        helpid = id;
     1754        PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
    17541755      }
    17551756      else
    1756         helpid = 0;
     1757        helpid = 0;
    17571758    }
    17581759    break;
     
    17611762    if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
    17621763      if ((char *)mp1 &&
    1763           (!hwndBubble ||
    1764            WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1765           !WinQueryCapture(HWND_DESKTOP)) {
    1766 
    1767         RECTL rcl;
    1768         POINTL ptl;
    1769 
    1770         WinQueryPointerPos(HWND_DESKTOP, &ptl);
    1771         WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
    1772         WinQueryWindowRect(hwnd, &rcl);
    1773         if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
    1774           BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
     1764          (!hwndBubble ||
     1765           WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1766          !WinQueryCapture(HWND_DESKTOP)) {
     1767
     1768        RECTL rcl;
     1769        POINTL ptl;
     1770
     1771        WinQueryPointerPos(HWND_DESKTOP, &ptl);
     1772        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
     1773        WinQueryWindowRect(hwnd, &rcl);
     1774        if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
     1775          BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
    17751776      }
    17761777    }
     
    17911792    *szDrv = 0;
    17921793    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1793                                        id + 50), sizeof(szDrv), szDrv);
     1794                                       id + 50), sizeof(szDrv), szDrv);
    17941795    if (isalpha(*szDrv)) {
    17951796      hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
    17961797      if (hwndMenu) {
    1797         BOOL rdy;
    1798         CHAR chDrv = *szDrv;
    1799         UINT iDrv;
    1800 
    1801         strcpy(szDrv + 2, "\\");
    1802         MakeValidDir(szDrv);
    1803         // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
    1804         rdy = toupper(*szDrv) == toupper(chDrv);
    1805         iDrv = toupper(*szDrv) - 'A';
    1806         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    1807           WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
    1808 
    1809         if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
    1810           WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
    1811           WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
    1812           WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
    1813           WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
    1814         }
    1815         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
    1816           WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
    1817           WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
    1818           WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
    1819         }
    1820         if (!rdy) {
    1821           WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
    1822           WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
    1823           WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
    1824           WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
    1825           WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
    1826         }
    1827         /* fixme to be gone?
    1828           if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
    1829             WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
    1830           }
    1831         */
    1832         PopupMenu(hwnd, hwnd, hwndMenu);
     1798        BOOL rdy;
     1799        CHAR chDrv = *szDrv;
     1800        UINT iDrv;
     1801
     1802        strcpy(szDrv + 2, "\\");
     1803        MakeValidDir(szDrv);
     1804        // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
     1805        rdy = toupper(*szDrv) == toupper(chDrv);
     1806        iDrv = toupper(*szDrv) - 'A';
     1807        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
     1808          WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
     1809
     1810        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
     1811          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     1812          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     1813          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     1814          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     1815        }
     1816        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
     1817          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     1818          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     1819          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     1820        }
     1821        if (!rdy) {
     1822          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     1823          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     1824          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     1825          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     1826          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     1827        }
     1828        /* fixme to be gone?
     1829          if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     1830            WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     1831          }
     1832        */
     1833        PopupMenu(hwnd, hwnd, hwndMenu);
    18331834      }
    18341835    }
     
    18451846    *szDrv = 0;
    18461847    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1847                                        id + 50), sizeof(szDrv), szDrv);
     1848                                       id + 50), sizeof(szDrv), szDrv);
    18481849    if (isalpha(*szDrv)) {
    18491850      strcat(szDrv, "\\");
    18501851      if (!FindDirCnrByName(szDrv, TRUE))
    1851         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
     1852        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
    18521853    }
    18531854    break;
     
    18611862    *szDrv = 0;
    18621863    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1863                                        id + 50), sizeof(szDrv), szDrv);
     1864                                       id + 50), sizeof(szDrv), szDrv);
    18641865    if (isalpha(*szDrv)) {
    18651866      strcat(szDrv, "\\");
     
    18721873    *szDrv = 0;
    18731874    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1874                                        id + 50), sizeof(szDrv), szDrv);
     1875                                       id + 50), sizeof(szDrv), szDrv);
    18751876    if (isalpha(*szDrv) &&
    1876         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1877        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18771878      if (!emphasized) {
    1878         emphasized = TRUE;
    1879         DrawTargetEmphasis(hwnd, emphasized);
     1879        emphasized = TRUE;
     1880        DrawTargetEmphasis(hwnd, emphasized);
    18801881      }
    18811882      if (AcceptOneDrop(hwnd, mp1, mp2))
    1882         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     1883        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    18831884      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    18841885    }
     
    18891890    *szDrv = 0;
    18901891    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1891                                        id + 50), sizeof(szDrv), szDrv);
     1892                                       id + 50), sizeof(szDrv), szDrv);
    18921893    if (isalpha(*szDrv) &&
    1893         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1894        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18941895      if (emphasized) {
    1895         emphasized = FALSE;
    1896         DrawTargetEmphasis(hwnd, emphasized);
     1896        emphasized = FALSE;
     1897        DrawTargetEmphasis(hwnd, emphasized);
    18971898      }
    18981899    }
     
    19031904    *szDrv = 0;
    19041905    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1905                                        id + 50), sizeof(szDrv), szDrv);
     1906                                       id + 50), sizeof(szDrv), szDrv);
    19061907    if (isalpha(*szDrv) &&
    1907         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1908        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19081909      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
    19091910      return 0;
     
    19151916    *szDrv = 0;
    19161917    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1917                                        id + 50), sizeof(szDrv), szDrv);
     1918                                       id + 50), sizeof(szDrv), szDrv);
    19181919    if (isalpha(*szDrv) &&
    1919         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1920        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19201921
    19211922      CNRDRAGINFO cnd;
     
    19241925
    19251926      if (emphasized) {
    1926         emphasized = FALSE;
    1927         DrawTargetEmphasis(hwnd, emphasized);
     1927        emphasized = FALSE;
     1928        DrawTargetEmphasis(hwnd, emphasized);
    19281929      }
    19291930      memset(&cnd, 0, sizeof(cnd));
     
    19311932      cnd.pRecord = NULL;
    19321933      li = DoFileDrop(hwnd,
    1933                       NULL,
    1934                       TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
     1934                      NULL,
     1935                      TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
    19351936      CheckPmDrgLimit(cnd.pDragInfo);
    19361937      if (li) {
    1937         strcpy(li->targetpath, szDrv);
    1938         strcat(li->targetpath, "\\");
    1939         if (li->list && li->list[0] && IsRoot(li->list[0]))
    1940           li->type = DO_LINK;
    1941         else if (fDragndropDlg && (!*li->arcname || !li->info)) {
    1942 
    1943           CHECKLIST cl;
    1944 
    1945           memset(&cl, 0, sizeof(cl));
    1946           cl.size = sizeof(cl);
    1947           cl.flags = li->type;
    1948           cl.list = li->list;
    1949           cl.cmd = li->type;
    1950           cl.prompt = li->targetpath;
    1951           li->type = WinDlgBox(HWND_DESKTOP,
    1952                                hwndMain,
    1953                                DropListProc,
    1954                                FM3ModHandle, DND_FRAME, MPFROMP(&cl));
    1955           if (li->type == DID_ERROR)
    1956                   Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
    1957                             "Drag & Drop Dialog");
    1958           if (!li->type) {
    1959             FreeListInfo(li);
    1960             return 0;
    1961           }
    1962           li->list = cl.list;
    1963           if (!li->list || !li->list[0]) {
    1964             FreeListInfo(li);
    1965             return 0;
    1966           }
    1967         }
    1968         else {
    1969           if (!WinDlgBox(HWND_DESKTOP,
    1970                         hwndMain,
    1971                         WalkDlgProc,
    1972                         FM3ModHandle,
    1973                         WALK_FRAME,
    1974                         MPFROMP(li->targetpath)) || !*li->targetpath) {
    1975             FreeListInfo(li);
    1976             return 0;
    1977           }
    1978         }
    1979         switch (li->type) {
    1980         case DND_LAUNCH:
    1981           strcat(li->targetpath, " %a");
    1982           ExecOnList(hwndMain,
    1983                      li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
    1984                      pszSrcFile, __LINE__);
    1985           FreeList(li->list);
    1986           li->list = NULL;
    1987           break;
    1988         case DO_LINK:
    1989           if (fLinkSetsIcon) {
    1990             li->type = IDM_SETICON;
    1991             action = UM_MASSACTION;
    1992           }
    1993           else
    1994             li->type = IDM_COMPARE;
    1995           break;
    1996         case DND_EXTRACT:
    1997           if (*li->targetpath && !IsFile(li->targetpath))
    1998             li->type = IDM_EXTRACT;
    1999           break;
    2000         case DND_MOVE:
    2001           li->type = IDM_MOVE;
    2002           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2003             action = UM_MASSACTION;
    2004             li->type = IDM_ARCHIVEM;
    2005           }
    2006           break;
    2007         case DND_WILDMOVE:
    2008           li->type = IDM_WILDMOVE;
    2009           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2010             action = UM_MASSACTION;
    2011             li->type = IDM_ARCHIVEM;
    2012           }
    2013           break;
    2014         case DND_OBJECT:
    2015           li->type = IDM_OBJECT;
    2016           action = UM_MASSACTION;
    2017           break;
    2018         case DND_SHADOW:
    2019           li->type = IDM_SHADOW;
    2020           action = UM_MASSACTION;
    2021           break;
    2022         case DND_COMPARE:
    2023           li->type = IDM_COMPARE;
    2024           break;
    2025         case DND_SETICON:
    2026           action = UM_MASSACTION;
    2027           li->type = IDM_SETICON;
    2028           break;
    2029         case DND_COPY:
    2030           li->type = IDM_COPY;
    2031           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2032             action = UM_MASSACTION;
    2033             li->type = IDM_ARCHIVE;
    2034           }
    2035           break;
    2036         case DND_WILDCOPY:
    2037           li->type = IDM_WILDCOPY;
    2038           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2039             action = UM_MASSACTION;
    2040             li->type = IDM_ARCHIVE;
    2041           }
    2042           break;
    2043         default:
    2044           if (*li->arcname && li->info) {
    2045             action = UM_MASSACTION;
    2046             li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
    2047               IDM_FAKEEXTRACT;
    2048           }
    2049           else if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2050             action = UM_MASSACTION;
    2051             li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
    2052           }
    2053           else
    2054             li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    2055           break;
    2056         }
    2057         if (!li->list || !li->list[0])
    2058           FreeListInfo(li);
    2059         else
    2060           WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
     1938        strcpy(li->targetpath, szDrv);
     1939        strcat(li->targetpath, "\\");
     1940        if (li->list && li->list[0] && IsRoot(li->list[0]))
     1941          li->type = DO_LINK;
     1942        else if (fDragndropDlg && (!*li->arcname || !li->info)) {
     1943
     1944          CHECKLIST cl;
     1945
     1946          memset(&cl, 0, sizeof(cl));
     1947          cl.size = sizeof(cl);
     1948          cl.flags = li->type;
     1949          cl.list = li->list;
     1950          cl.cmd = li->type;
     1951          cl.prompt = li->targetpath;
     1952          li->type = WinDlgBox(HWND_DESKTOP,
     1953                               hwndMain,
     1954                               DropListProc,
     1955                               FM3ModHandle, DND_FRAME, MPFROMP(&cl));
     1956          if (li->type == DID_ERROR)
     1957                  Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
     1958                            "Drag & Drop Dialog");
     1959          if (!li->type) {
     1960            FreeListInfo(li);
     1961            return 0;
     1962          }
     1963          li->list = cl.list;
     1964          if (!li->list || !li->list[0]) {
     1965            FreeListInfo(li);
     1966            return 0;
     1967          }
     1968        }
     1969        else {
     1970          if (!WinDlgBox(HWND_DESKTOP,
     1971                        hwndMain,
     1972                        WalkDlgProc,
     1973                        FM3ModHandle,
     1974                        WALK_FRAME,
     1975                        MPFROMP(li->targetpath)) || !*li->targetpath) {
     1976            FreeListInfo(li);
     1977            return 0;
     1978          }
     1979        }
     1980        switch (li->type) {
     1981        case DND_LAUNCH:
     1982          strcat(li->targetpath, " %a");
     1983          ExecOnList(hwndMain,
     1984                     li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
     1985                     pszSrcFile, __LINE__);
     1986          FreeList(li->list);
     1987          li->list = NULL;
     1988          break;
     1989        case DO_LINK:
     1990          if (fLinkSetsIcon) {
     1991            li->type = IDM_SETICON;
     1992            action = UM_MASSACTION;
     1993          }
     1994          else
     1995            li->type = IDM_COMPARE;
     1996          break;
     1997        case DND_EXTRACT:
     1998          if (*li->targetpath && !IsFile(li->targetpath))
     1999            li->type = IDM_EXTRACT;
     2000          break;
     2001        case DND_MOVE:
     2002          li->type = IDM_MOVE;
     2003          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2004            action = UM_MASSACTION;
     2005            li->type = IDM_ARCHIVEM;
     2006          }
     2007          break;
     2008        case DND_WILDMOVE:
     2009          li->type = IDM_WILDMOVE;
     2010          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2011            action = UM_MASSACTION;
     2012            li->type = IDM_ARCHIVEM;
     2013          }
     2014          break;
     2015        case DND_OBJECT:
     2016          li->type = IDM_OBJECT;
     2017          action = UM_MASSACTION;
     2018          break;
     2019        case DND_SHADOW:
     2020          li->type = IDM_SHADOW;
     2021          action = UM_MASSACTION;
     2022          break;
     2023        case DND_COMPARE:
     2024          li->type = IDM_COMPARE;
     2025          break;
     2026        case DND_SETICON:
     2027          action = UM_MASSACTION;
     2028          li->type = IDM_SETICON;
     2029          break;
     2030        case DND_COPY:
     2031          li->type = IDM_COPY;
     2032          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2033            action = UM_MASSACTION;
     2034            li->type = IDM_ARCHIVE;
     2035          }
     2036          break;
     2037        case DND_WILDCOPY:
     2038          li->type = IDM_WILDCOPY;
     2039          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2040            action = UM_MASSACTION;
     2041            li->type = IDM_ARCHIVE;
     2042          }
     2043          break;
     2044        default:
     2045          if (*li->arcname && li->info) {
     2046            action = UM_MASSACTION;
     2047            li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
     2048              IDM_FAKEEXTRACT;
     2049          }
     2050          else if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2051            action = UM_MASSACTION;
     2052            li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
     2053          }
     2054          else
     2055            li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
     2056          break;
     2057        }
     2058        if (!li->list || !li->list[0])
     2059          FreeListInfo(li);
     2060        else
     2061          WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
    20612062      }
    20622063      return 0;
     
    20922093    for (x = 0; x < 26; x++) {
    20932094      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    2094         if (x > 1) {
    2095           if (driveflags[x] & DRIVE_CDROM)
    2096             iconid = CDROM_ICON;
    2097           else
    2098             iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
    2099               REMOVABLE_ICON :
    2100                      (driveflags[x] & DRIVE_VIRTUAL) ?
    2101                       VIRTUAL_ICON :
    2102               (driveflags[x] & DRIVE_REMOTE) ?
    2103               REMOTE_ICON :
    2104                      (driveflags[x] & DRIVE_RAMDISK) ?
    2105                       RAMDISK_ICON :
    2106                      (driveflags[x] & DRIVE_ZIPSTREAM) ?
    2107                       ZIPSTREAM_ICON :DRIVE_ICON;
    2108         }
    2109         else
    2110           iconid = FLOPPY_ICON;
    2111         sprintf(s, "#%lu", iconid);
    2112         hwndB = WinCreateWindow(hwndT,
    2113                                 WC_DRIVEBUTTONS,
    2114                                 s,
    2115                                 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
    2116                                 0,
    2117                                 0,
    2118                                 28,
    2119                                 18,
    2120                                 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
    2121         if (!hwndB)
    2122           Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2123                      IDS_WINCREATEWINDOW);
    2124         else {
    2125           WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2126           sprintf(s, "%c:", (CHAR) x + 'A');
    2127           hwndB = WinCreateWindow(hwndT,
    2128                                   WC_STATIC,
    2129                                   s,
    2130                                   SS_TEXT | DT_LEFT | DT_VCENTER,
    2131                                   0,
    2132                                   0,
    2133                                   10,
    2134                                   18,
    2135                                   hwndT,
    2136                                   HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
    2137           if (!hwndB)
    2138             Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2139                        IDS_WINCREATEWINDOW);
    2140           else {
    2141             SetPresParams(hwndB,
    2142                           &RGBGREY,
    2143                           &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    2144             WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2145           }
    2146           y++;
    2147         }
     2095        if (x > 1) {
     2096          if (driveflags[x] & DRIVE_CDROM)
     2097            iconid = CDROM_ICON;
     2098          else
     2099            iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
     2100              REMOVABLE_ICON :
     2101                     (driveflags[x] & DRIVE_VIRTUAL) ?
     2102                      VIRTUAL_ICON :
     2103              (driveflags[x] & DRIVE_REMOTE) ?
     2104              REMOTE_ICON :
     2105                     (driveflags[x] & DRIVE_RAMDISK) ?
     2106                      RAMDISK_ICON :
     2107                     (driveflags[x] & DRIVE_ZIPSTREAM) ?
     2108                      ZIPSTREAM_ICON :DRIVE_ICON;
     2109        }
     2110        else
     2111          iconid = FLOPPY_ICON;
     2112        sprintf(s, "#%lu", iconid);
     2113        hwndB = WinCreateWindow(hwndT,
     2114                                WC_DRIVEBUTTONS,
     2115                                s,
     2116                                BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
     2117                                0,
     2118                                0,
     2119                                28,
     2120                                18,
     2121                                hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
     2122        if (!hwndB)
     2123          Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2124                     IDS_WINCREATEWINDOW);
     2125        else {
     2126          WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2127          sprintf(s, "%c:", (CHAR) x + 'A');
     2128          hwndB = WinCreateWindow(hwndT,
     2129                                  WC_STATIC,
     2130                                  s,
     2131                                  SS_TEXT | DT_LEFT | DT_VCENTER,
     2132                                  0,
     2133                                  0,
     2134                                  10,
     2135                                  18,
     2136                                  hwndT,
     2137                                  HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
     2138          if (!hwndB)
     2139            Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2140                       IDS_WINCREATEWINDOW);
     2141          else {
     2142            SetPresParams(hwndB,
     2143                          &RGBGREY,
     2144                          &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     2145            WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2146          }
     2147          y++;
     2148        }
    21482149      }
    21492150    }                                   // for
    21502151  }                                     // if drivebar
    21512152  PostMsg(WinQueryWindow(hwndT, QW_PARENT),
    2152           WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2153          WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    21532154}
    21542155
     
    21662167    WinQueryWindowRect(hwndT, &rcl);
    21672168    xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
    2168                                              SV_CYSIZEBORDER) * 2) + 2);
     2169                                             SV_CYSIZEBORDER) * 2) + 2);
    21692170  }
    21702171  henum = WinBeginEnumWindows(hwndT);
     
    21752176      ctrlxsize = 28;
    21762177    WinSetWindowPos(hwndB,
    2177                     HWND_TOP,
    2178                     ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
     2178                    HWND_TOP,
     2179                    ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
    21792180    ctrlxpos += (ctrlxsize + 2);
    21802181    if (ctrlxsize == 10) {
    21812182      if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
    2182                             256 : 0)) > xwidth) {
    2183         ctrlxpos = 2;
    2184         ctrlypos += 18;
    2185         DriveLines++;
     2183                            256 : 0)) > xwidth) {
     2184        ctrlxpos = 2;
     2185        ctrlypos += 18;
     2186        DriveLines++;
    21862187      }
    21872188    }
     
    22022203
    22032204      SetPresParams(hwnd,
    2204                     &RGBGREY,
    2205                     &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
     2205                    &RGBGREY,
     2206                    &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
    22062207      return mr;
    22072208    }
     
    22132214
    22142215      cbRetLen = WinQueryPresParam(hwnd,
    2215                                    (ULONG) mp1,
    2216                                    0,
    2217                                    &AttrFound,
    2218                                    (ULONG) sizeof(AttrValue), &AttrValue, 0);
     2216                                   (ULONG) mp1,
     2217                                   0,
     2218                                   &AttrFound,
     2219                                   (ULONG) sizeof(AttrValue), &AttrValue, 0);
    22192220      if (cbRetLen) {
    2220         PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2221                 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2221        PostMsg(WinQueryWindow(hwnd, QW_PARENT),
     2222                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22222223      }
    22232224    }
     
    22362237      WinQueryWindowPos(hwndTree, &swp);
    22372238      if (!(swp.fl & SWP_MAXIMIZE))
    2238         fl |= SWP_RESTORE;
     2239        fl |= SWP_RESTORE;
    22392240      WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
    22402241    }
     
    22692270
    22702271      if (fOtherHelp) {
    2271         if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    2272             && !WinQueryCapture(HWND_DESKTOP)) {
    2273           switch (id) {
    2274           case IDM_ATTRS:
    2275             if (WinQueryWindowTextLength(hwnd))
    2276               s = GetPString(IDS_ATTRSBUTTONHELP);
    2277             break;
    2278           case IDM_INFO:
    2279             if (WinQueryWindowTextLength(hwnd))
    2280               s = GetPString(IDS_INFOBUTTONHELP);
    2281             break;
    2282           case IDM_RENAME:
    2283             if (WinQueryWindowTextLength(hwnd))
    2284               s = GetPString(IDS_NAMEBUTTONHELP);
    2285             break;
    2286           case MAIN_STATUS2:
    2287             if (!hwndE)
    2288               s = GetPString(IDS_STATUS2HELP);
    2289             break;
    2290           default:
    2291             break;
    2292           }
    2293           if (s)
    2294             MakeBubble(hwnd, FALSE, s);
    2295           else if (hwndBubble)
    2296             WinDestroyWindow(hwndBubble);
    2297         }
     2272        if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
     2273            && !WinQueryCapture(HWND_DESKTOP)) {
     2274          switch (id) {
     2275          case IDM_ATTRS:
     2276            if (WinQueryWindowTextLength(hwnd))
     2277              s = GetPString(IDS_ATTRSBUTTONHELP);
     2278            break;
     2279          case IDM_INFO:
     2280            if (WinQueryWindowTextLength(hwnd))
     2281              s = GetPString(IDS_INFOBUTTONHELP);
     2282            break;
     2283          case IDM_RENAME:
     2284            if (WinQueryWindowTextLength(hwnd))
     2285              s = GetPString(IDS_NAMEBUTTONHELP);
     2286            break;
     2287          case MAIN_STATUS2:
     2288            if (!hwndE)
     2289              s = GetPString(IDS_STATUS2HELP);
     2290            break;
     2291          default:
     2292            break;
     2293          }
     2294          if (s)
     2295            MakeBubble(hwnd, FALSE, s);
     2296          else if (hwndBubble)
     2297            WinDestroyWindow(hwndBubble);
     2298        }
    22982299      }
    22992300      switch (id) {
     
    23022303      case IDM_RENAME:
    23032304      case MAIN_STATUS2:
    2304         return CommonTextProc(hwnd, msg, mp1, mp2);
     2305        return CommonTextProc(hwnd, msg, mp1, mp2);
    23052306      default:
    2306         break;
     2307        break;
    23072308      }
    23082309    }
     
    23272328      case IDM_RENAME:
    23282329      case MAIN_STATUS2:
    2329         return CommonTextButton(hwnd, msg, mp1, mp2);
     2330        return CommonTextButton(hwnd, msg, mp1, mp2);
    23302331      default:
    2331         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    2332         break;
     2332        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     2333        break;
    23332334      }
    23342335    }
     
    23422343      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23432344      if (id == MAIN_STATUS2 && hwndE)
    2344         WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2345        WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    23452346      else
    2346         return CommonTextButton(hwnd, msg, mp1, mp2);
     2347        return CommonTextButton(hwnd, msg, mp1, mp2);
    23472348    }
    23482349    break;
     
    23542355      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23552356      if (id == MAIN_STATUS) {
    2356         if (SHORT2FROMMP(mp2) & KC_CTRL)
    2357           PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2358                                   FID_CLIENT),
    2359                   WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    2360         else if (hwndTree)
    2361           PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
     2357        if (SHORT2FROMMP(mp2) & KC_CTRL)
     2358          PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2359                                  FID_CLIENT),
     2360                  WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     2361        else if (hwndTree)
     2362          PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
    23622363      }
    23632364    }
     
    23722373      if (id == MAIN_STATUS2 && !hwndE) {
    23732374
    2374         SWP swp;
    2375         CHAR directory[CCHMAXPATH];
    2376         PFNWP oldproce;
    2377 
    2378         *directory = 0;
    2379         TopWindowName(hwndMain, (HWND) 0, directory);
    2380         WinQueryWindowPos(hwnd, &swp);
    2381         hwndB = WinCreateWindow(hwnd,
    2382                                 WC_BUTTON,
    2383                                 "+",
    2384                                 WS_VISIBLE | BS_PUSHBUTTON |
    2385                                 BS_NOPOINTERFOCUS,
    2386                                 swp.cx - swp.cy,
    2387                                 0,
    2388                                 swp.cy,
    2389                                 swp.cy,
    2390                                 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
    2391         if (!hwndB)
    2392           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2393         hwndE = WinCreateWindow(hwnd,
    2394                                 WC_ENTRYFIELD,
    2395                                 NULL,
    2396                                 WS_VISIBLE | ES_AUTOSCROLL,
    2397                                 0,
    2398                                 0,
    2399                                 swp.cx - swp.cy,
    2400                                 swp.cy,
    2401                                 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
    2402         if (!hwndE)
    2403           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2404         if (!hwndE || !hwndB) {
    2405           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2406           return 0;
    2407         }
    2408         WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
    2409         WinSetWindowText(hwndStatus, directory);
    2410         if (*lastcmd)
    2411           WinSetWindowText(hwndE, lastcmd);
    2412         else
    2413           WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
    2414         oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
    2415         if (oldproce)
    2416           WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
    2417         PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
    2418         PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
    2419         return 0;
     2375        SWP swp;
     2376        CHAR directory[CCHMAXPATH];
     2377        PFNWP oldproce;
     2378
     2379        *directory = 0;
     2380        TopWindowName(hwndMain, (HWND) 0, directory);
     2381        WinQueryWindowPos(hwnd, &swp);
     2382        hwndB = WinCreateWindow(hwnd,
     2383                                WC_BUTTON,
     2384                                "+",
     2385                                WS_VISIBLE | BS_PUSHBUTTON |
     2386                                BS_NOPOINTERFOCUS,
     2387                                swp.cx - swp.cy,
     2388                                0,
     2389                                swp.cy,
     2390                                swp.cy,
     2391                                hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
     2392        if (!hwndB)
     2393          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2394        hwndE = WinCreateWindow(hwnd,
     2395                                WC_ENTRYFIELD,
     2396                                NULL,
     2397                                WS_VISIBLE | ES_AUTOSCROLL,
     2398                                0,
     2399                                0,
     2400                                swp.cx - swp.cy,
     2401                                swp.cy,
     2402                                hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
     2403        if (!hwndE)
     2404          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2405        if (!hwndE || !hwndB) {
     2406          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2407          return 0;
     2408        }
     2409        WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
     2410        WinSetWindowText(hwndStatus, directory);
     2411        if (*lastcmd)
     2412          WinSetWindowText(hwndE, lastcmd);
     2413        else
     2414          WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
     2415        oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
     2416        if (oldproce)
     2417          WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
     2418        PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
     2419        PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     2420        return 0;
    24202421      }
    24212422      if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
    2422         switch (id) {
    2423         case IDM_ATTRS:
    2424           id = IDM_SORTSIZE;
    2425           break;
    2426         case IDM_INFO:
    2427           id = IDM_SORTLWDATE;
    2428           break;
    2429         case IDM_RENAME:
    2430           id = IDM_SORTFILENAME;
    2431           break;
    2432         }
     2423        switch (id) {
     2424        case IDM_ATTRS:
     2425          id = IDM_SORTSIZE;
     2426          break;
     2427        case IDM_INFO:
     2428          id = IDM_SORTLWDATE;
     2429          break;
     2430        case IDM_RENAME:
     2431          id = IDM_SORTFILENAME;
     2432          break;
     2433        }
    24332434      }
    24342435      PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2435               WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
     2436              WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
    24362437    }
    24372438    return 0;
     
    24472448      case IDM_RENAME:
    24482449      case MAIN_STATUS2:
    2449         PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
    2450         break;
     2450        PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
     2451        break;
    24512452      default:
    2452         PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
    2453         break;
     2453        PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
     2454        break;
    24542455      }
    24552456      if (id == IDM_RENAME) {
    24562457
    2457         HPS hps;
    2458 
    2459         hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    2460         if (hps) {
    2461           PaintSTextWindow(hwnd, hps);
    2462           WinEndPaint(hps);
    2463         }
    2464         return 0;
     2458        HPS hps;
     2459
     2460        hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
     2461        if (hps) {
     2462          PaintSTextWindow(hwnd, hps);
     2463          WinEndPaint(hps);
     2464        }
     2465        return 0;
    24652466      }
    24662467    }
     
    24952496  case UM_COMMAND:
    24962497    return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2497                                       FID_CLIENT), msg, mp1, mp2);
     2498                                      FID_CLIENT), msg, mp1, mp2);
    24982499
    24992500  case WM_PAINT:
     
    25082509      hps = WinBeginPaint(hwnd, (HPS)0, NULL);
    25092510      if (hps) {
    2510         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
    2511         WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
    2512                           sizeof(lColor), &lColor, 0);
    2513         WinQueryWindowRect(hwnd, &rcl);
    2514         WinFillRect(hps, &rcl, lColor);
    2515         WinEndPaint(hps);
     2511        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
     2512        WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
     2513                          sizeof(lColor), &lColor, 0);
     2514        WinQueryWindowRect(hwnd, &rcl);
     2515        WinFillRect(hps, &rcl, lColor);
     2516        WinEndPaint(hps);
    25162517      }
    25172518
     
    25322533      tool = find_tool(id);
    25332534      if (tool) {
    2534         del_tool(tool);
    2535         WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
    2536         if (fToolTitles)
    2537           WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
    2538         ResizeTools(hwnd);
     2535        del_tool(tool);
     2536        WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
     2537        if (fToolTitles)
     2538          WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
     2539        ResizeTools(hwnd);
    25392540      }
    25402541    }
     
    25462547
    25472548      id = (USHORT) WinDlgBox(HWND_DESKTOP,
    2548                               hwnd,
    2549                               AddToolProc,
    2550                               FM3ModHandle, ADDBTN_FRAME, MPVOID);
     2549                              hwnd,
     2550                              AddToolProc,
     2551                              FM3ModHandle, ADDBTN_FRAME, MPVOID);
    25512552      if (id && id != (USHORT) - 1)
    2552         WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2553                                    FID_CLIENT),
    2554                    WM_COMMAND,
    2555                    MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
     2553        WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2554                                   FID_CLIENT),
     2555                   WM_COMMAND,
     2556                   MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
    25562557    }
    25572558    break;
     
    25592560  case WM_CONTEXTMENU:
    25602561    if (WinDlgBox(HWND_DESKTOP,
    2561                   hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
     2562                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    25622563      BuildTools(hwnd, TRUE);
    25632564    return MRFROMSHORT(TRUE);
     
    25822583  if (pswp) {
    25832584    if (WinQueryWindowPos(hwndTree, &swp) &&
    2584         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
     2585        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
    25852586      pswp->x = swp.cx;
    25862587      pswp->cx -= swp.cx;
     
    25892590  if (prectl) {
    25902591    if (WinQueryWindowPos(hwndTree, &swp) &&
    2591         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
    2592         WinQueryWindowRect(hwndTree, &rectl)) {
     2592        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
     2593        WinQueryWindowRect(hwndTree, &rectl)) {
    25932594      prectl->xLeft = rectl.xRight;
    25942595      prectl->xRight -= rectl.xRight;
     
    26422643    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    26432644      if (swp.x < swpT.cx) {
    2644         swp.x = swpT.cx;
    2645         if (swp.x + swp.cx > swpC.cx)
    2646           swp.cx = swpC.cx - swp.x;
    2647         if (swp.cx > 24)
    2648           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    2649                           SWP_SIZE | SWP_MOVE | SWP_SHOW);
     2645        swp.x = swpT.cx;
     2646        if (swp.x + swp.cx > swpC.cx)
     2647          swp.cx = swpC.cx - swp.x;
     2648        if (swp.cx > 24)
     2649          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     2650                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
    26502651      }
    26512652    }
     
    26672668      WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    26682669      WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    2669                       SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
     2670                      SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
    26702671    }
    26712672  }
     
    26892690    if (hwndNext) {
    26902691      if (!WinQueryWindowUShort(hwndNext, QWS_ID))
    2691         continue;
     2692        continue;
    26922693      if (next)
    2693         break;
     2694        break;
    26942695      if (hwndNext == hwndActive) {
    2695         if (!previous && hwndPrev) {
    2696           hwndNext = hwndPrev;
    2697           break;
    2698         }
    2699         else if (previous)
    2700           next = TRUE;
     2696        if (!previous && hwndPrev) {
     2697          hwndNext = hwndPrev;
     2698          break;
     2699        }
     2700        else if (previous)
     2701          next = TRUE;
    27012702      }
    27022703      hwndPrev = hwndNext;
     
    27042705    else {
    27052706      if ((!next && previous) || once)
    2706         break;
     2707        break;
    27072708      else if (!previous) {
    2708         hwndNext = hwndPrev;
    2709         break;
     2709        hwndNext = hwndPrev;
     2710        break;
    27102711      }
    27112712      else
    2712         once = next = TRUE;
     2713        once = next = TRUE;
    27132714    }
    27142715  }
     
    27172718  if (hwndNext && hwndNext != hwndActive) {
    27182719    WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
    2719                     SWP_ZORDER | SWP_ACTIVATE);
     2720                    SWP_ZORDER | SWP_ACTIVATE);
    27202721    WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
    2721                     0, 0, SWP_ZORDER);
     2722                    0, 0, SWP_ZORDER);
    27222723  }
    27232724}
     
    27342735    if (hwndChild != hwndTree) {
    27352736      WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2736                 WM_SAVEAPPLICATION, MPVOID, MPVOID);
     2737                WM_SAVEAPPLICATION, MPVOID, MPVOID);
    27372738      if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2738                      WM_CLOSE, MPVOID, MPVOID)) {
    2739         ret = TRUE;
    2740         break;
     2739                     WM_CLOSE, MPVOID, MPVOID)) {
     2740        ret = TRUE;
     2741        break;
    27412742      }
    27422743    }
     
    27612762      hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
    27622763      if (hwndTemp) {
    2763         hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
    2764         if (hwndDir) {
    2765           WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2766                      WM_CLOSE, MPVOID, MPVOID);
    2767           ret = TRUE;
    2768         }
     2764        hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
     2765        if (hwndDir) {
     2766          WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
     2767                     WM_CLOSE, MPVOID, MPVOID);
     2768          ret = TRUE;
     2769        }
    27692770      }
    27702771    }
     
    28142815      hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
    28152816      if (hwndC) {
    2816         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    2817         if (hwndDir) {
    2818           WinQueryWindowPos(hwndChild, &swp);
    2819           *szDir = 0;
    2820           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
    2821           if (*szDir) {
    2822            // If saving shutdown state skip no prescan drives
    2823            if (fIsShutDownState &&
    2824                driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    2825              continue;
    2826            }
    2827             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2828             PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    2829                                 sizeof(SWP));
    2830             dcd =
    2831               WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2832             if (dcd) {
    2833               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2834               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2835                                   sizeof(INT));
    2836               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2837               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2838                                   sizeof(MASK));
    2839               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    2840               flWindowAttr = dcd->flWindowAttr;
    2841               if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
    2842                 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    2843                 if (dcd->lastattr) {
    2844                   if (dcd->lastattr & CV_TEXT)
    2845                     flWindowAttr |= CV_TEXT;
    2846                   else if (dcd->lastattr & CV_DETAIL)
    2847                     flWindowAttr |= CV_DETAIL;
    2848                   else if (dcd->lastattr & CV_ICON)
    2849                     flWindowAttr |= CV_ICON;
    2850                   else
    2851                     flWindowAttr |= CV_NAME;
    2852                 }
    2853                 else
    2854                   flWindowAttr |= CV_NAME;
    2855               }
    2856               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    2857                                   sizeof(ULONG));
    2858               sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
    2859               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslongname,
    2860                                   sizeof(BOOL));
    2861               sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
    2862               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssubject,
    2863                                   sizeof(BOOL));
    2864               sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
    2865               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssize,
    2866                                   sizeof(BOOL));
    2867               sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
    2868               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsea,
    2869                                   sizeof(BOOL));
    2870               sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
    2871               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsattr,
    2872                                   sizeof(BOOL));
    2873               sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
    2874               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsicon,
    2875                                   sizeof(BOOL));
    2876               sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
    2877               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwdate,
    2878                                   sizeof(BOOL));
    2879               sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
    2880               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwtime,
    2881                                   sizeof(BOOL));
    2882               sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
    2883               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsladate,
    2884                                   sizeof(BOOL));
    2885               sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
    2886               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslatime,
    2887                                   sizeof(BOOL));
    2888               sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
    2889               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrdate,
    2890                                   sizeof(BOOL));
    2891               sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
    2892               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrtime,
    2893                                   sizeof(BOOL));
    2894               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2895               SavePresParams(hwndDir, szKey);
    2896             }
    2897             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    2898             PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    2899             nSaved++;
    2900           }
    2901         }
     2817        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     2818        if (hwndDir) {
     2819          WinQueryWindowPos(hwndChild, &swp);
     2820          *szDir = 0;
     2821          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
     2822          if (*szDir) {
     2823           // If saving shutdown state skip no prescan drives
     2824           if (fIsShutDownState &&
     2825               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     2826             continue;
     2827           }
     2828            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2829            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
     2830                                sizeof(SWP));
     2831            dcd =
     2832              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
     2833            if (dcd) {
     2834              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2835              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
     2836                                  sizeof(INT));
     2837              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2838              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
     2839                                  sizeof(MASK));
     2840              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2841              flWindowAttr = dcd->flWindowAttr;
     2842              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     2843                flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     2844                if (dcd->lastattr) {
     2845                  if (dcd->lastattr & CV_TEXT)
     2846                    flWindowAttr |= CV_TEXT;
     2847                  else if (dcd->lastattr & CV_DETAIL)
     2848                    flWindowAttr |= CV_DETAIL;
     2849                  else if (dcd->lastattr & CV_ICON)
     2850                    flWindowAttr |= CV_ICON;
     2851                  else
     2852                    flWindowAttr |= CV_NAME;
     2853                }
     2854                else
     2855                  flWindowAttr |= CV_NAME;
     2856              }
     2857              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2858                                  sizeof(ULONG));
     2859              sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
     2860              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslongname,
     2861                                  sizeof(BOOL));
     2862              sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
     2863              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssubject,
     2864                                  sizeof(BOOL));
     2865              sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
     2866              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssize,
     2867                                  sizeof(BOOL));
     2868              sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
     2869              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsea,
     2870                                  sizeof(BOOL));
     2871              sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
     2872              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsattr,
     2873                                  sizeof(BOOL));
     2874              sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
     2875              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsicon,
     2876                                  sizeof(BOOL));
     2877              sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
     2878              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwdate,
     2879                                  sizeof(BOOL));
     2880              sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
     2881              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwtime,
     2882                                  sizeof(BOOL));
     2883              sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
     2884              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsladate,
     2885                                  sizeof(BOOL));
     2886              sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
     2887              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslatime,
     2888                                  sizeof(BOOL));
     2889              sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
     2890              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrdate,
     2891                                  sizeof(BOOL));
     2892              sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
     2893              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrtime,
     2894                                  sizeof(BOOL));
     2895              sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
     2896              SavePresParams(hwndDir, szKey);
     2897            }
     2898            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     2899            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     2900            nSaved++;
     2901          }
     2902        }
    29022903      }
    29032904    }
     
    29452946    if (hwnd) {
    29462947      if (WinQueryWindowPos(hwnd, &swp)) {
    2947         if (pswp->x > swp.cx)
    2948           pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
    2949         if (pswp->y > swp.cy)
    2950           pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
    2951         if (pswp->x + pswp->cx > swp.cx)
    2952           pswp->cx = swp.cx - pswp->x;
    2953         if (pswp->y + pswp->cy > swp.cy)
    2954           pswp->cy = swp.cy - pswp->y;
     2948        if (pswp->x > swp.cx)
     2949          pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
     2950        if (pswp->y > swp.cy)
     2951          pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
     2952        if (pswp->x + pswp->cx > swp.cx)
     2953          pswp->cx = swp.cx - pswp->x;
     2954        if (pswp->y + pswp->cy > swp.cy)
     2955          pswp->cy = swp.cy - pswp->y;
    29552956      }
    29562957    }
     
    29993000  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    30003001  if (!PrfQueryProfileData(fmprof,
    3001                            FM3Str,
    3002                            szKey,
    3003                            (PVOID) & swpO,
    3004                            &size) ||
     3002                           FM3Str,
     3003                           szKey,
     3004                           (PVOID) & swpO,
     3005                           &size) ||
    30053006      size != sizeof(SWP) || !swp.cx || !swp.cy)
    30063007  {
     
    30303031      swp.fl &= (~SWP_ACTIVATE);
    30313032      WinSetWindowPos(hwndTree,
    3032                       HWND_TOP,
    3033                       swp.x,
    3034                       swp.y,
    3035                       swp.cx,
    3036                       swp.cy,
    3037                       swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     3033                      HWND_TOP,
     3034                      swp.x,
     3035                      swp.y,
     3036                      swp.cx,
     3037                      swp.cy,
     3038                      swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    30383039    }
    30393040    else {
    30403041      WinSetWindowPos(hwndTree,
    3041                       HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3042                      HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    30423043      WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
    30433044      WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
     
    30493050  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    30503051  if (PrfQueryProfileData(fmprof,
    3051                           FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) {
     3052                          FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) {
    30523053    if (fDeleteState)
    30533054      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     
    30563057      size = sizeof(SWP);
    30573058      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3058         if (fDeleteState)
    3059           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3060         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    3061         size = sizeof(szDir);
    3062         if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    3063           // If restoring shutdown state and drive marked no prescan
    3064           // bypass window restore
    3065           if (fIsShutDownState &&
    3066               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3067             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3068             continue;
    3069           }
    3070           if (fDeleteState)
    3071             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3072           localdcd.detailslongname = detailslongname;  // Set default
    3073           size = sizeof(BOOL);
    3074           sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
    3075           if (PrfQueryProfileData(fmprof,
    3076                                   FM3Str,
    3077                                   szKey,
    3078                                   (PVOID)&localdcd.detailslongname,
    3079                                   &size) &&
    3080               size == sizeof(BOOL))
    3081           {
    3082             if (fDeleteState)
    3083               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3084           }
    3085           localdcd.detailssubject = detailssubject;  // Set default
    3086           size = sizeof(BOOL);
    3087           sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
    3088           if (PrfQueryProfileData(fmprof,
    3089                                   FM3Str,
    3090                                   szKey,
    3091                                   (PVOID)&localdcd.detailssubject,
    3092                                   &size) &&
    3093               size == sizeof(BOOL))
    3094           {
    3095             if (fDeleteState)
    3096               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3097           }
    3098           localdcd.detailsea = detailsea;  // Set default
    3099           size = sizeof(BOOL);
    3100           sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
    3101           if (PrfQueryProfileData(fmprof,
    3102                                   FM3Str,
    3103                                   szKey,
    3104                                   (PVOID) & localdcd.detailsea,
    3105                                   &size) &&
    3106               size == sizeof(BOOL))
    3107           {
    3108             if (fDeleteState)
    3109               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3110           }
    3111           localdcd.detailssize = detailssize;  // Set default
    3112           size = sizeof(BOOL);
    3113           sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
    3114           if (PrfQueryProfileData(fmprof,
    3115                                   FM3Str,
    3116                                   szKey,
    3117                                   (PVOID) & localdcd.detailssize,
    3118                                   &size) &&
    3119               size == sizeof(BOOL))
    3120           {
    3121             if (fDeleteState)
    3122               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3123           }
    3124           localdcd.detailsicon = detailsicon;  // Set default
    3125           size = sizeof(BOOL);
    3126           sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
    3127           if (PrfQueryProfileData(fmprof,
    3128                                   FM3Str,
    3129                                   szKey,
    3130                                   (PVOID) & localdcd.detailsicon,
    3131                                   &size) &&
    3132               size == sizeof(BOOL))
    3133           {
    3134             if (fDeleteState)
    3135               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3136           }
    3137           localdcd.detailsattr = detailsattr;  // Set default
    3138           size = sizeof(BOOL);
    3139           sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
    3140           if (PrfQueryProfileData(fmprof,
    3141                                   FM3Str,
    3142                                   szKey,
    3143                                   (PVOID)&localdcd.detailsattr,
    3144                                   &size) &&
    3145               size == sizeof(BOOL))
    3146           {
    3147             if (fDeleteState)
    3148               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3149           }
    3150           localdcd.detailscrdate = detailscrdate;  // Set default
    3151           size = sizeof(BOOL);
    3152           sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
    3153           if (PrfQueryProfileData(fmprof,
    3154                                   FM3Str,
    3155                                   szKey,
    3156                                   (PVOID) & localdcd.detailscrdate,
    3157               &size) && size == sizeof(BOOL))
    3158           {
    3159             if (fDeleteState)
    3160               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3161           }
    3162           localdcd.detailscrtime = detailscrtime;  // Set default
    3163           size = sizeof(BOOL);
    3164           sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
    3165           if (PrfQueryProfileData(fmprof,
    3166                                   FM3Str,
    3167                                   szKey,
    3168                                   (PVOID)&localdcd.detailscrtime,
    3169                                   &size) &&
    3170               size == sizeof(BOOL))
    3171           {
    3172             if (fDeleteState)
    3173               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3174           }
    3175           localdcd.detailslwdate = detailslwdate;  // Set default
    3176           size = sizeof(BOOL);
    3177           sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
    3178           if (PrfQueryProfileData(fmprof,
    3179                                   FM3Str,
    3180                                   szKey,
    3181                                   (PVOID) & localdcd.detailslwdate,
    3182                                   &size) &&
    3183               size == sizeof(BOOL))
    3184           {
    3185             if (fDeleteState)
    3186               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3187           }
    3188           localdcd.detailslwtime = detailslwtime;  // Set default
    3189           size = sizeof(BOOL);
    3190           sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
    3191           if (PrfQueryProfileData(fmprof,
    3192                                   FM3Str,
    3193                                   szKey,
    3194                                   (PVOID) & localdcd.detailslwtime,
    3195                                   &size) &&
    3196               size == sizeof(BOOL))
    3197           {
    3198             if (fDeleteState)
    3199               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3200           }
    3201           localdcd.detailsladate = detailsladate;  // Set default
    3202           size = sizeof(BOOL);
    3203           sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
    3204           if (PrfQueryProfileData(fmprof,
    3205                                   FM3Str,
    3206                                   szKey,
    3207                                   (PVOID) & localdcd.detailsladate,
    3208                                   &size) &&
    3209               size == sizeof(BOOL))
    3210           {
    3211             if (fDeleteState)
    3212               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3213           }
    3214           localdcd.detailslatime = detailslatime;  // Set default
    3215           size = sizeof(BOOL);
    3216           sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
    3217           if (PrfQueryProfileData(fmprof,
    3218                                   FM3Str,
    3219                                   szKey,
    3220                                   (PVOID) & localdcd.detailslatime,
    3221                                   &size) &&
    3222               size == sizeof(BOOL))
    3223           {
    3224             if (fDeleteState)
    3225               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3226           }
    3227           hwndDir = (HWND) WinSendMsg(hwndClient,
    3228                                       UM_SETDIR,
    3229                                       MPFROMP(szDir), MPFROMLONG(1));
    3230           if (hwndDir) {
    3231             hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
    3232             if (hwndC) {
    3233               HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
    3234               if (!hwndPPSave) {
     3059        if (fDeleteState)
     3060          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3061        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3062        size = sizeof(szDir);
     3063        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     3064          // If restoring shutdown state and drive marked no prescan
     3065          // bypass window restore
     3066          if (fIsShutDownState &&
     3067              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     3068            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3069            continue;
     3070          }
     3071          if (fDeleteState)
     3072            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3073          localdcd.detailslongname = detailslongname;  // Set default
     3074          size = sizeof(BOOL);
     3075          sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
     3076          if (PrfQueryProfileData(fmprof,
     3077                                  FM3Str,
     3078                                  szKey,
     3079                                  (PVOID)&localdcd.detailslongname,
     3080                                  &size) &&
     3081              size == sizeof(BOOL))
     3082          {
     3083            if (fDeleteState)
     3084              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3085          }
     3086          localdcd.detailssubject = detailssubject;  // Set default
     3087          size = sizeof(BOOL);
     3088          sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
     3089          if (PrfQueryProfileData(fmprof,
     3090                                  FM3Str,
     3091                                  szKey,
     3092                                  (PVOID)&localdcd.detailssubject,
     3093                                  &size) &&
     3094              size == sizeof(BOOL))
     3095          {
     3096            if (fDeleteState)
     3097              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3098          }
     3099          localdcd.detailsea = detailsea;  // Set default
     3100          size = sizeof(BOOL);
     3101          sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
     3102          if (PrfQueryProfileData(fmprof,
     3103                                  FM3Str,
     3104                                  szKey,
     3105                                  (PVOID) & localdcd.detailsea,
     3106                                  &size) &&
     3107              size == sizeof(BOOL))
     3108          {
     3109            if (fDeleteState)
     3110              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3111          }
     3112          localdcd.detailssize = detailssize;  // Set default
     3113          size = sizeof(BOOL);
     3114          sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
     3115          if (PrfQueryProfileData(fmprof,
     3116                                  FM3Str,
     3117                                  szKey,
     3118                                  (PVOID) & localdcd.detailssize,
     3119                                  &size) &&
     3120              size == sizeof(BOOL))
     3121          {
     3122            if (fDeleteState)
     3123              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3124          }
     3125          localdcd.detailsicon = detailsicon;  // Set default
     3126          size = sizeof(BOOL);
     3127          sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
     3128          if (PrfQueryProfileData(fmprof,
     3129                                  FM3Str,
     3130                                  szKey,
     3131                                  (PVOID) & localdcd.detailsicon,
     3132                                  &size) &&
     3133              size == sizeof(BOOL))
     3134          {
     3135            if (fDeleteState)
     3136              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3137          }
     3138          localdcd.detailsattr = detailsattr;  // Set default
     3139          size = sizeof(BOOL);
     3140          sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
     3141          if (PrfQueryProfileData(fmprof,
     3142                                  FM3Str,
     3143                                  szKey,
     3144                                  (PVOID)&localdcd.detailsattr,
     3145                                  &size) &&
     3146              size == sizeof(BOOL))
     3147          {
     3148            if (fDeleteState)
     3149              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3150          }
     3151          localdcd.detailscrdate = detailscrdate;  // Set default
     3152          size = sizeof(BOOL);
     3153          sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
     3154          if (PrfQueryProfileData(fmprof,
     3155                                  FM3Str,
     3156                                  szKey,
     3157                                  (PVOID) & localdcd.detailscrdate,
     3158              &size) && size == sizeof(BOOL))
     3159          {
     3160            if (fDeleteState)
     3161              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3162          }
     3163          localdcd.detailscrtime = detailscrtime;  // Set default
     3164          size = sizeof(BOOL);
     3165          sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
     3166          if (PrfQueryProfileData(fmprof,
     3167                                  FM3Str,
     3168                                  szKey,
     3169                                  (PVOID)&localdcd.detailscrtime,
     3170                                  &size) &&
     3171              size == sizeof(BOOL))
     3172          {
     3173            if (fDeleteState)
     3174              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3175          }
     3176          localdcd.detailslwdate = detailslwdate;  // Set default
     3177          size = sizeof(BOOL);
     3178          sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
     3179          if (PrfQueryProfileData(fmprof,
     3180                                  FM3Str,
     3181                                  szKey,
     3182                                  (PVOID) & localdcd.detailslwdate,
     3183                                  &size) &&
     3184              size == sizeof(BOOL))
     3185          {
     3186            if (fDeleteState)
     3187              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3188          }
     3189          localdcd.detailslwtime = detailslwtime;  // Set default
     3190          size = sizeof(BOOL);
     3191          sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
     3192          if (PrfQueryProfileData(fmprof,
     3193                                  FM3Str,
     3194                                  szKey,
     3195                                  (PVOID) & localdcd.detailslwtime,
     3196                                  &size) &&
     3197              size == sizeof(BOOL))
     3198          {
     3199            if (fDeleteState)
     3200              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3201          }
     3202          localdcd.detailsladate = detailsladate;  // Set default
     3203          size = sizeof(BOOL);
     3204          sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
     3205          if (PrfQueryProfileData(fmprof,
     3206                                  FM3Str,
     3207                                  szKey,
     3208                                  (PVOID) & localdcd.detailsladate,
     3209                                  &size) &&
     3210              size == sizeof(BOOL))
     3211          {
     3212            if (fDeleteState)
     3213              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3214          }
     3215          localdcd.detailslatime = detailslatime;  // Set default
     3216          size = sizeof(BOOL);
     3217          sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
     3218          if (PrfQueryProfileData(fmprof,
     3219                                  FM3Str,
     3220                                  szKey,
     3221                                  (PVOID) & localdcd.detailslatime,
     3222                                  &size) &&
     3223              size == sizeof(BOOL))
     3224          {
     3225            if (fDeleteState)
     3226              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3227          }
     3228          hwndDir = (HWND) WinSendMsg(hwndClient,
     3229                                      UM_SETDIR,
     3230                                      MPFROMP(szDir), MPFROMLONG(1));
     3231          if (hwndDir) {
     3232            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     3233            if (hwndC) {
     3234              HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
     3235              if (!hwndPPSave) {
    32353236                hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
    3236                                              WC_CONTAINER,
    3237                                              NULL,
    3238                                              CCS_AUTOPOSITION | CCS_MINIICONS |
    3239                                              CCS_MINIRECORDCORE | ulCnrType |
    3240                                              WS_VISIBLE,
    3241                                              0,
    3242                                              0,
    3243                                              0,
    3244                                              0,
    3245                                              hwndCnr,
    3246                                              HWND_TOP, (ULONG) -1, NULL, NULL);
    3247                 CopyPresParams(hwndPPSave, hwndC);
    3248                 RestorePresParams(hwndPPSave, "DirCnr");
    3249               }
    3250               sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3251               RestorePresParams(hwndCnr, szKey);
    3252               dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    3253               if (dcd) {
    3254                 dcd->detailslongname = localdcd.detailslongname;
    3255                 dcd->detailssubject  = localdcd.detailssubject ;
    3256                 dcd->detailsattr     = localdcd.detailsattr    ;
    3257                 dcd->detailsea       = localdcd.detailsea      ;
    3258                 dcd->detailssize     = localdcd.detailssize    ;
    3259                 dcd->detailsicon     = localdcd.detailsicon    ;
    3260                 dcd->detailscrdate   = localdcd.detailscrdate  ;
    3261                 dcd->detailscrtime   = localdcd.detailscrtime  ;
    3262                 dcd->detailsladate   = localdcd.detailsladate  ;
    3263                 dcd->detailslatime   = localdcd.detailslatime  ;
    3264                 dcd->detailslwdate   = localdcd.detailslwdate  ;
    3265                 dcd->detailslwtime   = localdcd.detailslwtime  ;
    3266                 size = sizeof(INT);
    3267                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    3268                 if (PrfQueryProfileData(fmprof,
    3269                                         FM3Str,
    3270                                         szKey,
    3271                                         (PVOID) & dcd->sortFlags,
    3272                                         &size) && size == sizeof(INT)) {
    3273                   if (!dcd->sortFlags)
    3274                     dcd->sortFlags = SORT_PATHNAME;
    3275                 }
    3276                 if (fDeleteState)
    3277                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3278                 size = sizeof(MASK);
    3279                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    3280                 if (PrfQueryProfileData(fmprof,
    3281                                         FM3Str,
    3282                                         szKey,
    3283                                         (PVOID) & dcd->mask, &size) && size) {
    3284                   if (*dcd->mask.szMask)
    3285                     WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3286                                UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
    3287                 }
    3288                 *(dcd->mask.prompt) = 0;
    3289                 if (fDeleteState)
    3290                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3291                 size = sizeof(ULONG);
    3292                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    3293                 if (!noview) {
    3294                   if (PrfQueryProfileData(fmprof,
    3295                                           FM3Str,
    3296                                           szKey,
    3297                                           (PVOID) & dcd->flWindowAttr,
    3298                                           &size) && size == sizeof(ULONG)) {
    3299 
    3300                     CNRINFO cnri;
    3301 
    3302                     memset(&cnri, 0, sizeof(CNRINFO));
    3303                     cnri.cb = sizeof(CNRINFO);
    3304                     if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3305                                    CM_QUERYCNRINFO,
    3306                                    MPFROMP(&cnri),
    3307                                    MPFROMLONG(sizeof(CNRINFO)))) {
    3308                       cnri.flWindowAttr = dcd->flWindowAttr;
    3309                       WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3310                                 CM_SETCNRINFO,
    3311                                 MPFROMP(&cnri),
    3312                                 MPFROMLONG(CMA_FLWINDOWATTR));
    3313                     }
    3314                   }
    3315                 }
    3316                 if (fDeleteState)
    3317                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3318                 if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    3319                   WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
    3320               }
    3321             }
    3322             fRestored = TRUE;
    3323             swp.hwnd = hwndDir;
    3324             TransformSwp(&swp, xtrans, ytrans);
    3325             if (!fAutoTile && !(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3326               WinSetWindowPos(hwndDir,
    3327                               HWND_TOP,
    3328                               swp.x,
    3329                               swp.y,
    3330                               swp.cx,
    3331                               swp.cy,
    3332                               swp.fl | SWP_MOVE |
    3333                               SWP_SIZE | SWP_SHOW | SWP_ZORDER |
    3334                               SWP_ACTIVATE);
    3335             else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3336               WinSetWindowPos(hwndDir,
    3337                               HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    3338               WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
    3339               WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
    3340               WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
    3341               WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
    3342             }
    3343             else
    3344               WinSetWindowPos(hwndDir,
    3345                               HWND_BOTTOM,
    3346                               0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
    3347           }
    3348         }
     3237                                             WC_CONTAINER,
     3238                                             NULL,
     3239                                             CCS_AUTOPOSITION | CCS_MINIICONS |
     3240                                             CCS_MINIRECORDCORE | ulCnrType |
     3241                                             WS_VISIBLE,
     3242                                             0,
     3243                                             0,
     3244                                             0,
     3245                                             0,
     3246                                             hwndCnr,
     3247                                             HWND_TOP, (ULONG) -1, NULL, NULL);
     3248                CopyPresParams(hwndPPSave, hwndC);
     3249                RestorePresParams(hwndPPSave, "DirCnr");
     3250              }
     3251              sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
     3252              RestorePresParams(hwndCnr, szKey);
     3253              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
     3254              if (dcd) {
     3255                dcd->detailslongname = localdcd.detailslongname;
     3256                dcd->detailssubject  = localdcd.detailssubject ;
     3257                dcd->detailsattr     = localdcd.detailsattr    ;
     3258                dcd->detailsea       = localdcd.detailsea      ;
     3259                dcd->detailssize     = localdcd.detailssize    ;
     3260                dcd->detailsicon     = localdcd.detailsicon    ;
     3261                dcd->detailscrdate   = localdcd.detailscrdate  ;
     3262                dcd->detailscrtime   = localdcd.detailscrtime  ;
     3263                dcd->detailsladate   = localdcd.detailsladate  ;
     3264                dcd->detailslatime   = localdcd.detailslatime  ;
     3265                dcd->detailslwdate   = localdcd.detailslwdate  ;
     3266                dcd->detailslwtime   = localdcd.detailslwtime  ;
     3267                size = sizeof(INT);
     3268                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3269                if (PrfQueryProfileData(fmprof,
     3270                                        FM3Str,
     3271                                        szKey,
     3272                                        (PVOID) & dcd->sortFlags,
     3273                                        &size) && size == sizeof(INT)) {
     3274                  if (!dcd->sortFlags)
     3275                    dcd->sortFlags = SORT_PATHNAME;
     3276                }
     3277                if (fDeleteState)
     3278                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3279                size = sizeof(MASK);
     3280                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3281                if (PrfQueryProfileData(fmprof,
     3282                                        FM3Str,
     3283                                        szKey,
     3284                                        (PVOID) & dcd->mask, &size) && size) {
     3285                  if (*dcd->mask.szMask)
     3286                    WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3287                               UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
     3288                }
     3289                *(dcd->mask.prompt) = 0;
     3290                if (fDeleteState)
     3291                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3292                size = sizeof(ULONG);
     3293                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3294                if (!noview) {
     3295                  if (PrfQueryProfileData(fmprof,
     3296                                          FM3Str,
     3297                                          szKey,
     3298                                          (PVOID) & dcd->flWindowAttr,
     3299                                          &size) && size == sizeof(ULONG)) {
     3300
     3301                    CNRINFO cnri;
     3302
     3303                    memset(&cnri, 0, sizeof(CNRINFO));
     3304                    cnri.cb = sizeof(CNRINFO);
     3305                    if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3306                                   CM_QUERYCNRINFO,
     3307                                   MPFROMP(&cnri),
     3308                                   MPFROMLONG(sizeof(CNRINFO)))) {
     3309                      cnri.flWindowAttr = dcd->flWindowAttr;
     3310                      WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3311                                CM_SETCNRINFO,
     3312                                MPFROMP(&cnri),
     3313                                MPFROMLONG(CMA_FLWINDOWATTR));
     3314                    }
     3315                  }
     3316                }
     3317                if (fDeleteState)
     3318                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3319                  if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
     3320                    WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     3321              }
     3322            }
     3323            fRestored = TRUE;
     3324            swp.hwnd = hwndDir;
     3325            TransformSwp(&swp, xtrans, ytrans);
     3326            if (!fAutoTile && !(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3327              WinSetWindowPos(hwndDir,
     3328                              HWND_TOP,
     3329                              swp.x,
     3330                              swp.y,
     3331                              swp.cx,
     3332                              swp.cy,
     3333                              swp.fl | SWP_MOVE |
     3334                              SWP_SIZE | SWP_SHOW | SWP_ZORDER |
     3335                              SWP_ACTIVATE);
     3336            else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3337              WinSetWindowPos(hwndDir,
     3338                              HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3339              WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
     3340              WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
     3341              WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
     3342              WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
     3343            }
     3344            else
     3345              WinSetWindowPos(hwndDir,
     3346                              HWND_BOTTOM,
     3347                              0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
     3348          }
     3349        }
    33493350      }
    33503351    } // for
     
    33753376    if (ulNumMinChildren) {
    33763377      if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
    3377         (*ulNumMinChildren)++;
     3378        (*ulNumMinChildren)++;
    33783379    }
    33793380  }
     
    33833384
    33843385VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
    3385                       ULONG * ulNumMinChildrenR)
     3386                      ULONG * ulNumMinChildrenR)
    33863387{
    33873388  register ULONG ulCnt;
     
    34473448    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    34483449      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3449         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3450        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    34503451      if (swp.x != 0)
    3451         swp.x = 0;
     3452        swp.x = 0;
    34523453      if (swp.y < 0)
    3453         swp.y = 0;
     3454        swp.y = 0;
    34543455      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3455         swp.cx = Rectl.xRight - Rectl.xLeft;
     3456        swp.cx = Rectl.xRight - Rectl.xLeft;
    34563457      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3457                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3458                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    34583459    }
    34593460  }
     
    34673468      GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
    34683469      WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3469                       SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
    3470                       SWP_ZORDER | SWP_ACTIVATE);
     3470                      SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
     3471                      SWP_ZORDER | SWP_ACTIVATE);
    34713472      ulCnt++;
    34723473    }
     
    35213522    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    35223523      if (swp.y < 0)
    3523         swp.y = 0;
     3524        swp.y = 0;
    35243525      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3525         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3526        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    35263527      if (swp.x != 0)
    3527         swp.x = 0;
     3528        swp.x = 0;
    35283529      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3529         swp.cx = Rectl.xRight - Rectl.xLeft;
     3530        swp.cx = Rectl.xRight - Rectl.xLeft;
    35303531      WinSetWindowPos(hwndTree,
    3531                       HWND_TOP,
    3532                       swp.x,
    3533                       swp.y,
    3534                       swp.cx,
    3535                       swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3532                      HWND_TOP,
     3533                      swp.x,
     3534                      swp.y,
     3535                      swp.cx,
     3536                      swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    35363537      WinQueryWindowPos(hwndTree, &swp);
    35373538    }
     
    35583559
    35593560      for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
    3560         if ((ulNumRows - ulCurRow) <= ulExtraCols)
    3561           ulNumCols++;
    3562         for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
    3563           ulWidth = Rectl.xRight / ulNumCols;
    3564 
    3565           while (hwndChild) {
    3566             id = WinQueryWindowUShort(hwndChild, QWS_ID);
    3567             if (id && (id != TREE_FRAME || fFreeTree)) {
    3568               WinQueryWindowPos(hwndChild, &swp);
    3569               if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3570                 break;
    3571             }
    3572             hwndChild = WinGetNextWindow(henum);
    3573           }
    3574 
    3575           if (hwndChild) {
    3576             if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
    3577               WinGetMaxPosition(hwndChild, &swp);
    3578               WinSetWindowPos(hwndChild,
    3579                               HWND_TOP,
    3580                               swp.x,
    3581                               swp.y,
    3582                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3583               WinSetWindowUShort(hwndChild,
    3584                                 QWS_XRESTORE,
    3585                                 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
    3586               WinSetWindowUShort(hwndChild,
    3587                                 QWS_YRESTORE,
    3588                                 (USHORT) (Rectl.yTop -
    3589                                            (ulHeight * (ulCurRow + 1))));
    3590               WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    3591               WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
    3592             }
    3593             else
    3594               WinSetWindowPos(hwndChild,
    3595                               HWND_TOP,
    3596                               (ulWidth * ulCurCol) + Rectl.xLeft,
    3597                               Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    3598                               ulWidth,
    3599                               ulHeight,
    3600                               SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    3601             hwndChild = WinGetNextWindow(henum);
    3602           }
    3603         }
    3604         if ((ulNumRows - ulCurRow) <= ulExtraCols) {
    3605           ulNumCols--;
    3606           ulExtraCols--;
    3607         }
     3561        if ((ulNumRows - ulCurRow) <= ulExtraCols)
     3562          ulNumCols++;
     3563        for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
     3564          ulWidth = Rectl.xRight / ulNumCols;
     3565
     3566          while (hwndChild) {
     3567            id = WinQueryWindowUShort(hwndChild, QWS_ID);
     3568            if (id && (id != TREE_FRAME || fFreeTree)) {
     3569              WinQueryWindowPos(hwndChild, &swp);
     3570              if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3571                break;
     3572            }
     3573            hwndChild = WinGetNextWindow(henum);
     3574          }
     3575
     3576          if (hwndChild) {
     3577            if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
     3578              WinGetMaxPosition(hwndChild, &swp);
     3579              WinSetWindowPos(hwndChild,
     3580                              HWND_TOP,
     3581                              swp.x,
     3582                              swp.y,
     3583                              swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3584              WinSetWindowUShort(hwndChild,
     3585                                QWS_XRESTORE,
     3586                                (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
     3587              WinSetWindowUShort(hwndChild,
     3588                                QWS_YRESTORE,
     3589                                (USHORT) (Rectl.yTop -
     3590                                           (ulHeight * (ulCurRow + 1))));
     3591              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
     3592              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     3593            }
     3594            else
     3595              WinSetWindowPos(hwndChild,
     3596                              HWND_TOP,
     3597                              (ulWidth * ulCurCol) + Rectl.xLeft,
     3598                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
     3599                              ulWidth,
     3600                              ulHeight,
     3601                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3602            hwndChild = WinGetNextWindow(henum);
     3603          }
     3604        }
     3605        if ((ulNumRows - ulCurRow) <= ulExtraCols) {
     3606          ulNumCols--;
     3607          ulExtraCols--;
     3608        }
    36083609      }
    36093610    }
     
    36153616
    36163617static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
    3617                            SHORT newcx, SHORT newcy)
     3618                           SHORT newcx, SHORT newcy)
    36183619{
    36193620  /*
     
    36333634    while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
    36343635      if (!WinQueryWindowUShort(hwndChild, QWS_ID))
    3635         continue;
     3636        continue;
    36363637      if (WinQueryWindowPos(hwndChild, &swp)) {
    3637         if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
    3638           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3639           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3640           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3641           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3642         }
    3643         else if (swp.fl & SWP_MAXIMIZE) {
    3644           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3645           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3646           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3647           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3648         }
    3649         cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
    3650         cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
    3651         x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
    3652         y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
    3653         if (x < 0)
    3654           x = 0;
    3655         if (y < 0)
    3656           y = 0;
    3657         ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
    3658         uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
    3659         ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
    3660         ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
    3661         if (ux + ucx > newcx)
    3662           ucx = newcx - ux;
    3663         if (uy + ucy > newcy)
    3664           ucy = newcy - uy;
    3665 
    3666         if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
    3667           WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
    3668                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3669         else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3670           WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
    3671           WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    3672           WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    3673                           SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
    3674           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3675           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3676           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3677           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3678         }
    3679         else {
    3680           WinGetMaxPosition(hwndChild, &swp);
    3681           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3682                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3683           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3684           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3685           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3686           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3687         }
     3638        if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
     3639          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3640          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3641          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3642          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3643        }
     3644        else if (swp.fl & SWP_MAXIMIZE) {
     3645          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3646          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3647          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3648          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3649        }
     3650        cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
     3651        cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
     3652        x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
     3653        y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
     3654        if (x < 0)
     3655          x = 0;
     3656        if (y < 0)
     3657          y = 0;
     3658        ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
     3659        uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
     3660        ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
     3661        ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
     3662        if (ux + ucx > newcx)
     3663          ucx = newcx - ux;
     3664        if (uy + ucy > newcy)
     3665          ucy = newcy - uy;
     3666
     3667        if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
     3668          WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
     3669                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3670        else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3671          WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
     3672          WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
     3673          WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
     3674                          SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
     3675          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3676          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3677          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3678          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3679        }
     3680        else {
     3681          WinGetMaxPosition(hwndChild, &swp);
     3682          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     3683                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3684          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3685          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3686          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3687          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3688        }
    36883689      }
    36893690    }
     
    37013702
    37023703      if (!fNoTreeGap) {
    3703         INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    3704         if (swp.y < height)
    3705           swp.y = height;       // Force bottom to position
     3704        INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     3705        if (swp.y < height)
     3706          swp.y = height;        // Force bottom to position
    37063707      }
    37073708      else
    3708         swp.y = 0;              // Force bottom to position
     3709        swp.y = 0;                // Force bottom to position
    37093710
    37103711      swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    37113712      if (swp.cy < 0)
    3712         swp.cy = 0;
     3713        swp.cy = 0;
    37133714
    37143715      if (swp.x != 0)
    3715         swp.x = 0;              // Left align
     3716        swp.x = 0;                // Left align
    37163717
    37173718      // AdjustSizeOfClient can return bogus xRight values - fixme someday
    37183719      if (Rectl.xRight >= Rectl.xLeft) {
    3719         if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3720           swp.cx = Rectl.xRight - Rectl.xLeft;
     3720        if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
     3721          swp.cx = Rectl.xRight - Rectl.xLeft;
    37213722      }
    37223723      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3723                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3724                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    37243725    }
    37253726  }
     
    37493750
    37503751static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
    3751                                              ULONG msg,
    3752                                              MPARAM mp1, MPARAM mp2)
     3752                                             ULONG msg,
     3753                                             MPARAM mp1, MPARAM mp2)
    37533754{
    37543755  USHORT id;
     
    37643765    if (fOtherHelp) {
    37653766      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    3766           && !WinQueryCapture(HWND_DESKTOP)) {
    3767         id = WinQueryWindowUShort(hwnd, QWS_ID);
    3768         switch (id) {
    3769         case IDM_OPENWALK:
    3770           MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
    3771           break;
    3772         case IDM_USERLIST:
    3773           MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
    3774           break;
    3775         }
     3767          && !WinQueryCapture(HWND_DESKTOP)) {
     3768        id = WinQueryWindowUShort(hwnd, QWS_ID);
     3769        switch (id) {
     3770        case IDM_OPENWALK:
     3771          MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
     3772          break;
     3773        case IDM_USERLIST:
     3774          MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
     3775          break;
     3776        }
    37763777      }
    37773778    }
     
    37873788      switch (id) {
    37883789      case IDM_OPENWALK:
    3789         switch (msg) {
    3790         case WM_BUTTON2CLICK:
    3791           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3792               (KC_ALT | KC_SHIFT | KC_CTRL))
    3793             cmd = IDM_GREP;
    3794           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3795             CascadeChildren(hwndMain);
     3790        switch (msg) {
     3791        case WM_BUTTON2CLICK:
     3792          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3793              (KC_ALT | KC_SHIFT | KC_CTRL))
     3794            cmd = IDM_GREP;
     3795          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3796            CascadeChildren(hwndMain);
    37963797
    37973798#ifdef NEVER
    3798           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3799             cmd = IDM_SYSINFO;
     3799          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3800            cmd = IDM_SYSINFO;
    38003801#endif
    38013802
    3802           else if (shiftstate & KC_SHIFT)
    3803             cmd = IDM_WINDOWDLG;
    3804           else if (shiftstate & KC_CTRL)
    3805             cmd = IDM_SEEALL;
    3806           else if (shiftstate & KC_ALT)
    3807             TileChildren(hwndMain, TRUE);
    3808           else
    3809             cmd = IDM_WALKDIR;
    3810           break;
    3811         case WM_BUTTON3CLICK:
    3812           TileChildren(hwndMain, TRUE);
    3813           break;
    3814         }
    3815         break;
     3803          else if (shiftstate & KC_SHIFT)
     3804            cmd = IDM_WINDOWDLG;
     3805          else if (shiftstate & KC_CTRL)
     3806            cmd = IDM_SEEALL;
     3807          else if (shiftstate & KC_ALT)
     3808            TileChildren(hwndMain, TRUE);
     3809          else
     3810            cmd = IDM_WALKDIR;
     3811          break;
     3812        case WM_BUTTON3CLICK:
     3813          TileChildren(hwndMain, TRUE);
     3814          break;
     3815        }
     3816        break;
    38163817      case IDM_USERLIST:
    3817         switch (msg) {
    3818         case WM_BUTTON2CLICK:
    3819           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3820               (KC_ALT | KC_SHIFT | KC_CTRL))
    3821             cmd = IDM_COLORPALETTE;
    3822           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3823             cmd = IDM_HIDEMENU;
    3824           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3825             cmd = IDM_NOTEBOOK;
    3826           else if (shiftstate & KC_SHIFT)
    3827             cmd = IDM_TOOLTITLES;
    3828           else if (shiftstate & KC_CTRL)
    3829             cmd = IDM_TEXTTOOLS;
    3830           else if (shiftstate & KC_ALT)
    3831             cmd = IDM_FONTPALETTE;
    3832           else
    3833             cmd = IDM_TOOLBAR;
    3834           break;
    3835         case WM_BUTTON3CLICK:
    3836           cmd = IDM_DRIVEBAR;
    3837           break;
    3838         }
    3839         break;
     3818        switch (msg) {
     3819        case WM_BUTTON2CLICK:
     3820          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3821              (KC_ALT | KC_SHIFT | KC_CTRL))
     3822            cmd = IDM_COLORPALETTE;
     3823          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3824            cmd = IDM_HIDEMENU;
     3825          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3826            cmd = IDM_NOTEBOOK;
     3827          else if (shiftstate & KC_SHIFT)
     3828            cmd = IDM_TOOLTITLES;
     3829          else if (shiftstate & KC_CTRL)
     3830            cmd = IDM_TEXTTOOLS;
     3831          else if (shiftstate & KC_ALT)
     3832            cmd = IDM_FONTPALETTE;
     3833          else
     3834            cmd = IDM_TOOLBAR;
     3835          break;
     3836        case WM_BUTTON3CLICK:
     3837          cmd = IDM_DRIVEBAR;
     3838          break;
     3839        }
     3840        break;
    38403841      }                                 // switch id
    38413842
    38423843      if (cmd) {
    3843         PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
    3844                 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
     3844        PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
     3845                WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
    38453846      }
    38463847    }
     
    38513852    if (id == IDM_OPENWALK) {
    38523853      if (!emphasized) {
    3853         emphasized = TRUE;
    3854         DrawTargetEmphasis(hwnd, emphasized);
     3854        emphasized = TRUE;
     3855        DrawTargetEmphasis(hwnd, emphasized);
    38553856      }
    38563857      if (AcceptOneDrop(hwnd, mp1, mp2))
    3857         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     3858        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    38583859    }
    38593860    return MRFROM2SHORT(DOR_NEVERDROP, 0);
     
    38753876
    38763877      if (emphasized) {
    3877         emphasized = FALSE;
    3878         DrawTargetEmphasis(hwnd, emphasized);
     3878        emphasized = FALSE;
     3879        DrawTargetEmphasis(hwnd, emphasized);
    38793880      }
    38803881      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    3881         if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
    3882           OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
    3883         }
     3882        if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
     3883          OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
     3884        }
    38843885      }
    38853886    }
     
    38943895
    38953896static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    3896                                         MPARAM mp2)
     3897                                        MPARAM mp2)
    38973898{
    38983899  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    39063907      pswp = (SWP *) mp1;
    39073908      if (fDataMin && !fAmClosing) {
    3908         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3909 
    3910           SWP swp;
    3911 
    3912           WinQueryWindowPos(hwnd, &swp);
    3913           PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
    3914           HideNote();
    3915         }
    3916         else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    3917           if (DataHwnd)
    3918             PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
    3919         }
     3909        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3910
     3911          SWP swp;
     3912
     3913          WinQueryWindowPos(hwnd, &swp);
     3914          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     3915          HideNote();
     3916        }
     3917        else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
     3918          if (DataHwnd)
     3919            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     3920        }
    39203921      }
    39213922      if (!fAmClosing) {
    3922         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    3923           HideNote();
     3923        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
     3924          HideNote();
    39243925      }
    39253926    }
     
    39443945  case WM_CONTROL:
    39453946    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
    3946                       mp2);
     3947                      mp2);
    39473948
    39483949  case WM_COMMAND:
     
    39643965
    39653966      if (mr && mp2) {
    3966         prectl = (PRECTL) mp1;
    3967         if (prectl->yBottom != prectl->yTop) {
    3968           {
    3969             HPS hps;
    3970             POINTL aptl[TXTBOX_COUNT];
    3971 
    3972             hps = WinGetPS(hwndStatus);
    3973             if (hps) {
    3974               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    3975               bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    3976               WinReleasePS(hps);
    3977             }
    3978           }
    3979           prectl->yBottom += (sheight + 4);
    3980           prectl->yTop -= (sheight + 4);
    3981           if (fMoreButtons) {
    3982 
    3983             HPS hps;
    3984             POINTL aptl[TXTBOX_COUNT];
    3985 
    3986             hps = WinGetPS(hwndName);
    3987             if (hps) {
    3988               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    3989               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    3990               WinReleasePS(hps);
    3991             }
    3992             prectl->yBottom += (bheight + 4);
    3993             prectl->yTop -= (bheight + 4);
    3994           }
    3995           if (fToolbar) {
    3996             if (!fTextTools)
    3997               prectl->yTop -= ((fToolTitles) ? 50 : 40);
    3998             else
    3999               prectl->yTop -= 32;
    4000           }
    4001           if (fDrivebar) {
    4002             ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
    4003                         ((prectl->xRight -
    4004                            (WinQuerySysValue(HWND_DESKTOP,
    4005                                              SV_CYSIZEBORDER) * 2)) - 4));
    4006             prectl->yTop -= (16 * (DriveLines * 18));
    4007           }
    4008           if (fUserComboBox) {
    4009             if (!aheight) {
    4010 
    4011               SWP swpTemp;
    4012 
    4013               WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4014                                 &swpTemp);
    4015               aheight = swpTemp.cy;
    4016             }
    4017             prectl->yTop -= (aheight + 6L);
    4018           }
    4019           if (fAutoView) {
    4020             AutoviewHeight = min(AutoviewHeight,
    4021                                 (prectl->yTop - prectl->yBottom) - 116);
    4022             AutoviewHeight = max(AutoviewHeight, 36);
    4023             prectl->yBottom += (AutoviewHeight + 6);
    4024           }
    4025         }
     3967        prectl = (PRECTL) mp1;
     3968        if (prectl->yBottom != prectl->yTop) {
     3969          {
     3970            HPS hps;
     3971            POINTL aptl[TXTBOX_COUNT];
     3972
     3973            hps = WinGetPS(hwndStatus);
     3974            if (hps) {
     3975              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     3976              bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     3977              WinReleasePS(hps);
     3978            }
     3979          }
     3980          prectl->yBottom += (sheight + 4);
     3981          prectl->yTop -= (sheight + 4);
     3982          if (fMoreButtons) {
     3983
     3984            HPS hps;
     3985            POINTL aptl[TXTBOX_COUNT];
     3986
     3987            hps = WinGetPS(hwndName);
     3988            if (hps) {
     3989              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     3990              bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     3991              WinReleasePS(hps);
     3992            }
     3993            prectl->yBottom += (bheight + 4);
     3994            prectl->yTop -= (bheight + 4);
     3995          }
     3996          if (fToolbar) {
     3997            if (!fTextTools)
     3998              prectl->yTop -= ((fToolTitles) ? 50 : 40);
     3999            else
     4000              prectl->yTop -= 32;
     4001          }
     4002          if (fDrivebar) {
     4003            ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     4004                        ((prectl->xRight -
     4005                           (WinQuerySysValue(HWND_DESKTOP,
     4006                                             SV_CYSIZEBORDER) * 2)) - 4));
     4007            prectl->yTop -= (16 * (DriveLines * 18));
     4008          }
     4009          if (fUserComboBox) {
     4010            if (!aheight) {
     4011
     4012              SWP swpTemp;
     4013
     4014              WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4015                                &swpTemp);
     4016              aheight = swpTemp.cy;
     4017            }
     4018            prectl->yTop -= (aheight + 6L);
     4019          }
     4020          if (fAutoView) {
     4021            AutoviewHeight = min(AutoviewHeight,
     4022                                (prectl->yTop - prectl->yBottom) - 116);
     4023            AutoviewHeight = max(AutoviewHeight, 36);
     4024            prectl->yBottom += (AutoviewHeight + 6);
     4025          }
     4026        }
    40264027      }
    40274028      return mr;
     
    40474048      pswp = (PSWP) mp1;
    40484049      {
    4049         SHORT x;
    4050 
    4051         for (x = 0; x < soldCount; x++) {
    4052           if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
    4053             pswpClient = pswp;
    4054             break;
    4055           }
    4056           pswp++;
    4057         }
     4050        SHORT x;
     4051
     4052        for (x = 0; x < soldCount; x++) {
     4053          if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
     4054            pswpClient = pswp;
     4055            break;
     4056          }
     4057          pswp++;
     4058        }
    40584059      }
    40594060
    40604061      {
    4061         HPS hps;
    4062         POINTL aptl[TXTBOX_COUNT];
    4063 
    4064         hps = WinGetPS(hwndStatus);
    4065         if (hps) {
    4066           GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4067           bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4068           WinReleasePS(hps);
    4069         }
    4070         if (fMoreButtons) {
    4071           hps = WinGetPS(hwndName);
    4072           if (hps) {
    4073             GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4074             bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4075             WinReleasePS(hps);
    4076           }
    4077         }
     4062        HPS hps;
     4063        POINTL aptl[TXTBOX_COUNT];
     4064
     4065        hps = WinGetPS(hwndStatus);
     4066        if (hps) {
     4067          GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4068          bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4069          WinReleasePS(hps);
     4070        }
     4071        if (fMoreButtons) {
     4072          hps = WinGetPS(hwndName);
     4073          if (hps) {
     4074            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4075            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4076            WinReleasePS(hps);
     4077          }
     4078        }
    40784079      }
    40794080      pswpNew = (PSWP) mp1 + soldCount;
     
    40854086      pswpNew->y = swpClient.y + 2;
    40864087      if (!fSplitStatus)
    4087         width = swpClient.cx - (16 + (sheight * 2) + 4);
     4088        width = swpClient.cx - (16 + (sheight * 2) + 4);
    40884089      else
    4089         width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
     4090        width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
    40904091      width = max(width, 10);
    40914092      if (fSplitStatus)
    4092         pswpNew->cx = width - 6;
     4093        pswpNew->cx = width - 6;
    40934094      else
    4094         pswpNew->cx = width - 8;
     4095        pswpNew->cx = width - 8;
    40954096      pswpNew->cy = sheight;
    40964097      pswpClient->y = pswpNew->y + pswpNew->cy + 3;
     
    40994100
    41004101      if (fSplitStatus) {
    4101         pswpNew = (PSWP) mp1 + (soldCount + 1);
    4102         *pswpNew = *pswpClient;
    4103         pswpNew->hwnd = hwndStatus2;
    4104         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4105         pswpNew->x = width + 8;
    4106         pswpNew->y = swpClient.y + 2;
    4107         pswpNew->cx = width - 6;
    4108         pswpNew->cy = sheight;
    4109         sCount++;
     4102        pswpNew = (PSWP) mp1 + (soldCount + 1);
     4103        *pswpNew = *pswpClient;
     4104        pswpNew->hwnd = hwndStatus2;
     4105        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4106        pswpNew->x = width + 8;
     4107        pswpNew->y = swpClient.y + 2;
     4108        pswpNew->cx = width - 6;
     4109        pswpNew->cy = sheight;
     4110        sCount++;
    41104111      }
    41114112      else {
    4112         WinShowWindow(hwndStatus2, FALSE);
    4113         WinSetWindowText(hwndStatus2, NullStr);
     4113        WinShowWindow(hwndStatus2, FALSE);
     4114        WinSetWindowText(hwndStatus2, NullStr);
    41144115      }
    41154116
    41164117      if (fToolbar) {
    4117         if (fTextTools)
    4118           theight = 32L;
    4119         else if (!fToolTitles)
    4120           theight = 40L;
    4121         pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
    4122         *pswpNew = *pswpClient;
    4123         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
    4124         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4125         pswpNew->x = swpClient.x + 2;
    4126         pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    4127         pswpNew->cx = swpClient.cx - 4;
    4128         pswpNew->cy = theight - 4;
    4129         pswpClient->cy -= theight;
    4130         sCount++;
     4118        if (fTextTools)
     4119          theight = 32L;
     4120        else if (!fToolTitles)
     4121          theight = 40L;
     4122        pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
     4123        *pswpNew = *pswpClient;
     4124        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     4125        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4126        pswpNew->x = swpClient.x + 2;
     4127        pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
     4128        pswpNew->cx = swpClient.cx - 4;
     4129        pswpNew->cy = theight - 4;
     4130        pswpClient->cy -= theight;
     4131        sCount++;
    41314132      }
    41324133      else
    4133         WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     4134        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
    41344135
    41354136      if (fDrivebar) {
    4136         ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
    4137         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4138                                 (fSplitStatus != FALSE) +
    4139                                 (fToolbar != FALSE));
    4140         *pswpNew = *pswpClient;
    4141         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
    4142         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4143         pswpNew->x = swpClient.x + 2;
    4144         dheight += ((dheight - 2) * DriveLines);
    4145         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    4146         if (fToolbar)
    4147           pswpNew->y -= theight;
    4148         pswpNew->cx = swpClient.cx - 4;
    4149         pswpNew->cy = dheight - 4;
    4150         pswpClient->cy -= dheight;
    4151         sCount++;
     4137        ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
     4138        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4139                                (fSplitStatus != FALSE) +
     4140                                (fToolbar != FALSE));
     4141        *pswpNew = *pswpClient;
     4142        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     4143        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4144        pswpNew->x = swpClient.x + 2;
     4145        dheight += ((dheight - 2) * DriveLines);
     4146        pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
     4147        if (fToolbar)
     4148          pswpNew->y -= theight;
     4149        pswpNew->cx = swpClient.cx - 4;
     4150        pswpNew->cy = dheight - 4;
     4151        pswpClient->cy -= dheight;
     4152        sCount++;
    41524153      }
    41534154      else
    4154         WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
     4155        WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
    41554156
    41564157      if (fAutoView) {
    4157         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4158                                 (fToolbar != FALSE) +
    4159                                 (fDrivebar != FALSE) +
    4160                                 (fSplitStatus != FALSE));
    4161         *pswpNew = *pswpClient;
    4162         pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    4163         pswpNew->x = pswpClient->x + 3;
    4164         pswpNew->y = pswpClient->y + 3;
    4165         if (fMoreButtons)
    4166           pswpNew->y += (bheight + 4);
    4167         pswpNew->cx = pswpClient->cx - 6;
    4168         AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
    4169         AutoviewHeight = max(AutoviewHeight, 36);
    4170         pswpNew->cy = AutoviewHeight;
    4171         pswpClient->y += (AutoviewHeight + 6);
    4172         pswpClient->cy -= (AutoviewHeight + 6);
    4173         sCount++;
    4174         WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     4158        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4159                                (fToolbar != FALSE) +
     4160                                (fDrivebar != FALSE) +
     4161                                (fSplitStatus != FALSE));
     4162        *pswpNew = *pswpClient;
     4163        pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     4164        pswpNew->x = pswpClient->x + 3;
     4165        pswpNew->y = pswpClient->y + 3;
     4166        if (fMoreButtons)
     4167          pswpNew->y += (bheight + 4);
     4168        pswpNew->cx = pswpClient->cx - 6;
     4169        AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
     4170        AutoviewHeight = max(AutoviewHeight, 36);
     4171        pswpNew->cy = AutoviewHeight;
     4172        pswpClient->y += (AutoviewHeight + 6);
     4173        pswpClient->cy -= (AutoviewHeight + 6);
     4174        sCount++;
     4175        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
    41754176      }
    41764177      else {
    4177         WinShowWindow(hwndAutoview, FALSE);
    4178         WinShowWindow(hwndAutoMLE, FALSE);
     4178        WinShowWindow(hwndAutoview, FALSE);
     4179        WinShowWindow(hwndAutoMLE, FALSE);
    41794180      }
    41804181
    41814182      pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4182                               (fToolbar != FALSE) +
    4183                               (fDrivebar != FALSE) +
    4184                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4183                              (fToolbar != FALSE) +
     4184                              (fDrivebar != FALSE) +
     4185                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41854186      *pswpNew = *pswpClient;
    41864187      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
     
    41914192      sCount++;
    41924193      pswpNew = (PSWP) mp1 + (soldCount + 2 +
    4193                               (fToolbar != FALSE) +
    4194                               (fDrivebar != FALSE) +
    4195                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4194                              (fToolbar != FALSE) +
     4195                              (fDrivebar != FALSE) +
     4196                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41964197      *pswpNew = *pswpClient;
    41974198      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
     
    42024203      sCount++;
    42034204      pswpNew = (PSWP) mp1 + (soldCount + 3 +
    4204                               (fToolbar != FALSE) +
    4205                               (fDrivebar != FALSE) +
    4206                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4205                              (fToolbar != FALSE) +
     4206                              (fDrivebar != FALSE) +
     4207                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42074208      *pswpNew = *pswpClient;
    42084209      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
     
    42134214      sCount++;
    42144215      pswpNew = (PSWP) mp1 + (soldCount + 4 +
    4215                               (fToolbar != FALSE) +
    4216                               (fDrivebar != FALSE) +
    4217                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4216                              (fToolbar != FALSE) +
     4217                              (fDrivebar != FALSE) +
     4218                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42184219      *pswpNew = *pswpClient;
    42194220      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     
    42244225      sCount++;
    42254226      if (fUserComboBox) {
    4226         if (!aheight) {
    4227 
    4228           SWP swpTemp;
    4229 
    4230           WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4231                             &swpTemp);
    4232           aheight = swpTemp.cy;
    4233         }
    4234         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4235                                 (fToolbar != FALSE) +
    4236                                 (fSplitStatus != FALSE) +
    4237                                 (fDrivebar != FALSE) + (fAutoView != FALSE));
    4238         *pswpNew = *pswpClient;
    4239         pswpNew->hwnd = hwndDrivelist;
    4240         pswpNew->x = swpClient.x;
    4241         pswpNew->cx = 48;
    4242         pswpClient->cy -= (aheight + 6L);
    4243         pswpNew->y = pswpClient->y;
    4244         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4245         sCount++;
    4246         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4247                                 (fToolbar != FALSE) +
    4248                                 (fDrivebar != FALSE) +
    4249                                 (fSplitStatus != FALSE) +
    4250                                 (fAutoView != FALSE));
    4251         *pswpNew = *pswpClient;
    4252         pswpNew->hwnd = hwndStatelist;
    4253         pswpNew->x = swpClient.x + 48;
    4254         pswpNew->cx = (swpClient.cx - 48) / 7;
    4255         pswpNew->y = pswpClient->y;
    4256         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4257         sCount++;
    4258         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4259                                 (fToolbar != FALSE) +
    4260                                 (fDrivebar != FALSE) +
    4261                                 (fSplitStatus != FALSE) +
    4262                                 (fAutoView != FALSE));
    4263         *pswpNew = *pswpClient;
    4264         pswpNew->hwnd = hwndCmdlist;
    4265         pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
    4266         pswpNew->cx = (swpClient.cx - 48) / 5 +
    4267           ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
    4268         pswpNew->y = pswpClient->y;
    4269         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4270         sCount++;
    4271         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4272                                 (fToolbar != FALSE) +
    4273                                 (fDrivebar != FALSE) +
    4274                                 (fSplitStatus != FALSE) +
    4275                                 (fAutoView != FALSE));
    4276         *pswpNew = *pswpClient;
    4277         pswpNew->hwnd = hwndUserlist;
    4278         pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
    4279         pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
    4280           ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
    4281         pswpNew->y = pswpClient->y;
    4282         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4283         sCount++;
    4284         if (fToolbar) {
    4285           pswpNew = (PSWP) mp1 + (soldCount + 9 +
    4286                                   (fToolbar != FALSE) +
    4287                                   (fDrivebar != FALSE) +
    4288                                   (fSplitStatus != FALSE) +
    4289                                   (fAutoView != FALSE));
    4290           *pswpNew = *pswpClient;
    4291           pswpNew->hwnd = hwndButtonlist;
    4292           pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
    4293           pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
    4294           pswpNew->y = pswpClient->y;
    4295           pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4296           sCount++;
    4297         }
    4298         else
    4299           WinShowWindow(hwndButtonlist, FALSE);
     4227        if (!aheight) {
     4228
     4229          SWP swpTemp;
     4230
     4231          WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4232                            &swpTemp);
     4233          aheight = swpTemp.cy;
     4234        }
     4235        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4236                                (fToolbar != FALSE) +
     4237                                (fSplitStatus != FALSE) +
     4238                                (fDrivebar != FALSE) + (fAutoView != FALSE));
     4239        *pswpNew = *pswpClient;
     4240        pswpNew->hwnd = hwndDrivelist;
     4241        pswpNew->x = swpClient.x;
     4242        pswpNew->cx = 48;
     4243        pswpClient->cy -= (aheight + 6L);
     4244        pswpNew->y = pswpClient->y;
     4245        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4246        sCount++;
     4247        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4248                                (fToolbar != FALSE) +
     4249                                (fDrivebar != FALSE) +
     4250                                (fSplitStatus != FALSE) +
     4251                                (fAutoView != FALSE));
     4252        *pswpNew = *pswpClient;
     4253        pswpNew->hwnd = hwndStatelist;
     4254        pswpNew->x = swpClient.x + 48;
     4255        pswpNew->cx = (swpClient.cx - 48) / 7;
     4256        pswpNew->y = pswpClient->y;
     4257        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4258        sCount++;
     4259        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4260                                (fToolbar != FALSE) +
     4261                                (fDrivebar != FALSE) +
     4262                                (fSplitStatus != FALSE) +
     4263                                (fAutoView != FALSE));
     4264        *pswpNew = *pswpClient;
     4265        pswpNew->hwnd = hwndCmdlist;
     4266        pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
     4267        pswpNew->cx = (swpClient.cx - 48) / 5 +
     4268          ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
     4269        pswpNew->y = pswpClient->y;
     4270        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4271        sCount++;
     4272        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4273                                (fToolbar != FALSE) +
     4274                                (fDrivebar != FALSE) +
     4275                                (fSplitStatus != FALSE) +
     4276                                (fAutoView != FALSE));
     4277        *pswpNew = *pswpClient;
     4278        pswpNew->hwnd = hwndUserlist;
     4279        pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
     4280        pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
     4281          ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
     4282        pswpNew->y = pswpClient->y;
     4283        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4284        sCount++;
     4285        if (fToolbar) {
     4286          pswpNew = (PSWP) mp1 + (soldCount + 9 +
     4287                                  (fToolbar != FALSE) +
     4288                                  (fDrivebar != FALSE) +
     4289                                  (fSplitStatus != FALSE) +
     4290                                  (fAutoView != FALSE));
     4291          *pswpNew = *pswpClient;
     4292          pswpNew->hwnd = hwndButtonlist;
     4293          pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
     4294          pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
     4295          pswpNew->y = pswpClient->y;
     4296          pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4297          sCount++;
     4298        }
     4299        else
     4300          WinShowWindow(hwndButtonlist, FALSE);
    43004301      }
    43014302      else {
    4302         WinShowWindow(hwndUserlist, FALSE);
    4303         WinShowWindow(hwndDrivelist, FALSE);
    4304         WinShowWindow(hwndStatelist, FALSE);
    4305         WinShowWindow(hwndButtonlist, FALSE);
    4306         WinShowWindow(hwndCmdlist, FALSE);
     4303        WinShowWindow(hwndUserlist, FALSE);
     4304        WinShowWindow(hwndDrivelist, FALSE);
     4305        WinShowWindow(hwndStatelist, FALSE);
     4306        WinShowWindow(hwndButtonlist, FALSE);
     4307        WinShowWindow(hwndCmdlist, FALSE);
    43074308      }
    43084309      {
    4309         PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
    4310         SHORT x;
    4311 
    4312         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4313                                 (fToolbar != FALSE) +
    4314                                 (fDrivebar != FALSE) +
    4315                                 (fSplitStatus != FALSE) +
    4316                                 (fAutoView != FALSE) +
    4317                                 ((fUserComboBox != FALSE) * 4) +
    4318                                 (fUserComboBox != FALSE &&
    4319                                 fToolbar != FALSE));
    4320         pswp = (PSWP) mp1;
    4321         for (x = 0; x < soldCount; x++) {
    4322           if (!pswpTitlebar &&
    4323               WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
    4324             pswpTitlebar = pswp;
    4325           else if (!pswpMinbutton &&
    4326                    WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
    4327             pswpMinbutton = pswp;
    4328           if (pswpTitlebar && pswpMinbutton)
    4329             break;
    4330           pswp++;
    4331         }
    4332         if (pswpMinbutton && pswpTitlebar) {
    4333           *pswpNew = *pswpMinbutton;
    4334           pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
    4335           pswpNew->cy = pswpMinbutton->cy + 3;
    4336           pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
    4337           pswpTitlebar->cx -= (pswpNew->cx - 1);
    4338           pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
    4339           pswpNew->y = pswpMinbutton->y - 1;
    4340           sCount++;
    4341         }
    4342         else
    4343           WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
     4310        PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
     4311        SHORT x;
     4312
     4313        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4314                                (fToolbar != FALSE) +
     4315                                (fDrivebar != FALSE) +
     4316                                (fSplitStatus != FALSE) +
     4317                                (fAutoView != FALSE) +
     4318                                ((fUserComboBox != FALSE) * 4) +
     4319                                (fUserComboBox != FALSE &&
     4320                                fToolbar != FALSE));
     4321        pswp = (PSWP) mp1;
     4322        for (x = 0; x < soldCount; x++) {
     4323          if (!pswpTitlebar &&
     4324              WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
     4325            pswpTitlebar = pswp;
     4326          else if (!pswpMinbutton &&
     4327                   WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
     4328            pswpMinbutton = pswp;
     4329          if (pswpTitlebar && pswpMinbutton)
     4330            break;
     4331          pswp++;
     4332        }
     4333        if (pswpMinbutton && pswpTitlebar) {
     4334          *pswpNew = *pswpMinbutton;
     4335          pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
     4336          pswpNew->cy = pswpMinbutton->cy + 3;
     4337          pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
     4338          pswpTitlebar->cx -= (pswpNew->cx - 1);
     4339          pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
     4340          pswpNew->y = pswpMinbutton->y - 1;
     4341          sCount++;
     4342        }
     4343        else
     4344          WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
    43444345      }
    43454346
    43464347      if (fMoreButtons) {
    43474348
    4348         LONG lastx;
    4349 
    4350         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4351                                 (fToolbar != FALSE) +
    4352                                 (fDrivebar != FALSE) +
    4353                                 (fSplitStatus != FALSE) +
    4354                                 (fAutoView != FALSE) +
    4355                                 ((fUserComboBox != FALSE) * 4) +
    4356                                 (fUserComboBox != FALSE &&
    4357                                 fToolbar != FALSE));
    4358         *pswpNew = *pswpClient;
    4359         pswpNew->hwnd = hwndName;
    4360         pswpNew->x = swpClient.x + 3;
    4361         pswpNew->y = swpClient.y + (sheight + 6);
    4362         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    4363         lastx = pswpNew->x + pswpNew->cx;
    4364         pswpNew->cy = bheight;
    4365         pswpClient->y += (bheight + 4);
    4366         pswpClient->cy -= (bheight + 4);
    4367         sCount++;
    4368         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4369                                 (fToolbar != FALSE) +
    4370                                 (fDrivebar != FALSE) +
    4371                                 (fSplitStatus != FALSE) +
    4372                                 (fAutoView != FALSE) +
    4373                                 ((fUserComboBox != FALSE) * 4) +
    4374                                 (fUserComboBox != FALSE &&
    4375                                 fToolbar != FALSE));
    4376         *pswpNew = *pswpClient;
    4377         pswpNew->hwnd = hwndDate;
    4378         pswpNew->x = lastx + 3;
    4379         pswpNew->y = swpClient.y + (sheight + 6);
    4380         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    4381         lastx = pswpNew->x + pswpNew->cx;
    4382         pswpNew->cy = bheight;
    4383         sCount++;
    4384         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4385                                 (fToolbar != FALSE) +
    4386                                 (fDrivebar != FALSE) +
    4387                                 (fSplitStatus != FALSE) +
    4388                                 (fAutoView != FALSE) +
    4389                                 ((fUserComboBox != FALSE) * 4) +
    4390                                 (fUserComboBox != FALSE &&
    4391                                 fToolbar != FALSE));
    4392         *pswpNew = *pswpClient;
    4393         pswpNew->hwnd = hwndAttr;
    4394         pswpNew->x = lastx + 3;
    4395         pswpNew->y = swpClient.y + (sheight + 6);
    4396         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    4397         pswpNew->cy = bheight;
    4398         sCount++;
     4349        LONG lastx;
     4350
     4351        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4352                                (fToolbar != FALSE) +
     4353                                (fDrivebar != FALSE) +
     4354                                (fSplitStatus != FALSE) +
     4355                                (fAutoView != FALSE) +
     4356                                ((fUserComboBox != FALSE) * 4) +
     4357                                (fUserComboBox != FALSE &&
     4358                                fToolbar != FALSE));
     4359        *pswpNew = *pswpClient;
     4360        pswpNew->hwnd = hwndName;
     4361        pswpNew->x = swpClient.x + 3;
     4362        pswpNew->y = swpClient.y + (sheight + 6);
     4363        pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     4364        lastx = pswpNew->x + pswpNew->cx;
     4365        pswpNew->cy = bheight;
     4366        pswpClient->y += (bheight + 4);
     4367        pswpClient->cy -= (bheight + 4);
     4368        sCount++;
     4369        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4370                                (fToolbar != FALSE) +
     4371                                (fDrivebar != FALSE) +
     4372                                (fSplitStatus != FALSE) +
     4373                                (fAutoView != FALSE) +
     4374                                ((fUserComboBox != FALSE) * 4) +
     4375                                (fUserComboBox != FALSE &&
     4376                                fToolbar != FALSE));
     4377        *pswpNew = *pswpClient;
     4378        pswpNew->hwnd = hwndDate;
     4379        pswpNew->x = lastx + 3;
     4380        pswpNew->y = swpClient.y + (sheight + 6);
     4381        pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     4382        lastx = pswpNew->x + pswpNew->cx;
     4383        pswpNew->cy = bheight;
     4384        sCount++;
     4385        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4386                                (fToolbar != FALSE) +
     4387                                (fDrivebar != FALSE) +
     4388                                (fSplitStatus != FALSE) +
     4389                                (fAutoView != FALSE) +
     4390                                ((fUserComboBox != FALSE) * 4) +
     4391                                (fUserComboBox != FALSE &&
     4392                                fToolbar != FALSE));
     4393        *pswpNew = *pswpClient;
     4394        pswpNew->hwnd = hwndAttr;
     4395        pswpNew->x = lastx + 3;
     4396        pswpNew->y = swpClient.y + (sheight + 6);
     4397        pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
     4398        pswpNew->cy = bheight;
     4399        sCount++;
    43994400      }
    44004401      else {
    4401         WinShowWindow(hwndAttr, FALSE);
    4402         WinShowWindow(hwndName, FALSE);
    4403         WinShowWindow(hwndDate, FALSE);
     4402        WinShowWindow(hwndAttr, FALSE);
     4403        WinShowWindow(hwndName, FALSE);
     4404        WinShowWindow(hwndDate, FALSE);
    44044405      }
    44054406      return MRFROMSHORT(sCount);
     
    44144415      sCount += 6;
    44154416      if (fSplitStatus)
    4416         sCount++;
     4417        sCount++;
    44174418      if (fToolbar)
    4418         sCount++;
     4419        sCount++;
    44194420      if (fUserComboBox) {
    4420         sCount += 4;
    4421         if (fToolbar)
    4422           sCount++;
     4421        sCount += 4;
     4422        if (fToolbar)
     4423          sCount++;
    44234424      }
    44244425      if (fDrivebar)
    4425         sCount++;
     4426        sCount++;
    44264427      if (fAutoView)
    4427         sCount++;
     4428        sCount++;
    44284429      if (fMoreButtons)
    4429         sCount += 3;
     4430        sCount += 3;
    44304431      return MRFROMSHORT(sCount);
    44314432    }
     
    44484449      // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
    44494450      if (hwnd != NULLHANDLE) {
    4450         HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
    4451         USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
    4452         switch (id) {
    4453         case MAIN_SETUPLIST:
    4454         case MAIN_USERLIST:
    4455         case MAIN_CMDLIST:
    4456           // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
    4457           WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
    4458         }
     4451        HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
     4452        USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
     4453        switch (id) {
     4454        case MAIN_SETUPLIST:
     4455        case MAIN_USERLIST:
     4456        case MAIN_CMDLIST:
     4457          // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
     4458          WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
     4459        }
    44594460      }
    44604461    }
     
    44854486      wa.size = sizeof(wa);
    44864487      pci =
    4487         (PCNRITEM)
    4488         WinSendMsg(WinWindowFromID
    4489                    (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
    4490                    CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
    4491                    MPFROMSHORT(CRA_CURSORED));
     4488        (PCNRITEM)
     4489        WinSendMsg(WinWindowFromID
     4490                   (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
     4491                   CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
     4492                   MPFROMSHORT(CRA_CURSORED));
    44924493      if (pci && (INT) pci != -1) {
    4493         strcpy(wa.szCurrentPath1, pci->pszFileName);
    4494         MakeValidDir(wa.szCurrentPath1);
     4494        strcpy(wa.szCurrentPath1, pci->pszFileName);
     4495        MakeValidDir(wa.szCurrentPath1);
    44954496      }
    44964497      else
    4497         save_dir2(wa.szCurrentPath1);
     4498        save_dir2(wa.szCurrentPath1);
    44984499      TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
    44994500      if (!*wa.szCurrentPath2)
    4500         strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
     4501        strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
    45014502      MakeValidDir(wa.szCurrentPath2);
    45024503      if (WinDlgBox(HWND_DESKTOP,
    4503                     hwnd,
    4504                     WalkTwoCmpDlgProc,
    4505                     FM3ModHandle,
    4506                     WALK2_FRAME,
    4507                     MPFROMP(&wa)) &&
    4508           !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
    4509         if (!*dircompare) {
    4510 
    4511           COMPARE *cmp;
    4512 
    4513           cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    4514           if (cmp) {
    4515             cmp->size = sizeof(COMPARE);
    4516             strcpy(cmp->leftdir, wa.szCurrentPath1);
    4517             strcpy(cmp->rightdir, wa.szCurrentPath2);
    4518             cmp->hwndParent = hwnd;
    4519             cmp->dcd.hwndParent = hwnd;
    4520             WinDlgBox(HWND_DESKTOP,
    4521                       HWND_DESKTOP,
    4522                       CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    4523           }
    4524         }
    4525         else {
    4526 
    4527           CHAR szPath1[CCHMAXPATH];
    4528           CHAR szPath2[CCHMAXPATH];
    4529           runemf2(SEPARATE,
    4530                   HWND_DESKTOP, pszSrcFile, __LINE__,
    4531                   NULL, NULL,
    4532                   "%s %s %s",
    4533                   dircompare,
    4534                   BldQuotedFileName(szPath1, wa.szCurrentPath1),
    4535                   BldQuotedFileName(szPath2, wa.szCurrentPath2));
    4536         }
     4504                    hwnd,
     4505                    WalkTwoCmpDlgProc,
     4506                    FM3ModHandle,
     4507                    WALK2_FRAME,
     4508                    MPFROMP(&wa)) &&
     4509          !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
     4510        if (!*dircompare) {
     4511
     4512          COMPARE *cmp;
     4513
     4514          cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
     4515          if (cmp) {
     4516            cmp->size = sizeof(COMPARE);
     4517            strcpy(cmp->leftdir, wa.szCurrentPath1);
     4518            strcpy(cmp->rightdir, wa.szCurrentPath2);
     4519            cmp->hwndParent = hwnd;
     4520            cmp->dcd.hwndParent = hwnd;
     4521            WinDlgBox(HWND_DESKTOP,
     4522                      HWND_DESKTOP,
     4523                      CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
     4524          }
     4525        }
     4526        else {
     4527
     4528          CHAR szPath1[CCHMAXPATH];
     4529          CHAR szPath2[CCHMAXPATH];
     4530          runemf2(SEPARATE,
     4531                  HWND_DESKTOP, pszSrcFile, __LINE__,
     4532                  NULL, NULL,
     4533                  "%s %s %s",
     4534                  dircompare,
     4535                  BldQuotedFileName(szPath1, wa.szCurrentPath1),
     4536                  BldQuotedFileName(szPath2, wa.szCurrentPath2));
     4537        }
    45374538      }
    45384539    }
     
    45464547  case IDM_CLI:
    45474548    if (fSplitStatus &&
    4548         hwndStatus2 &&
    4549         !WinIsWindow(WinQueryAnchorBlock(hwnd),
    4550                      WinWindowFromID(hwndStatus2, COMMAND_LINE)))
     4549        hwndStatus2 &&
     4550        !WinIsWindow(WinQueryAnchorBlock(hwnd),
     4551                     WinWindowFromID(hwndStatus2, COMMAND_LINE)))
    45514552      PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
    45524553    break;
     
    45614562      bstrip(temp);
    45624563      if (*temp &&
    4563           !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
    4564         if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
    4565           add_udir(TRUE, path);
    4566           if (fUdirsChanged)
    4567             save_udirs();
    4568           WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4569         }
    4570         else {
    4571           if (!remove_udir(path))
    4572             Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
    4573           else {
    4574             if (fUdirsChanged)
    4575               save_udirs();
    4576             WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4577           }
    4578         }
     4564          !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
     4565        if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
     4566          add_udir(TRUE, path);
     4567          if (fUdirsChanged)
     4568            save_udirs();
     4569          WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4570        }
     4571        else {
     4572          if (!remove_udir(path))
     4573            Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
     4574          else {
     4575            if (fUdirsChanged)
     4576              save_udirs();
     4577            WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4578          }
     4579        }
    45794580      }
    45804581    }
     
    45914592      // Complain if attempting to use reserved name
    45924593      if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
    4593 //        stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0 ||
    4594 //        stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
    4595           stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
     4594          stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
    45964595      {
    4597         saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4598                GetPString(IDS_WARNINGTEXT),
    4599                "\"%s\" is a reserved state name", szStateName);
     4596        saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4597               GetPString(IDS_WARNINGTEXT),
     4598               "\"%s\" is a reserved state name", szStateName);
    46004599      }
    46014600      // Ignore request if blank
    4602       else if (*szStateName)
    4603       {
    4604         BOOL fAbortOperation = FALSE;
    4605         if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
    4606         {       
    4607           if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
    4608               GetPString(IDS_WARNINGTEXT),
    4609               "\"%s\" is the state name used by 'Save directory container state'. Any changes to this state will last only until FM/2 closes or this setting is disabled. Proceed with this change?", szStateName) == MBID_NO)
    4610               fAbortOperation = TRUE;
    4611         }
    4612         if (!fAbortOperation) {
     4601      else if (*szStateName) {
     4602        BOOL fAbortOperation = FALSE;
     4603        if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
     4604         {
     4605          if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
     4606              GetPString(IDS_WARNINGTEXT),
     4607              "\"%s\" is the state name used by \"Save directory container state\". Any changes to this state will last only until FM/2 closes or this setting is disabled. Proceed with this change?", szStateName) == MBID_NO)
     4608              fAbortOperation = TRUE;
     4609        }
     4610        if (!fAbortOperation) {
    46134611          if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
    46144612            // Save
     
    46174615              INT ret = add_setup(szStateName);
    46184616              if (ret == 0) {
    4619                 WinSendMsg(hwndStatelist, LM_INSERTITEM,
    4620                            MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    4621                 save_setups();
     4617                WinSendMsg(hwndStatelist, LM_INSERTITEM,
     4618                           MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
     4619                save_setups();
    46224620              }
    46234621              else if (ret != 1) {
    4624                 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4625                        GetPString(IDS_WARNINGTEXT),
    4626                        "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    4627                 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4622                saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4623                       GetPString(IDS_WARNINGTEXT),
     4624                       "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
     4625                WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    46284626              }
    46294627            }
    4630             else {
    4631                     saymsg(MB_ENTER | MB_ICONASTERISK,
    4632                            hwnd,
    4633                            GetPString(IDS_WARNINGTEXT),
    4634                            nSaved == 0 ?
    4635                              "Nothing to save" :
    4636                              "State data save failed");
    4637                     WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4638                   }
    4639                 }
    4640                 else {
    4641                   // Delete
    4642                   ULONG numsaves = 0, size, x;
    4643                   CHAR s[STATE_NAME_MAX_BYTES + 80];
    4644 
    4645                   INT ret = remove_setup(szStateName);
    4646                   if (ret == 1)
    4647                     save_setups();
    4648                   sprintf(s, "%s.NumDirsLastTime", szStateName);
    4649                   size = sizeof(ULONG);
    4650                   if (!PrfQueryProfileData(fmprof,
    4651                                            FM3Str,
    4652                                            s,
    4653                                            (PVOID)&numsaves,
    4654                                            &size)) {
    4655                     saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4656                            GetPString(IDS_WARNINGTEXT),
    4657                            GetPString(IDS_DOESNTEXISTTEXT), szStateName);
    4658                   }
    4659                   else if (!size)
    4660                     Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    4661                   else {
    4662                     PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4663                     for (x = 0; x < numsaves; x++) {
    4664                       sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4665                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4666                       sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4667                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4668                       sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4669                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4670                       sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4671                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4672                       sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4673                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4674                       sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
    4675                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4676                       sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
    4677                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4678                       sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
    4679                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4680                       sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
    4681                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4682                       sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
    4683                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4684                       sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
    4685                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4686                       sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
    4687                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4688                       sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
    4689                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4690                       sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
    4691                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4692                       sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
    4693                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4694                       sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
    4695                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4696                       sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
    4697                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4698                       sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
    4699                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4700                       sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
    4701                       PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4702                     }
    4703                     sprintf(s, "%s.LastTreePos", szStateName);
    4704                     PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4705                     sprintf(s, "%s.MySizeLastTime", szStateName);
    4706                     PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4707                   }
    4708                   PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
    4709                 }
    4710         }
     4628            else {
     4629              saymsg(MB_ENTER | MB_ICONASTERISK,
     4630                     hwnd,
     4631                     GetPString(IDS_WARNINGTEXT),
     4632                     nSaved == 0 ?
     4633                     "Nothing to save" :
     4634                     "State data save failed");
     4635              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4636            }
     4637          }
     4638          else {
     4639            // Delete
     4640            ULONG numsaves = 0, size, x;
     4641            CHAR s[STATE_NAME_MAX_BYTES + 80];
     4642
     4643            INT ret = remove_setup(szStateName);
     4644            if (ret == 1)
     4645              save_setups();
     4646            sprintf(s, "%s.NumDirsLastTime", szStateName);
     4647            size = sizeof(ULONG);
     4648            if (!PrfQueryProfileData(fmprof,
     4649                                     FM3Str,
     4650                                     s,
     4651                                     (PVOID)&numsaves,
     4652                                     &size)) {
     4653              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4654                     GetPString(IDS_WARNINGTEXT),
     4655                     GetPString(IDS_DOESNTEXISTTEXT), szStateName);
     4656            }
     4657            else if (!size)
     4658              Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     4659            else {
     4660              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     4661              for (x = 0; x < numsaves; x++) {
     4662                sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
     4663                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4664                sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
     4665                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4666                sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
     4667                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4668                sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
     4669                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4670                sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
     4671                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4672                sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
     4673                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4674                sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
     4675                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4676                sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
     4677                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4678                sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
     4679                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4680                sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
     4681                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4682                sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
     4683                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4684                sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
     4685                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4686                sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
     4687                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4688                sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
     4689                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4690                sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
     4691                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4692                sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
     4693                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4694                sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
     4695                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4696                sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
     4697                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4698                sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
     4699                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4700              }
     4701              sprintf(s, "%s.LastTreePos", szStateName);
     4702              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4703              sprintf(s, "%s.MySizeLastTime", szStateName);
     4704              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4705            }
     4706            PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     4707          }
     4708        }
    47114709      }
    47124710    }
     
    47214719      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    47224720      if (swp.fl & SWP_MAXIMIZE) {
    4723         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
    4724                    MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    4725         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     4721        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
     4722                   MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     4723        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    47264724      }
    47274725      WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
     
    47314729      swpD.cy -= (icz + bsz);
    47324730      if (swp.x == swpD.x && swp.y == swpD.y &&
    4733           swp.cx == swpD.cx && swp.cy == swpD.cy &&
    4734           // fixme to be #defined someday
    4735           WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
    4736           WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
    4737         swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
    4738         swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
    4739         swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
    4740         swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
     4731          swp.cx == swpD.cx && swp.cy == swpD.cy &&
     4732          // fixme to be #defined someday
     4733          WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
     4734          WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
     4735        swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
     4736        swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
     4737        swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
     4738        swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
    47414739      }
    47424740      else {
    4743         WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
    4744         WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
    4745         WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
    4746         WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
     4741        WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
     4742        WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
     4743        WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
     4744        WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
    47474745      }
    47484746      WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
    4749                       swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
     4747                      swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
    47504748    }
    47514749    break;
     
    47534751  case IDM_BLINK:
    47544752    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4755                     SWP_MINIMIZE);
     4753                    SWP_MINIMIZE);
    47564754    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4757                     SWP_RESTORE | SWP_ZORDER);
     4755                    SWP_RESTORE | SWP_ZORDER);
    47584756    break;
    47594757
     
    47634761
    47644762      if (hwndTop)
    4765         WinSetFocus(HWND_DESKTOP, hwndTop);
     4763        WinSetFocus(HWND_DESKTOP, hwndTop);
    47664764    }
    47674765    break;
     
    47854783  case IDM_QUICKSETTINGS:
    47864784    WinDlgBox(HWND_DESKTOP,
    4787               hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
     4785              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
    47884786    break;
    47894787
     
    47914789  case IDM_VIEWINFS:
    47924790    WinDlgBox(HWND_DESKTOP,
    4793               HWND_DESKTOP,
    4794               ViewInfProc,
    4795               FM3ModHandle,
    4796               VINF_FRAME,
    4797               ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
    4798                MPFROMP(NullStr) : MPVOID));
     4791              HWND_DESKTOP,
     4792              ViewInfProc,
     4793              FM3ModHandle,
     4794              VINF_FRAME,
     4795              ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
     4796               MPFROMP(NullStr) : MPVOID));
    47994797    break;
    48004798
     
    48064804      TopWindowName(hwnd, (HWND) 0, newpath);
    48074805      if (WinDlgBox(HWND_DESKTOP,
    4808                     hwnd,
    4809                     WalkAllDlgProc,
    4810                     FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
    4811         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
     4806                    hwnd,
     4807                    WalkAllDlgProc,
     4808                    FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
     4809        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
    48124810    }
    48134811    break;
     
    48304828      if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    48314829
    4832         RECTL rcl;
    4833         ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
    4834 
    4835         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4836         rcl.yBottom += icz;
    4837         rcl.yTop -= icz;
    4838         rcl.xLeft += icz;
    4839         rcl.xRight -= icz;
    4840         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4830        RECTL rcl;
     4831        ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
     4832
     4833        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4834        rcl.yBottom += icz;
     4835        rcl.yTop -= icz;
     4836        rcl.xLeft += icz;
     4837        rcl.xRight -= icz;
     4838        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    48414839      }
    48424840      else {
    48434841
    4844         RECTL rcl;
    4845 
    4846         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4847         rcl.yBottom += 8;
    4848         rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
    4849         rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
    4850         rcl.xRight -= 8;
    4851         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4842        RECTL rcl;
     4843
     4844        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4845        rcl.yBottom += 8;
     4846        rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
     4847        rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
     4848        rcl.xRight -= 8;
     4849        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    48524850      }
    48534851      switch (SHORT1FROMMP(mp1)) {
    48544852      case IDM_HELPCONTEXT:
    4855         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4856                    MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
    4857         break;
     4853        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4854                   MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
     4855        break;
    48584856
    48594857      case IDM_HELPMOUSE:
    4860         if (hwndHelp)
    4861           WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4862                      MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
    4863         break;
     4858        if (hwndHelp)
     4859          WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4860                     MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
     4861        break;
    48644862
    48654863      case IDM_HELPPIX:
    4866         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4867                    MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
    4868         break;
     4864        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4865                   MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
     4866        break;
    48694867
    48704868      case IDM_HELPTUTOR:
    4871         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4872                    MPFROM2SHORT(HELP_TUTORIAL, 0),
    4873                    MPFROMSHORT(HM_RESOURCEID));
    4874         break;
     4869        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4870                   MPFROM2SHORT(HELP_TUTORIAL, 0),
     4871                   MPFROMSHORT(HM_RESOURCEID));
     4872        break;
    48754873
    48764874      case IDM_HELPHINTS:
    4877         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4878                    MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
    4879         break;
     4875        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4876                   MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
     4877        break;
    48804878
    48814879      case IDM_HELPGENERAL:
    4882         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4883                    MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
    4884         break;
     4880        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4881                   MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
     4882        break;
    48854883      case IDM_HELPKEYS:
    4886         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4887                    MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
    4888         break;
     4884        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4885                   MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
     4886        break;
    48894887
    48904888      case IDM_HELP:
    48914889      case IDM_HELPCONTENTS:
    4892         WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
    4893         break;
     4890        WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
     4891        break;
    48944892
    48954893      case IDM_HELPUSERLIST:
    4896         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4897                    MPFROM2SHORT(HELP_USERLISTS, 0),
    4898                    MPFROMSHORT(HM_RESOURCEID));
    4899         break;
     4894        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4895                   MPFROM2SHORT(HELP_USERLISTS, 0),
     4896                   MPFROMSHORT(HM_RESOURCEID));
     4897        break;
    49004898      }
    49014899    }
     
    49084906  case IDM_ABOUT:
    49094907    WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
    4910               ABT_FRAME, MPVOID);
     4908              ABT_FRAME, MPVOID);
    49114909    break;
    49124910
     
    49224920
    49234921      if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
    4924                            (PVOID) & version, (ULONG) sizeof(version))) {
    4925         if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
    4926           if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
    4927             palette = "<WP_HIRESCLRPAL>";
    4928           else
    4929             palette = "<WP_LORESCLRPAL>";
    4930         }
     4922                           (PVOID) & version, (ULONG) sizeof(version))) {
     4923        if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
     4924          if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
     4925            palette = "<WP_HIRESCLRPAL>";
     4926          else
     4927            palette = "<WP_LORESCLRPAL>";
     4928        }
    49314929      }
    49324930      OpenObject(palette, Default, hwnd);
     
    49444942      hWPSObject = WinQueryObject("<WP_SCHPAL>");
    49454943      if (hWPSObject != NULLHANDLE)
    4946         WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
    4947                         "Spring:PM_Spring,Summer:PM_Summer,"
    4948                         "System:PM_System,Windows:PM_Windows;"
    4949                         "OPEN=DEFAULT");
     4944        WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
     4945                        "Spring:PM_Spring,Summer:PM_Summer,"
     4946                        "System:PM_System,Windows:PM_Windows;"
     4947                        "OPEN=DEFAULT");
    49504948    }
    49514949    break;
     
    49584956  case IDM_SYSINFO:
    49594957    WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
    4960               SYS_FRAME, NULL);
     4958              SYS_FRAME, NULL);
    49614959    break;
    49624960#endif
     
    49684966
    49694967      if (hwndTree)
    4970         pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
    4971                                     MPFROMLONG(CMA_FIRST),
    4972                                     MPFROMSHORT(CRA_CURSORED));
     4968        pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
     4969                                    MPFROMLONG(CMA_FIRST),
     4970                                    MPFROMSHORT(CRA_CURSORED));
    49734971      if (pci && (INT) pci != -1) {
    4974         strcpy(path, pci->pszFileName);
    4975         MakeValidDir(path);
     4972        strcpy(path, pci->pszFileName);
     4973        MakeValidDir(path);
    49764974      }
    49774975      else
    4978         save_dir2(path);
     4976        save_dir2(path);
    49794977      WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
    4980                 BAT_FRAME, MPFROMP(path));
     4978                BAT_FRAME, MPFROMP(path));
    49814979    }
    49824980    break;
     
    49924990      TopWindowName(hwnd, (HWND) 0, path);
    49934991      if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
    4994         env = GetCmdSpec(TRUE);
     4992        env = GetCmdSpec(TRUE);
    49954993      else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
    4996         env = "WINOS2.COM";
    4997         type = SEPARATE | FULLSCREEN;
     4994        env = "WINOS2.COM";
     4995        type = SEPARATE | FULLSCREEN;
    49984996      }
    49994997      runemf2(type, hwnd, pszSrcFile, __LINE__,
    5000               path, NULL, "%s", env);
     4998              path, NULL, "%s", env);
    50014999    }
    50025000    break;
     
    50045002  case IDM_KILLPROC:
    50055003    WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
    5006               KILL_FRAME, NULL);
     5004              KILL_FRAME, NULL);
    50075005    break;
    50085006
     
    50195017  case IDM_AUTOVIEW:
    50205018    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5021                 &fAutoView, TRUE, "AutoView");
     5019                &fAutoView, TRUE, "AutoView");
    50225020  AutoChange:
    50235021    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5024             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5022            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50255023    if (fAutoView) {
    50265024
     
    50315029      hwndDir = TopWindowName(hwnd, (HWND) 0, s);
    50325030      if (hwndDir) {
    5033         hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
    5034         if (hwndDir) {
    5035           hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
    5036           if (hwndDir) {
    5037             pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
    5038                                         MPFROMLONG(CMA_FIRST),
    5039                                         MPFROMSHORT(CRA_CURSORED));
    5040             if (pci && (INT) pci != -1 &&
    5041                 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
    5042               WinSendMsg(hwnd,
    5043                         UM_LOADFILE,
    5044                         MPFROMP(pci->pszFileName),
    5045                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    5046                         MPVOID : MPFROMLONG(1));
    5047           }
    5048         }
     5031        hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
     5032        if (hwndDir) {
     5033          hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
     5034          if (hwndDir) {
     5035            pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
     5036                                        MPFROMLONG(CMA_FIRST),
     5037                                        MPFROMSHORT(CRA_CURSORED));
     5038            if (pci && (INT) pci != -1 &&
     5039                (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
     5040              WinSendMsg(hwnd,
     5041                        UM_LOADFILE,
     5042                        MPFROMP(pci->pszFileName),
     5043                        (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
     5044                        MPVOID : MPFROMLONG(1));
     5045          }
     5046        }
    50495047      }
    50505048    }
     
    50535051  case IDM_TEXTTOOLS:
    50545052    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5055                 &fTextTools, TRUE, "TextTools");
     5053                &fTextTools, TRUE, "TextTools");
    50565054    BuildTools(hwndToolback, TRUE);
    50575055    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5058             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5056            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50595057    break;
    50605058
    50615059  case IDM_TOOLTITLES:
    50625060    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5063                 &fToolTitles, TRUE, "ToolTitles");
     5061                &fToolTitles, TRUE, "ToolTitles");
    50645062    BuildTools(hwndToolback, TRUE);
    50655063    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5066             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5064            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50675065    break;
    50685066
     
    50725070      MenuInvisible = MenuInvisible ? FALSE : TRUE;
    50735071      if (MenuInvisible) {
    5074         WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
    5075         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5076                                            FID_SYSMENU), IDM_HIDEMENU,
    5077                            GetPString(IDS_UNHIDEMENUTEXT));
     5072        WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
     5073        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5074                                           FID_SYSMENU), IDM_HIDEMENU,
     5075                           GetPString(IDS_UNHIDEMENUTEXT));
    50785076      }
    50795077      else {
    5080         WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
    5081         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5082                                            FID_SYSMENU), IDM_HIDEMENU,
    5083                            GetPString(IDS_HIDEMENUTEXT));
     5078        WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
     5079        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5080                                           FID_SYSMENU), IDM_HIDEMENU,
     5081                           GetPString(IDS_HIDEMENUTEXT));
    50845082      }
    50855083      PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5086               MPFROMLONG(FCF_MENU), MPVOID);
     5084              MPFROMLONG(FCF_MENU), MPVOID);
    50875085      PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
    5088                           &MenuInvisible, sizeof(BOOL));
     5086                          &MenuInvisible, sizeof(BOOL));
    50895087    }
    50905088    break;
     
    50995097
    51005098      if (Collector)
    5101         already = TRUE;
     5099        already = TRUE;
    51025100      if (!already && !fAutoTile && !fExternalCollector)
    5103         GetNextWindowPos(hwnd, &swp, NULL, NULL);
     5101        GetNextWindowPos(hwnd, &swp, NULL, NULL);
    51045102      hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
    51055103      if (hwndC) {
    5106         if (!already && !fAutoTile && !fExternalCollector)
    5107           WinSetWindowPos(hwndC, HWND_TOP,
    5108                           swp.x, swp.y, swp.cx, swp.cy,
    5109                           SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    5110         else if (fAutoTile && !already)
    5111           TileChildren(hwnd, TRUE);
    5112         WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
    5113                         SWP_ACTIVATE);
    5114         if (SHORT1FROMMP(mp1) == IDM_GREP)
    5115           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5116                   MPFROM2SHORT(IDM_GREP, 0), MPVOID);
    5117         if (SHORT1FROMMP(mp1) == IDM_SEEALL)
    5118           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5119                   MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
     5104        if (!already && !fAutoTile && !fExternalCollector)
     5105          WinSetWindowPos(hwndC, HWND_TOP,
     5106                          swp.x, swp.y, swp.cx, swp.cy,
     5107                          SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     5108        else if (fAutoTile && !already)
     5109          TileChildren(hwnd, TRUE);
     5110        WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
     5111                        SWP_ACTIVATE);
     5112        if (SHORT1FROMMP(mp1) == IDM_GREP)
     5113          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5114                  MPFROM2SHORT(IDM_GREP, 0), MPVOID);
     5115        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     5116          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5117                  MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
    51205118      }
    51215119    }
     
    51285126
    51295127      if (!toolhead || !toolhead->next) {
    5130         firsttool = (toolhead) ? toolhead->id : 0;
    5131         break;
     5128        firsttool = (toolhead) ? toolhead->id : 0;
     5129        break;
    51325130      }
    51335131      tool = find_tool(firsttool);
    51345132      if (!tool)
    5135         tool = toolhead;
     5133        tool = toolhead;
    51365134      if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
    5137         tool = prev_tool(tool, TRUE);
    5138         firsttool = tool->id;
     5135        tool = prev_tool(tool, TRUE);
     5136        firsttool = tool->id;
    51395137      }
    51405138      else {
    5141         tool = next_tool(tool, TRUE);
    5142         firsttool = tool->id;
     5139        tool = next_tool(tool, TRUE);
     5140        firsttool = tool->id;
    51435141      }
    51445142      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5145                                   MAIN_TOOLS));
     5143                                  MAIN_TOOLS));
    51465144    }
    51475145    break;
     
    51535151  case IDM_TOOLBAR:
    51545152    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5155                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
     5153                IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    51565154    BuildTools(hwndToolback, TRUE);
    51575155    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5158                                   MAIN_TOOLS), fToolbar);
     5156                                  MAIN_TOOLS), fToolbar);
    51595157    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    5160                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5158               WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51615159    if (fDrivebar)
    51625160      WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5163                                         MAIN_DRIVES), NULL, TRUE);
     5161                                        MAIN_DRIVES), NULL, TRUE);
    51645162    break;
    51655163
    51665164  case IDM_DRIVEBAR:
    51675165    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5168                 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
     5166                IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
    51695167    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5170                                   MAIN_DRIVES), fDrivebar);
     5168                                  MAIN_DRIVES), fDrivebar);
    51715169    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5172             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5170            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51735171    PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    51745172    break;
     
    51765174  case IDM_USERLIST:
    51775175    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5178                 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
     5176                SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
    51795177    WinShowWindow(hwndUserlist, fUserComboBox);
    51805178    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5181             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5179            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51825180    PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    51835181    PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    51915189    WinSetWindowText(hwndAttr, NullStr);
    51925190    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5193                 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
     5191                SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
    51945192    if (fMoreButtons) {
    51955193
     
    51995197
    52005198      if (hwndTemp) {
    5201         WinSetFocus(HWND_DESKTOP, hwnd);
    5202         WinSetFocus(HWND_DESKTOP, hwndTemp);
     5199        WinSetFocus(HWND_DESKTOP, hwnd);
     5200        WinSetFocus(HWND_DESKTOP, hwndTemp);
    52035201      }
    52045202    }
    52055203    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5206             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5204            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52075205    break;
    52085206
    52095207  case IDM_TOGGLEDRAGDIALOG:
    52105208    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5211                 IDM_TOGGLEDRAGDIALOG,
    5212                 &fDragndropDlg,
    5213                 TRUE,
    5214                 "Drag&DropDlg");
     5209                IDM_TOGGLEDRAGDIALOG,
     5210                &fDragndropDlg,
     5211                TRUE,
     5212                "Drag&DropDlg");
    52155213    break;
    52165214
    52175215  case IDM_SYNCUPDATES:
    52185216    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5219                 IDM_SYNCUPDATES,
    5220                 &fSyncUpdates,
    5221                 TRUE,
    5222                 "SyncUpdates");
     5217                IDM_SYNCUPDATES,
     5218                &fSyncUpdates,
     5219                TRUE,
     5220                "SyncUpdates");
    52235221    break;
    52245222
     
    52305228      WinQueryWindowPos(hwnd, &swp);
    52315229      WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
    5232                       SWP_MOVE);
     5230                      SWP_MOVE);
    52335231    }
    52345232    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5235                 &fFreeTree, TRUE, "FreeTree");
     5233                &fFreeTree, TRUE, "FreeTree");
    52365234    if (fAutoTile)
    52375235      TileChildren(hwnd, TRUE);
     
    52405238  case IDM_AUTOTILE:
    52415239    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5242                 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
     5240                SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
    52435241    if (fAutoTile)
    52445242      TileChildren(hwnd, TRUE);
     
    52475245  case IDM_TILEBACKWARDS:
    52485246    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5249                 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
     5247                SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
    52505248    if (fAutoTile)
    52515249      TileChildren(hwnd, TRUE);
     
    52925290  default:
    52935291    if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
    5294                        SHORT1FROMMP(mp1))) {
     5292                       SHORT1FROMMP(mp1))) {
    52955293      if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    5296           SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    5297 
    5298         INT x;
    5299         HWND hwndCnr;
    5300 
    5301         if (!cmdloaded)
    5302           load_commands();
    5303         hwndCnr = TopWindow(hwnd, (HWND) 0);
    5304         hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
    5305                                     UM_CONTAINERHWND, MPVOID, MPVOID);
    5306         if (!hwndCnr) {
    5307           Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
    5308           break;
    5309         }
    5310         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    5311         if (x >= 0) {
    5312           x++;
    5313           RunCommand(hwndCnr, x);
    5314           if (fUnHilite) {
    5315 
    5316             PCNRITEM pci;
    5317             DIRCNRDATA *dcd = NULL;
    5318 
    5319             // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
    5320             if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
    5321               dcd = INSTDATA(hwndCnr);
    5322             pci = (PCNRITEM) WinSendMsg(hwndCnr,
    5323                                         CM_QUERYRECORDEMPHASIS,
    5324                                         MPFROMLONG(CMA_FIRST),
    5325                                         MPFROMSHORT(CRA_CURSORED));
    5326             if (pci && (INT) pci != -1 &&
    5327                 (pci->rc.flRecordAttr & CRA_SELECTED))
    5328             {
    5329               UnHilite(hwnd,
    5330                        TRUE,
    5331                        dcd ? &dcd->lastselection : NULL,
    5332                        dcd ? dcd ->ulItemsToUnHilite : 0);
    5333             }
    5334           }
    5335         }
     5294          SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
     5295
     5296        INT x;
     5297        HWND hwndCnr;
     5298
     5299        if (!cmdloaded)
     5300          load_commands();
     5301        hwndCnr = TopWindow(hwnd, (HWND) 0);
     5302        hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     5303                                    UM_CONTAINERHWND, MPVOID, MPVOID);
     5304        if (!hwndCnr) {
     5305          Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
     5306          break;
     5307        }
     5308        x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     5309        if (x >= 0) {
     5310          x++;
     5311          RunCommand(hwndCnr, x);
     5312          if (fUnHilite) {
     5313
     5314            PCNRITEM pci;
     5315            DIRCNRDATA *dcd = NULL;
     5316
     5317            // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
     5318            if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     5319              dcd = INSTDATA(hwndCnr);
     5320            pci = (PCNRITEM) WinSendMsg(hwndCnr,
     5321                                        CM_QUERYRECORDEMPHASIS,
     5322                                        MPFROMLONG(CMA_FIRST),
     5323                                        MPFROMSHORT(CRA_CURSORED));
     5324            if (pci && (INT) pci != -1 &&
     5325                (pci->rc.flRecordAttr & CRA_SELECTED))
     5326            {
     5327              UnHilite(hwnd,
     5328                       TRUE,
     5329                       dcd ? &dcd->lastselection : NULL,
     5330                       dcd ? dcd ->ulItemsToUnHilite : 0);
     5331            }
     5332          }
     5333        }
    53365334      }
    53375335      else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    5338                SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
    5339         if (!qtloaded)
    5340           load_quicktools();
    5341         if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
    5342           if (fToolsChanged)
    5343             save_tools(NULL);
    5344           if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
    5345             load_tools(NULL);
    5346           else {
    5347             strcpy(lasttoolbox,
    5348                    quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    5349             PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
    5350           }
    5351           BuildTools(hwndToolback, TRUE);
    5352         }
     5336               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
     5337        if (!qtloaded)
     5338          load_quicktools();
     5339        if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
     5340          if (fToolsChanged)
     5341            save_tools(NULL);
     5342          if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
     5343            load_tools(NULL);
     5344          else {
     5345            strcpy(lasttoolbox,
     5346                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
     5347            PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
     5348          }
     5349          BuildTools(hwndToolback, TRUE);
     5350        }
    53535351      }
    53545352      else {
    53555353
    5356         HWND hwndActive;
    5357 
    5358         hwndActive = TopWindow(hwnd, (HWND) 0);
    5359         if (hwndActive)
    5360           PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    5361                   WM_COMMAND, mp1, mp2);
     5354        HWND hwndActive;
     5355
     5356        hwndActive = TopWindow(hwnd, (HWND) 0);
     5357        if (hwndActive)
     5358          PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     5359                  WM_COMMAND, mp1, mp2);
    53625360      }
    53635361    }
     
    53685366
    53695367static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
    5370                                    MPARAM mp2)
     5368                                   MPARAM mp2)
    53715369{
    53725370  TID tid;
     
    53915389    if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
    53925390      Runtime_Error(pszSrcFile, __LINE__,
    5393                     GetPString(IDS_COULDNTSTARTTHREADTEXT));
     5391                    GetPString(IDS_COULDNTSTARTTHREADTEXT));
    53945392      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    53955393      return 0;
     
    54105408
    54115409    if (!WinCreateWindow(hwndFrame,
    5412                         WC_BUTTON,
    5413                         "I",
    5414                         WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
    5415                         ((swp.cx -
    5416                            WinQuerySysValue(HWND_DESKTOP,
    5417                                             SV_CXMINMAXBUTTON)) -
    5418                           WinQuerySysValue(HWND_DESKTOP,
    5419                                            SV_CXMINMAXBUTTON) / 2) -
    5420                         WinQuerySysValue(HWND_DESKTOP,
    5421                                           SV_CXSIZEBORDER),
    5422                         (swp.cy - WinQuerySysValue(HWND_DESKTOP,
    5423                                                     SV_CYMINMAXBUTTON)) -
    5424                         WinQuerySysValue(HWND_DESKTOP,
    5425                                           SV_CYSIZEBORDER),
    5426                         WinQuerySysValue(HWND_DESKTOP,
    5427                                           SV_CXMINMAXBUTTON) / 2,
    5428                         WinQuerySysValue(HWND_DESKTOP,
    5429                                           SV_CYMINMAXBUTTON),
    5430                         hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
     5410                        WC_BUTTON,
     5411                        "I",
     5412                        WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
     5413                        ((swp.cx -
     5414                           WinQuerySysValue(HWND_DESKTOP,
     5415                                            SV_CXMINMAXBUTTON)) -
     5416                          WinQuerySysValue(HWND_DESKTOP,
     5417                                           SV_CXMINMAXBUTTON) / 2) -
     5418                        WinQuerySysValue(HWND_DESKTOP,
     5419                                          SV_CXSIZEBORDER),
     5420                        (swp.cy - WinQuerySysValue(HWND_DESKTOP,
     5421                                                    SV_CYMINMAXBUTTON)) -
     5422                        WinQuerySysValue(HWND_DESKTOP,
     5423                                          SV_CYSIZEBORDER),
     5424                        WinQuerySysValue(HWND_DESKTOP,
     5425                                          SV_CXMINMAXBUTTON) / 2,
     5426                        WinQuerySysValue(HWND_DESKTOP,
     5427                                          SV_CYMINMAXBUTTON),
     5428                        hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
    54315429      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54325430    }
    54335431    else {
    54345432      WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
    5435                         IdealButtonProc);
     5433                        IdealButtonProc);
    54365434      SetPresParams(WinWindowFromID(hwndFrame,
    5437                                     IDM_IDEALSIZE),
    5438                     NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
     5435                                    IDM_IDEALSIZE),
     5436                    NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
    54395437    }
    54405438
    54415439    hwndTmp = WinCreateWindow(hwndFrame,
    5442                               WC_BUTTON,
    5443                               "#1019",
    5444                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5445                               BS_BITMAP,
    5446                               swp.cx - 46,
    5447                               swp.y + 2,
    5448                               24,
    5449                               22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
     5440                              WC_BUTTON,
     5441                              "#1019",
     5442                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5443                              BS_BITMAP,
     5444                              swp.cx - 46,
     5445                              swp.y + 2,
     5446                              24,
     5447                              22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
    54505448    if (!hwndTmp)
    54515449      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54525450
    54535451    hwndTmp = WinCreateWindow(hwndFrame,
    5454                               WC_BUTTON,
    5455                               "#3062",
    5456                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5457                               BS_BITMAP,
    5458                               swp.cx - 22,
    5459                               swp.y + 2,
    5460                               24,
    5461                               22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
     5452                              WC_BUTTON,
     5453                              "#3062",
     5454                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5455                              BS_BITMAP,
     5456                              swp.cx - 22,
     5457                              swp.y + 2,
     5458                              24,
     5459                              22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
    54625460    if (!hwndTmp)
    54635461      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54645462
    54655463    hwndUserlist = WinCreateWindow(hwndFrame,
    5466                                    WC_COMBOBOX,
    5467                                    (PSZ) NULL,
    5468                                    WS_VISIBLE | CBS_DROPDOWN |
    5469                                    LS_HORZSCROLL,
    5470                                    (swp.x +
    5471                                     WinQuerySysValue(HWND_DESKTOP,
    5472                                                      SV_CXSIZEBORDER) + 48L),
    5473                                    (swp.cy -
    5474                                     WinQuerySysValue(HWND_DESKTOP,
    5475                                                      SV_CYSIZEBORDER)) - 60,
    5476                                    ((swp.cx -
    5477                                      (WinQuerySysValue(HWND_DESKTOP,
    5478                                                        SV_CXSIZEBORDER) *
    5479                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5480                                    MAIN_USERLIST, NULL, NULL);
     5464                                   WC_COMBOBOX,
     5465                                   (PSZ) NULL,
     5466                                   WS_VISIBLE | CBS_DROPDOWN |
     5467                                   LS_HORZSCROLL,
     5468                                   (swp.x +
     5469                                    WinQuerySysValue(HWND_DESKTOP,
     5470                                                     SV_CXSIZEBORDER) + 48L),
     5471                                   (swp.cy -
     5472                                    WinQuerySysValue(HWND_DESKTOP,
     5473                                                     SV_CYSIZEBORDER)) - 60,
     5474                                   ((swp.cx -
     5475                                     (WinQuerySysValue(HWND_DESKTOP,
     5476                                                       SV_CXSIZEBORDER) *
     5477                                      2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5478                                   MAIN_USERLIST, NULL, NULL);
    54815479    if (!hwndUserlist)
    54825480      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54835481    hwndCmdlist = WinCreateWindow(hwndFrame,
    5484                                   WC_COMBOBOX,
    5485                                   (PSZ) NULL,
    5486                                   WS_VISIBLE | CBS_DROPDOWN |
    5487                                   LS_HORZSCROLL,
    5488                                   (swp.x +
    5489                                    WinQuerySysValue(HWND_DESKTOP,
    5490                                                     SV_CXSIZEBORDER) + 48L),
    5491                                   (swp.cy -
    5492                                    WinQuerySysValue(HWND_DESKTOP,
    5493                                                     SV_CYSIZEBORDER)) - 60,
    5494                                   ((swp.cx -
    5495                                     (WinQuerySysValue(HWND_DESKTOP,
    5496                                                       SV_CXSIZEBORDER) * 2)) -
    5497                                    64L), 60L, hwndFrame, HWND_TOP,
    5498                                   MAIN_CMDLIST, NULL, NULL);
     5482                                  WC_COMBOBOX,
     5483                                  (PSZ) NULL,
     5484                                  WS_VISIBLE | CBS_DROPDOWN |
     5485                                  LS_HORZSCROLL,
     5486                                  (swp.x +
     5487                                   WinQuerySysValue(HWND_DESKTOP,
     5488                                                    SV_CXSIZEBORDER) + 48L),
     5489                                  (swp.cy -
     5490                                   WinQuerySysValue(HWND_DESKTOP,
     5491                                                    SV_CYSIZEBORDER)) - 60,
     5492                                  ((swp.cx -
     5493                                    (WinQuerySysValue(HWND_DESKTOP,
     5494                                                      SV_CXSIZEBORDER) * 2)) -
     5495                                   64L), 60L, hwndFrame, HWND_TOP,
     5496                                  MAIN_CMDLIST, NULL, NULL);
    54995497    if (!hwndCmdlist)
    55005498      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55015499    WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    55025500    hwndStatelist = WinCreateWindow(hwndFrame,
    5503                                     WC_COMBOBOX,
    5504                                     (PSZ) NULL,
    5505                                     WS_VISIBLE | CBS_DROPDOWN |
    5506                                     LS_HORZSCROLL,
    5507                                     (swp.x +
    5508                                      WinQuerySysValue(HWND_DESKTOP,
    5509                                                       SV_CXSIZEBORDER) + 48L),
    5510                                     (swp.cy -
    5511                                      WinQuerySysValue(HWND_DESKTOP,
    5512                                                       SV_CYSIZEBORDER)) - 60,
    5513                                     ((swp.cx -
    5514                                       (WinQuerySysValue(HWND_DESKTOP,
    5515                                                         SV_CXSIZEBORDER) *
    5516                                        2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5517                                     MAIN_SETUPLIST, NULL, NULL);
     5501                                    WC_COMBOBOX,
     5502                                    (PSZ) NULL,
     5503                                    WS_VISIBLE | CBS_DROPDOWN |
     5504                                    LS_HORZSCROLL,
     5505                                    (swp.x +
     5506                                     WinQuerySysValue(HWND_DESKTOP,
     5507                                                      SV_CXSIZEBORDER) + 48L),
     5508                                    (swp.cy -
     5509                                     WinQuerySysValue(HWND_DESKTOP,
     5510                                                      SV_CYSIZEBORDER)) - 60,
     5511                                    ((swp.cx -
     5512                                      (WinQuerySysValue(HWND_DESKTOP,
     5513                                                        SV_CXSIZEBORDER) *
     5514                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5515                                    MAIN_SETUPLIST, NULL, NULL);
    55185516    if (!hwndStatelist)
    55195517      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55205518
    55215519    hwndDrivelist = WinCreateWindow(hwndFrame,
    5522                                     WC_COMBOBOX,
    5523                                     (PSZ) NULL,
    5524                                     WS_VISIBLE | CBS_DROPDOWN,
    5525                                     (swp.x +
    5526                                      WinQuerySysValue(HWND_DESKTOP,
    5527                                                       SV_CXSIZEBORDER)),
    5528                                     (swp.cy -
    5529                                      WinQuerySysValue(HWND_DESKTOP,
    5530                                                       SV_CYSIZEBORDER)) - 60,
    5531                                     48L,
    5532                                     60L,
    5533                                     hwndFrame,
    5534                                     HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
     5520                                    WC_COMBOBOX,
     5521                                    (PSZ) NULL,
     5522                                    WS_VISIBLE | CBS_DROPDOWN,
     5523                                    (swp.x +
     5524                                     WinQuerySysValue(HWND_DESKTOP,
     5525                                                      SV_CXSIZEBORDER)),
     5526                                    (swp.cy -
     5527                                     WinQuerySysValue(HWND_DESKTOP,
     5528                                                      SV_CYSIZEBORDER)) - 60,
     5529                                    48L,
     5530                                    60L,
     5531                                    hwndFrame,
     5532                                    HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
    55355533    if (!hwndDrivelist)
    55365534      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55375535    SetPresParams(hwndDrivelist,
    5538                   NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
     5536                  NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
    55395537    hwndButtonlist = WinCreateWindow(hwndFrame,
    5540                                      WC_COMBOBOX,
    5541                                      (PSZ) NULL,
    5542                                      WS_VISIBLE | CBS_DROPDOWN |
    5543                                      LS_HORZSCROLL,
    5544                                      (swp.cx -
    5545                                       WinQuerySysValue(HWND_DESKTOP,
    5546                                                        SV_CXSIZEBORDER)) -
    5547                                      164L,
    5548                                      (swp.cy -
    5549                                       WinQuerySysValue(HWND_DESKTOP,
    5550                                                        SV_CYSIZEBORDER)) - 60,
    5551                                      164L, 60L, hwndFrame, HWND_TOP,
    5552                                      MAIN_BUTTONLIST, NULL, NULL);
     5538                                     WC_COMBOBOX,
     5539                                     (PSZ) NULL,
     5540                                     WS_VISIBLE | CBS_DROPDOWN |
     5541                                     LS_HORZSCROLL,
     5542                                     (swp.cx -
     5543                                      WinQuerySysValue(HWND_DESKTOP,
     5544                                                       SV_CXSIZEBORDER)) -
     5545                                     164L,
     5546                                     (swp.cy -
     5547                                      WinQuerySysValue(HWND_DESKTOP,
     5548                                                       SV_CYSIZEBORDER)) - 60,
     5549                                     164L, 60L, hwndFrame, HWND_TOP,
     5550                                     MAIN_BUTTONLIST, NULL, NULL);
    55535551    if (!hwndButtonlist)
    55545552      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55555553    WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5556                EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     5554               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    55575555    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5558                EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
     5556               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    55595557    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5560                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5558               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    55615559    WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5562                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5560               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    55635561    WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5564                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5562               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    55655563
    55665564    oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5567                                 DropDownListProc);
     5565                                DropDownListProc);
    55685566    WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5569                     QWL_USER, (PVOID) oldproc);
     5567                    QWL_USER, (PVOID) oldproc);
    55705568    oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5571                                 DropDownListProc);
     5569                                DropDownListProc);
    55725570    WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5573                     QWL_USER, (PVOID) oldproc);
     5571                    QWL_USER, (PVOID) oldproc);
    55745572    oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5575                                 DropDownListProc);
     5573                                DropDownListProc);
    55765574    WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5577                     QWL_USER, (PVOID) oldproc);
     5575                    QWL_USER, (PVOID) oldproc);
    55785576    oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5579                                 DropDownListProc);
     5577                                DropDownListProc);
    55805578    WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5581                     QWL_USER, (PVOID) oldproc);
     5579                    QWL_USER, (PVOID) oldproc);
    55825580    oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5583                                 DropDownListProc);
     5581                                DropDownListProc);
    55845582    WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5585                     QWL_USER, (PVOID) oldproc);
     5583                    QWL_USER, (PVOID) oldproc);
    55865584    oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
    55875585    WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
     
    55955593    WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
    55965594    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5597                                 ChildFrameButtonProc);
     5595                                ChildFrameButtonProc);
    55985596    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5599                     QWL_USER, (PVOID) oldproc);
     5597                    QWL_USER, (PVOID) oldproc);
    56005598    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5601                                 ChildFrameButtonProc);
     5599                                ChildFrameButtonProc);
    56025600    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5603                     QWL_USER, (PVOID) oldproc);
     5601                    QWL_USER, (PVOID) oldproc);
    56045602    hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
    56055603    WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
    56065604    SetToggleChecks(hwndMenu);
    5607     CfgMenuInit(hwndMenu, FALSE);       // 14 Feb 08 SHL
     5605    CfgMenuInit(hwndMenu, FALSE);        // 14 Feb 08 SHL
    56085606    SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
    56095607    SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
     
    56155613    hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
    56165614    idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
    5617                                         MM_ITEMIDFROMPOSITION,
    5618                                         MPVOID, MPVOID));
     5615                                        MM_ITEMIDFROMPOSITION,
     5616                                        MPVOID, MPVOID));
    56195617    WinSendMsg(hwndSysMenu,
    5620                MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
     5618               MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
    56215619    hwndSysSubMenu = mit.hwndSubMenu;
    56225620    mi.iPosition = MIT_END;
     
    56275625    mi.id = IDM_IDEALSIZE;
    56285626    WinSendMsg(hwndSysSubMenu,
    5629                MM_INSERTITEM,
    5630                MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
     5627               MM_INSERTITEM,
     5628               MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
    56315629    mi.afStyle = MIS_TEXT;
    56325630    mi.id = IDM_HIDEMENU;
    56335631    WinSendMsg(hwndSysSubMenu,
    5634                MM_INSERTITEM,
    5635                MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
     5632               MM_INSERTITEM,
     5633               MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
    56365634    SetSysMenu(hwndSysMenu);
    56375635
    56385636    size = sizeof(BOOL);
    56395637    if (PrfQueryProfileData(fmprof,
    5640                             FM3Str,
    5641                             "MenuInvisible", &temp, &size) && size && temp)
     5638                            FM3Str,
     5639                            "MenuInvisible", &temp, &size) && size && temp)
    56425640      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
    56435641    size = sizeof(BOOL);
    56445642    if (PrfQueryProfileData(fmprof,
    5645                             FM3Str, "FreeTree", &temp, &size) && size && temp)
     5643                            FM3Str, "FreeTree", &temp, &size) && size && temp)
    56465644      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
    56475645    size = sizeof(BOOL);
    56485646    if (PrfQueryProfileData(fmprof,
    5649                             FM3Str,
    5650                             "AutoTile", &temp, &size) && size && !temp)
     5647                            FM3Str,
     5648                            "AutoTile", &temp, &size) && size && !temp)
    56515649      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
    56525650    size = sizeof(BOOL);
    56535651    if (PrfQueryProfileData(fmprof,
    5654                             FM3Str, "Toolbar", &temp, &size) && size && !temp)
     5652                            FM3Str, "Toolbar", &temp, &size) && size && !temp)
    56555653      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
    56565654
     
    56775675      hwndTree = StartTreeCnr(hwnd, 4);
    56785676      if (!hwndTree)
    5679         WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     5677        WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    56805678      else {
    5681         if (!fSaveState ||
    5682             !PrfQueryProfileData(fmprof,
    5683                                 FM3Str,
    5684                                 "LastTreePos",
    5685                                 &swp, &size) || size != sizeof(SWP)) {
    5686 
    5687           INT ratio, height = 0;
    5688 
    5689           if (!fNoTreeGap)
    5690             height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    5691           size = sizeof(ratio);
    5692           if (!PrfQueryProfileData(fmprof,
    5693                                    FM3Str,
    5694                                    "TreeWindowRatio",
    5695                                    (PVOID) & ratio,
    5696                                    &size) || size < sizeof(ratio))
    5697             ratio = 400;
    5698           WinSetWindowPos(hwndTree,
    5699                           HWND_TOP,
    5700                           0,
    5701                           height,
    5702                           (swp.cx * 100) / ratio,
    5703                           swp.cy - height,
    5704                           SWP_SHOW | SWP_SIZE | SWP_MOVE |
    5705                           SWP_ACTIVATE | SWP_ZORDER);
    5706         }
    5707         else
    5708           WinSetWindowPos(hwndTree,
    5709                           HWND_TOP,
    5710                           swp.x,
    5711                           swp.y,
    5712                           swp.cx,
    5713                           swp.cy,
    5714                           swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
    5715                           SWP_ZORDER | SWP_ACTIVATE);
     5679        if (!fSaveState ||
     5680            !PrfQueryProfileData(fmprof,
     5681                                FM3Str,
     5682                                "LastTreePos",
     5683                                &swp, &size) || size != sizeof(SWP)) {
     5684
     5685          INT ratio, height = 0;
     5686
     5687          if (!fNoTreeGap)
     5688            height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     5689          size = sizeof(ratio);
     5690          if (!PrfQueryProfileData(fmprof,
     5691                                   FM3Str,
     5692                                   "TreeWindowRatio",
     5693                                   (PVOID) & ratio,
     5694                                   &size) || size < sizeof(ratio))
     5695            ratio = 400;
     5696          WinSetWindowPos(hwndTree,
     5697                          HWND_TOP,
     5698                          0,
     5699                          height,
     5700                          (swp.cx * 100) / ratio,
     5701                          swp.cy - height,
     5702                          SWP_SHOW | SWP_SIZE | SWP_MOVE |
     5703                          SWP_ACTIVATE | SWP_ZORDER);
     5704        }
     5705        else
     5706          WinSetWindowPos(hwndTree,
     5707                          HWND_TOP,
     5708                          swp.x,
     5709                          swp.y,
     5710                          swp.cx,
     5711                          swp.cy,
     5712                          swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
     5713                          SWP_ZORDER | SWP_ACTIVATE);
    57165714      }
    57175715      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5718                                   MAIN_TOOLS));
     5716                                  MAIN_TOOLS));
    57195717    }
    57205718    PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
     
    57275725      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pStatename), MPVOID);
    57285726      if (!add_setup(pStatename))
    5729         save_setups();
     5727              save_setups();
    57305728    }
    57315729    PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
     
    57385736
    57395737      for (x = 1; x < argc; x++) {
    5740         if (*argv[x] == '/' || *argv[x] == ';')
    5741           continue;
    5742         if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
    5743           OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
     5738        if (*argv[x] == '/' || *argv[x] == ';')
     5739          continue;
     5740        if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
     5741          OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
    57445742      }
    57455743    }
     
    57595757      hwndActive = TopWindow(hwnd, hwndTree);
    57605758      if (hwndActive)
    5761         WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
     5759        WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
    57625760    }
    57635761    if (fStartMinimized || fReminimize)
     
    57925790  case WM_CONTROLPOINTER:
    57935791    if (!fNoFinger &&
    5794         (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
    5795         SHORT1FROMMP(mp1) == IDM_USERLIST))
     5792        (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
     5793        SHORT1FROMMP(mp1) == IDM_USERLIST))
    57965794      return MRFROMLONG(hptrFinger);
    57975795    break;
     
    58335831    if (mp1) {
    58345832      if (fUserComboBox)
    5835         WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5836                         (CHAR *)mp1);
     5833        WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
     5834                        (CHAR *)mp1);
    58375835      if (add_udir(FALSE, (CHAR *)mp1)) {
    5838         if (fUserComboBox && fAutoAddDirs) {
    5839           WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5840                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5841                      MPFROMP((CHAR *)mp1));
    5842         }
     5836        if (fUserComboBox && fAutoAddDirs) {
     5837          WinSendMsg(hwndUserlist, LM_INSERTITEM,
     5838                     MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5839                     MPFROMP((CHAR *)mp1));
     5840        }
    58435841      }
    58445842    }
     
    58725870      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    58735871      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    5874         WinStoreWindowPos(FM2Str,
    5875                           "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
    5876         if (!fNoSaveState && fSaveState)
    5877           SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
     5872        WinStoreWindowPos(FM2Str,
     5873                          "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
     5874        if (!fNoSaveState && fSaveState)
     5875          SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
    58785876      }
    58795877    }
     
    58855883    case 1:
    58865884      {
    5887         HWND hwndCurrent;
    5888         ULONG wmsg;
    5889 
    5890         wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
    5891         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5892         PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
    5893                                                        FID_CLIENT), wmsg,
    5894                                        MPVOID, MPVOID), mp1, mp2);
     5885        HWND hwndCurrent;
     5886        ULONG wmsg;
     5887
     5888        wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
     5889        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5890        PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
     5891                                                       FID_CLIENT), wmsg,
     5892                                       MPVOID, MPVOID), mp1, mp2);
    58955893      }
    58965894      break;
     
    59105908       */
    59115909      {
    5912         HWND hwndMenu, hwndSubMenu;
    5913         MENUITEM mi;
    5914 
    5915         hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
    5916         memset(&mi, 0, sizeof(mi));
    5917         mi.iPosition = MIT_END;
    5918         mi.afStyle = MIS_TEXT;
    5919         if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
    5920                         MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
    5921           break;
    5922         hwndSubMenu = mi.hwndSubMenu;
    5923         SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
     5910        HWND hwndMenu, hwndSubMenu;
     5911        MENUITEM mi;
     5912
     5913        hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
     5914        memset(&mi, 0, sizeof(mi));
     5915        mi.iPosition = MIT_END;
     5916        mi.afStyle = MIS_TEXT;
     5917        if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
     5918                        MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
     5919          break;
     5920        hwndSubMenu = mi.hwndSubMenu;
     5921        SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
    59245922      }
    59255923      break;
     
    59275925    default:
    59285926      {
    5929         HWND hwndCurrent;
    5930 
    5931         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5932         if (hwndCurrent)
    5933           WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
     5927        HWND hwndCurrent;
     5928
     5929        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5930        if (hwndCurrent)
     5931          WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
    59345932      }
    59355933      break;
     
    59395937  case UM_ADDTOMENU:
    59405938    AddToMenu((CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5941                                             FID_MENU));
     5939                                            FID_MENU));
    59425940    return 0;
    59435941
     
    59525950      info = cmdhead;
    59535951      while (info) {
    5954         WinSendMsg(hwndCmdlist, LM_INSERTITEM,
    5955                    MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
    5956         info = info->next;
     5952        WinSendMsg(hwndCmdlist, LM_INSERTITEM,
     5953                   MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
     5954        info = info->next;
    59575955      }
    59585956    }
     
    59785976      ulSearchCount = 1;
    59795977      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    5980                         &findbuf, sizeof(FILEFINDBUF3),
    5981                         &ulSearchCount, FIL_STANDARD)) {
    5982         do {
    5983           priority_bumped();
    5984           if (!foundit) {
    5985             thisone = FALSE;
    5986             p = strrchr(lasttoolbox, '\\');
    5987             if (!p)
    5988               p = lasttoolbox;
    5989             else
    5990               p++;
    5991             if (!stricmp(findbuf.achName, p))
    5992               thisone = TRUE;
    5993           }
    5994           p = strrchr(findbuf.achName, '.');
    5995           if (p)
    5996             *p = 0;
    5997           sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
    5998                                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5999                                        MPFROMP(findbuf.achName));
    6000           if (!foundit && thisone && sSelect >= 0) {
    6001             WinSendMsg(hwndButtonlist, LM_SELECTITEM,
    6002                        MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
    6003             foundit = TRUE;
    6004           }
    6005         }
    6006         while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
    6007                             &ulSearchCount));
    6008         DosFindClose(hDir);
    6009         priority_bumped();
     5978                        &findbuf, sizeof(FILEFINDBUF3),
     5979                        &ulSearchCount, FIL_STANDARD)) {
     5980        do {
     5981          priority_bumped();
     5982          if (!foundit) {
     5983            thisone = FALSE;
     5984            p = strrchr(lasttoolbox, '\\');
     5985            if (!p)
     5986              p = lasttoolbox;
     5987            else
     5988              p++;
     5989            if (!stricmp(findbuf.achName, p))
     5990              thisone = TRUE;
     5991          }
     5992          p = strrchr(findbuf.achName, '.');
     5993          if (p)
     5994            *p = 0;
     5995          sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
     5996                                       MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5997                                       MPFROMP(findbuf.achName));
     5998          if (!foundit && thisone && sSelect >= 0) {
     5999            WinSendMsg(hwndButtonlist, LM_SELECTITEM,
     6000                       MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
     6001            foundit = TRUE;
     6002          }
     6003        }
     6004        while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
     6005                            &ulSearchCount));
     6006        DosFindClose(hDir);
     6007        priority_bumped();
    60106008      }
    60116009      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     
    60266024
    60276025      if (!loadedudirs)
    6028         load_udirs();
     6026        load_udirs();
    60296027      DosError(FERR_DISABLEHARDERR);
    60306028      DosQCurDisk(&ulDriveNum, &ulDriveMap);
    60316029      info = udirhead;
    60326030      while (info) {
    6033         if (IsFullName(info->path) &&
    6034             !(driveflags[toupper(*info->path) - 'A'] &
    6035               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6036           DosError(FERR_DISABLEHARDERR);
    6037           hDir = HDIR_CREATE;
    6038           ulSearchCount = 1;
    6039           if (!IsRoot(info->path))
    6040             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6041                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6042                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6043                               &findbuf, sizeof(FILEFINDBUF3),
    6044                               &ulSearchCount, FIL_STANDARD);
    6045           else {
    6046             rc = 0;
    6047             findbuf.attrFile = FILE_DIRECTORY;
    6048           }
    6049           priority_bumped();
    6050           if (!rc) {
    6051             if (!IsRoot(info->path))
    6052               DosFindClose(hDir);
    6053             if (findbuf.attrFile & FILE_DIRECTORY)
    6054               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6055                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6056                         MPFROMP(info->path));
    6057             else {
    6058               temp = info->next;
    6059               remove_udir(info->path);
    6060               info = temp;
    6061               continue;
    6062             }
    6063           }
    6064           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6065             temp = info->next;
    6066             remove_udir(info->path);
    6067             info = temp;
    6068             continue;
    6069           }
    6070         }
    6071         info = info->next;
     6031        if (IsFullName(info->path) &&
     6032            !(driveflags[toupper(*info->path) - 'A'] &
     6033              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6034          DosError(FERR_DISABLEHARDERR);
     6035          hDir = HDIR_CREATE;
     6036          ulSearchCount = 1;
     6037          if (!IsRoot(info->path))
     6038            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6039                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6040                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6041                              &findbuf, sizeof(FILEFINDBUF3),
     6042                              &ulSearchCount, FIL_STANDARD);
     6043          else {
     6044            rc = 0;
     6045            findbuf.attrFile = FILE_DIRECTORY;
     6046          }
     6047          priority_bumped();
     6048          if (!rc) {
     6049            if (!IsRoot(info->path))
     6050              DosFindClose(hDir);
     6051            if (findbuf.attrFile & FILE_DIRECTORY)
     6052              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6053                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6054                        MPFROMP(info->path));
     6055            else {
     6056              temp = info->next;
     6057              remove_udir(info->path);
     6058              info = temp;
     6059              continue;
     6060            }
     6061          }
     6062          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6063            temp = info->next;
     6064            remove_udir(info->path);
     6065            info = temp;
     6066            continue;
     6067          }
     6068        }
     6069        info = info->next;
    60726070      }
    60736071      info = ldirhead;
    60746072      while (info) {
    6075         if (IsFullName(info->path) &&
    6076             !(driveflags[toupper(*info->path) - 'A'] &
    6077               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6078           DosError(FERR_DISABLEHARDERR);
    6079           hDir = HDIR_CREATE;
    6080           ulSearchCount = 1;
    6081           if (!IsRoot(info->path))
    6082             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6083                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6084                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6085                               &findbuf, sizeof(FILEFINDBUF3),
    6086                               &ulSearchCount, FIL_STANDARD);
    6087           else {
    6088             rc = 0;
    6089             findbuf.attrFile = FILE_DIRECTORY;
    6090           }
    6091           priority_bumped();
    6092           if (!rc) {
    6093             if (!IsRoot(info->path))
    6094               DosFindClose(hDir);
    6095             if (findbuf.attrFile & FILE_DIRECTORY)
    6096               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6097                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6098                         MPFROMP(info->path));
    6099             else {
    6100               temp = info->next;
    6101               remove_udir(info->path);
    6102               info = temp;
    6103               continue;
    6104             }
    6105           }
    6106           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6107             temp = info->next;
    6108             remove_udir(info->path);
    6109             info = temp;
    6110             continue;
    6111           }
    6112         }
    6113         info = info->next;
     6073        if (IsFullName(info->path) &&
     6074            !(driveflags[toupper(*info->path) - 'A'] &
     6075              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6076          DosError(FERR_DISABLEHARDERR);
     6077          hDir = HDIR_CREATE;
     6078          ulSearchCount = 1;
     6079          if (!IsRoot(info->path))
     6080            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6081                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6082                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6083                              &findbuf, sizeof(FILEFINDBUF3),
     6084                              &ulSearchCount, FIL_STANDARD);
     6085          else {
     6086            rc = 0;
     6087            findbuf.attrFile = FILE_DIRECTORY;
     6088          }
     6089          priority_bumped();
     6090          if (!rc) {
     6091            if (!IsRoot(info->path))
     6092              DosFindClose(hDir);
     6093            if (findbuf.attrFile & FILE_DIRECTORY)
     6094              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6095                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6096                        MPFROMP(info->path));
     6097            else {
     6098              temp = info->next;
     6099              remove_udir(info->path);
     6100              info = temp;
     6101              continue;
     6102            }
     6103          }
     6104          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6105            temp = info->next;
     6106            remove_udir(info->path);
     6107            info = temp;
     6108            continue;
     6109          }
     6110        }
     6111        info = info->next;
    61146112      }
    61156113      WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6116                 MPFROM2SHORT(0, 0),
    6117                 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
     6114                MPFROM2SHORT(0, 0),
     6115                MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
    61186116      WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
    61196117    }
     
    61296127  case WM_SIZE:
    61306128    ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
    6131                    SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
     6129                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
    61326130    break;
    61336131
     
    61436141      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    61446142      if (hps) {
    6145         WinQueryWindowRect(hwnd, &rcl);
    6146         WinFillRect(hps, &rcl, CLR_PALEGRAY);
    6147         WinEndPaint(hps);
     6143        WinQueryWindowRect(hwnd, &rcl);
     6144        WinFillRect(hps, &rcl, CLR_PALEGRAY);
     6145        WinEndPaint(hps);
    61486146      }
    61496147    }
     
    61596157      switch (SHORT2FROMMP(mp1)) {
    61606158      case CBN_ENTER:
    6161         {
    6162           HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6163                                         SHORT1FROMMP(mp1));
    6164           CHAR path[CCHMAXPATH];
    6165           ULONG ul;
    6166 
    6167           switch (SHORT1FROMMP(mp1)) {
    6168           case MAIN_USERLIST:
    6169             ul = CCHMAXPATH;
    6170             break;
    6171           case MAIN_SETUPLIST:
    6172             ul = STATE_NAME_MAX_BYTES;
    6173             break;
    6174           default:
    6175             ul = 13;                    // fixme to not be hardcoded
    6176           }
    6177 
    6178           SetShiftState();
    6179           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    6180           bstrip(path);
    6181           if (*path) {
    6182             if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
    6183               if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
    6184                 if (!LastDir ||
    6185                     !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
    6186                                 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
    6187                   save_dir2(path);
    6188                 if (!PMMkDir(hwnd, path, TRUE)) {
    6189                   WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
    6190                   break;
    6191                 }
    6192               }
    6193               if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
    6194 
    6195                 HWND hwndDir;
    6196 
    6197                 if ((fUserListSwitches &&
    6198                      !(shiftstate & KC_SHIFT)) ||
    6199                     (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
    6200                   hwndDir = FindDirCnr(hwnd);
    6201                   if (hwndDir) {
    6202                     WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
    6203                     break;
    6204                   }
    6205                 }
    6206                 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
    6207               }
    6208             }
    6209             else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
    6210               ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    6211                                                           FID_CLIENT),
    6212                                           TREE_CNR), path, FALSE, TRUE);
    6213               WinSetFocus(HWND_DESKTOP, hwndTree);
    6214             }
    6215             else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
    6216               strcat(path, ".TLS");
    6217               load_tools(path);
    6218               PrfWriteProfileString(fmprof,
    6219                                     FM3Str, "LastToolBox", lasttoolbox);
    6220               BuildTools(hwndToolback, TRUE);
    6221               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
    6222             }
    6223             else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    6224               CHAR szKey[80];
    6225               ULONG size, numsaves = 0;
    6226 
    6227               SetShiftState();
    6228               size = sizeof(ULONG);
    6229               sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
    6230               if (!PrfQueryProfileData(fmprof,
    6231                                        FM3Str,
    6232                                        szKey,
    6233                                        (PVOID)&numsaves,
    6234                                        &size))
    6235               {
    6236                 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
    6237                   saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    6238                         GetPString(IDS_WARNINGTEXT),
    6239                         GetPString(IDS_DOESNTEXISTTEXT), path);
    6240                 }
    6241                 else {
    6242                   Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
    6243                              IDS_PRFQUERYPROFILEDATA);
    6244                 }
    6245               }
    6246               else if (!numsaves)
    6247                 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    6248               else {
    6249                 char *pszStateName;
    6250                 if ((shiftstate & KC_SHIFT) == 0)
    6251                   PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
    6252                 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
    6253                 if (!pszStateName) {
    6254                   // Fall back if out of memory - already complained
    6255                   if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
    6256                     // Autotile requested or forced
    6257                     PostMsg(MainObjectHwnd,
    6258                             UM_RESTORE,
    6259                             MPVOID,
    6260                             MPFROMLONG(1));             // Autotile
    6261                   }
    6262                 }
    6263                 else if (!PostMsg(MainObjectHwnd,
    6264                                   UM_RESTORE,
    6265                                   MPFROMP(pszStateName),
    6266                                   MPVOID)) {
    6267                   xfree(pszStateName, pszSrcFile, __LINE__);
    6268                 }
    6269               }
    6270             }
    6271             else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
    6272 
    6273               SHORT sSelect;
    6274 
    6275               sSelect = (SHORT) WinSendMsg(hwndCmdlist,
    6276                                            LM_QUERYSELECTION,
    6277                                            MPFROMSHORT(LIT_FIRST), MPVOID);
    6278               if (sSelect >= 0)
    6279                 WinPostMsg(hwnd,
    6280                            WM_COMMAND,
    6281                            MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
    6282                            MPVOID);
    6283               WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    6284             }
    6285           }
    6286         }
    6287         break;
     6159        {
     6160          HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     6161                                        SHORT1FROMMP(mp1));
     6162          CHAR path[CCHMAXPATH];
     6163          ULONG ul;
     6164
     6165          switch (SHORT1FROMMP(mp1)) {
     6166          case MAIN_USERLIST:
     6167            ul = CCHMAXPATH;
     6168            break;
     6169          case MAIN_SETUPLIST:
     6170            ul = STATE_NAME_MAX_BYTES;
     6171            break;
     6172          default:
     6173            ul = 13;                    // fixme to not be hardcoded
     6174          }
     6175
     6176          SetShiftState();
     6177          WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
     6178          bstrip(path);
     6179          if (*path) {
     6180            if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
     6181              if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
     6182                if (!LastDir ||
     6183                    !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
     6184                                UM_CONTAINERDIR, MPFROMP(path), MPVOID))
     6185                  save_dir2(path);
     6186                if (!PMMkDir(hwnd, path, TRUE)) {
     6187                  WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
     6188                  break;
     6189                }
     6190              }
     6191              if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
     6192
     6193                HWND hwndDir;
     6194
     6195                if ((fUserListSwitches &&
     6196                     !(shiftstate & KC_SHIFT)) ||
     6197                    (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
     6198                  hwndDir = FindDirCnr(hwnd);
     6199                  if (hwndDir) {
     6200                    WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
     6201                    break;
     6202                  }
     6203                }
     6204                OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
     6205              }
     6206            }
     6207            else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
     6208              ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
     6209                                                          FID_CLIENT),
     6210                                          TREE_CNR), path, FALSE, TRUE);
     6211              WinSetFocus(HWND_DESKTOP, hwndTree);
     6212            }
     6213            else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
     6214              strcat(path, ".TLS");
     6215              load_tools(path);
     6216              PrfWriteProfileString(fmprof,
     6217                                    FM3Str, "LastToolBox", lasttoolbox);
     6218              BuildTools(hwndToolback, TRUE);
     6219              WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     6220            }
     6221            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
     6222              CHAR szKey[80];
     6223              ULONG size, numsaves = 0;
     6224
     6225              SetShiftState();
     6226              size = sizeof(ULONG);
     6227              sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
     6228              if (!PrfQueryProfileData(fmprof,
     6229                                       FM3Str,
     6230                                       szKey,
     6231                                       (PVOID)&numsaves,
     6232                                       &size))
     6233              {
     6234                if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
     6235                  saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     6236                        GetPString(IDS_WARNINGTEXT),
     6237                        GetPString(IDS_DOESNTEXISTTEXT), path);
     6238                }
     6239                else {
     6240                  Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
     6241                             IDS_PRFQUERYPROFILEDATA);
     6242                }
     6243              }
     6244              else if (!numsaves)
     6245                Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     6246              else {
     6247                char *pszStateName;
     6248                if ((shiftstate & KC_SHIFT) == 0)
     6249                  PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
     6250                pszStateName = xstrdup(path, pszSrcFile, __LINE__);
     6251                if (!pszStateName) {
     6252                  // Fall back if out of memory - already complained
     6253                  if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
     6254                    // Autotile requested or forced
     6255                    PostMsg(MainObjectHwnd,
     6256                            UM_RESTORE,
     6257                            MPVOID,
     6258                            MPFROMLONG(1));                // Autotile
     6259                  }
     6260                }
     6261                else if (!PostMsg(MainObjectHwnd,
     6262                                  UM_RESTORE,
     6263                                  MPFROMP(pszStateName),
     6264                                  MPVOID)) {
     6265                  xfree(pszStateName, pszSrcFile, __LINE__);
     6266                }
     6267              }
     6268            }
     6269            else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
     6270
     6271              SHORT sSelect;
     6272
     6273              sSelect = (SHORT) WinSendMsg(hwndCmdlist,
     6274                                           LM_QUERYSELECTION,
     6275                                           MPFROMSHORT(LIT_FIRST), MPVOID);
     6276              if (sSelect >= 0)
     6277                WinPostMsg(hwnd,
     6278                           WM_COMMAND,
     6279                           MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
     6280                           MPVOID);
     6281              WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
     6282            }
     6283          }
     6284        }
     6285        break;
    62886286
    62896287      default:
    6290         break;
     6288        break;
    62916289      }
    62926290      break;
     
    63086306  case WM_CLOSE:
    63096307    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6310                WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     6308               WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    63116309    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    63126310    fAmClosing = TRUE;
    63136311    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6314                WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
     6312               WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
    63156313    if (CloseChildren(hwnd)) {
    63166314      fAmClosing = FALSE;
    63176315      if (fAutoTile)
    6318         PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
     6316        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
    63196317      return 0;
    63206318    }
    63216319    if (hwndTree) {
    63226320      if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
    6323         WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
     6321        WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    63246322    }
    63256323    DosSleep(1);
     
    63356333      // Try to restore saved shutdown state
    63366334      char *pszDefaultStateName = xstrdup(GetPString(IDS_SHUTDOWNSTATE),
    6337                                           pszSrcFile, __LINE__);
     6335                                          pszSrcFile, __LINE__);
    63386336      if (pszDefaultStateName) {
    6339         if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
    6340           // 05 Feb 08 SHL fixme to complain?
    6341           xfree(pszDefaultStateName, pszSrcFile, __LINE__);
     6337        if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
     6338          // 05 Feb 08 SHL fixme to complain?
     6339          xfree(pszDefaultStateName, pszSrcFile, __LINE__);
    63426340      }
    63436341    }
     
    63486346    if (mp1)
    63496347      return MRFROMLONG(OpenDirCnr((HWND) 0,
    6350                                    hwndMain,
    6351                                    hwndTree, (BOOL) mp2, (char *)mp1));
     6348                                   hwndMain,
     6349                                   hwndTree, (BOOL) mp2, (char *)mp1));
    63526350    return 0;
    63536351
  • trunk/dll/walkem.c

    r1025 r1027  
    2727  29 Feb 08 GKY Use xfree where appropriate
    2828  29 Feb 08 GKY Refactor global command line variables to notebook.h
     29  19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
    2930
    3031***********************************************************************/
     
    9394                 MPFROMP(pld->path));
    9495    }
    95 //     if (fSaveState) {
    96 //       WinSendMsg(hwndStatelist,
    97 //               LM_INSERTITEM,
    98 //               MPFROM2SHORT(LIT_SORTASCENDING, 0),
    99 //               MPFROMP(GetPString(IDS_SHUTDOWNSTATE)));
    100 //     }
    10196    WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    10297  }
Note: See TracChangeset for help on using the changeset viewer.