Changeset 941 for trunk/dll/mainwnd.c


Ignore:
Timestamp:
Feb 9, 2008, 10:38:39 PM (18 years ago)
Author:
Steven Levine
Message:

Restore no-prescan drives if restoring named state
This reverts to orginal behavior for named states

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r940 r941  
    4949  17 Jan 08 GKY Add presparam save & restore for individual directory containers
    5050  19 Jan 08 GKY Rework Utilities menu
     51  05 Feb 08 SHL Restore no-prescan drives if restoring named state
    5152
    5253***********************************************************************/
     
    7677#pragma data_seg(DATA1)
    7778
    78 // #define FM2_STATE_AT_CLOSE GetPString(IDS_FM2TEMPTEXT)
    79 #define FM2_STATE_AT_CLOSE "LastClose"
    80 
    8179static PSZ pszSrcFile = __FILE__;
    8280
     
    8785
    8886static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    89                                           MPARAM mp2)
     87                                          MPARAM mp2)
    9088{
    9189  switch (msg) {
     
    113111      *dv = 0;
    114112      WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
    115                                         id + 50), sizeof(dv), dv);
     113                                        id + 50), sizeof(dv), dv);
    116114      d = toupper(*dv);
    117115      if (isalpha(d) && d > 'B' &&
    118           !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
    119                                    DRIVE_SLOW)) &&
    120           (!hwndBubble ||
    121            WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    122           !WinQueryCapture(HWND_DESKTOP)) {
    123 
    124         FSALLOCATE fsa;
    125         CHAR s[90], szQty[38];
    126         ULONG ulPctFree;
    127         ULONGLONG ullFreeQty;
    128 
    129         if (!DosQueryFSInfo((d - 'A') + 1,
    130                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    131           ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
    132             (fsa.cSectorUnit * fsa.cbSector);
    133           ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
    134             (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
    135           CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
    136           sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
    137         }
    138         if ((!hwndBubble ||
    139              WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    140             !WinQueryCapture(HWND_DESKTOP))
    141           WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
     116          !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
     117                                   DRIVE_SLOW)) &&
     118          (!hwndBubble ||
     119           WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     120          !WinQueryCapture(HWND_DESKTOP)) {
     121
     122        FSALLOCATE fsa;
     123        CHAR s[90], szQty[38];
     124        ULONG ulPctFree;
     125        ULONGLONG ullFreeQty;
     126
     127        if (!DosQueryFSInfo((d - 'A') + 1,
     128                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     129          ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
     130            (fsa.cSectorUnit * fsa.cbSector);
     131          ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
     132            (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
     133          CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
     134          sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
     135        }
     136        if ((!hwndBubble ||
     137             WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     138            !WinQueryCapture(HWND_DESKTOP))
     139          WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
    142140      }
    143141    }
     
    150148
    151149      if (DosQuerySysInfo(QSV_BOOT_DRIVE,
    152                           QSV_BOOT_DRIVE,
    153                           (PVOID) & bd, (ULONG) sizeof(ULONG)))
    154         bd = 3L;
     150                          QSV_BOOT_DRIVE,
     151                          (PVOID) & bd, (ULONG) sizeof(ULONG)))
     152        bd = 3L;
    155153      *s = (CHAR) bd + '@';
    156154      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    157155      if (!mp1) {
    158         s[3] = 0;
    159         WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
     156        s[3] = 0;
     157        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    160158      }
    161159      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
     
    164162
    165163  case UM_RESTORE:
    166     if (mp2) {
    167       switch ((ULONG) mp2) {
    168       case 1:
    169         TileChildren(hwndMain, TRUE);
    170         break;
    171       case 2:
    172         CloseDirCnrChildren(hwndMain);
    173         break;
    174       }
    175     }
    176     else {
     164    switch ((ULONG)mp2) {
     165    case 1:
     166      TileChildren(hwndMain, TRUE);
     167      break;
     168    case 2:
     169      CloseDirCnrChildren(hwndMain);
     170      break;
     171    case 0:
    177172      fNoTileUpdate = TRUE;
    178173      WinEnableWindow(WinQueryWindow(hwndMain, QW_PARENT), FALSE);
     
    181176      fNoTileUpdate = FALSE;
    182177      if (mp1)
    183         free((char *)mp1);
     178        free((char *)mp1);
    184179      if (fAutoTile)
    185         TileChildren(hwndMain, TRUE);
     180        TileChildren(hwndMain, TRUE);
     181      break;
     182    default:
     183      Runtime_Error(pszSrcFile, __LINE__, "%u unexpected", mp2);
    186184    }
    187185    return 0;
     
    216214      DosError(FERR_DISABLEHARDERR);
    217215      WinRegisterClass(hab2,
    218                        (PSZ) WC_OBJECTWINDOW,
    219                        MainObjectWndProc, 0, sizeof(PVOID));
     216                       (PSZ) WC_OBJECTWINDOW,
     217                       MainObjectWndProc, 0, sizeof(PVOID));
    220218      MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
    221                                        WC_OBJECTWINDOW,
    222                                        (PSZ) NULL,
    223                                        0,
    224                                        0L,
    225                                        0L,
    226                                        0L,
    227                                        0L,
    228                                        0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
     219                                       WC_OBJECTWINDOW,
     220                                       (PSZ) NULL,
     221                                       0,
     222                                       0L,
     223                                       0L,
     224                                       0L,
     225                                       0L,
     226                                       0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
    229227      if (!MainObjectHwnd)
    230         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
    231                    IDS_WINCREATEWINDOW);
     228        Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
     229                   IDS_WINCREATEWINDOW);
    232230      else {
    233         WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
    234         while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
    235           WinDispatchMsg(hab2, &qmsg2);
    236         WinDestroyWindow(MainObjectHwnd);
     231        WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
     232        while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
     233          WinDispatchMsg(hab2, &qmsg2);
     234        WinDestroyWindow(MainObjectHwnd);
    237235      }
    238236      WinDestroyMsgQueue(hmq2);
     
    243241
    244242static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
    245                                         MPARAM mp2)
     243                                        MPARAM mp2)
    246244{
    247245  switch (msg) {
     
    263261    while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    264262      if (hwndC != exclude) {
    265         id = WinQueryWindowUShort(hwndC, QWS_ID);
    266         if (id)
    267           break;
     263        id = WinQueryWindowUShort(hwndC, QWS_ID);
     264        if (id)
     265          break;
    268266      }
    269267    }
     
    285283      henum = WinBeginEnumWindows(hwndMain);
    286284      while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    287         // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
    288         if (hwndC != exclude && hwndC != hwndTree) {
    289           id = WinQueryWindowUShort(hwndC, QWS_ID);
    290           if (id) {
    291             hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
    292             if (hwndClient) {
    293               hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
    294               if (hwndDir) {
    295                 if (fLookInDir) {
    296                   pci = (PCNRITEM) WinSendMsg(hwndDir,
    297                                               CM_QUERYRECORDEMPHASIS,
    298                                               MPFROMLONG(CMA_FIRST),
    299                                               MPFROMSHORT(CRA_CURSORED));
    300                   if (pci && (INT) pci != -1)
    301                     break;
    302                 }
    303                 if (WinSendMsg(hwndClient,
    304                                UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
    305                   MakeValidDir(ret);
    306                   // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
    307                   WinEndEnumWindows(henum);
    308                   return hwndC;
    309                 }
    310               }
    311             }
    312           }
    313         }
     285        // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
     286        if (hwndC != exclude && hwndC != hwndTree) {
     287          id = WinQueryWindowUShort(hwndC, QWS_ID);
     288          if (id) {
     289            hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
     290            if (hwndClient) {
     291              hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
     292              if (hwndDir) {
     293                if (fLookInDir) {
     294                  pci = (PCNRITEM) WinSendMsg(hwndDir,
     295                                              CM_QUERYRECORDEMPHASIS,
     296                                              MPFROMLONG(CMA_FIRST),
     297                                              MPFROMSHORT(CRA_CURSORED));
     298                  if (pci && (INT) pci != -1)
     299                    break;
     300                }
     301                if (WinSendMsg(hwndClient,
     302                               UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
     303                  MakeValidDir(ret);
     304                  // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
     305                  WinEndEnumWindows(henum);
     306                  return hwndC;
     307                }
     308              }
     309            }
     310          }
     311        }
    314312      }
    315313      WinEndEnumWindows(henum);
    316314      if (!pci || (INT) pci == -1) {
    317         hwndC = hwndTree;
    318         pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
    319                                                                     FID_CLIENT),
    320                                                     TREE_CNR),
    321                                     CM_QUERYRECORDEMPHASIS,
    322                                     MPFROMLONG(CMA_FIRST),
    323                                     MPFROMSHORT(CRA_CURSORED));
     315        hwndC = hwndTree;
     316        pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
     317                                                                    FID_CLIENT),
     318                                                    TREE_CNR),
     319                                    CM_QUERYRECORDEMPHASIS,
     320                                    MPFROMLONG(CMA_FIRST),
     321                                    MPFROMSHORT(CRA_CURSORED));
    324322      }
    325323      if (pci && (INT) pci != -1) {
    326         strcpy(ret, pci->pszFileName);
    327         MakeValidDir(ret);
     324        strcpy(ret, pci->pszFileName);
     325        MakeValidDir(ret);
    328326      }
    329327      else
    330         save_dir2(ret);
     328        save_dir2(ret);
    331329    }
    332330  }
     
    346344      hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    347345      if (hwndDir)
    348         ret++;
     346        ret++;
    349347    }
    350348  }
     
    364362      hwndC = WinWindowFromID(hwndF, FID_CLIENT);
    365363      if (hwndC) {
    366         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    367         if (hwndDir) {
    368           *retstr = 0;
    369           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
    370           if (*retstr && !stricmp(retstr, directory)) {
    371             if (restore)
    372               WinSetWindowPos(hwndF,
    373                               HWND_TOP,
    374                               0,
    375                               0,
    376                               0,
    377                               0,
    378                               SWP_RESTORE | SWP_SHOW |
    379                               SWP_ACTIVATE | SWP_ZORDER);
    380             break;
    381           }
    382         }
     364        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     365        if (hwndDir) {
     366          *retstr = 0;
     367          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
     368          if (*retstr && !stricmp(retstr, directory)) {
     369            if (restore)
     370              WinSetWindowPos(hwndF,
     371                              HWND_TOP,
     372                              0,
     373                              0,
     374                              0,
     375                              0,
     376                              SWP_RESTORE | SWP_SHOW |
     377                              SWP_ACTIVATE | SWP_ZORDER);
     378            break;
     379          }
     380        }
    383381      }
    384382    }
     
    447445    while (tool) {
    448446      if (!(tool->flags & T_INVISIBLE)) {
    449         swp[x].x = butx;
    450         if (fTextTools || (tool->flags & T_TEXT)) {
    451           butx += 55L;
    452           swp[x].cx = 54L;
    453           swp[x].cy = 24L;
    454           swp[x].y = 3L;
    455         }
    456         else
    457           butx += 33L;
    458         if (tool->flags & T_SEPARATOR)
    459           butx += 12;
     447        swp[x].x = butx;
     448        if (fTextTools || (tool->flags & T_TEXT)) {
     449          butx += 55L;
     450          swp[x].cx = 54L;
     451          swp[x].cy = 24L;
     452          swp[x].y = 3L;
     453        }
     454        else
     455          butx += 33L;
     456        if (tool->flags & T_SEPARATOR)
     457          butx += 12;
    460458      }
    461459      else
    462         swp[x].fl = noattrib;
     460        swp[x].fl = noattrib;
    463461      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    464462      x++;
     
    469467      swp[x].x = butx;
    470468      if (!(tool->flags & T_INVISIBLE)) {
    471         if (fTextTools || (tool->flags & T_TEXT)) {
    472           butx += 55L;
    473           swp[x].cx = 54L;
    474           swp[x].cy = 24L;
    475           swp[x].y = 3L;
    476         }
    477         else
    478           butx += 33L;
    479         if (tool->flags & T_SEPARATOR)
    480           butx += 12;
     469        if (fTextTools || (tool->flags & T_TEXT)) {
     470          butx += 55L;
     471          swp[x].cx = 54L;
     472          swp[x].cy = 24L;
     473          swp[x].y = 3L;
     474        }
     475        else
     476          butx += 33L;
     477        if (tool->flags & T_SEPARATOR)
     478          butx += 12;
    481479      }
    482480      else
    483         swp[x].fl = noattrib;
     481        swp[x].fl = noattrib;
    484482      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    485483      x++;
     
    489487    if (!fTextTools && fToolTitles) {
    490488      for (x = 2L; x < numtools + 2L; x++) {
    491         if (fTextTools || !fToolTitles)
    492           swp[x].fl = noattrib;
    493         else {
    494           tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
    495           if (tool && (tool->flags & T_TEXT))
    496             swp[x].fl = noattrib;
    497           else {
    498             swp[x].hwndInsertBehind = HWND_TOP;
    499             swp[x].y = 1L;
    500             swp[x].cy = 10L;
    501           }
    502         }
    503         swp[x].hwnd = WinWindowFromID(hwnd,
    504                                       WinQueryWindowUShort(swp[x].hwnd,
    505                                                            QWS_ID) + 25000);
     489        if (fTextTools || !fToolTitles)
     490          swp[x].fl = noattrib;
     491        else {
     492          tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
     493          if (tool && (tool->flags & T_TEXT))
     494            swp[x].fl = noattrib;
     495          else {
     496            swp[x].hwndInsertBehind = HWND_TOP;
     497            swp[x].y = 1L;
     498            swp[x].cy = 10L;
     499          }
     500        }
     501        swp[x].hwnd = WinWindowFromID(hwnd,
     502                                      WinQueryWindowUShort(swp[x].hwnd,
     503                                                           QWS_ID) + 25000);
    506504      }
    507505      WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
     
    513511
    514512static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
    515                                         MPARAM mp2)
     513                                        MPARAM mp2)
    516514{
    517515  PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
     
    551549      id = WinQueryWindowUShort(hwndParent, QWS_ID);
    552550      if (SHORT1FROMMP(mp2)) {
    553         // If getting focus 1st time - save original accelerator
    554         if (haccelSaved == NULLHANDLE) {
    555           haccelSaved = WinQueryAccelTable(hab, hwndFrame);
    556           if (haccelSaved == NULLHANDLE)
    557             Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
    558           // else
    559             // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
    560         }
    561         if (haccelSaved != NULLHANDLE) {
    562           switch (id) {
    563           case MAIN_DRIVELIST:
    564             if (haccelDriveList == NULLHANDLE) {
    565                 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
    566                 if (haccelDriveList == NULLHANDLE)
    567                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    568             }
    569             if (haccelDriveList != NULLHANDLE) {
    570               if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
    571                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    572               // else
    573                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
    574             }
    575             break;
    576           case MAIN_SETUPLIST:
    577             if (haccelSetupList == NULLHANDLE) {
    578                 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
    579                 if (haccelSetupList == NULLHANDLE)
    580                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    581             }
    582             if (haccelSetupList != NULLHANDLE) {
    583               if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
    584                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    585               // else
    586                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
    587             }
    588             break;
    589           case MAIN_CMDLIST:
    590             if (haccelCmdList == NULLHANDLE) {
    591                 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
    592                 if (haccelCmdList == NULLHANDLE)
    593                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    594             }
    595             if (haccelCmdList != NULLHANDLE) {
    596               if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
    597                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    598               // else
    599                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
    600             }
    601             break;
    602           case MAIN_USERLIST:
    603             if (haccelUserList == NULLHANDLE) {
    604                 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
    605                 if (haccelUserList == NULLHANDLE)
    606                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    607             }
    608             if (haccelUserList != NULLHANDLE) {
    609               if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
    610                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    611               // else
    612                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
    613             }
    614             break;
    615           case MAIN_BUTTONLIST:
    616             if (haccelButtonList == NULLHANDLE) {
    617                 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
    618                 if (haccelButtonList == NULLHANDLE)
    619                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    620             }
    621             if (haccelButtonList != NULLHANDLE) {
    622               if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
    623                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    624               // else
    625                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
    626             }
    627             break;
    628           } // switch
    629         }
     551        // If getting focus 1st time - save original accelerator
     552        if (haccelSaved == NULLHANDLE) {
     553          haccelSaved = WinQueryAccelTable(hab, hwndFrame);
     554          if (haccelSaved == NULLHANDLE)
     555            Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
     556          // else
     557            // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
     558        }
     559        if (haccelSaved != NULLHANDLE) {
     560          switch (id) {
     561          case MAIN_DRIVELIST:
     562            if (haccelDriveList == NULLHANDLE) {
     563                haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
     564                if (haccelDriveList == NULLHANDLE)
     565                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     566            }
     567            if (haccelDriveList != NULLHANDLE) {
     568              if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
     569                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     570              // else
     571                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
     572            }
     573            break;
     574          case MAIN_SETUPLIST:
     575            if (haccelSetupList == NULLHANDLE) {
     576                haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
     577                if (haccelSetupList == NULLHANDLE)
     578                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     579            }
     580            if (haccelSetupList != NULLHANDLE) {
     581              if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
     582                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     583              // else
     584                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
     585            }
     586            break;
     587          case MAIN_CMDLIST:
     588            if (haccelCmdList == NULLHANDLE) {
     589                haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
     590                if (haccelCmdList == NULLHANDLE)
     591                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     592            }
     593            if (haccelCmdList != NULLHANDLE) {
     594              if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
     595                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     596              // else
     597                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
     598            }
     599            break;
     600          case MAIN_USERLIST:
     601            if (haccelUserList == NULLHANDLE) {
     602                haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
     603                if (haccelUserList == NULLHANDLE)
     604                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     605            }
     606            if (haccelUserList != NULLHANDLE) {
     607              if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
     608                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     609              // else
     610                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
     611            }
     612            break;
     613          case MAIN_BUTTONLIST:
     614            if (haccelButtonList == NULLHANDLE) {
     615                haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
     616                if (haccelButtonList == NULLHANDLE)
     617                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     618            }
     619            if (haccelButtonList != NULLHANDLE) {
     620              if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
     621                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     622              // else
     623                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
     624            }
     625            break;
     626          } // switch
     627        }
    630628      }
    631629      else {
    632         // Losing focus
    633         switch (id) {
    634         case MAIN_DRIVELIST:
    635         case MAIN_SETUPLIST:
    636         case MAIN_CMDLIST:
    637         case MAIN_USERLIST:
    638         case MAIN_BUTTONLIST:
    639           if (haccelSaved != NULLHANDLE) {
    640             if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
    641               Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    642             // else
    643               // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
    644           }
    645           break;
    646         } // switch
     630        // Losing focus
     631        switch (id) {
     632        case MAIN_DRIVELIST:
     633        case MAIN_SETUPLIST:
     634        case MAIN_CMDLIST:
     635        case MAIN_USERLIST:
     636        case MAIN_BUTTONLIST:
     637          if (haccelSaved != NULLHANDLE) {
     638            if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
     639              Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     640            // else
     641              // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
     642          }
     643          break;
     644        } // switch
    647645      }
    648646    }
     
    654652
    655653      if (hwndMenu)
    656         WinDestroyWindow(hwndMenu);
     654        WinDestroyWindow(hwndMenu);
    657655      hwndMenu = (HWND) 0;
    658656      id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
    659657      switch (id) {
    660658      case MAIN_CMDLIST:
    661         WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    662                                                                 QW_PARENT),
    663                                                   QW_PARENT),
    664                                    FID_CLIENT),
    665                    WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
    666         break;
     659        WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     660                                                                QW_PARENT),
     661                                                  QW_PARENT),
     662                                   FID_CLIENT),
     663                   WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
     664        break;
    667665      case MAIN_USERLIST:
    668666      case MAIN_SETUPLIST:
    669         hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    670         if (hwndMenu)
    671           PopupMenu(hwnd,
    672                     WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    673                                                                   QW_PARENT),
    674                                                    QW_PARENT),
    675                                     FID_CLIENT), hwndMenu);
    676         break;
     667        hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     668        if (hwndMenu)
     669          PopupMenu(hwnd,
     670                    WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     671                                                                  QW_PARENT),
     672                                                   QW_PARENT),
     673                                    FID_CLIENT), hwndMenu);
     674        break;
    677675      default:
    678         ret = FALSE;
    679         break;
     676        ret = FALSE;
     677        break;
    680678      } // switch
    681679      return ret;
     
    686684      switch (SHORT1FROMMP(mp1)) {
    687685      case CBID_EDIT:
    688         id = WinQueryWindowUShort(hwnd, QWS_ID);
    689         switch (SHORT2FROMMP(mp1)) {
    690         case EN_SETFOCUS:
    691           switch (id) {
    692           case MAIN_CMDLIST:
    693             WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
    694             break;
    695           case MAIN_SETUPLIST:
    696             WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
    697             break;
    698           case MAIN_USERLIST:
    699             WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
    700             break;
    701           case MAIN_DRIVELIST:
    702             WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
    703             break;
    704           case MAIN_BUTTONLIST:
    705             WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
    706             break;
    707           default:
    708             break;
    709           }
    710           break;
    711 
    712         default:
    713           break;
    714         }
     686        id = WinQueryWindowUShort(hwnd, QWS_ID);
     687        switch (SHORT2FROMMP(mp1)) {
     688        case EN_SETFOCUS:
     689          switch (id) {
     690          case MAIN_CMDLIST:
     691            WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
     692            break;
     693          case MAIN_SETUPLIST:
     694            WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
     695            break;
     696          case MAIN_USERLIST:
     697            WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
     698            break;
     699          case MAIN_DRIVELIST:
     700            WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
     701            break;
     702          case MAIN_BUTTONLIST:
     703            WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
     704            break;
     705          default:
     706            break;
     707          }
     708          break;
     709
     710        default:
     711          break;
     712        }
    715713      }
    716714      break;
     
    725723    // 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);
    726724    if (id == CBID_EDIT &&
    727         WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
    728         MAIN_USERLIST) {
     725        WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
     726        MAIN_USERLIST) {
    729727
    730728      CHAR path[CCHMAXPATH];
     
    735733      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
    736734      if (*path && !IsRoot(path))
    737         DragOne(hwnd, (HWND) 0, path, FALSE);
     735        DragOne(hwnd, (HWND) 0, path, FALSE);
    738736      return 0;
    739737    }
     
    744742    if (id == MAIN_USERLIST) {
    745743      if (!emphasized) {
    746         emphasized = TRUE;
    747         DrawTargetEmphasis(hwnd, emphasized);
     744        emphasized = TRUE;
     745        DrawTargetEmphasis(hwnd, emphasized);
    748746      }
    749747      if (AcceptOneDrop(hwnd, mp1, mp2))
    750         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     748        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    751749      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    752750    }
     
    757755    if (id == MAIN_USERLIST) {
    758756      if (emphasized) {
    759         emphasized = FALSE;
    760         DrawTargetEmphasis(hwnd, emphasized);
     757        emphasized = FALSE;
     758        DrawTargetEmphasis(hwnd, emphasized);
    761759      }
    762760    }
     
    778776
    779777      if (emphasized) {
    780         emphasized = FALSE;
    781         DrawTargetEmphasis(hwnd, emphasized);
     778        emphasized = FALSE;
     779        DrawTargetEmphasis(hwnd, emphasized);
    782780      }
    783781      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    784         MakeValidDir(szFrom);
    785         WinSetWindowText(hwnd, szFrom);
    786         PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    787                                                               QW_PARENT),
    788                                                QW_PARENT),
    789                                 FID_CLIENT),
    790                 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
    791         return 0;
     782        MakeValidDir(szFrom);
     783        WinSetWindowText(hwnd, szFrom);
     784        PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     785                                                              QW_PARENT),
     786                                               QW_PARENT),
     787                                FID_CLIENT),
     788                UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
     789        return 0;
    792790      }
    793791    }
     
    810808       (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
    811809    if ((!hwndBubble ||
    812         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    813         !WinQueryCapture(HWND_DESKTOP))
     810        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     811        !WinQueryCapture(HWND_DESKTOP))
    814812      MakeBubble(hwnd, above, help);
    815813  }
     
    832830      /* don't bring up help if window isn't active */
    833831      if (!WinIsChild(hwnd, hwndActive))
    834         return;
     832        return;
    835833    }
    836834    hwndActive = WinQueryFocus(HWND_DESKTOP);
     
    838836      /* don't bring up help if a menu is active */
    839837      if (!strcmp(ucClassname, "#4"))
    840         return;
     838        return;
    841839    }
    842840  }
    843841
    844842  hwndBubble = WinCreateWindow(HWND_DESKTOP,
    845                                WC_BUBBLE,
    846                                help,
    847                                WS_CLIPSIBLINGS | SS_TEXT |
    848                                DT_CENTER | DT_VCENTER,
    849                                0,
    850                                0,
    851                                0,
    852                                0,
    853                                HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
     843                               WC_BUBBLE,
     844                               help,
     845                               WS_CLIPSIBLINGS | SS_TEXT |
     846                               DT_CENTER | DT_VCENTER,
     847                               0,
     848                               0,
     849                               0,
     850                               0,
     851                               HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
    854852  if (!hwndBubble)
    855853    Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    856                IDS_WINCREATEWINDOW);
     854               IDS_WINCREATEWINDOW);
    857855  else {
    858856    HPS hps;
     
    874872      pp = strchr(p, '\r');
    875873      if (pp) {
    876         wp = pp;
    877         *pp = 0;
    878         pp++;
     874        wp = pp;
     875        *pp = 0;
     876        pp++;
    879877      }
    880878      GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    881879      tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
    882880      if (tptl.y)
    883         tptl.y += extra;
     881        tptl.y += extra;
    884882      else
    885         extra = aptl[TXTBOX_TOPLEFT].y / 4;
     883        extra = aptl[TXTBOX_TOPLEFT].y / 4;
    886884      tptl.y += aptl[TXTBOX_TOPLEFT].y;
    887885      if (wp)
    888         *wp = '\r';
     886        *wp = '\r';
    889887      p = pp;
    890888    }
     
    896894      sy = ptl.y + swp.cy + 4;
    897895      if (sy + tptl.y + 12 > lyScreen) {
    898         above = FALSE;
    899         sy = ptl.y - (tptl.y + 14);
     896        above = FALSE;
     897        sy = ptl.y - (tptl.y + 14);
    900898      }
    901899    }
     
    913911      sy = ptl.y + swp.cy + 4;
    914912      if (sy + tptl.y + 12 > lyScreen)
    915         sy = 0;
     913        sy = 0;
    916914    }
    917915    WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
    918                     tptl.x + 14,
    919                     tptl.y + 12,
    920                     SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
    921                     SWP_MOVE | SWP_SIZE);
     916                    tptl.x + 14,
     917                    tptl.y + 12,
     918                    SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
     919                    SWP_MOVE | SWP_SIZE);
    922920  }
    923921}
     
    945943      WinQueryPointerPos(HWND_DESKTOP, &ptl);
    946944      if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
    947           WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
    948         WinDestroyWindow(hwnd);
     945          WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
     946        WinDestroyWindow(hwnd);
    949947    }
    950948    return 0;
     
    960958      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    961959      if (hps) {
    962         WinQueryWindowPos(hwnd, &swp);
    963         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
    964         GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
    965         GpiSetBackMix(hps, BM_LEAVEALONE);
    966         GpiSetMix(hps, FM_OVERPAINT);
    967         ptl.x = ptl.y = 0;
    968         GpiMove(hps, &ptl);
    969         ptl.x = swp.cx - 1;
    970         ptl.y = swp.cy - 1;
    971         GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
    972         tlen = WinQueryWindowTextLength(hwnd);
    973         if (tlen) {
    974           s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
    975           if (s) {
    976             WinQueryWindowText(hwnd, tlen + 1, s);
    977             if (*s) {
    978               p = s;
    979               y = swp.cy - 3;
    980               extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
    981               GpiSetColor(hps, 0);
    982               GpiSetMix(hps, FM_OVERPAINT);
    983               while (p && *p) {
    984                 wp = NULL;
    985                 pp = strchr(p, '\r');
    986                 if (pp) {
    987                   wp = pp;
    988                   *pp = 0;
    989                   pp++;
    990                 }
    991                 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    992                 ptl.x = 7;
    993                 y -= aptl[TXTBOX_TOPLEFT].y;
    994                 if (p != s)
    995                   y -= extra;
    996                 ptl.y = y;
    997                 GpiCharStringAt(hps, &ptl, strlen(p), p);
    998                 if (wp)
    999                   *wp = '\r';
    1000                 p = pp;
    1001               }
    1002             }
    1003             free(s);
    1004           }
    1005         }
    1006         if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
    1007           GpiSetColor(hps, CLR_WHITE);
    1008           ptl.x = 1;
    1009           ptl.y = 1;
    1010           GpiMove(hps, &ptl);
    1011           ptl.y = swp.cy - 2;
    1012           GpiLine(hps, &ptl);
    1013           ptl.x = swp.cx - 2;
    1014           GpiLine(hps, &ptl);
    1015           ptl.x = 2;
    1016           ptl.y = 2;
    1017           GpiMove(hps, &ptl);
    1018           ptl.y = swp.cy - 3;
    1019           GpiLine(hps, &ptl);
    1020           ptl.x = swp.cx - 3;
    1021           GpiLine(hps, &ptl);
    1022           GpiSetColor(hps, CLR_BROWN);
    1023           ptl.x = 1;
    1024           ptl.y = 1;
    1025           GpiMove(hps, &ptl);
    1026           ptl.x = swp.cx - 2;
    1027           GpiLine(hps, &ptl);
    1028           ptl.y = swp.cy - 2;
    1029           GpiLine(hps, &ptl);
    1030           ptl.x = 2;
    1031           ptl.y = 2;
    1032           GpiMove(hps, &ptl);
    1033           ptl.x = swp.cx - 3;
    1034           GpiLine(hps, &ptl);
    1035           ptl.y = swp.cy - 3;
    1036           GpiLine(hps, &ptl);
    1037         }
    1038         WinEndPaint(hps);
     960        WinQueryWindowPos(hwnd, &swp);
     961        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
     962        GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
     963        GpiSetBackMix(hps, BM_LEAVEALONE);
     964        GpiSetMix(hps, FM_OVERPAINT);
     965        ptl.x = ptl.y = 0;
     966        GpiMove(hps, &ptl);
     967        ptl.x = swp.cx - 1;
     968        ptl.y = swp.cy - 1;
     969        GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     970        tlen = WinQueryWindowTextLength(hwnd);
     971        if (tlen) {
     972          s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
     973          if (s) {
     974            WinQueryWindowText(hwnd, tlen + 1, s);
     975            if (*s) {
     976              p = s;
     977              y = swp.cy - 3;
     978              extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
     979              GpiSetColor(hps, 0);
     980              GpiSetMix(hps, FM_OVERPAINT);
     981              while (p && *p) {
     982                wp = NULL;
     983                pp = strchr(p, '\r');
     984                if (pp) {
     985                  wp = pp;
     986                  *pp = 0;
     987                  pp++;
     988                }
     989                GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
     990                ptl.x = 7;
     991                y -= aptl[TXTBOX_TOPLEFT].y;
     992                if (p != s)
     993                  y -= extra;
     994                ptl.y = y;
     995                GpiCharStringAt(hps, &ptl, strlen(p), p);
     996                if (wp)
     997                  *wp = '\r';
     998                p = pp;
     999              }
     1000            }
     1001            free(s);
     1002          }
     1003        }
     1004        if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
     1005          GpiSetColor(hps, CLR_WHITE);
     1006          ptl.x = 1;
     1007          ptl.y = 1;
     1008          GpiMove(hps, &ptl);
     1009          ptl.y = swp.cy - 2;
     1010          GpiLine(hps, &ptl);
     1011          ptl.x = swp.cx - 2;
     1012          GpiLine(hps, &ptl);
     1013          ptl.x = 2;
     1014          ptl.y = 2;
     1015          GpiMove(hps, &ptl);
     1016          ptl.y = swp.cy - 3;
     1017          GpiLine(hps, &ptl);
     1018          ptl.x = swp.cx - 3;
     1019          GpiLine(hps, &ptl);
     1020          GpiSetColor(hps, CLR_BROWN);
     1021          ptl.x = 1;
     1022          ptl.y = 1;
     1023          GpiMove(hps, &ptl);
     1024          ptl.x = swp.cx - 2;
     1025          GpiLine(hps, &ptl);
     1026          ptl.y = swp.cy - 2;
     1027          GpiLine(hps, &ptl);
     1028          ptl.x = 2;
     1029          ptl.y = 2;
     1030          GpiMove(hps, &ptl);
     1031          ptl.x = swp.cx - 3;
     1032          GpiLine(hps, &ptl);
     1033          ptl.y = swp.cy - 3;
     1034          GpiLine(hps, &ptl);
     1035        }
     1036        WinEndPaint(hps);
    10391037      }
    10401038    }
     
    10631061      switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
    10641062      case MAIN_LED:
    1065         hps = WinGetPS(hwnd);
    1066         hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
    1067         if (!fBlueLED) {
    1068           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
    1069           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
    1070         }
    1071         else {
    1072           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
    1073           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
    1074         }
    1075         if (hbmLEDoff && hbmLEDon)
    1076           WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
    1077         else {
    1078           if (hbmLEDoff)
    1079             GpiDeleteBitmap(hbmLEDoff);
    1080           if (hbmLEDon)
    1081             GpiDeleteBitmap(hbmLEDon);
    1082         }
    1083         if (hbmold &&
    1084             hbmLEDon &&
    1085             hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
    1086           GpiDeleteBitmap(hbmold);
    1087         if (hps)
    1088           WinReleasePS(hps);
    1089         break;
     1063        hps = WinGetPS(hwnd);
     1064        hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
     1065        if (!fBlueLED) {
     1066          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
     1067          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
     1068        }
     1069        else {
     1070          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
     1071          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
     1072        }
     1073        if (hbmLEDoff && hbmLEDon)
     1074          WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
     1075        else {
     1076          if (hbmLEDoff)
     1077            GpiDeleteBitmap(hbmLEDoff);
     1078          if (hbmLEDon)
     1079            GpiDeleteBitmap(hbmLEDon);
     1080        }
     1081        if (hbmold &&
     1082            hbmLEDon &&
     1083            hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
     1084          GpiDeleteBitmap(hbmold);
     1085        if (hps)
     1086          WinReleasePS(hps);
     1087        break;
    10901088      default:
    1091         SetPresParams(hwnd,
    1092                       &RGBGREY,
    1093                       &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    1094         break;
     1089        SetPresParams(hwnd,
     1090                      &RGBGREY,
     1091                      &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     1092        break;
    10951093      }
    10961094      return mr;
     
    11161114  case WM_BUTTON1CLICK:
    11171115    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1118             WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
     1116            WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
    11191117    break;
    11201118
    11211119  case WM_BUTTON2CLICK:
    11221120    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1123             WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
     1121            WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
    11241122    break;
    11251123
     
    11271125  case WM_BUTTON3CLICK:
    11281126    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1129             WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     1127            WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    11301128    break;
    11311129  }
     
    11501148    if (fToolbarHelp) {
    11511149      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    1152           && !WinQueryCapture(HWND_DESKTOP)) {
    1153         id = WinQueryWindowUShort(hwnd, QWS_ID);
    1154         tool = find_tool(id);
    1155         if (tool && tool->help && *tool->help) {
    1156 
    1157           char s[128];
    1158 
    1159           strcpy(s, tool->help);
    1160           if (tool->flags & T_DROPABLE)
    1161             strcat(s, GetPString(IDS_DROPONMETEXT));
    1162           MakeBubble(hwnd, FALSE, s);
    1163         }
     1150          && !WinQueryCapture(HWND_DESKTOP)) {
     1151        id = WinQueryWindowUShort(hwnd, QWS_ID);
     1152        tool = find_tool(id);
     1153        if (tool && tool->help && *tool->help) {
     1154
     1155          char s[128];
     1156
     1157          strcpy(s, tool->help);
     1158          if (tool->flags & T_DROPABLE)
     1159            strcat(s, GetPString(IDS_DROPONMETEXT));
     1160          MakeBubble(hwnd, FALSE, s);
     1161        }
    11641162      }
    11651163    }
     
    11701168    case IDM_HELP:
    11711169      if (hwndHelp)
    1172         WinSendMsg(hwndHelp,
    1173                    HM_DISPLAY_HELP,
    1174                    MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
     1170        WinSendMsg(hwndHelp,
     1171                   HM_DISPLAY_HELP,
     1172                   MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
    11751173      break;
    11761174
     
    11781176    case IDM_HIDETOOL:                  /* hide tool */
    11791177      if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
    1180         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1178        id = WinQueryWindowUShort(hwnd, QWS_ID);
    11811179      else
    1182         id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
    1183                                 PickToolProc, FM3ModHandle,
    1184                                 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
     1180        id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
     1181                                PickToolProc, FM3ModHandle,
     1182                                PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
    11851183      if (id) {
    1186         tool = find_tool(id);
    1187         if (tool) {
    1188           tool->flags |= T_INVISIBLE;
    1189           fToolsChanged = TRUE;
    1190         }
     1184        tool = find_tool(id);
     1185        if (tool) {
     1186          tool->flags |= T_INVISIBLE;
     1187          fToolsChanged = TRUE;
     1188        }
    11911189      }
    11921190      break;
     
    11951193      tool = toolhead;
    11961194      while (tool) {
    1197         tool->flags &= (~T_INVISIBLE);
    1198         tool = tool->next;
    1199         fToolsChanged = TRUE;
     1195        tool->flags &= (~T_INVISIBLE);
     1196        tool = tool->next;
     1197        fToolsChanged = TRUE;
    12001198      }
    12011199      break;
     
    12041202    case IDM_DELETETOOL:                /* delete button */
    12051203      if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
    1206         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1204        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12071205      else
    1208         id =
    1209           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1210                              PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
     1206        id =
     1207          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1208                             PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
    12111209      if (id)
    1212         PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
    1213                 MPFROM2SHORT(id, 0), MPVOID);
     1210        PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
     1211                MPFROM2SHORT(id, 0), MPVOID);
    12141212      return 0;
    12151213
     
    12171215    case IDM_EDITTOOL:                  /* edit button */
    12181216      if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
    1219         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1217        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12201218      else
    1221         id =
    1222           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1223                              PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
     1219        id =
     1220          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1221                             PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
    12241222      if (id) {
    1225         tool = find_tool(id);
    1226         if (tool) {
    1227           if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1228                         ADDBTN_FRAME, (PVOID) tool))
    1229             WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1230                                                                      QW_PARENT),
    1231                                                       QW_PARENT), FID_CLIENT),
    1232                        WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1233                        MPFROM2SHORT(id, 0));
    1234         }
     1223        tool = find_tool(id);
     1224        if (tool) {
     1225          if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
     1226                        ADDBTN_FRAME, (PVOID) tool))
     1227            WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1228                                                                     QW_PARENT),
     1229                                                      QW_PARENT), FID_CLIENT),
     1230                       WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1231                       MPFROM2SHORT(id, 0));
     1232        }
    12351233      }
    12361234      break;
     
    12381236    case IDM_ADDTOOL:                   /* add tool */
    12391237      id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1240                               ADDBTN_FRAME, MPVOID);
     1238                              ADDBTN_FRAME, MPVOID);
    12411239      if (id && id != (USHORT) - 1)
    1242         WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1243                                                                 QW_PARENT),
    1244                                                   QW_PARENT), FID_CLIENT),
    1245                    WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1246                    MPFROM2SHORT(id, 0));
     1240        WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1241                                                                QW_PARENT),
     1242                                                  QW_PARENT), FID_CLIENT),
     1243                   WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1244                   MPFROM2SHORT(id, 0));
    12471245      break;
    12481246
    12491247    case IDM_REORDERTOOLS:              /* reorder tools */
    12501248      WinDlgBox(HWND_DESKTOP,
    1251                 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
     1249                hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
    12521250      break;
    12531251
     
    12551253    case IDM_LOADTOOLS:
    12561254      if (WinDlgBox(HWND_DESKTOP,
    1257                     hwnd,
    1258                     ToolIODlgProc,
    1259                     FM3ModHandle,
    1260                     SVBTN_FRAME,
    1261                     (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    1262                     "TRUE" : NULL))
    1263         BuildTools(hwndToolback, TRUE);
     1255                    hwnd,
     1256                    ToolIODlgProc,
     1257                    FM3ModHandle,
     1258                    SVBTN_FRAME,
     1259                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
     1260                    "TRUE" : NULL))
     1261        BuildTools(hwndToolback, TRUE);
    12641262      break;
    12651263    }
     
    12931291      tool = find_tool(id);
    12941292      if (!tool) {
    1295         DrgFreeDraginfo(pDInfo);
    1296         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1293        DrgFreeDraginfo(pDInfo);
     1294        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    12971295      }
    12981296      if (!(tool->flags & T_DROPABLE)) {
    1299         DrgFreeDraginfo(pDInfo);
    1300         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1297        DrgFreeDraginfo(pDInfo);
     1298        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13011299      }
    13021300      {
    1303         PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
    1304 
    1305         pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
    1306                                      0);        /* Index to DRAGITEM */
    1307         if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
    1308                         DRM_OS2FILE,   /* mechanisms and data */
    1309                         NULL)) {       /* formats */
    1310           if (!(tool->flags & T_EMPHASIZED)) {
    1311             tool->flags |= T_EMPHASIZED;
    1312             DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1313             DrgFreeDraginfo(pDInfo);
    1314           }
    1315           return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
    1316                                DO_MOVE));       /* Move operation valid */
    1317         }
    1318         DrgFreeDraginfo(pDInfo);
     1301        PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
     1302
     1303        pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
     1304                                     0);        /* Index to DRAGITEM */
     1305        if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
     1306                        DRM_OS2FILE,   /* mechanisms and data */
     1307                        NULL)) {       /* formats */
     1308          if (!(tool->flags & T_EMPHASIZED)) {
     1309            tool->flags |= T_EMPHASIZED;
     1310            DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1311            DrgFreeDraginfo(pDInfo);
     1312          }
     1313          return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
     1314                               DO_MOVE));       /* Move operation valid */
     1315        }
     1316        DrgFreeDraginfo(pDInfo);
    13191317      }
    13201318    }
     
    13331331    if (tool && (tool->flags & T_DROPABLE)) {
    13341332      if (tool->flags & T_EMPHASIZED) {
    1335         tool->flags &= (~T_EMPHASIZED);
    1336         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1333        tool->flags &= (~T_EMPHASIZED);
     1334        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    13371335      }
    13381336    }
     
    13471345
    13481346      if (tool->flags & T_EMPHASIZED) {
    1349         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1350         tool->flags &= (~T_EMPHASIZED);
     1347        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1348        tool->flags &= (~T_EMPHASIZED);
    13511349      }
    13521350      memset(&cdi, 0, sizeof(cdi));
     
    13551353      CheckPmDrgLimit(cdi.pDragInfo);
    13561354      if (li) {
    1357         li->type = id;
    1358         if (!li->list || !li->list[0])
    1359           FreeListInfo(li);
    1360         else {
    1361           HWND hwndActive;
    1362 
    1363           hwndActive = TopWindow(hwndMain, (HWND) 0);
    1364           if (hwndActive) {
    1365             if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
    1366               FreeListInfo(li);
    1367           }
    1368           else
    1369             FreeListInfo(li);
    1370         }
     1355        li->type = id;
     1356        if (!li->list || !li->list[0])
     1357          FreeListInfo(li);
     1358        else {
     1359          HWND hwndActive;
     1360
     1361          hwndActive = TopWindow(hwndMain, (HWND) 0);
     1362          if (hwndActive) {
     1363            if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
     1364              FreeListInfo(li);
     1365          }
     1366          else
     1367            FreeListInfo(li);
     1368        }
    13711369      }
    13721370    }
     
    14051403    if (!fTextTools) {
    14061404      if (!(tool->flags & T_MYICON)) {
    1407         hwndTool = WinCreateWindow(hwndT,
    1408                                    WC_TOOLBUTTONS,
    1409                                    s,
    1410                                    BS_NOPOINTERFOCUS |
    1411                                    BS_BITMAP | BS_PUSHBUTTON,
    1412                                    ctrlxpos,
    1413                                    14,
    1414                                    32,
    1415                                    32, hwndT, HWND_TOP, tool->id, NULL, NULL);
     1405        hwndTool = WinCreateWindow(hwndT,
     1406                                   WC_TOOLBUTTONS,
     1407                                   s,
     1408                                   BS_NOPOINTERFOCUS |
     1409                                   BS_BITMAP | BS_PUSHBUTTON,
     1410                                   ctrlxpos,
     1411                                   14,
     1412                                   32,
     1413                                   32, hwndT, HWND_TOP, tool->id, NULL, NULL);
    14161414      }
    14171415      if (!hwndTool) {
    1418         HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
    1419 
    1420         if (hbm) {
    1421           BTNCDATA btc;
    1422 
    1423           memset(&btc, 0, sizeof(btc));
    1424           btc.cb = sizeof(btc);
    1425           btc.hImage = hbm;
    1426           hwndTool = WinCreateWindow(hwndT,
    1427                                      WC_TOOLBUTTONS,
    1428                                      NullStr,
    1429                                      BS_NOPOINTERFOCUS |
    1430                                      BS_BITMAP | BS_PUSHBUTTON,
    1431                                      ctrlxpos,
    1432                                      14,
    1433                                      32,
    1434                                      32,
    1435                                      hwndT, HWND_TOP, tool->id, &btc, NULL);
    1436           if (!hwndTool)
    1437             GpiDeleteBitmap(hbm);
    1438         }
     1416        HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
     1417
     1418        if (hbm) {
     1419          BTNCDATA btc;
     1420
     1421          memset(&btc, 0, sizeof(btc));
     1422          btc.cb = sizeof(btc);
     1423          btc.hImage = hbm;
     1424          hwndTool = WinCreateWindow(hwndT,
     1425                                     WC_TOOLBUTTONS,
     1426                                     NullStr,
     1427                                     BS_NOPOINTERFOCUS |
     1428                                     BS_BITMAP | BS_PUSHBUTTON,
     1429                                     ctrlxpos,
     1430                                     14,
     1431                                     32,
     1432                                     32,
     1433                                     hwndT, HWND_TOP, tool->id, &btc, NULL);
     1434          if (!hwndTool)
     1435            GpiDeleteBitmap(hbm);
     1436        }
    14391437      }
    14401438      if (hwndTool)
    1441         tool->flags &= (~T_TEXT);
     1439        tool->flags &= (~T_TEXT);
    14421440    }
    14431441    if (!hwndTool) {
    14441442      hwndTool = WinCreateWindow(hwndT,
    1445                                 WC_TOOLBUTTONS,
    1446                                 (!tool->text && tool->id >= IDM_COMMANDSTART
    1447                                   && tool->id <
    1448                                   IDM_QUICKTOOLSTART) ? command_title(tool->
    1449                                                                       id -
    1450                                                                       IDM_COMMANDSTART)
    1451                                 : tool->text,
    1452                                 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
    1453                                 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
    1454                                 NULL);
     1443                                WC_TOOLBUTTONS,
     1444                                (!tool->text && tool->id >= IDM_COMMANDSTART
     1445                                  && tool->id <
     1446                                  IDM_QUICKTOOLSTART) ? command_title(tool->
     1447                                                                      id -
     1448                                                                      IDM_COMMANDSTART)
     1449                                : tool->text,
     1450                                BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
     1451                                2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
     1452                                NULL);
    14551453      if (!hwndTool)
    1456         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1457                    IDS_WINCREATEWINDOW);
     1454        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1455                   IDS_WINCREATEWINDOW);
    14581456      tool->flags |= T_TEXT;
    14591457    }
    14601458    if (fToolTitles && !fTextTools) {
    14611459      hwndTool = WinCreateWindow(hwndT,
    1462                                 WC_STATIC,
    1463                                 tool->text,
    1464                                 SS_TEXT | DT_LEFT | DT_VCENTER,
    1465                                 ctrlxpos,
    1466                                 1,
    1467                                 32,
    1468                                 10,
    1469                                 hwndT,
    1470                                 HWND_TOP, tool->id + 25000, NULL, NULL);
     1460                                WC_STATIC,
     1461                                tool->text,
     1462                                SS_TEXT | DT_LEFT | DT_VCENTER,
     1463                                ctrlxpos,
     1464                                1,
     1465                                32,
     1466                                10,
     1467                                hwndT,
     1468                                HWND_TOP, tool->id + 25000, NULL, NULL);
    14711469      if (!hwndTool)
    1472         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1473                    IDS_WINCREATEWINDOW);
     1470        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1471                   IDS_WINCREATEWINDOW);
    14741472      else {
    1475         SetPresParams(hwndTool,
    1476                       &RGBGREY,
    1477                       &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
     1473        SetPresParams(hwndTool,
     1474                      &RGBGREY,
     1475                      &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
    14781476      }
    14791477    }
    14801478    ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
    14811479    SetPresParams(WinWindowFromID(hwndT, tool->id),
    1482                   NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
     1480                  NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
    14831481    tool = tool->next;
    14841482  }                                     // while tool
    14851483
    14861484  hwndTool = WinCreateWindow(hwndT,
    1487                              WC_BUTTON,
    1488                              "#6010",
    1489                              BS_NOPOINTERFOCUS |
    1490                              BS_BITMAP | BS_PUSHBUTTON,
    1491                              1,
    1492                              19,
    1493                              14,
    1494                              13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
     1485                             WC_BUTTON,
     1486                             "#6010",
     1487                             BS_NOPOINTERFOCUS |
     1488                             BS_BITMAP | BS_PUSHBUTTON,
     1489                             1,
     1490                             19,
     1491                             14,
     1492                             13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
    14951493  if (!hwndTool)
    14961494    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1497                IDS_WINCREATEWINDOW);
     1495               IDS_WINCREATEWINDOW);
    14981496  hwndTool =
    14991497    WinCreateWindow(hwndT, WC_BUTTON, "#6011",
    1500                     BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
    1501                     13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
     1498                    BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
     1499                    13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
    15021500  if (!hwndTool)
    15031501    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1504                IDS_WINCREATEWINDOW);
     1502               IDS_WINCREATEWINDOW);
    15051503  if (resize)
    15061504    ResizeTools(hwndT);
     
    15081506
    15091507static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
    1510                                         MPARAM mp2)
     1508                                        MPARAM mp2)
    15111509{
    15121510  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    15251523
    15261524      if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
    1527         break;
     1525        break;
    15281526      if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
    1529         WinDestroyWindow(hwnd);
     1527        WinDestroyWindow(hwnd);
    15301528    }
    15311529    break;
     
    15381536      lbup = TRUE;
    15391537      if (WinDlgBox(HWND_DESKTOP,
    1540                     hwnd,
    1541                     CmdLine2DlgProc,
    1542                     FM3ModHandle, EXEC2_FRAME, MPFROMP(cl))) {
    1543         lstrip(cl);
    1544         WinSetWindowText(hwnd, cl);
     1538                    hwnd,
     1539                    CmdLine2DlgProc,
     1540                    FM3ModHandle, EXEC2_FRAME, MPFROMP(cl))) {
     1541        lstrip(cl);
     1542        WinSetWindowText(hwnd, cl);
    15451543      }
    15461544      PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     
    15611559    case COMMAND_BUTTON:
    15621560      if (!lbup)
    1563         PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1561        PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    15641562      break;
    15651563    }
     
    15801578      bstrip(cl + len);
    15811579      if (strlen(cl) > len) {
    1582         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    1583                    UM_SETUP, MPFROMP(cl + len), MPVOID);
    1584         WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
    1585         bstrip(directory);
    1586         if (*directory && (IsRoot(directory) || !IsFile(directory))) {
    1587           if (!FM2Command(directory, cl + len)) {
    1588             hwndCnr = TopWindow(hwndMain, (HWND) 0);
    1589             if (hwndCnr) {
    1590               hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
    1591               if (hwndCnr) {
    1592                 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
    1593                 if (hwndCnr)
    1594                   list = BuildList(hwndCnr);
    1595               }
    1596             }
    1597             WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
    1598             if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
    1599               save_cmdlines(FALSE);
    1600             ExecOnList(hwndCnr,
    1601                        cl,
    1602                        WINDOWED | ((fKeepCmdLine) ?
    1603                                    SEPARATEKEEP : SEPARATE),
    1604                        directory, list, NULL, pszSrcFile, __LINE__);
    1605             if (list)
    1606               free(list);
    1607             WinDestroyWindow(hwnd);
    1608             break;
    1609           }
    1610         }
     1580        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
     1581                   UM_SETUP, MPFROMP(cl + len), MPVOID);
     1582        WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
     1583        bstrip(directory);
     1584        if (*directory && (IsRoot(directory) || !IsFile(directory))) {
     1585          if (!FM2Command(directory, cl + len)) {
     1586            hwndCnr = TopWindow(hwndMain, (HWND) 0);
     1587            if (hwndCnr) {
     1588              hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
     1589              if (hwndCnr) {
     1590                hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
     1591                if (hwndCnr)
     1592                  list = BuildList(hwndCnr);
     1593              }
     1594            }
     1595            WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
     1596            if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
     1597              save_cmdlines(FALSE);
     1598            ExecOnList(hwndCnr,
     1599                       cl,
     1600                       WINDOWED | ((fKeepCmdLine) ?
     1601                                   SEPARATEKEEP : SEPARATE),
     1602                       directory, list, NULL, pszSrcFile, __LINE__);
     1603            if (list)
     1604              free(list);
     1605            WinDestroyWindow(hwnd);
     1606            break;
     1607          }
     1608        }
    16111609      }
    16121610      WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     
    16171615    if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
    16181616      if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
    1619         if ((SHORT1FROMMP(mp2) & 255) == '\r')
    1620           PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
    1621         else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
    1622           WinDestroyWindow(hwnd);
    1623         else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
    1624           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1617        if ((SHORT1FROMMP(mp2) & 255) == '\r')
     1618          PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
     1619        else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
     1620          WinDestroyWindow(hwnd);
     1621        else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
     1622          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    16251623      }
    16261624    }
    16271625    else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
    1628              ((SHORT2FROMMP(mp2) == VK_UP ||
    1629                SHORT2FROMMP(mp2) == VK_DOWN) ||
    1630               (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
     1626             ((SHORT2FROMMP(mp2) == VK_UP ||
     1627               SHORT2FROMMP(mp2) == VK_DOWN) ||
     1628              (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
    16311629      return 0;
    16321630    break;
     
    16541652      rgb.bRed = (BYTE)128;
    16551653      SetPresParams(hwnd,
    1656                     &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
     1654                    &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
    16571655      SetTargetDir(hwnd, TRUE);
    16581656    }
     
    16841682  case WM_CONTROLPOINTER:
    16851683    if (!fNoFinger &&
    1686         (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
    1687         SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
     1684        (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
     1685        SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
    16881686      return MRFROMLONG(hptrFinger);
    16891687    break;
     
    16951693      *dv = 0;
    16961694      WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
    1697                         2, dv);
     1695                        2, dv);
    16981696      if (isalpha(*dv)) {
    16991697
    1700         HWND hwndActive;
    1701 
    1702         dv[1] = ':';
    1703         dv[2] = '\\';
    1704         dv[3] = 0;
    1705         hwndActive = TopWindow(hwnd, (HWND) 0);
    1706         if (hwndActive)
    1707           WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    1708                      UM_DRIVECMD, MPFROMP(dv), MPVOID);
     1698        HWND hwndActive;
     1699
     1700        dv[1] = ':';
     1701        dv[2] = '\\';
     1702        dv[3] = 0;
     1703        hwndActive = TopWindow(hwnd, (HWND) 0);
     1704        if (hwndActive)
     1705          WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     1706                     UM_DRIVECMD, MPFROMP(dv), MPVOID);
    17091707      }
    17101708    }
     
    17341732  case WM_MOUSEMOVE:
    17351733    if (fDrivebarHelp &&
    1736         (!hwndBubble ||
    1737         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1738         !WinQueryCapture(HWND_DESKTOP)) {
     1734        (!hwndBubble ||
     1735        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1736        !WinQueryCapture(HWND_DESKTOP)) {
    17391737      id = WinQueryWindowUShort(hwnd, QWS_ID);
    17401738      if (helpid != id) {
    1741         helpid = id;
    1742         PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
     1739        helpid = id;
     1740        PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
    17431741      }
    17441742      else
    1745         helpid = 0;
     1743        helpid = 0;
    17461744    }
    17471745    break;
     
    17501748    if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
    17511749      if ((char *)mp1 &&
    1752           (!hwndBubble ||
    1753            WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1754           !WinQueryCapture(HWND_DESKTOP)) {
    1755 
    1756         RECTL rcl;
    1757         POINTL ptl;
    1758 
    1759         WinQueryPointerPos(HWND_DESKTOP, &ptl);
    1760         WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
    1761         WinQueryWindowRect(hwnd, &rcl);
    1762         if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
    1763           BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
     1750          (!hwndBubble ||
     1751           WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1752          !WinQueryCapture(HWND_DESKTOP)) {
     1753
     1754        RECTL rcl;
     1755        POINTL ptl;
     1756
     1757        WinQueryPointerPos(HWND_DESKTOP, &ptl);
     1758        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
     1759        WinQueryWindowRect(hwnd, &rcl);
     1760        if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
     1761          BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
    17641762      }
    17651763    }
     
    17801778    *szDrv = 0;
    17811779    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1782                                        id + 50), sizeof(szDrv), szDrv);
     1780                                       id + 50), sizeof(szDrv), szDrv);
    17831781    if (isalpha(*szDrv)) {
    17841782      hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
    17851783      if (hwndMenu) {
    1786         BOOL rdy;
    1787         CHAR chDrv = *szDrv;
    1788         UINT iDrv;
    1789 
    1790         strcpy(szDrv + 2, "\\");
    1791         MakeValidDir(szDrv);
    1792         // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
    1793         rdy = toupper(*szDrv) == toupper(chDrv);
    1794         iDrv = toupper(*szDrv) - 'A';
    1795         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    1796           WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
    1797 
    1798         if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
    1799           WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
    1800           WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
    1801           WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
    1802           WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
    1803         }
    1804         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
    1805           WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
    1806           WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
    1807           WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
    1808         }
    1809         if (!rdy) {
    1810           WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
    1811           WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
    1812           WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
    1813           WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
    1814           WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
    1815         }
    1816         /* fixme to be gone?
    1817            if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
    1818            WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
    1819            }
    1820         */
    1821         PopupMenu(hwnd, hwnd, hwndMenu);
     1784        BOOL rdy;
     1785        CHAR chDrv = *szDrv;
     1786        UINT iDrv;
     1787
     1788        strcpy(szDrv + 2, "\\");
     1789        MakeValidDir(szDrv);
     1790        // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
     1791        rdy = toupper(*szDrv) == toupper(chDrv);
     1792        iDrv = toupper(*szDrv) - 'A';
     1793        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
     1794          WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
     1795
     1796        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
     1797          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     1798          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     1799          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     1800          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     1801        }
     1802        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
     1803          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     1804          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     1805          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     1806        }
     1807        if (!rdy) {
     1808          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     1809          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     1810          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     1811          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     1812          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     1813        }
     1814        /* fixme to be gone?
     1815           if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     1816           WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     1817           }
     1818        */
     1819        PopupMenu(hwnd, hwnd, hwndMenu);
    18221820      }
    18231821    }
     
    18341832    *szDrv = 0;
    18351833    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1836                                        id + 50), sizeof(szDrv), szDrv);
     1834                                       id + 50), sizeof(szDrv), szDrv);
    18371835    if (isalpha(*szDrv)) {
    18381836      strcat(szDrv, "\\");
    18391837      if (!FindDirCnrByName(szDrv, TRUE))
    1840         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
     1838        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
    18411839    }
    18421840    break;
     
    18501848    *szDrv = 0;
    18511849    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1852                                        id + 50), sizeof(szDrv), szDrv);
     1850                                       id + 50), sizeof(szDrv), szDrv);
    18531851    if (isalpha(*szDrv)) {
    18541852      strcat(szDrv, "\\");
     
    18611859    *szDrv = 0;
    18621860    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1863                                        id + 50), sizeof(szDrv), szDrv);
     1861                                       id + 50), sizeof(szDrv), szDrv);
    18641862    if (isalpha(*szDrv) &&
    1865         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1863        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18661864      if (!emphasized) {
    1867         emphasized = TRUE;
    1868         DrawTargetEmphasis(hwnd, emphasized);
     1865        emphasized = TRUE;
     1866        DrawTargetEmphasis(hwnd, emphasized);
    18691867      }
    18701868      if (AcceptOneDrop(hwnd, mp1, mp2))
    1871         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     1869        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    18721870      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    18731871    }
     
    18781876    *szDrv = 0;
    18791877    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1880                                        id + 50), sizeof(szDrv), szDrv);
     1878                                       id + 50), sizeof(szDrv), szDrv);
    18811879    if (isalpha(*szDrv) &&
    1882         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1880        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18831881      if (emphasized) {
    1884         emphasized = FALSE;
    1885         DrawTargetEmphasis(hwnd, emphasized);
     1882        emphasized = FALSE;
     1883        DrawTargetEmphasis(hwnd, emphasized);
    18861884      }
    18871885    }
     
    18921890    *szDrv = 0;
    18931891    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1894                                        id + 50), sizeof(szDrv), szDrv);
     1892                                       id + 50), sizeof(szDrv), szDrv);
    18951893    if (isalpha(*szDrv) &&
    1896         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1894        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18971895      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
    18981896      return 0;
     
    19041902    *szDrv = 0;
    19051903    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1906                                        id + 50), sizeof(szDrv), szDrv);
     1904                                       id + 50), sizeof(szDrv), szDrv);
    19071905    if (isalpha(*szDrv) &&
    1908         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1906        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19091907
    19101908      CNRDRAGINFO cnd;
     
    19131911
    19141912      if (emphasized) {
    1915         emphasized = FALSE;
    1916         DrawTargetEmphasis(hwnd, emphasized);
     1913        emphasized = FALSE;
     1914        DrawTargetEmphasis(hwnd, emphasized);
    19171915      }
    19181916      memset(&cnd, 0, sizeof(cnd));
     
    19201918      cnd.pRecord = NULL;
    19211919      li = DoFileDrop(hwnd,
    1922                       NULL,
    1923                       TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
     1920                      NULL,
     1921                      TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
    19241922      CheckPmDrgLimit(cnd.pDragInfo);
    19251923      if (li) {
    1926         strcpy(li->targetpath, szDrv);
    1927         strcat(li->targetpath, "\\");
    1928         if (li->list && li->list[0] && IsRoot(li->list[0]))
    1929           li->type = DO_LINK;
    1930         else if (fDragndropDlg && (!*li->arcname || !li->info)) {
    1931 
    1932           CHECKLIST cl;
    1933 
    1934           memset(&cl, 0, sizeof(cl));
    1935           cl.size = sizeof(cl);
    1936           cl.flags = li->type;
    1937           cl.list = li->list;
    1938           cl.cmd = li->type;
    1939           cl.prompt = li->targetpath;
    1940           li->type = WinDlgBox(HWND_DESKTOP,
    1941                                hwndMain,
    1942                                DropListProc,
    1943                                FM3ModHandle, DND_FRAME, MPFROMP(&cl));
    1944           if (li->type == DID_ERROR)
    1945                   Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
    1946                             "Drag & Drop Dialog");
    1947           if (!li->type) {
    1948             FreeListInfo(li);
    1949             return 0;
    1950           }
    1951           li->list = cl.list;
    1952           if (!li->list || !li->list[0]) {
    1953             FreeListInfo(li);
    1954             return 0;
    1955           }
    1956         }
    1957         else {
    1958           if (!WinDlgBox(HWND_DESKTOP,
    1959                         hwndMain,
    1960                         WalkDlgProc,
    1961                         FM3ModHandle,
    1962                         WALK_FRAME,
    1963                         MPFROMP(li->targetpath)) || !*li->targetpath) {
    1964             FreeListInfo(li);
    1965             return 0;
    1966           }
    1967         }
    1968         switch (li->type) {
    1969         case DND_LAUNCH:
    1970           strcat(li->targetpath, " %a");
    1971           ExecOnList(hwndMain,
    1972                      li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
    1973                      pszSrcFile, __LINE__);
    1974           FreeList(li->list);
    1975           li->list = NULL;
    1976           break;
    1977         case DO_LINK:
    1978           if (fLinkSetsIcon) {
    1979             li->type = IDM_SETICON;
    1980             action = UM_MASSACTION;
    1981           }
    1982           else
    1983             li->type = IDM_COMPARE;
    1984           break;
    1985         case DND_EXTRACT:
    1986           if (*li->targetpath && !IsFile(li->targetpath))
    1987             li->type = IDM_EXTRACT;
    1988           break;
    1989         case DND_MOVE:
    1990           li->type = IDM_MOVE;
    1991           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    1992             action = UM_MASSACTION;
    1993             li->type = IDM_ARCHIVEM;
    1994           }
    1995           break;
    1996         case DND_WILDMOVE:
    1997           li->type = IDM_WILDMOVE;
    1998           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    1999             action = UM_MASSACTION;
    2000             li->type = IDM_ARCHIVEM;
    2001           }
    2002           break;
    2003         case DND_OBJECT:
    2004           li->type = IDM_OBJECT;
    2005           action = UM_MASSACTION;
    2006           break;
    2007         case DND_SHADOW:
    2008           li->type = IDM_SHADOW;
    2009           action = UM_MASSACTION;
    2010           break;
    2011         case DND_COMPARE:
    2012           li->type = IDM_COMPARE;
    2013           break;
    2014         case DND_SETICON:
    2015           action = UM_MASSACTION;
    2016           li->type = IDM_SETICON;
    2017           break;
    2018         case DND_COPY:
    2019           li->type = IDM_COPY;
    2020           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2021             action = UM_MASSACTION;
    2022             li->type = IDM_ARCHIVE;
    2023           }
    2024           break;
    2025         case DND_WILDCOPY:
    2026           li->type = IDM_WILDCOPY;
    2027           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2028             action = UM_MASSACTION;
    2029             li->type = IDM_ARCHIVE;
    2030           }
    2031           break;
    2032         default:
    2033           if (*li->arcname && li->info) {
    2034             action = UM_MASSACTION;
    2035             li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
    2036               IDM_FAKEEXTRACT;
    2037           }
    2038           else if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2039             action = UM_MASSACTION;
    2040             li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
    2041           }
    2042           else
    2043             li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    2044           break;
    2045         }
    2046         if (!li->list || !li->list[0])
    2047           FreeListInfo(li);
    2048         else
    2049           WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
     1924        strcpy(li->targetpath, szDrv);
     1925        strcat(li->targetpath, "\\");
     1926        if (li->list && li->list[0] && IsRoot(li->list[0]))
     1927          li->type = DO_LINK;
     1928        else if (fDragndropDlg && (!*li->arcname || !li->info)) {
     1929
     1930          CHECKLIST cl;
     1931
     1932          memset(&cl, 0, sizeof(cl));
     1933          cl.size = sizeof(cl);
     1934          cl.flags = li->type;
     1935          cl.list = li->list;
     1936          cl.cmd = li->type;
     1937          cl.prompt = li->targetpath;
     1938          li->type = WinDlgBox(HWND_DESKTOP,
     1939                               hwndMain,
     1940                               DropListProc,
     1941                               FM3ModHandle, DND_FRAME, MPFROMP(&cl));
     1942          if (li->type == DID_ERROR)
     1943                  Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
     1944                            "Drag & Drop Dialog");
     1945          if (!li->type) {
     1946            FreeListInfo(li);
     1947            return 0;
     1948          }
     1949          li->list = cl.list;
     1950          if (!li->list || !li->list[0]) {
     1951            FreeListInfo(li);
     1952            return 0;
     1953          }
     1954        }
     1955        else {
     1956          if (!WinDlgBox(HWND_DESKTOP,
     1957                        hwndMain,
     1958                        WalkDlgProc,
     1959                        FM3ModHandle,
     1960                        WALK_FRAME,
     1961                        MPFROMP(li->targetpath)) || !*li->targetpath) {
     1962            FreeListInfo(li);
     1963            return 0;
     1964          }
     1965        }
     1966        switch (li->type) {
     1967        case DND_LAUNCH:
     1968          strcat(li->targetpath, " %a");
     1969          ExecOnList(hwndMain,
     1970                     li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
     1971                     pszSrcFile, __LINE__);
     1972          FreeList(li->list);
     1973          li->list = NULL;
     1974          break;
     1975        case DO_LINK:
     1976          if (fLinkSetsIcon) {
     1977            li->type = IDM_SETICON;
     1978            action = UM_MASSACTION;
     1979          }
     1980          else
     1981            li->type = IDM_COMPARE;
     1982          break;
     1983        case DND_EXTRACT:
     1984          if (*li->targetpath && !IsFile(li->targetpath))
     1985            li->type = IDM_EXTRACT;
     1986          break;
     1987        case DND_MOVE:
     1988          li->type = IDM_MOVE;
     1989          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     1990            action = UM_MASSACTION;
     1991            li->type = IDM_ARCHIVEM;
     1992          }
     1993          break;
     1994        case DND_WILDMOVE:
     1995          li->type = IDM_WILDMOVE;
     1996          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     1997            action = UM_MASSACTION;
     1998            li->type = IDM_ARCHIVEM;
     1999          }
     2000          break;
     2001        case DND_OBJECT:
     2002          li->type = IDM_OBJECT;
     2003          action = UM_MASSACTION;
     2004          break;
     2005        case DND_SHADOW:
     2006          li->type = IDM_SHADOW;
     2007          action = UM_MASSACTION;
     2008          break;
     2009        case DND_COMPARE:
     2010          li->type = IDM_COMPARE;
     2011          break;
     2012        case DND_SETICON:
     2013          action = UM_MASSACTION;
     2014          li->type = IDM_SETICON;
     2015          break;
     2016        case DND_COPY:
     2017          li->type = IDM_COPY;
     2018          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2019            action = UM_MASSACTION;
     2020            li->type = IDM_ARCHIVE;
     2021          }
     2022          break;
     2023        case DND_WILDCOPY:
     2024          li->type = IDM_WILDCOPY;
     2025          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2026            action = UM_MASSACTION;
     2027            li->type = IDM_ARCHIVE;
     2028          }
     2029          break;
     2030        default:
     2031          if (*li->arcname && li->info) {
     2032            action = UM_MASSACTION;
     2033            li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
     2034              IDM_FAKEEXTRACT;
     2035          }
     2036          else if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2037            action = UM_MASSACTION;
     2038            li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
     2039          }
     2040          else
     2041            li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
     2042          break;
     2043        }
     2044        if (!li->list || !li->list[0])
     2045          FreeListInfo(li);
     2046        else
     2047          WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
    20502048      }
    20512049      return 0;
     
    20812079    for (x = 0; x < 26; x++) {
    20822080      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    2083         if (x > 1) {
    2084           if (driveflags[x] & DRIVE_CDROM)
    2085             iconid = CDROM_ICON;
    2086           else
    2087             iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
    2088               REMOVABLE_ICON :
    2089                      (driveflags[x] & DRIVE_VIRTUAL) ?
    2090                       VIRTUAL_ICON :
    2091               (driveflags[x] & DRIVE_REMOTE) ?
    2092               REMOTE_ICON :
    2093                      (driveflags[x] & DRIVE_RAMDISK) ?
    2094                       RAMDISK_ICON :
    2095                      (driveflags[x] & DRIVE_ZIPSTREAM) ?
    2096                       ZIPSTREAM_ICON :DRIVE_ICON;
    2097         }
    2098         else
    2099           iconid = FLOPPY_ICON;
    2100         sprintf(s, "#%lu", iconid);
    2101         hwndB = WinCreateWindow(hwndT,
    2102                                 WC_DRIVEBUTTONS,
    2103                                 s,
    2104                                 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
    2105                                 0,
    2106                                 0,
    2107                                 28,
    2108                                 18,
    2109                                 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
    2110         if (!hwndB)
    2111           Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2112                      IDS_WINCREATEWINDOW);
    2113         else {
    2114           WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2115           sprintf(s, "%c:", (CHAR) x + 'A');
    2116           hwndB = WinCreateWindow(hwndT,
    2117                                   WC_STATIC,
    2118                                   s,
    2119                                   SS_TEXT | DT_LEFT | DT_VCENTER,
    2120                                   0,
    2121                                   0,
    2122                                   10,
    2123                                   18,
    2124                                   hwndT,
    2125                                   HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
    2126           if (!hwndB)
    2127             Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2128                        IDS_WINCREATEWINDOW);
    2129           else {
    2130             SetPresParams(hwndB,
    2131                           &RGBGREY,
    2132                           &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    2133             WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2134           }
    2135           y++;
    2136         }
     2081        if (x > 1) {
     2082          if (driveflags[x] & DRIVE_CDROM)
     2083            iconid = CDROM_ICON;
     2084          else
     2085            iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
     2086              REMOVABLE_ICON :
     2087                     (driveflags[x] & DRIVE_VIRTUAL) ?
     2088                      VIRTUAL_ICON :
     2089              (driveflags[x] & DRIVE_REMOTE) ?
     2090              REMOTE_ICON :
     2091                     (driveflags[x] & DRIVE_RAMDISK) ?
     2092                      RAMDISK_ICON :
     2093                     (driveflags[x] & DRIVE_ZIPSTREAM) ?
     2094                      ZIPSTREAM_ICON :DRIVE_ICON;
     2095        }
     2096        else
     2097          iconid = FLOPPY_ICON;
     2098        sprintf(s, "#%lu", iconid);
     2099        hwndB = WinCreateWindow(hwndT,
     2100                                WC_DRIVEBUTTONS,
     2101                                s,
     2102                                BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
     2103                                0,
     2104                                0,
     2105                                28,
     2106                                18,
     2107                                hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
     2108        if (!hwndB)
     2109          Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2110                     IDS_WINCREATEWINDOW);
     2111        else {
     2112          WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2113          sprintf(s, "%c:", (CHAR) x + 'A');
     2114          hwndB = WinCreateWindow(hwndT,
     2115                                  WC_STATIC,
     2116                                  s,
     2117                                  SS_TEXT | DT_LEFT | DT_VCENTER,
     2118                                  0,
     2119                                  0,
     2120                                  10,
     2121                                  18,
     2122                                  hwndT,
     2123                                  HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
     2124          if (!hwndB)
     2125            Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2126                       IDS_WINCREATEWINDOW);
     2127          else {
     2128            SetPresParams(hwndB,
     2129                          &RGBGREY,
     2130                          &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     2131            WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2132          }
     2133          y++;
     2134        }
    21372135      }
    21382136    }                                   // for
    21392137  }                                     // if drivebar
    21402138  PostMsg(WinQueryWindow(hwndT, QW_PARENT),
    2141           WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2139          WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    21422140}
    21432141
     
    21552153    WinQueryWindowRect(hwndT, &rcl);
    21562154    xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
    2157                                              SV_CYSIZEBORDER) * 2) + 2);
     2155                                             SV_CYSIZEBORDER) * 2) + 2);
    21582156  }
    21592157  henum = WinBeginEnumWindows(hwndT);
     
    21642162      ctrlxsize = 28;
    21652163    WinSetWindowPos(hwndB,
    2166                     HWND_TOP,
    2167                     ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
     2164                    HWND_TOP,
     2165                    ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
    21682166    ctrlxpos += (ctrlxsize + 2);
    21692167    if (ctrlxsize == 10) {
    21702168      if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
    2171                             256 : 0)) > xwidth) {
    2172         ctrlxpos = 2;
    2173         ctrlypos += 18;
    2174         DriveLines++;
     2169                            256 : 0)) > xwidth) {
     2170        ctrlxpos = 2;
     2171        ctrlypos += 18;
     2172        DriveLines++;
    21752173      }
    21762174    }
     
    21912189
    21922190      SetPresParams(hwnd,
    2193                     &RGBGREY,
    2194                     &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
     2191                    &RGBGREY,
     2192                    &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
    21952193      return mr;
    21962194    }
     
    22022200
    22032201      cbRetLen = WinQueryPresParam(hwnd,
    2204                                    (ULONG) mp1,
    2205                                    0,
    2206                                    &AttrFound,
    2207                                    (ULONG) sizeof(AttrValue), &AttrValue, 0);
     2202                                   (ULONG) mp1,
     2203                                   0,
     2204                                   &AttrFound,
     2205                                   (ULONG) sizeof(AttrValue), &AttrValue, 0);
    22082206      if (cbRetLen) {
    2209         //switch (AttrFound) {
    2210         //case PP_FONTNAMESIZE:
    2211           PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2212                   WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    2213 // JBS2   break;
    2214 
     2207        PostMsg(WinQueryWindow(hwnd, QW_PARENT),
     2208                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22152209      }
    22162210    }
     
    22292223      WinQueryWindowPos(hwndTree, &swp);
    22302224      if (!(swp.fl & SWP_MAXIMIZE))
    2231         fl |= SWP_RESTORE;
     2225        fl |= SWP_RESTORE;
    22322226      WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
    22332227    }
     
    22622256
    22632257      if (fOtherHelp) {
    2264         if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    2265             && !WinQueryCapture(HWND_DESKTOP)) {
    2266           switch (id) {
    2267           case IDM_ATTRS:
    2268             if (WinQueryWindowTextLength(hwnd))
    2269               s = GetPString(IDS_ATTRSBUTTONHELP);
    2270             break;
    2271           case IDM_INFO:
    2272             if (WinQueryWindowTextLength(hwnd))
    2273               s = GetPString(IDS_INFOBUTTONHELP);
    2274             break;
    2275           case IDM_RENAME:
    2276             if (WinQueryWindowTextLength(hwnd))
    2277               s = GetPString(IDS_NAMEBUTTONHELP);
    2278             break;
    2279           case MAIN_STATUS2:
    2280             if (!hwndE)
    2281               s = GetPString(IDS_STATUS2HELP);
    2282             break;
    2283           default:
    2284             break;
    2285           }
    2286           if (s)
    2287             MakeBubble(hwnd, FALSE, s);
    2288           else if (hwndBubble)
    2289             WinDestroyWindow(hwndBubble);
    2290         }
     2258        if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
     2259            && !WinQueryCapture(HWND_DESKTOP)) {
     2260          switch (id) {
     2261          case IDM_ATTRS:
     2262            if (WinQueryWindowTextLength(hwnd))
     2263              s = GetPString(IDS_ATTRSBUTTONHELP);
     2264            break;
     2265          case IDM_INFO:
     2266            if (WinQueryWindowTextLength(hwnd))
     2267              s = GetPString(IDS_INFOBUTTONHELP);
     2268            break;
     2269          case IDM_RENAME:
     2270            if (WinQueryWindowTextLength(hwnd))
     2271              s = GetPString(IDS_NAMEBUTTONHELP);
     2272            break;
     2273          case MAIN_STATUS2:
     2274            if (!hwndE)
     2275              s = GetPString(IDS_STATUS2HELP);
     2276            break;
     2277          default:
     2278            break;
     2279          }
     2280          if (s)
     2281            MakeBubble(hwnd, FALSE, s);
     2282          else if (hwndBubble)
     2283            WinDestroyWindow(hwndBubble);
     2284        }
    22912285      }
    22922286      switch (id) {
     
    22952289      case IDM_RENAME:
    22962290      case MAIN_STATUS2:
    2297         return CommonTextProc(hwnd, msg, mp1, mp2);
     2291        return CommonTextProc(hwnd, msg, mp1, mp2);
    22982292      default:
    2299         break;
     2293        break;
    23002294      }
    23012295    }
     
    23202314      case IDM_RENAME:
    23212315      case MAIN_STATUS2:
    2322         return CommonTextButton(hwnd, msg, mp1, mp2);
     2316        return CommonTextButton(hwnd, msg, mp1, mp2);
    23232317      default:
    2324         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    2325         break;
     2318        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     2319        break;
    23262320      }
    23272321    }
     
    23352329      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23362330      if (id == MAIN_STATUS2 && hwndE)
    2337         WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2331        WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    23382332      else
    2339         return CommonTextButton(hwnd, msg, mp1, mp2);
     2333        return CommonTextButton(hwnd, msg, mp1, mp2);
    23402334    }
    23412335    break;
     
    23472341      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23482342      if (id == MAIN_STATUS) {
    2349         if (SHORT2FROMMP(mp2) & KC_CTRL)
    2350           PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2351                                   FID_CLIENT),
    2352                   WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    2353         else if (hwndTree)
    2354           PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
     2343        if (SHORT2FROMMP(mp2) & KC_CTRL)
     2344          PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2345                                  FID_CLIENT),
     2346                  WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     2347        else if (hwndTree)
     2348          PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
    23552349      }
    23562350    }
     
    23652359      if (id == MAIN_STATUS2 && !hwndE) {
    23662360
    2367         SWP swp;
    2368         CHAR directory[CCHMAXPATH];
    2369         PFNWP oldproce;
    2370 
    2371         *directory = 0;
    2372         TopWindowName(hwndMain, (HWND) 0, directory);
    2373         WinQueryWindowPos(hwnd, &swp);
    2374         hwndB = WinCreateWindow(hwnd,
    2375                                 WC_BUTTON,
    2376                                 "+",
    2377                                 WS_VISIBLE | BS_PUSHBUTTON |
    2378                                 BS_NOPOINTERFOCUS,
    2379                                 swp.cx - swp.cy,
    2380                                 0,
    2381                                 swp.cy,
    2382                                 swp.cy,
    2383                                 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
    2384         if (!hwndB)
    2385           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2386         hwndE = WinCreateWindow(hwnd,
    2387                                 WC_ENTRYFIELD,
    2388                                 NULL,
    2389                                 WS_VISIBLE | ES_AUTOSCROLL,
    2390                                 0,
    2391                                 0,
    2392                                 swp.cx - swp.cy,
    2393                                 swp.cy,
    2394                                 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
    2395         if (!hwndE)
    2396           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2397         if (!hwndE || !hwndB) {
    2398           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2399           return 0;
    2400         }
    2401         WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
    2402         WinSetWindowText(hwndStatus, directory);
    2403         if (*lastcmd)
    2404           WinSetWindowText(hwndE, lastcmd);
    2405         else
    2406           WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
    2407         oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
    2408         if (oldproce)
    2409           WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
    2410         PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
    2411         PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
    2412         return 0;
     2361        SWP swp;
     2362        CHAR directory[CCHMAXPATH];
     2363        PFNWP oldproce;
     2364
     2365        *directory = 0;
     2366        TopWindowName(hwndMain, (HWND) 0, directory);
     2367        WinQueryWindowPos(hwnd, &swp);
     2368        hwndB = WinCreateWindow(hwnd,
     2369                                WC_BUTTON,
     2370                                "+",
     2371                                WS_VISIBLE | BS_PUSHBUTTON |
     2372                                BS_NOPOINTERFOCUS,
     2373                                swp.cx - swp.cy,
     2374                                0,
     2375                                swp.cy,
     2376                                swp.cy,
     2377                                hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
     2378        if (!hwndB)
     2379          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2380        hwndE = WinCreateWindow(hwnd,
     2381                                WC_ENTRYFIELD,
     2382                                NULL,
     2383                                WS_VISIBLE | ES_AUTOSCROLL,
     2384                                0,
     2385                                0,
     2386                                swp.cx - swp.cy,
     2387                                swp.cy,
     2388                                hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
     2389        if (!hwndE)
     2390          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2391        if (!hwndE || !hwndB) {
     2392          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2393          return 0;
     2394        }
     2395        WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
     2396        WinSetWindowText(hwndStatus, directory);
     2397        if (*lastcmd)
     2398          WinSetWindowText(hwndE, lastcmd);
     2399        else
     2400          WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
     2401        oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
     2402        if (oldproce)
     2403          WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
     2404        PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
     2405        PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     2406        return 0;
    24132407      }
    24142408      if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
    2415         switch (id) {
    2416         case IDM_ATTRS:
    2417           id = IDM_SORTSIZE;
    2418           break;
    2419         case IDM_INFO:
    2420           id = IDM_SORTLWDATE;
    2421           break;
    2422         case IDM_RENAME:
    2423           id = IDM_SORTFILENAME;
    2424           break;
    2425         }
     2409        switch (id) {
     2410        case IDM_ATTRS:
     2411          id = IDM_SORTSIZE;
     2412          break;
     2413        case IDM_INFO:
     2414          id = IDM_SORTLWDATE;
     2415          break;
     2416        case IDM_RENAME:
     2417          id = IDM_SORTFILENAME;
     2418          break;
     2419        }
    24262420      }
    24272421      PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2428               WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
     2422              WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
    24292423    }
    24302424    return 0;
     
    24402434      case IDM_RENAME:
    24412435      case MAIN_STATUS2:
    2442         PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
    2443         break;
     2436        PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
     2437        break;
    24442438      default:
    2445         PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
    2446         break;
     2439        PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
     2440        break;
    24472441      }
    24482442      if (id == IDM_RENAME) {
    24492443
    2450         HPS hps;
    2451 
    2452         hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    2453         if (hps) {
    2454           PaintSTextWindow(hwnd, hps);
    2455           WinEndPaint(hps);
    2456         }
    2457         return 0;
     2444        HPS hps;
     2445
     2446        hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
     2447        if (hps) {
     2448          PaintSTextWindow(hwnd, hps);
     2449          WinEndPaint(hps);
     2450        }
     2451        return 0;
    24582452      }
    24592453    }
     
    24882482  case UM_COMMAND:
    24892483    return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2490                                       FID_CLIENT), msg, mp1, mp2);
     2484                                      FID_CLIENT), msg, mp1, mp2);
    24912485
    24922486  case WM_PAINT:
     
    25012495      hps = WinBeginPaint(hwnd, (HPS)0, NULL);
    25022496      if (hps) {
    2503         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
    2504         WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
    2505                           sizeof(lColor), &lColor, 0);
    2506         WinQueryWindowRect(hwnd, &rcl);
    2507         WinFillRect(hps, &rcl, lColor);
    2508         WinEndPaint(hps);
     2497        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
     2498        WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
     2499                          sizeof(lColor), &lColor, 0);
     2500        WinQueryWindowRect(hwnd, &rcl);
     2501        WinFillRect(hps, &rcl, lColor);
     2502        WinEndPaint(hps);
    25092503      }
    25102504
     
    25242518      tool = find_tool(id);
    25252519      if (tool) {
    2526         del_tool(tool);
    2527         WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
    2528         if (fToolTitles)
    2529           WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
    2530         ResizeTools(hwnd);
     2520        del_tool(tool);
     2521        WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
     2522        if (fToolTitles)
     2523          WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
     2524        ResizeTools(hwnd);
    25312525      }
    25322526    }
     
    25382532
    25392533      id = (USHORT) WinDlgBox(HWND_DESKTOP,
    2540                               hwnd,
    2541                               AddToolProc,
    2542                               FM3ModHandle, ADDBTN_FRAME, MPVOID);
     2534                              hwnd,
     2535                              AddToolProc,
     2536                              FM3ModHandle, ADDBTN_FRAME, MPVOID);
    25432537      if (id && id != (USHORT) - 1)
    2544         WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2545                                    FID_CLIENT),
    2546                    WM_COMMAND,
    2547                    MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
     2538        WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2539                                   FID_CLIENT),
     2540                   WM_COMMAND,
     2541                   MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
    25482542    }
    25492543    break;
     
    25512545  case WM_CONTEXTMENU:
    25522546    if (WinDlgBox(HWND_DESKTOP,
    2553                   hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
     2547                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    25542548      BuildTools(hwnd, TRUE);
    25552549    return MRFROMSHORT(TRUE);
     
    25742568  if (pswp) {
    25752569    if (WinQueryWindowPos(hwndTree, &swp) &&
    2576         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
     2570        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
    25772571      pswp->x = swp.cx;
    25782572      pswp->cx -= swp.cx;
     
    25812575  if (prectl) {
    25822576    if (WinQueryWindowPos(hwndTree, &swp) &&
    2583         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
    2584         WinQueryWindowRect(hwndTree, &rectl)) {
     2577        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
     2578        WinQueryWindowRect(hwndTree, &rectl)) {
    25852579      prectl->xLeft = rectl.xRight;
    25862580      prectl->xRight -= rectl.xRight;
     
    26342628    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    26352629      if (swp.x < swpT.cx) {
    2636         swp.x = swpT.cx;
    2637         if (swp.x + swp.cx > swpC.cx)
    2638           swp.cx = swpC.cx - swp.x;
    2639         if (swp.cx > 24)
    2640           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    2641                           SWP_SIZE | SWP_MOVE | SWP_SHOW);
     2630        swp.x = swpT.cx;
     2631        if (swp.x + swp.cx > swpC.cx)
     2632          swp.cx = swpC.cx - swp.x;
     2633        if (swp.cx > 24)
     2634          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     2635                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
    26422636      }
    26432637    }
     
    26592653      WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    26602654      WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    2661                       SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
     2655                      SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
    26622656    }
    26632657  }
     
    26812675    if (hwndNext) {
    26822676      if (!WinQueryWindowUShort(hwndNext, QWS_ID))
    2683         continue;
     2677        continue;
    26842678      if (next)
    2685         break;
     2679        break;
    26862680      if (hwndNext == hwndActive) {
    2687         if (!previous && hwndPrev) {
    2688           hwndNext = hwndPrev;
    2689           break;
    2690         }
    2691         else if (previous)
    2692           next = TRUE;
     2681        if (!previous && hwndPrev) {
     2682          hwndNext = hwndPrev;
     2683          break;
     2684        }
     2685        else if (previous)
     2686          next = TRUE;
    26932687      }
    26942688      hwndPrev = hwndNext;
     
    26962690    else {
    26972691      if ((!next && previous) || once)
    2698         break;
     2692        break;
    26992693      else if (!previous) {
    2700         hwndNext = hwndPrev;
    2701         break;
     2694        hwndNext = hwndPrev;
     2695        break;
    27022696      }
    27032697      else
    2704         once = next = TRUE;
     2698        once = next = TRUE;
    27052699    }
    27062700  }
     
    27092703  if (hwndNext && hwndNext != hwndActive) {
    27102704    WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
    2711                     SWP_ZORDER | SWP_ACTIVATE);
     2705                    SWP_ZORDER | SWP_ACTIVATE);
    27122706    WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
    2713                     0, 0, SWP_ZORDER);
     2707                    0, 0, SWP_ZORDER);
    27142708  }
    27152709}
     
    27262720    if (hwndChild != hwndTree) {
    27272721      WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2728                 WM_SAVEAPPLICATION, MPVOID, MPVOID);
     2722                WM_SAVEAPPLICATION, MPVOID, MPVOID);
    27292723      if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2730                      WM_CLOSE, MPVOID, MPVOID)) {
    2731         ret = TRUE;
    2732         break;
     2724                     WM_CLOSE, MPVOID, MPVOID)) {
     2725        ret = TRUE;
     2726        break;
    27332727      }
    27342728    }
     
    27532747      hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
    27542748      if (hwndTemp) {
    2755         hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
    2756         if (hwndDir) {
    2757           WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2758                      WM_CLOSE, MPVOID, MPVOID);
    2759           ret = TRUE;
    2760         }
     2749        hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
     2750        if (hwndDir) {
     2751          WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
     2752                     WM_CLOSE, MPVOID, MPVOID);
     2753          ret = TRUE;
     2754        }
    27612755      }
    27622756    }
     
    27752769
    27762770#define STATE_NAME_MAX_BYTES    256
     2771#define FM2_STATE_AT_CLOSE "LastClose"
    27772772
    27782773INT SaveDirCnrState(HWND hwndClient, PSZ pszStateName)
     
    27872782  INT nSaved = 0;
    27882783  DIRCNRDATA *dcd;
    2789 
    2790   if (!pszStateName)
    2791     strcpy(szPrefix, NullStr);
    2792   else {
    2793     if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
    2794       Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState");
     2784  BOOL fIsShutDownState;
     2785
     2786  if (!pszStateName || !*pszStateName) {
     2787    Runtime_Error(pszSrcFile, __LINE__, "no data");
    27952788      return -1;
    2796     }
    2797     sprintf(szPrefix, "%s.", pszStateName);
    27982789  }
     2790  if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
     2791    Runtime_Error(pszSrcFile, __LINE__, "SaveDirCnrState");
     2792    return -1;
     2793  }
     2794
     2795  fIsShutDownState = strcmp(pszStateName, FM2_STATE_AT_CLOSE) == 0;
     2796  sprintf(szPrefix, "%s.", pszStateName);
    27992797
    28002798  henum = WinBeginEnumWindows(hwndClient);
     
    28032801      hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
    28042802      if (hwndC) {
    2805         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    2806         if (hwndDir) {
    2807           WinQueryWindowPos(hwndChild, &swp);
    2808           *szDir = 0;
    2809           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
    2810           if (*szDir) {
    2811            if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN)
    2812              continue;
    2813             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2814             PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    2815                                 sizeof(SWP));
    2816             dcd =
    2817               WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2818             if (dcd) {
    2819               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2820               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2821                                   sizeof(INT));
    2822               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2823               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2824                                   sizeof(MASK));
    2825               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    2826               flWindowAttr = dcd->flWindowAttr;
    2827               if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
    2828                 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    2829                 if (dcd->lastattr) {
    2830                   if (dcd->lastattr & CV_TEXT)
    2831                     flWindowAttr |= CV_TEXT;
    2832                   else if (dcd->lastattr & CV_DETAIL)
    2833                     flWindowAttr |= CV_DETAIL;
    2834                   else if (dcd->lastattr & CV_ICON)
    2835                     flWindowAttr |= CV_ICON;
    2836                   else
    2837                     flWindowAttr |= CV_NAME;
    2838                 }
    2839                 else
    2840                   flWindowAttr |= CV_NAME;
    2841               }
    2842               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    2843                                   sizeof(ULONG));
    2844               sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
    2845               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslongname,
    2846                                   sizeof(BOOL));
    2847               sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
    2848               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssubject,
    2849                                   sizeof(BOOL));
    2850               sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
    2851               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssize,
    2852                                   sizeof(BOOL));
    2853               sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
    2854               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsea,
    2855                                   sizeof(BOOL));
    2856               sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
    2857               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsattr,
    2858                                   sizeof(BOOL));
    2859               sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
    2860               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsicon,
    2861                                   sizeof(BOOL));
    2862               sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
    2863               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwdate,
    2864                                   sizeof(BOOL));
    2865               sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
    2866               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwtime,
    2867                                   sizeof(BOOL));
    2868               sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
    2869               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsladate,
    2870                                   sizeof(BOOL));
    2871               sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
    2872               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslatime,
    2873                                   sizeof(BOOL));
    2874               sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
    2875               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrdate,
    2876                                   sizeof(BOOL));
    2877               sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
    2878               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrtime,
    2879                                   sizeof(BOOL));
    2880               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2881               SavePresParams(hwndDir, szKey);
    2882             }
    2883             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    2884             PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    2885             nSaved++;
    2886           }
    2887         }
     2803        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     2804        if (hwndDir) {
     2805          WinQueryWindowPos(hwndChild, &swp);
     2806          *szDir = 0;
     2807          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
     2808          if (*szDir) {
     2809           // If saving shutdown state skip no prescan drives
     2810           if (fIsShutDownState &&
     2811               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     2812             continue;
     2813           }
     2814            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2815            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
     2816                                sizeof(SWP));
     2817            dcd =
     2818              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
     2819            if (dcd) {
     2820              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2821              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
     2822                                  sizeof(INT));
     2823              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2824              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
     2825                                  sizeof(MASK));
     2826              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2827              flWindowAttr = dcd->flWindowAttr;
     2828              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     2829                flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     2830                if (dcd->lastattr) {
     2831                  if (dcd->lastattr & CV_TEXT)
     2832                    flWindowAttr |= CV_TEXT;
     2833                  else if (dcd->lastattr & CV_DETAIL)
     2834                    flWindowAttr |= CV_DETAIL;
     2835                  else if (dcd->lastattr & CV_ICON)
     2836                    flWindowAttr |= CV_ICON;
     2837                  else
     2838                    flWindowAttr |= CV_NAME;
     2839                }
     2840                else
     2841                  flWindowAttr |= CV_NAME;
     2842              }
     2843              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2844                                  sizeof(ULONG));
     2845              sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
     2846              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslongname,
     2847                                  sizeof(BOOL));
     2848              sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
     2849              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssubject,
     2850                                  sizeof(BOOL));
     2851              sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
     2852              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailssize,
     2853                                  sizeof(BOOL));
     2854              sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
     2855              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsea,
     2856                                  sizeof(BOOL));
     2857              sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
     2858              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsattr,
     2859                                  sizeof(BOOL));
     2860              sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
     2861              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsicon,
     2862                                  sizeof(BOOL));
     2863              sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
     2864              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwdate,
     2865                                  sizeof(BOOL));
     2866              sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
     2867              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslwtime,
     2868                                  sizeof(BOOL));
     2869              sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
     2870              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailsladate,
     2871                                  sizeof(BOOL));
     2872              sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
     2873              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailslatime,
     2874                                  sizeof(BOOL));
     2875              sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
     2876              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrdate,
     2877                                  sizeof(BOOL));
     2878              sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
     2879              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->detailscrtime,
     2880                                  sizeof(BOOL));
     2881              sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
     2882              SavePresParams(hwndDir, szKey);
     2883            }
     2884            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     2885            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     2886            nSaved++;
     2887          }
     2888        }
    28882889      }
    28892890    }
     
    29272928    if (hwnd) {
    29282929      if (WinQueryWindowPos(hwnd, &swp)) {
    2929         if (pswp->x > swp.cx)
    2930           pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
    2931         if (pswp->y > swp.cy)
    2932           pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
    2933         if (pswp->x + pswp->cx > swp.cx)
    2934           pswp->cx = swp.cx - pswp->x;
    2935         if (pswp->y + pswp->cy > swp.cy)
    2936           pswp->cy = swp.cy - pswp->y;
     2930        if (pswp->x > swp.cx)
     2931          pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
     2932        if (pswp->y > swp.cy)
     2933          pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
     2934        if (pswp->x + pswp->cx > swp.cx)
     2935          pswp->cx = swp.cx - pswp->x;
     2936        if (pswp->y + pswp->cy > swp.cy)
     2937          pswp->cy = swp.cy - pswp->y;
    29372938      }
    29382939    }
     
    29432944 * @param hwndClient Client window handle
    29442945 * @param pszStateName State name to restore, NULL to restore global state
     2946 * @param noview request view state restore bypass
    29452947 * @returns TRUE if one or more directory containers were opened
    29462948 * @seealso SaveDirCnrState
     
    29542956  HWND hwndDir, hwndC;
    29552957  SWP swp, swpO, swpN;
    2956   ULONG size, numsaves = 0L, x;
     2958  ULONG size, numsaves = 0, x;
    29572959  double xtrans, ytrans;
    29582960  BOOL fRestored = FALSE;
    29592961  DIRCNRDATA localdcd, *dcd;
    2960 
    2961   if (!pszStateName)
    2962     strcpy(szPrefix, NullStr);
    2963   else {
    2964     if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
    2965       Runtime_Error(pszSrcFile, __LINE__, "RestoreDirCnrState");
    2966       return fRestored;
    2967     }
    2968     sprintf(szPrefix, "%s.", pszStateName);
     2962  BOOL fIsShutDownState;
     2963
     2964  if (!pszStateName || !*pszStateName) {
     2965    Runtime_Error(pszSrcFile, __LINE__, "no name");
     2966    return fRestored;
    29692967  }
     2968  if (strlen(pszStateName) > sizeof(szPrefix) - 2) {
     2969    Runtime_Error(pszSrcFile, __LINE__, "name too long");
     2970    return fRestored;
     2971  }
     2972
     2973  sprintf(szPrefix, "%s.", pszStateName);
     2974  fIsShutDownState = strcmp(pszStateName, FM2_STATE_AT_CLOSE) == 0;
     2975
    29702976
    29712977  size = sizeof(SWP);
    29722978  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    29732979  if (!PrfQueryProfileData(fmprof,
    2974                            FM3Str,
    2975                            szKey,
    2976                            (PVOID) & swpO,
    2977                            &size) ||
     2980                           FM3Str,
     2981                           szKey,
     2982                           (PVOID) & swpO,
     2983                           &size) ||
    29782984      size != sizeof(SWP) || !swp.cx || !swp.cy)
    29792985  {
    29802986    WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpO);
    29812987  }
    2982   if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
     2988  // If restoring saved shutdown state, forget info
     2989  if (fIsShutDownState)
    29832990    PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    29842991  WinQueryWindowPos(WinQueryWindow(hwndClient, QW_PARENT), &swpN);
     
    29902997  sprintf(szKey, "%sLastTreePos", szPrefix);
    29912998  if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) & swp, &size)) {
    2992     if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
     2999    if (fIsShutDownState)
    29933000      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    29943001    swp.hwnd = hwndTree;
     
    30023009      swp.fl &= (~SWP_ACTIVATE);
    30033010      WinSetWindowPos(hwndTree,
    3004                       HWND_TOP,
    3005                       swp.x,
    3006                       swp.y,
    3007                       swp.cx,
    3008                       swp.cy,
    3009                       swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     3011                      HWND_TOP,
     3012                      swp.x,
     3013                      swp.y,
     3014                      swp.cx,
     3015                      swp.cy,
     3016                      swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    30103017    }
    30113018    else {
    30123019      WinSetWindowPos(hwndTree,
    3013                       HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3020                      HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    30143021      WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
    30153022      WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
     
    30213028  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    30223029  if (PrfQueryProfileData(fmprof,
    3023                           FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) {
    3024     if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
     3030                          FM3Str, szKey, (PVOID) & numsaves, &size) && numsaves) {
     3031    if (fIsShutDownState)
    30253032      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    30263033    for (x = 0; x < numsaves; x++) {
     
    30283035      size = sizeof(SWP);
    30293036      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3030         if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    3031           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3032         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    3033         size = sizeof(szDir);
    3034         if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    3035           if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    3036             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3037           if (driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3038             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3039             continue;
    3040           }
    3041           localdcd.detailslongname = detailslongname;  // Set default
    3042           size = sizeof(BOOL);
    3043           sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
    3044           if (PrfQueryProfileData(fmprof,
    3045                                   FM3Str,
    3046                                   szKey,
    3047                                   (PVOID) & localdcd.detailslongname,
    3048                                   &size) && size == sizeof(BOOL))
    3049                                   {
    3050                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3051                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3052                                   }
    3053           localdcd.detailssubject = detailssubject;  // Set default
    3054           size = sizeof(BOOL);
    3055           sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
    3056           if (PrfQueryProfileData(fmprof,
    3057                                   FM3Str,
    3058                                   szKey,
    3059                                   (PVOID) & localdcd.detailssubject,
    3060                                   &size) && size == sizeof(BOOL))
    3061                                   {
    3062                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3063                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3064                                   }
    3065           localdcd.detailsea = detailsea;  // Set default
    3066           size = sizeof(BOOL);
    3067           sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
    3068           if (PrfQueryProfileData(fmprof,
    3069                                   FM3Str,
    3070                                   szKey,
    3071                                   (PVOID) & localdcd.detailsea,
    3072                                   &size) && size == sizeof(BOOL))
    3073                                   {
    3074                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3075                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3076                                   }
    3077           localdcd.detailssize = detailssize;  // Set default
    3078           size = sizeof(BOOL);
    3079           sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
    3080           if (PrfQueryProfileData(fmprof,
    3081                                   FM3Str,
    3082                                   szKey,
    3083                                   (PVOID) & localdcd.detailssize,
    3084                                   &size) && size == sizeof(BOOL))
    3085                                   {
    3086                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3087                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3088                                   }
    3089           localdcd.detailsicon = detailsicon;  // Set default
    3090           size = sizeof(BOOL);
    3091           sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
    3092           if (PrfQueryProfileData(fmprof,
    3093                                   FM3Str,
    3094                                   szKey,
    3095                                   (PVOID) & localdcd.detailsicon,
    3096                                   &size) && size == sizeof(BOOL))
    3097                                   {
    3098                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3099                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3100                                   }
    3101           localdcd.detailsattr = detailsattr;  // Set default
    3102           size = sizeof(BOOL);
    3103           sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
    3104           if (PrfQueryProfileData(fmprof,
    3105                                   FM3Str,
    3106                                   szKey,
    3107                                   (PVOID) & localdcd.detailsattr,
    3108                                   &size) && size == sizeof(BOOL))
    3109                                   {
    3110                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3111                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3112                                   }
    3113           localdcd.detailscrdate = detailscrdate;  // Set default
    3114           size = sizeof(BOOL);
    3115           sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
    3116           if (PrfQueryProfileData(fmprof,
    3117                                   FM3Str,
    3118                                   szKey,
    3119                                   (PVOID) & localdcd.detailscrdate,
    3120                                   &size) && size == sizeof(BOOL))
    3121                                   {
    3122                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3123                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3124                                   }
    3125           localdcd.detailscrtime = detailscrtime;  // Set default
    3126           size = sizeof(BOOL);
    3127           sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
    3128           if (PrfQueryProfileData(fmprof,
    3129                                   FM3Str,
    3130                                   szKey,
    3131                                   (PVOID) & localdcd.detailscrtime,
    3132                                   &size) && size == sizeof(BOOL))
    3133                                   {
    3134                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3135                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3136                                   }
    3137           localdcd.detailslwdate = detailslwdate;  // Set default
    3138           size = sizeof(BOOL);
    3139           sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
    3140           if (PrfQueryProfileData(fmprof,
    3141                                   FM3Str,
    3142                                   szKey,
    3143                                   (PVOID) & localdcd.detailslwdate,
    3144                                   &size) && size == sizeof(BOOL))
    3145                                   {
    3146                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3147                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3148                                   }
    3149           localdcd.detailslwtime = detailslwtime;  // Set default
    3150           size = sizeof(BOOL);
    3151           sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
    3152           if (PrfQueryProfileData(fmprof,
    3153                                   FM3Str,
    3154                                   szKey,
    3155                                   (PVOID) & localdcd.detailslwtime,
    3156                                   &size) && size == sizeof(BOOL))
    3157                                   {
    3158                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3159                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3160                                   }
    3161           localdcd.detailsladate = detailsladate;  // Set default
    3162           size = sizeof(BOOL);
    3163           sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
    3164           if (PrfQueryProfileData(fmprof,
    3165                                   FM3Str,
    3166                                   szKey,
    3167                                   (PVOID) & localdcd.detailsladate,
    3168                                   &size) && size == sizeof(BOOL))
    3169                                   {
    3170                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3171                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3172                                   }
    3173           localdcd.detailslatime = detailslatime;  // Set default
    3174           size = sizeof(BOOL);
    3175           sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
    3176           if (PrfQueryProfileData(fmprof,
    3177                                   FM3Str,
    3178                                   szKey,
    3179                                   (PVOID) & localdcd.detailslatime,
    3180                                   &size) && size == sizeof(BOOL))
    3181                                   {
    3182                                     if (!pszStateName || !strcmp(pszStateName, FM2_STATE_AT_CLOSE))
    3183                                       PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3184                                   }
    3185           sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3186           RestorePresParams(hwndClient, szKey);
    3187           SavePresParams(hwndClient, "DirCnr");
    3188           hwndDir = (HWND) WinSendMsg(hwndClient,
    3189                                       UM_SETDIR,
    3190                                       MPFROMP(szDir), MPFROMLONG(1));
    3191           if (hwndDir) {
    3192             hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
    3193             if (hwndC) {
    3194               HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
    3195               dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    3196               if (dcd) {
    3197                 dcd->detailslongname = localdcd.detailslongname;
    3198                 dcd->detailssubject  = localdcd.detailssubject ;
    3199                 dcd->detailsattr     = localdcd.detailsattr    ;
    3200                 dcd->detailsea       = localdcd.detailsea      ;
    3201                 dcd->detailssize     = localdcd.detailssize    ;
    3202                 dcd->detailsicon     = localdcd.detailsicon    ;
    3203                 dcd->detailscrdate   = localdcd.detailscrdate  ;
    3204                 dcd->detailscrtime   = localdcd.detailscrtime  ;
    3205                 dcd->detailsladate   = localdcd.detailsladate  ;
    3206                 dcd->detailslatime   = localdcd.detailslatime  ;
    3207                 dcd->detailslwdate   = localdcd.detailslwdate  ;
    3208                 dcd->detailslwtime   = localdcd.detailslwtime  ;
    3209                 size = sizeof(INT);
    3210                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    3211                 if (PrfQueryProfileData(fmprof,
    3212                                         FM3Str,
    3213                                         szKey,
    3214                                         (PVOID) & dcd->sortFlags,
    3215                                         &size) && size == sizeof(INT)) {
    3216                   if (!dcd->sortFlags)
    3217                     dcd->sortFlags = SORT_PATHNAME;
    3218                 }
    3219                 if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    3220                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3221                 size = sizeof(MASK);
    3222                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    3223                 if (PrfQueryProfileData(fmprof,
    3224                                         FM3Str,
    3225                                         szKey,
    3226                                         (PVOID) & dcd->mask, &size) && size) {
    3227                   if (*dcd->mask.szMask)
    3228                     WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3229                                UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
    3230                 }
    3231                 *(dcd->mask.prompt) = 0;
    3232                 if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    3233                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3234                 size = sizeof(ULONG);
    3235                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    3236                 if (!noview) {
    3237                   if (PrfQueryProfileData(fmprof,
    3238                                           FM3Str,
    3239                                           szKey,
    3240                                           (PVOID) & dcd->flWindowAttr,
    3241                                           &size) && size == sizeof(ULONG)) {
    3242 
    3243                     CNRINFO cnri;
    3244 
    3245                     memset(&cnri, 0, sizeof(CNRINFO));
    3246                     cnri.cb = sizeof(CNRINFO);
    3247                     if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3248                                    CM_QUERYCNRINFO,
    3249                                    MPFROMP(&cnri),
    3250                                    MPFROMLONG(sizeof(CNRINFO)))) {
    3251                       cnri.flWindowAttr = dcd->flWindowAttr;
    3252                       WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3253                                  CM_SETCNRINFO,
    3254                                  MPFROMP(&cnri),
    3255                                  MPFROMLONG(CMA_FLWINDOWATTR));
    3256                     }
    3257                   }
    3258                 }
    3259                 if (!pszStateName || !strcmp(pszStateName, GetPString(IDS_FM2TEMPTEXT)))
    3260                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3261                 if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    3262                   WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
    3263               }
    3264             }
    3265             fRestored = TRUE;
    3266             swp.hwnd = hwndDir;
    3267             TransformSwp(&swp, xtrans, ytrans);
    3268             if (!fAutoTile && !(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3269               WinSetWindowPos(hwndDir,
    3270                               HWND_TOP,
    3271                               swp.x,
    3272                               swp.y,
    3273                               swp.cx,
    3274                               swp.cy,
    3275                               swp.fl | SWP_MOVE |
    3276                               SWP_SIZE | SWP_SHOW | SWP_ZORDER |
    3277                               SWP_ACTIVATE);
    3278             else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3279               WinSetWindowPos(hwndDir,
    3280                               HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    3281               WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
    3282               WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
    3283               WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
    3284               WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
    3285             }
    3286             else
    3287               WinSetWindowPos(hwndDir,
     3037        if (fIsShutDownState)
     3038          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3039        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3040        size = sizeof(szDir);
     3041        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     3042          // If drive marked no prescan, and restoring shutdown state
     3043          // bypass window restore
     3044          if (fIsShutDownState &&
     3045              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     3046            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3047            continue;
     3048          }
     3049          if (fIsShutDownState)
     3050            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3051          localdcd.detailslongname = detailslongname;  // Set default
     3052          size = sizeof(BOOL);
     3053          sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
     3054          if (PrfQueryProfileData(fmprof,
     3055                                  FM3Str,
     3056                                  szKey,
     3057                                  (PVOID)&localdcd.detailslongname,
     3058                                  &size) &&
     3059              size == sizeof(BOOL))
     3060          {
     3061            if (fIsShutDownState)
     3062              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3063          }
     3064          localdcd.detailssubject = detailssubject;  // Set default
     3065          size = sizeof(BOOL);
     3066          sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
     3067          if (PrfQueryProfileData(fmprof,
     3068                                  FM3Str,
     3069                                  szKey,
     3070                                  (PVOID)&localdcd.detailssubject,
     3071                                  &size) &&
     3072              size == sizeof(BOOL))
     3073          {
     3074            if (fIsShutDownState)
     3075              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3076          }
     3077          localdcd.detailsea = detailsea;  // Set default
     3078          size = sizeof(BOOL);
     3079          sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
     3080          if (PrfQueryProfileData(fmprof,
     3081                                  FM3Str,
     3082                                  szKey,
     3083                                  (PVOID) & localdcd.detailsea,
     3084                                  &size) &&
     3085              size == sizeof(BOOL))
     3086          {
     3087            if (fIsShutDownState)
     3088              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3089          }
     3090          localdcd.detailssize = detailssize;  // Set default
     3091          size = sizeof(BOOL);
     3092          sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
     3093          if (PrfQueryProfileData(fmprof,
     3094                                  FM3Str,
     3095                                  szKey,
     3096                                  (PVOID) & localdcd.detailssize,
     3097                                  &size) &&
     3098              size == sizeof(BOOL))
     3099          {
     3100            if (fIsShutDownState)
     3101              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3102          }
     3103          localdcd.detailsicon = detailsicon;  // Set default
     3104          size = sizeof(BOOL);
     3105          sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
     3106          if (PrfQueryProfileData(fmprof,
     3107                                  FM3Str,
     3108                                  szKey,
     3109                                  (PVOID) & localdcd.detailsicon,
     3110                                  &size) &&
     3111              size == sizeof(BOOL))
     3112          {
     3113            if (fIsShutDownState)
     3114              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3115          }
     3116          localdcd.detailsattr = detailsattr;  // Set default
     3117          size = sizeof(BOOL);
     3118          sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
     3119          if (PrfQueryProfileData(fmprof,
     3120                                  FM3Str,
     3121                                  szKey,
     3122                                  (PVOID)&localdcd.detailsattr,
     3123                                  &size) &&
     3124              size == sizeof(BOOL))
     3125          {
     3126            if (fIsShutDownState)
     3127              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3128          }
     3129          localdcd.detailscrdate = detailscrdate;  // Set default
     3130          size = sizeof(BOOL);
     3131          sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
     3132          if (PrfQueryProfileData(fmprof,
     3133                                  FM3Str,
     3134                                  szKey,
     3135                                  (PVOID) & localdcd.detailscrdate,
     3136              &size) && size == sizeof(BOOL))
     3137          {
     3138            if (fIsShutDownState)
     3139              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3140          }
     3141          localdcd.detailscrtime = detailscrtime;  // Set default
     3142          size = sizeof(BOOL);
     3143          sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
     3144          if (PrfQueryProfileData(fmprof,
     3145                                  FM3Str,
     3146                                  szKey,
     3147                                  (PVOID)&localdcd.detailscrtime,
     3148                                  &size) &&
     3149              size == sizeof(BOOL))
     3150          {
     3151            if (fIsShutDownState)
     3152              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3153          }
     3154          localdcd.detailslwdate = detailslwdate;  // Set default
     3155          size = sizeof(BOOL);
     3156          sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
     3157          if (PrfQueryProfileData(fmprof,
     3158                                  FM3Str,
     3159                                  szKey,
     3160                                  (PVOID) & localdcd.detailslwdate,
     3161                                  &size) &&
     3162              size == sizeof(BOOL))
     3163          {
     3164            if (fIsShutDownState)
     3165              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3166          }
     3167          localdcd.detailslwtime = detailslwtime;  // Set default
     3168          size = sizeof(BOOL);
     3169          sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
     3170          if (PrfQueryProfileData(fmprof,
     3171                                  FM3Str,
     3172                                  szKey,
     3173                                  (PVOID) & localdcd.detailslwtime,
     3174                                  &size) &&
     3175              size == sizeof(BOOL))
     3176          {
     3177            if (fIsShutDownState)
     3178              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3179          }
     3180          localdcd.detailsladate = detailsladate;  // Set default
     3181          size = sizeof(BOOL);
     3182          sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
     3183          if (PrfQueryProfileData(fmprof,
     3184                                  FM3Str,
     3185                                  szKey,
     3186                                  (PVOID) & localdcd.detailsladate,
     3187                                  &size) &&
     3188              size == sizeof(BOOL))
     3189          {
     3190            if (fIsShutDownState)
     3191              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3192          }
     3193          localdcd.detailslatime = detailslatime;  // Set default
     3194          size = sizeof(BOOL);
     3195          sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
     3196          if (PrfQueryProfileData(fmprof,
     3197                                  FM3Str,
     3198                                  szKey,
     3199                                  (PVOID) & localdcd.detailslatime,
     3200                                  &size) &&
     3201              size == sizeof(BOOL))
     3202          {
     3203            if (fIsShutDownState)
     3204              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3205          }
     3206          sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
     3207          RestorePresParams(hwndClient, szKey);
     3208          SavePresParams(hwndClient, "DirCnr");
     3209          hwndDir = (HWND) WinSendMsg(hwndClient,
     3210                                      UM_SETDIR,
     3211                                      MPFROMP(szDir), MPFROMLONG(1));
     3212          if (hwndDir) {
     3213            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     3214            if (hwndC) {
     3215              HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
     3216              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
     3217              if (dcd) {
     3218                dcd->detailslongname = localdcd.detailslongname;
     3219                dcd->detailssubject  = localdcd.detailssubject ;
     3220                dcd->detailsattr     = localdcd.detailsattr    ;
     3221                dcd->detailsea       = localdcd.detailsea      ;
     3222                dcd->detailssize     = localdcd.detailssize    ;
     3223                dcd->detailsicon     = localdcd.detailsicon    ;
     3224                dcd->detailscrdate   = localdcd.detailscrdate  ;
     3225                dcd->detailscrtime   = localdcd.detailscrtime  ;
     3226                dcd->detailsladate   = localdcd.detailsladate  ;
     3227                dcd->detailslatime   = localdcd.detailslatime  ;
     3228                dcd->detailslwdate   = localdcd.detailslwdate  ;
     3229                dcd->detailslwtime   = localdcd.detailslwtime  ;
     3230                size = sizeof(INT);
     3231                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3232                if (PrfQueryProfileData(fmprof,
     3233                                        FM3Str,
     3234                                        szKey,
     3235                                        (PVOID) & dcd->sortFlags,
     3236                                        &size) && size == sizeof(INT)) {
     3237                  if (!dcd->sortFlags)
     3238                    dcd->sortFlags = SORT_PATHNAME;
     3239                }
     3240                if (fIsShutDownState)
     3241                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3242                size = sizeof(MASK);
     3243                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3244                if (PrfQueryProfileData(fmprof,
     3245                                        FM3Str,
     3246                                        szKey,
     3247                                        (PVOID) & dcd->mask, &size) && size) {
     3248                  if (*dcd->mask.szMask)
     3249                    WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3250                               UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
     3251                }
     3252                *(dcd->mask.prompt) = 0;
     3253                if (fIsShutDownState)
     3254                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3255                size = sizeof(ULONG);
     3256                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3257                if (!noview) {
     3258                  if (PrfQueryProfileData(fmprof,
     3259                                          FM3Str,
     3260                                          szKey,
     3261                                          (PVOID) & dcd->flWindowAttr,
     3262                                          &size) && size == sizeof(ULONG)) {
     3263
     3264                    CNRINFO cnri;
     3265
     3266                    memset(&cnri, 0, sizeof(CNRINFO));
     3267                    cnri.cb = sizeof(CNRINFO);
     3268                    if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3269                                   CM_QUERYCNRINFO,
     3270                                   MPFROMP(&cnri),
     3271                                   MPFROMLONG(sizeof(CNRINFO)))) {
     3272                      cnri.flWindowAttr = dcd->flWindowAttr;
     3273                      WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3274                                 CM_SETCNRINFO,
     3275                                 MPFROMP(&cnri),
     3276                                 MPFROMLONG(CMA_FLWINDOWATTR));
     3277                    }
     3278                  }
     3279                }
     3280                if (fIsShutDownState)
     3281                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3282                if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
     3283                  WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     3284              }
     3285            }
     3286            fRestored = TRUE;
     3287            swp.hwnd = hwndDir;
     3288            TransformSwp(&swp, xtrans, ytrans);
     3289            if (!fAutoTile && !(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3290              WinSetWindowPos(hwndDir,
     3291                              HWND_TOP,
     3292                              swp.x,
     3293                              swp.y,
     3294                              swp.cx,
     3295                              swp.cy,
     3296                              swp.fl | SWP_MOVE |
     3297                              SWP_SIZE | SWP_SHOW | SWP_ZORDER |
     3298                              SWP_ACTIVATE);
     3299            else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3300              WinSetWindowPos(hwndDir,
     3301                              HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3302              WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
     3303              WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
     3304              WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
     3305              WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
     3306            }
     3307            else
     3308              WinSetWindowPos(hwndDir,
    32883309                              HWND_BOTTOM,
    3289                               0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
    3290           }
    3291         }
     3310                              0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE);
     3311          }
     3312        }
    32923313      }
    32933314    } // for
     
    33143335    if (ulNumMinChildren) {
    33153336      if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
    3316         (*ulNumMinChildren)++;
     3337        (*ulNumMinChildren)++;
    33173338    }
    33183339  }
     
    33223343
    33233344VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
    3324                       ULONG * ulNumMinChildrenR)
     3345                      ULONG * ulNumMinChildrenR)
    33253346{
    33263347  register ULONG ulCnt;
     
    33863407    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    33873408      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3388         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3409        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    33893410      if (swp.x != 0)
    3390         swp.x = 0;
     3411        swp.x = 0;
    33913412      if (swp.y < 0)
    3392         swp.y = 0;
     3413        swp.y = 0;
    33933414      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3394         swp.cx = Rectl.xRight - Rectl.xLeft;
     3415        swp.cx = Rectl.xRight - Rectl.xLeft;
    33953416      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3396                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3417                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    33973418    }
    33983419  }
     
    34063427      GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
    34073428      WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3408                       SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
    3409                       SWP_ZORDER | SWP_ACTIVATE);
     3429                      SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
     3430                      SWP_ZORDER | SWP_ACTIVATE);
    34103431      ulCnt++;
    34113432    }
     
    34603481    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    34613482      if (swp.y < 0)
    3462         swp.y = 0;
     3483        swp.y = 0;
    34633484      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3464         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3485        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    34653486      if (swp.x != 0)
    3466         swp.x = 0;
     3487        swp.x = 0;
    34673488      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3468         swp.cx = Rectl.xRight - Rectl.xLeft;
     3489        swp.cx = Rectl.xRight - Rectl.xLeft;
    34693490      WinSetWindowPos(hwndTree,
    3470                       HWND_TOP,
    3471                       swp.x,
    3472                       swp.y,
    3473                       swp.cx,
    3474                       swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3491                      HWND_TOP,
     3492                      swp.x,
     3493                      swp.y,
     3494                      swp.cx,
     3495                      swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    34753496      WinQueryWindowPos(hwndTree, &swp);
    34763497    }
     
    34973518
    34983519      for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
    3499         if ((ulNumRows - ulCurRow) <= ulExtraCols)
    3500           ulNumCols++;
    3501         for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
    3502           ulWidth = Rectl.xRight / ulNumCols;
    3503 
    3504           while (hwndChild) {
    3505             id = WinQueryWindowUShort(hwndChild, QWS_ID);
    3506             if (id && (id != TREE_FRAME || fFreeTree)) {
    3507               WinQueryWindowPos(hwndChild, &swp);
    3508               if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3509                 break;
    3510             }
    3511             hwndChild = WinGetNextWindow(henum);
    3512           }
    3513 
    3514           if (hwndChild) {
    3515             if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
    3516               WinGetMaxPosition(hwndChild, &swp);
    3517               WinSetWindowPos(hwndChild,
    3518                               HWND_TOP,
    3519                               swp.x,
    3520                               swp.y,
    3521                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3522               WinSetWindowUShort(hwndChild,
    3523                                 QWS_XRESTORE,
    3524                                 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
    3525               WinSetWindowUShort(hwndChild,
    3526                                 QWS_YRESTORE,
    3527                                 (USHORT) (Rectl.yTop -
    3528                                            (ulHeight * (ulCurRow + 1))));
    3529               WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    3530               WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
    3531             }
    3532             else
    3533               WinSetWindowPos(hwndChild,
    3534                               HWND_TOP,
    3535                               (ulWidth * ulCurCol) + Rectl.xLeft,
    3536                               Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    3537                               ulWidth,
    3538                               ulHeight,
    3539                               SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    3540             hwndChild = WinGetNextWindow(henum);
    3541           }
    3542         }
    3543         if ((ulNumRows - ulCurRow) <= ulExtraCols) {
    3544           ulNumCols--;
    3545           ulExtraCols--;
    3546         }
     3520        if ((ulNumRows - ulCurRow) <= ulExtraCols)
     3521          ulNumCols++;
     3522        for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
     3523          ulWidth = Rectl.xRight / ulNumCols;
     3524
     3525          while (hwndChild) {
     3526            id = WinQueryWindowUShort(hwndChild, QWS_ID);
     3527            if (id && (id != TREE_FRAME || fFreeTree)) {
     3528              WinQueryWindowPos(hwndChild, &swp);
     3529              if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3530                break;
     3531            }
     3532            hwndChild = WinGetNextWindow(henum);
     3533          }
     3534
     3535          if (hwndChild) {
     3536            if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
     3537              WinGetMaxPosition(hwndChild, &swp);
     3538              WinSetWindowPos(hwndChild,
     3539                              HWND_TOP,
     3540                              swp.x,
     3541                              swp.y,
     3542                              swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3543              WinSetWindowUShort(hwndChild,
     3544                                QWS_XRESTORE,
     3545                                (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
     3546              WinSetWindowUShort(hwndChild,
     3547                                QWS_YRESTORE,
     3548                                (USHORT) (Rectl.yTop -
     3549                                           (ulHeight * (ulCurRow + 1))));
     3550              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
     3551              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     3552            }
     3553            else
     3554              WinSetWindowPos(hwndChild,
     3555                              HWND_TOP,
     3556                              (ulWidth * ulCurCol) + Rectl.xLeft,
     3557                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
     3558                              ulWidth,
     3559                              ulHeight,
     3560                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3561            hwndChild = WinGetNextWindow(henum);
     3562          }
     3563        }
     3564        if ((ulNumRows - ulCurRow) <= ulExtraCols) {
     3565          ulNumCols--;
     3566          ulExtraCols--;
     3567        }
    35473568      }
    35483569    }
     
    35543575
    35553576static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
    3556                            SHORT newcx, SHORT newcy)
     3577                           SHORT newcx, SHORT newcy)
    35573578{
    35583579  /*
     
    35723593    while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
    35733594      if (!WinQueryWindowUShort(hwndChild, QWS_ID))
    3574         continue;
     3595        continue;
    35753596      if (WinQueryWindowPos(hwndChild, &swp)) {
    3576         if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
    3577           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3578           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3579           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3580           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3581         }
    3582         else if (swp.fl & SWP_MAXIMIZE) {
    3583           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3584           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3585           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3586           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3587         }
    3588         cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
    3589         cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
    3590         x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
    3591         y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
    3592         if (x < 0)
    3593           x = 0;
    3594         if (y < 0)
    3595           y = 0;
    3596         ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
    3597         uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
    3598         ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
    3599         ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
    3600         if (ux + ucx > newcx)
    3601           ucx = newcx - ux;
    3602         if (uy + ucy > newcy)
    3603           ucy = newcy - uy;
    3604 
    3605         if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
    3606           WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
    3607                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3608         else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3609           WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
    3610           WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    3611           WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    3612                           SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
    3613           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3614           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3615           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3616           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3617         }
    3618         else {
    3619           WinGetMaxPosition(hwndChild, &swp);
    3620           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3621                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3622           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3623           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3624           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3625           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3626         }
     3597        if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
     3598          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3599          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3600          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3601          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3602        }
     3603        else if (swp.fl & SWP_MAXIMIZE) {
     3604          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3605          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3606          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3607          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3608        }
     3609        cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
     3610        cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
     3611        x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
     3612        y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
     3613        if (x < 0)
     3614          x = 0;
     3615        if (y < 0)
     3616          y = 0;
     3617        ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
     3618        uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
     3619        ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
     3620        ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
     3621        if (ux + ucx > newcx)
     3622          ucx = newcx - ux;
     3623        if (uy + ucy > newcy)
     3624          ucy = newcy - uy;
     3625
     3626        if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
     3627          WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
     3628                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3629        else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3630          WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
     3631          WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
     3632          WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
     3633                          SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
     3634          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3635          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3636          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3637          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3638        }
     3639        else {
     3640          WinGetMaxPosition(hwndChild, &swp);
     3641          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     3642                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3643          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3644          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3645          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3646          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3647        }
    36273648      }
    36283649    }
     
    36393660    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    36403661      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3641         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3662        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    36423663      if (swp.x != 0)
    3643         swp.x = 0;
     3664        swp.x = 0;
    36443665      if (swp.y < 0)
    3645         swp.y = 0;
     3666        swp.y = 0;
    36463667      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3647         swp.cx = Rectl.xRight - Rectl.xLeft;
     3668        swp.cx = Rectl.xRight - Rectl.xLeft;
    36483669      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3649                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3670                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    36503671    }
    36513672  }
     
    36753696
    36763697static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
    3677                                              ULONG msg,
    3678                                              MPARAM mp1, MPARAM mp2)
     3698                                             ULONG msg,
     3699                                             MPARAM mp1, MPARAM mp2)
    36793700{
    36803701  USHORT id;
     
    36903711    if (fOtherHelp) {
    36913712      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    3692           && !WinQueryCapture(HWND_DESKTOP)) {
    3693         id = WinQueryWindowUShort(hwnd, QWS_ID);
    3694         switch (id) {
    3695         case IDM_OPENWALK:
    3696           MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
    3697           break;
    3698         case IDM_USERLIST:
    3699           MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
    3700           break;
    3701         }
     3713          && !WinQueryCapture(HWND_DESKTOP)) {
     3714        id = WinQueryWindowUShort(hwnd, QWS_ID);
     3715        switch (id) {
     3716        case IDM_OPENWALK:
     3717          MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
     3718          break;
     3719        case IDM_USERLIST:
     3720          MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
     3721          break;
     3722        }
    37023723      }
    37033724    }
     
    37133734      switch (id) {
    37143735      case IDM_OPENWALK:
    3715         switch (msg) {
    3716         case WM_BUTTON2CLICK:
    3717           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3718               (KC_ALT | KC_SHIFT | KC_CTRL))
    3719             cmd = IDM_GREP;
    3720           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3721             CascadeChildren(hwndMain);
     3736        switch (msg) {
     3737        case WM_BUTTON2CLICK:
     3738          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3739              (KC_ALT | KC_SHIFT | KC_CTRL))
     3740            cmd = IDM_GREP;
     3741          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3742            CascadeChildren(hwndMain);
    37223743
    37233744#ifdef NEVER
    3724           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3725             cmd = IDM_SYSINFO;
     3745          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3746            cmd = IDM_SYSINFO;
    37263747#endif
    37273748
    3728           else if (shiftstate & KC_SHIFT)
    3729             cmd = IDM_WINDOWDLG;
    3730           else if (shiftstate & KC_CTRL)
    3731             cmd = IDM_SEEALL;
    3732           else if (shiftstate & KC_ALT)
    3733             TileChildren(hwndMain, TRUE);
    3734           else
    3735             cmd = IDM_WALKDIR;
    3736           break;
    3737         case WM_BUTTON3CLICK:
    3738           TileChildren(hwndMain, TRUE);
    3739           break;
    3740         }
    3741         break;
     3749          else if (shiftstate & KC_SHIFT)
     3750            cmd = IDM_WINDOWDLG;
     3751          else if (shiftstate & KC_CTRL)
     3752            cmd = IDM_SEEALL;
     3753          else if (shiftstate & KC_ALT)
     3754            TileChildren(hwndMain, TRUE);
     3755          else
     3756            cmd = IDM_WALKDIR;
     3757          break;
     3758        case WM_BUTTON3CLICK:
     3759          TileChildren(hwndMain, TRUE);
     3760          break;
     3761        }
     3762        break;
    37423763      case IDM_USERLIST:
    3743         switch (msg) {
    3744         case WM_BUTTON2CLICK:
    3745           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3746               (KC_ALT | KC_SHIFT | KC_CTRL))
    3747             cmd = IDM_COLORPALETTE;
    3748           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3749             cmd = IDM_HIDEMENU;
    3750           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3751             cmd = IDM_NOTEBOOK;
    3752           else if (shiftstate & KC_SHIFT)
    3753             cmd = IDM_TOOLTITLES;
    3754           else if (shiftstate & KC_CTRL)
    3755             cmd = IDM_TEXTTOOLS;
    3756           else if (shiftstate & KC_ALT)
    3757             cmd = IDM_FONTPALETTE;
    3758           else
    3759             cmd = IDM_TOOLBAR;
    3760           break;
    3761         case WM_BUTTON3CLICK:
    3762           cmd = IDM_DRIVEBAR;
    3763           break;
    3764         }
    3765         break;
     3764        switch (msg) {
     3765        case WM_BUTTON2CLICK:
     3766          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3767              (KC_ALT | KC_SHIFT | KC_CTRL))
     3768            cmd = IDM_COLORPALETTE;
     3769          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3770            cmd = IDM_HIDEMENU;
     3771          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3772            cmd = IDM_NOTEBOOK;
     3773          else if (shiftstate & KC_SHIFT)
     3774            cmd = IDM_TOOLTITLES;
     3775          else if (shiftstate & KC_CTRL)
     3776            cmd = IDM_TEXTTOOLS;
     3777          else if (shiftstate & KC_ALT)
     3778            cmd = IDM_FONTPALETTE;
     3779          else
     3780            cmd = IDM_TOOLBAR;
     3781          break;
     3782        case WM_BUTTON3CLICK:
     3783          cmd = IDM_DRIVEBAR;
     3784          break;
     3785        }
     3786        break;
    37663787      }                                 // switch id
    37673788
    37683789      if (cmd) {
    3769         PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
    3770                 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
     3790        PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
     3791                WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
    37713792      }
    37723793    }
     
    37773798    if (id == IDM_OPENWALK) {
    37783799      if (!emphasized) {
    3779         emphasized = TRUE;
    3780         DrawTargetEmphasis(hwnd, emphasized);
     3800        emphasized = TRUE;
     3801        DrawTargetEmphasis(hwnd, emphasized);
    37813802      }
    37823803      if (AcceptOneDrop(hwnd, mp1, mp2))
    3783         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     3804        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    37843805    }
    37853806    return MRFROM2SHORT(DOR_NEVERDROP, 0);
     
    38013822
    38023823      if (emphasized) {
    3803         emphasized = FALSE;
    3804         DrawTargetEmphasis(hwnd, emphasized);
     3824        emphasized = FALSE;
     3825        DrawTargetEmphasis(hwnd, emphasized);
    38053826      }
    38063827      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    3807         if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
    3808           OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
    3809         }
     3828        if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
     3829          OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
     3830        }
    38103831      }
    38113832    }
     
    38203841
    38213842static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    3822                                         MPARAM mp2)
     3843                                        MPARAM mp2)
    38233844{
    38243845  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    38323853      pswp = (SWP *) mp1;
    38333854      if (fDataMin && !fAmClosing) {
    3834         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3835 
    3836           SWP swp;
    3837 
    3838           WinQueryWindowPos(hwnd, &swp);
    3839           PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
    3840           HideNote();
    3841         }
    3842         else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    3843           if (DataHwnd)
    3844             PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
    3845         }
     3855        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3856
     3857          SWP swp;
     3858
     3859          WinQueryWindowPos(hwnd, &swp);
     3860          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     3861          HideNote();
     3862        }
     3863        else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
     3864          if (DataHwnd)
     3865            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     3866        }
    38463867      }
    38473868      if (!fAmClosing) {
    3848         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    3849           HideNote();
     3869        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
     3870          HideNote();
    38503871      }
    38513872    }
     
    38703891  case WM_CONTROL:
    38713892    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
    3872                       mp2);
     3893                      mp2);
    38733894
    38743895  case WM_COMMAND:
     
    38903911
    38913912      if (mr && mp2) {
    3892         prectl = (PRECTL) mp1;
    3893         if (prectl->yBottom != prectl->yTop) {
    3894           {
    3895             HPS hps;
    3896             POINTL aptl[TXTBOX_COUNT];
    3897 
    3898             hps = WinGetPS(hwndStatus);
    3899             if (hps) {
    3900               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    3901               bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    3902               WinReleasePS(hps);
    3903             }
    3904           }
    3905           prectl->yBottom += (sheight + 4);
    3906           prectl->yTop -= (sheight + 4);
    3907           if (fMoreButtons) {
    3908 
    3909             HPS hps;
    3910             POINTL aptl[TXTBOX_COUNT];
    3911 
    3912             hps = WinGetPS(hwndName);
    3913             if (hps) {
    3914               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    3915               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    3916               WinReleasePS(hps);
    3917             }
    3918             prectl->yBottom += (bheight + 4);
    3919             prectl->yTop -= (bheight + 4);
    3920           }
    3921           if (fToolbar) {
    3922             if (!fTextTools)
    3923               prectl->yTop -= ((fToolTitles) ? 50 : 40);
    3924             else
    3925               prectl->yTop -= 32;
    3926           }
    3927           if (fDrivebar) {
    3928             ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
    3929                         ((prectl->xRight -
    3930                            (WinQuerySysValue(HWND_DESKTOP,
    3931                                              SV_CYSIZEBORDER) * 2)) - 4));
    3932             prectl->yTop -= (16 * (DriveLines * 18));
    3933           }
    3934           if (fUserComboBox) {
    3935             if (!aheight) {
    3936 
    3937               SWP swpTemp;
    3938 
    3939               WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    3940                                 &swpTemp);
    3941               aheight = swpTemp.cy;
    3942             }
    3943             prectl->yTop -= (aheight + 6L);
    3944           }
    3945           if (fAutoView) {
    3946             AutoviewHeight = min(AutoviewHeight,
    3947                                 (prectl->yTop - prectl->yBottom) - 116);
    3948             AutoviewHeight = max(AutoviewHeight, 36);
    3949             prectl->yBottom += (AutoviewHeight + 6);
    3950           }
    3951         }
     3913        prectl = (PRECTL) mp1;
     3914        if (prectl->yBottom != prectl->yTop) {
     3915          {
     3916            HPS hps;
     3917            POINTL aptl[TXTBOX_COUNT];
     3918
     3919            hps = WinGetPS(hwndStatus);
     3920            if (hps) {
     3921              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     3922              bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     3923              WinReleasePS(hps);
     3924            }
     3925          }
     3926          prectl->yBottom += (sheight + 4);
     3927          prectl->yTop -= (sheight + 4);
     3928          if (fMoreButtons) {
     3929
     3930            HPS hps;
     3931            POINTL aptl[TXTBOX_COUNT];
     3932
     3933            hps = WinGetPS(hwndName);
     3934            if (hps) {
     3935              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     3936              bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     3937              WinReleasePS(hps);
     3938            }
     3939            prectl->yBottom += (bheight + 4);
     3940            prectl->yTop -= (bheight + 4);
     3941          }
     3942          if (fToolbar) {
     3943            if (!fTextTools)
     3944              prectl->yTop -= ((fToolTitles) ? 50 : 40);
     3945            else
     3946              prectl->yTop -= 32;
     3947          }
     3948          if (fDrivebar) {
     3949            ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     3950                        ((prectl->xRight -
     3951                           (WinQuerySysValue(HWND_DESKTOP,
     3952                                             SV_CYSIZEBORDER) * 2)) - 4));
     3953            prectl->yTop -= (16 * (DriveLines * 18));
     3954          }
     3955          if (fUserComboBox) {
     3956            if (!aheight) {
     3957
     3958              SWP swpTemp;
     3959
     3960              WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     3961                                &swpTemp);
     3962              aheight = swpTemp.cy;
     3963            }
     3964            prectl->yTop -= (aheight + 6L);
     3965          }
     3966          if (fAutoView) {
     3967            AutoviewHeight = min(AutoviewHeight,
     3968                                (prectl->yTop - prectl->yBottom) - 116);
     3969            AutoviewHeight = max(AutoviewHeight, 36);
     3970            prectl->yBottom += (AutoviewHeight + 6);
     3971          }
     3972        }
    39523973      }
    39533974      return mr;
     
    39733994      pswp = (PSWP) mp1;
    39743995      {
    3975         SHORT x;
    3976 
    3977         for (x = 0; x < soldCount; x++) {
    3978           if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
    3979             pswpClient = pswp;
    3980             break;
    3981           }
    3982           pswp++;
    3983         }
     3996        SHORT x;
     3997
     3998        for (x = 0; x < soldCount; x++) {
     3999          if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
     4000            pswpClient = pswp;
     4001            break;
     4002          }
     4003          pswp++;
     4004        }
    39844005      }
    39854006
    39864007      {
    3987         HPS hps;
    3988         POINTL aptl[TXTBOX_COUNT];
    3989 
    3990         hps = WinGetPS(hwndStatus);
    3991         if (hps) {
    3992           GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    3993           bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    3994           WinReleasePS(hps);
    3995         }
    3996         if (fMoreButtons) {
    3997           hps = WinGetPS(hwndName);
    3998           if (hps) {
    3999             GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4000             bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4001             WinReleasePS(hps);
    4002           }
    4003         }
     4008        HPS hps;
     4009        POINTL aptl[TXTBOX_COUNT];
     4010
     4011        hps = WinGetPS(hwndStatus);
     4012        if (hps) {
     4013          GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4014          bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4015          WinReleasePS(hps);
     4016        }
     4017        if (fMoreButtons) {
     4018          hps = WinGetPS(hwndName);
     4019          if (hps) {
     4020            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4021            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4022            WinReleasePS(hps);
     4023          }
     4024        }
    40044025      }
    40054026      pswpNew = (PSWP) mp1 + soldCount;
     
    40114032      pswpNew->y = swpClient.y + 2;
    40124033      if (!fSplitStatus)
    4013         width = swpClient.cx - (16 + (sheight * 2) + 4);
     4034        width = swpClient.cx - (16 + (sheight * 2) + 4);
    40144035      else
    4015         width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
     4036        width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
    40164037      width = max(width, 10);
    40174038      if (fSplitStatus)
    4018         pswpNew->cx = width - 6;
     4039        pswpNew->cx = width - 6;
    40194040      else
    4020         pswpNew->cx = width - 8;
     4041        pswpNew->cx = width - 8;
    40214042      pswpNew->cy = sheight;
    40224043      pswpClient->y = pswpNew->y + pswpNew->cy + 3;
     
    40254046
    40264047      if (fSplitStatus) {
    4027         pswpNew = (PSWP) mp1 + (soldCount + 1);
    4028         *pswpNew = *pswpClient;
    4029         pswpNew->hwnd = hwndStatus2;
    4030         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4031         pswpNew->x = width + 8;
    4032         pswpNew->y = swpClient.y + 2;
    4033         pswpNew->cx = width - 6;
    4034         pswpNew->cy = sheight;
    4035         sCount++;
     4048        pswpNew = (PSWP) mp1 + (soldCount + 1);
     4049        *pswpNew = *pswpClient;
     4050        pswpNew->hwnd = hwndStatus2;
     4051        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4052        pswpNew->x = width + 8;
     4053        pswpNew->y = swpClient.y + 2;
     4054        pswpNew->cx = width - 6;
     4055        pswpNew->cy = sheight;
     4056        sCount++;
    40364057      }
    40374058      else {
    4038         WinShowWindow(hwndStatus2, FALSE);
    4039         WinSetWindowText(hwndStatus2, NullStr);
     4059        WinShowWindow(hwndStatus2, FALSE);
     4060        WinSetWindowText(hwndStatus2, NullStr);
    40404061      }
    40414062
    40424063      if (fToolbar) {
    4043         if (fTextTools)
    4044           theight = 32L;
    4045         else if (!fToolTitles)
    4046           theight = 40L;
    4047         pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
    4048         *pswpNew = *pswpClient;
    4049         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
    4050         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4051         pswpNew->x = swpClient.x + 2;
    4052         pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    4053         pswpNew->cx = swpClient.cx - 4;
    4054         pswpNew->cy = theight - 4;
    4055         pswpClient->cy -= theight;
    4056         sCount++;
     4064        if (fTextTools)
     4065          theight = 32L;
     4066        else if (!fToolTitles)
     4067          theight = 40L;
     4068        pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
     4069        *pswpNew = *pswpClient;
     4070        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     4071        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4072        pswpNew->x = swpClient.x + 2;
     4073        pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
     4074        pswpNew->cx = swpClient.cx - 4;
     4075        pswpNew->cy = theight - 4;
     4076        pswpClient->cy -= theight;
     4077        sCount++;
    40574078      }
    40584079      else
    4059         WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     4080        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
    40604081
    40614082      if (fDrivebar) {
    4062         ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
    4063         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4064                                 (fSplitStatus != FALSE) +
    4065                                 (fToolbar != FALSE));
    4066         *pswpNew = *pswpClient;
    4067         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
    4068         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4069         pswpNew->x = swpClient.x + 2;
    4070         dheight += ((dheight - 2) * DriveLines);
    4071         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    4072         if (fToolbar)
    4073           pswpNew->y -= theight;
    4074         pswpNew->cx = swpClient.cx - 4;
    4075         pswpNew->cy = dheight - 4;
    4076         pswpClient->cy -= dheight;
    4077         sCount++;
     4083        ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
     4084        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4085                                (fSplitStatus != FALSE) +
     4086                                (fToolbar != FALSE));
     4087        *pswpNew = *pswpClient;
     4088        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     4089        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4090        pswpNew->x = swpClient.x + 2;
     4091        dheight += ((dheight - 2) * DriveLines);
     4092        pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
     4093        if (fToolbar)
     4094          pswpNew->y -= theight;
     4095        pswpNew->cx = swpClient.cx - 4;
     4096        pswpNew->cy = dheight - 4;
     4097        pswpClient->cy -= dheight;
     4098        sCount++;
    40784099      }
    40794100      else
    4080         WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
     4101        WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
    40814102
    40824103      if (fAutoView) {
    4083         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4084                                 (fToolbar != FALSE) +
    4085                                 (fDrivebar != FALSE) +
    4086                                 (fSplitStatus != FALSE));
    4087         *pswpNew = *pswpClient;
    4088         pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    4089         pswpNew->x = pswpClient->x + 3;
    4090         pswpNew->y = pswpClient->y + 3;
    4091         if (fMoreButtons)
    4092           pswpNew->y += (bheight + 4);
    4093         pswpNew->cx = pswpClient->cx - 6;
    4094         AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
    4095         AutoviewHeight = max(AutoviewHeight, 36);
    4096         pswpNew->cy = AutoviewHeight;
    4097         pswpClient->y += (AutoviewHeight + 6);
    4098         pswpClient->cy -= (AutoviewHeight + 6);
    4099         sCount++;
    4100         WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     4104        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4105                                (fToolbar != FALSE) +
     4106                                (fDrivebar != FALSE) +
     4107                                (fSplitStatus != FALSE));
     4108        *pswpNew = *pswpClient;
     4109        pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     4110        pswpNew->x = pswpClient->x + 3;
     4111        pswpNew->y = pswpClient->y + 3;
     4112        if (fMoreButtons)
     4113          pswpNew->y += (bheight + 4);
     4114        pswpNew->cx = pswpClient->cx - 6;
     4115        AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
     4116        AutoviewHeight = max(AutoviewHeight, 36);
     4117        pswpNew->cy = AutoviewHeight;
     4118        pswpClient->y += (AutoviewHeight + 6);
     4119        pswpClient->cy -= (AutoviewHeight + 6);
     4120        sCount++;
     4121        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
    41014122      }
    41024123      else {
    4103         WinShowWindow(hwndAutoview, FALSE);
    4104         WinShowWindow(hwndAutoMLE, FALSE);
     4124        WinShowWindow(hwndAutoview, FALSE);
     4125        WinShowWindow(hwndAutoMLE, FALSE);
    41054126      }
    41064127
    41074128      pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4108                               (fToolbar != FALSE) +
    4109                               (fDrivebar != FALSE) +
    4110                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4129                              (fToolbar != FALSE) +
     4130                              (fDrivebar != FALSE) +
     4131                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41114132      *pswpNew = *pswpClient;
    41124133      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
     
    41174138      sCount++;
    41184139      pswpNew = (PSWP) mp1 + (soldCount + 2 +
    4119                               (fToolbar != FALSE) +
    4120                               (fDrivebar != FALSE) +
    4121                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4140                              (fToolbar != FALSE) +
     4141                              (fDrivebar != FALSE) +
     4142                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41224143      *pswpNew = *pswpClient;
    41234144      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
     
    41284149      sCount++;
    41294150      pswpNew = (PSWP) mp1 + (soldCount + 3 +
    4130                               (fToolbar != FALSE) +
    4131                               (fDrivebar != FALSE) +
    4132                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4151                              (fToolbar != FALSE) +
     4152                              (fDrivebar != FALSE) +
     4153                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41334154      *pswpNew = *pswpClient;
    41344155      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
     
    41394160      sCount++;
    41404161      pswpNew = (PSWP) mp1 + (soldCount + 4 +
    4141                               (fToolbar != FALSE) +
    4142                               (fDrivebar != FALSE) +
    4143                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4162                              (fToolbar != FALSE) +
     4163                              (fDrivebar != FALSE) +
     4164                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    41444165      *pswpNew = *pswpClient;
    41454166      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     
    41504171      sCount++;
    41514172      if (fUserComboBox) {
    4152         if (!aheight) {
    4153 
    4154           SWP swpTemp;
    4155 
    4156           WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4157                             &swpTemp);
    4158           aheight = swpTemp.cy;
    4159         }
    4160         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4161                                 (fToolbar != FALSE) +
    4162                                 (fSplitStatus != FALSE) +
    4163                                 (fDrivebar != FALSE) + (fAutoView != FALSE));
    4164         *pswpNew = *pswpClient;
    4165         pswpNew->hwnd = hwndDrivelist;
    4166         pswpNew->x = swpClient.x;
    4167         pswpNew->cx = 48;
    4168         pswpClient->cy -= (aheight + 6L);
    4169         pswpNew->y = pswpClient->y;
    4170         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4171         sCount++;
    4172         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4173                                 (fToolbar != FALSE) +
    4174                                 (fDrivebar != FALSE) +
    4175                                 (fSplitStatus != FALSE) +
    4176                                 (fAutoView != FALSE));
    4177         *pswpNew = *pswpClient;
    4178         pswpNew->hwnd = hwndStatelist;
    4179         pswpNew->x = swpClient.x + 48;
    4180         pswpNew->cx = (swpClient.cx - 48) / 7;
    4181         pswpNew->y = pswpClient->y;
    4182         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4183         sCount++;
    4184         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4185                                 (fToolbar != FALSE) +
    4186                                 (fDrivebar != FALSE) +
    4187                                 (fSplitStatus != FALSE) +
    4188                                 (fAutoView != FALSE));
    4189         *pswpNew = *pswpClient;
    4190         pswpNew->hwnd = hwndCmdlist;
    4191         pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
    4192         pswpNew->cx = (swpClient.cx - 48) / 5 +
    4193           ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
    4194         pswpNew->y = pswpClient->y;
    4195         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4196         sCount++;
    4197         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4198                                 (fToolbar != FALSE) +
    4199                                 (fDrivebar != FALSE) +
    4200                                 (fSplitStatus != FALSE) +
    4201                                 (fAutoView != FALSE));
    4202         *pswpNew = *pswpClient;
    4203         pswpNew->hwnd = hwndUserlist;
    4204         pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
    4205         pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
    4206           ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
    4207         pswpNew->y = pswpClient->y;
    4208         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4209         sCount++;
    4210         if (fToolbar) {
    4211           pswpNew = (PSWP) mp1 + (soldCount + 9 +
    4212                                   (fToolbar != FALSE) +
    4213                                   (fDrivebar != FALSE) +
    4214                                   (fSplitStatus != FALSE) +
    4215                                   (fAutoView != FALSE));
    4216           *pswpNew = *pswpClient;
    4217           pswpNew->hwnd = hwndButtonlist;
    4218           pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
    4219           pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
    4220           pswpNew->y = pswpClient->y;
    4221           pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4222           sCount++;
    4223         }
    4224         else
    4225           WinShowWindow(hwndButtonlist, FALSE);
     4173        if (!aheight) {
     4174
     4175          SWP swpTemp;
     4176
     4177          WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4178                            &swpTemp);
     4179          aheight = swpTemp.cy;
     4180        }
     4181        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4182                                (fToolbar != FALSE) +
     4183                                (fSplitStatus != FALSE) +
     4184                                (fDrivebar != FALSE) + (fAutoView != FALSE));
     4185        *pswpNew = *pswpClient;
     4186        pswpNew->hwnd = hwndDrivelist;
     4187        pswpNew->x = swpClient.x;
     4188        pswpNew->cx = 48;
     4189        pswpClient->cy -= (aheight + 6L);
     4190        pswpNew->y = pswpClient->y;
     4191        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4192        sCount++;
     4193        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4194                                (fToolbar != FALSE) +
     4195                                (fDrivebar != FALSE) +
     4196                                (fSplitStatus != FALSE) +
     4197                                (fAutoView != FALSE));
     4198        *pswpNew = *pswpClient;
     4199        pswpNew->hwnd = hwndStatelist;
     4200        pswpNew->x = swpClient.x + 48;
     4201        pswpNew->cx = (swpClient.cx - 48) / 7;
     4202        pswpNew->y = pswpClient->y;
     4203        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4204        sCount++;
     4205        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4206                                (fToolbar != FALSE) +
     4207                                (fDrivebar != FALSE) +
     4208                                (fSplitStatus != FALSE) +
     4209                                (fAutoView != FALSE));
     4210        *pswpNew = *pswpClient;
     4211        pswpNew->hwnd = hwndCmdlist;
     4212        pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
     4213        pswpNew->cx = (swpClient.cx - 48) / 5 +
     4214          ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
     4215        pswpNew->y = pswpClient->y;
     4216        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4217        sCount++;
     4218        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4219                                (fToolbar != FALSE) +
     4220                                (fDrivebar != FALSE) +
     4221                                (fSplitStatus != FALSE) +
     4222                                (fAutoView != FALSE));
     4223        *pswpNew = *pswpClient;
     4224        pswpNew->hwnd = hwndUserlist;
     4225        pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
     4226        pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
     4227          ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
     4228        pswpNew->y = pswpClient->y;
     4229        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4230        sCount++;
     4231        if (fToolbar) {
     4232          pswpNew = (PSWP) mp1 + (soldCount + 9 +
     4233                                  (fToolbar != FALSE) +
     4234                                  (fDrivebar != FALSE) +
     4235                                  (fSplitStatus != FALSE) +
     4236                                  (fAutoView != FALSE));
     4237          *pswpNew = *pswpClient;
     4238          pswpNew->hwnd = hwndButtonlist;
     4239          pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
     4240          pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
     4241          pswpNew->y = pswpClient->y;
     4242          pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4243          sCount++;
     4244        }
     4245        else
     4246          WinShowWindow(hwndButtonlist, FALSE);
    42264247      }
    42274248      else {
    4228         WinShowWindow(hwndUserlist, FALSE);
    4229         WinShowWindow(hwndDrivelist, FALSE);
    4230         WinShowWindow(hwndStatelist, FALSE);
    4231         WinShowWindow(hwndButtonlist, FALSE);
    4232         WinShowWindow(hwndCmdlist, FALSE);
     4249        WinShowWindow(hwndUserlist, FALSE);
     4250        WinShowWindow(hwndDrivelist, FALSE);
     4251        WinShowWindow(hwndStatelist, FALSE);
     4252        WinShowWindow(hwndButtonlist, FALSE);
     4253        WinShowWindow(hwndCmdlist, FALSE);
    42334254      }
    42344255      {
    4235         PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
    4236         SHORT x;
    4237 
    4238         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4239                                 (fToolbar != FALSE) +
    4240                                 (fDrivebar != FALSE) +
    4241                                 (fSplitStatus != FALSE) +
    4242                                 (fAutoView != FALSE) +
    4243                                 ((fUserComboBox != FALSE) * 4) +
    4244                                 (fUserComboBox != FALSE &&
    4245                                 fToolbar != FALSE));
    4246         pswp = (PSWP) mp1;
    4247         for (x = 0; x < soldCount; x++) {
    4248           if (!pswpTitlebar &&
    4249               WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
    4250             pswpTitlebar = pswp;
    4251           else if (!pswpMinbutton &&
    4252                    WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
    4253             pswpMinbutton = pswp;
    4254           if (pswpTitlebar && pswpMinbutton)
    4255             break;
    4256           pswp++;
    4257         }
    4258         if (pswpMinbutton && pswpTitlebar) {
    4259           *pswpNew = *pswpMinbutton;
    4260           pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
    4261           pswpNew->cy = pswpMinbutton->cy + 3;
    4262           pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
    4263           pswpTitlebar->cx -= (pswpNew->cx - 1);
    4264           pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
    4265           pswpNew->y = pswpMinbutton->y - 1;
    4266           sCount++;
    4267         }
    4268         else
    4269           WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
     4256        PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
     4257        SHORT x;
     4258
     4259        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4260                                (fToolbar != FALSE) +
     4261                                (fDrivebar != FALSE) +
     4262                                (fSplitStatus != FALSE) +
     4263                                (fAutoView != FALSE) +
     4264                                ((fUserComboBox != FALSE) * 4) +
     4265                                (fUserComboBox != FALSE &&
     4266                                fToolbar != FALSE));
     4267        pswp = (PSWP) mp1;
     4268        for (x = 0; x < soldCount; x++) {
     4269          if (!pswpTitlebar &&
     4270              WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
     4271            pswpTitlebar = pswp;
     4272          else if (!pswpMinbutton &&
     4273                   WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
     4274            pswpMinbutton = pswp;
     4275          if (pswpTitlebar && pswpMinbutton)
     4276            break;
     4277          pswp++;
     4278        }
     4279        if (pswpMinbutton && pswpTitlebar) {
     4280          *pswpNew = *pswpMinbutton;
     4281          pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
     4282          pswpNew->cy = pswpMinbutton->cy + 3;
     4283          pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
     4284          pswpTitlebar->cx -= (pswpNew->cx - 1);
     4285          pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
     4286          pswpNew->y = pswpMinbutton->y - 1;
     4287          sCount++;
     4288        }
     4289        else
     4290          WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
    42704291      }
    42714292
    42724293      if (fMoreButtons) {
    42734294
    4274         LONG lastx;
    4275 
    4276         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4277                                 (fToolbar != FALSE) +
    4278                                 (fDrivebar != FALSE) +
    4279                                 (fSplitStatus != FALSE) +
    4280                                 (fAutoView != FALSE) +
    4281                                 ((fUserComboBox != FALSE) * 4) +
    4282                                 (fUserComboBox != FALSE &&
    4283                                 fToolbar != FALSE));
    4284         *pswpNew = *pswpClient;
    4285         pswpNew->hwnd = hwndName;
    4286         pswpNew->x = swpClient.x + 3;
    4287         pswpNew->y = swpClient.y + (sheight + 6);
    4288         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    4289         lastx = pswpNew->x + pswpNew->cx;
    4290         pswpNew->cy = bheight;
    4291         pswpClient->y += (bheight + 4);
    4292         pswpClient->cy -= (bheight + 4);
    4293         sCount++;
    4294         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4295                                 (fToolbar != FALSE) +
    4296                                 (fDrivebar != FALSE) +
    4297                                 (fSplitStatus != FALSE) +
    4298                                 (fAutoView != FALSE) +
    4299                                 ((fUserComboBox != FALSE) * 4) +
    4300                                 (fUserComboBox != FALSE &&
    4301                                 fToolbar != FALSE));
    4302         *pswpNew = *pswpClient;
    4303         pswpNew->hwnd = hwndDate;
    4304         pswpNew->x = lastx + 3;
    4305         pswpNew->y = swpClient.y + (sheight + 6);
    4306         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    4307         lastx = pswpNew->x + pswpNew->cx;
    4308         pswpNew->cy = bheight;
    4309         sCount++;
    4310         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4311                                 (fToolbar != FALSE) +
    4312                                 (fDrivebar != FALSE) +
    4313                                 (fSplitStatus != FALSE) +
    4314                                 (fAutoView != FALSE) +
    4315                                 ((fUserComboBox != FALSE) * 4) +
    4316                                 (fUserComboBox != FALSE &&
    4317                                 fToolbar != FALSE));
    4318         *pswpNew = *pswpClient;
    4319         pswpNew->hwnd = hwndAttr;
    4320         pswpNew->x = lastx + 3;
    4321         pswpNew->y = swpClient.y + (sheight + 6);
    4322         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    4323         pswpNew->cy = bheight;
    4324         sCount++;
     4295        LONG lastx;
     4296
     4297        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4298                                (fToolbar != FALSE) +
     4299                                (fDrivebar != FALSE) +
     4300                                (fSplitStatus != FALSE) +
     4301                                (fAutoView != FALSE) +
     4302                                ((fUserComboBox != FALSE) * 4) +
     4303                                (fUserComboBox != FALSE &&
     4304                                fToolbar != FALSE));
     4305        *pswpNew = *pswpClient;
     4306        pswpNew->hwnd = hwndName;
     4307        pswpNew->x = swpClient.x + 3;
     4308        pswpNew->y = swpClient.y + (sheight + 6);
     4309        pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     4310        lastx = pswpNew->x + pswpNew->cx;
     4311        pswpNew->cy = bheight;
     4312        pswpClient->y += (bheight + 4);
     4313        pswpClient->cy -= (bheight + 4);
     4314        sCount++;
     4315        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4316                                (fToolbar != FALSE) +
     4317                                (fDrivebar != FALSE) +
     4318                                (fSplitStatus != FALSE) +
     4319                                (fAutoView != FALSE) +
     4320                                ((fUserComboBox != FALSE) * 4) +
     4321                                (fUserComboBox != FALSE &&
     4322                                fToolbar != FALSE));
     4323        *pswpNew = *pswpClient;
     4324        pswpNew->hwnd = hwndDate;
     4325        pswpNew->x = lastx + 3;
     4326        pswpNew->y = swpClient.y + (sheight + 6);
     4327        pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     4328        lastx = pswpNew->x + pswpNew->cx;
     4329        pswpNew->cy = bheight;
     4330        sCount++;
     4331        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4332                                (fToolbar != FALSE) +
     4333                                (fDrivebar != FALSE) +
     4334                                (fSplitStatus != FALSE) +
     4335                                (fAutoView != FALSE) +
     4336                                ((fUserComboBox != FALSE) * 4) +
     4337                                (fUserComboBox != FALSE &&
     4338                                fToolbar != FALSE));
     4339        *pswpNew = *pswpClient;
     4340        pswpNew->hwnd = hwndAttr;
     4341        pswpNew->x = lastx + 3;
     4342        pswpNew->y = swpClient.y + (sheight + 6);
     4343        pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
     4344        pswpNew->cy = bheight;
     4345        sCount++;
    43254346      }
    43264347      else {
    4327         WinShowWindow(hwndAttr, FALSE);
    4328         WinShowWindow(hwndName, FALSE);
    4329         WinShowWindow(hwndDate, FALSE);
     4348        WinShowWindow(hwndAttr, FALSE);
     4349        WinShowWindow(hwndName, FALSE);
     4350        WinShowWindow(hwndDate, FALSE);
    43304351      }
    43314352      return MRFROMSHORT(sCount);
     
    43404361      sCount += 6;
    43414362      if (fSplitStatus)
    4342         sCount++;
     4363        sCount++;
    43434364      if (fToolbar)
    4344         sCount++;
     4365        sCount++;
    43454366      if (fUserComboBox) {
    4346         sCount += 4;
    4347         if (fToolbar)
    4348           sCount++;
     4367        sCount += 4;
     4368        if (fToolbar)
     4369          sCount++;
    43494370      }
    43504371      if (fDrivebar)
    4351         sCount++;
     4372        sCount++;
    43524373      if (fAutoView)
    4353         sCount++;
     4374        sCount++;
    43544375      if (fMoreButtons)
    4355         sCount += 3;
     4376        sCount += 3;
    43564377      return MRFROMSHORT(sCount);
    43574378    }
     
    43744395      // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
    43754396      if (hwnd != NULLHANDLE) {
    4376         HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
    4377         USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
    4378         switch (id) {
    4379         case MAIN_SETUPLIST:
    4380         case MAIN_USERLIST:
    4381         case MAIN_CMDLIST:
    4382           // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
    4383           WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
    4384         }
     4397        HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
     4398        USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
     4399        switch (id) {
     4400        case MAIN_SETUPLIST:
     4401        case MAIN_USERLIST:
     4402        case MAIN_CMDLIST:
     4403          // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
     4404          WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
     4405        }
    43854406      }
    43864407    }
     
    44114432      wa.size = sizeof(wa);
    44124433      pci =
    4413         (PCNRITEM)
    4414         WinSendMsg(WinWindowFromID
    4415                    (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
    4416                    CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
    4417                    MPFROMSHORT(CRA_CURSORED));
     4434        (PCNRITEM)
     4435        WinSendMsg(WinWindowFromID
     4436                   (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
     4437                   CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
     4438                   MPFROMSHORT(CRA_CURSORED));
    44184439      if (pci && (INT) pci != -1) {
    4419         strcpy(wa.szCurrentPath1, pci->pszFileName);
    4420         MakeValidDir(wa.szCurrentPath1);
     4440        strcpy(wa.szCurrentPath1, pci->pszFileName);
     4441        MakeValidDir(wa.szCurrentPath1);
    44214442      }
    44224443      else
    4423         save_dir2(wa.szCurrentPath1);
     4444        save_dir2(wa.szCurrentPath1);
    44244445      TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
    44254446      if (!*wa.szCurrentPath2)
    4426         strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
     4447        strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
    44274448      MakeValidDir(wa.szCurrentPath2);
    44284449      if (WinDlgBox(HWND_DESKTOP,
    4429                     hwnd,
    4430                     WalkTwoCmpDlgProc,
    4431                     FM3ModHandle,
    4432                     WALK2_FRAME,
    4433                     MPFROMP(&wa)) &&
    4434           !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
    4435         if (!*dircompare) {
    4436 
    4437           COMPARE *cmp;
    4438 
    4439           cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    4440           if (cmp) {
    4441             cmp->size = sizeof(COMPARE);
    4442             strcpy(cmp->leftdir, wa.szCurrentPath1);
    4443             strcpy(cmp->rightdir, wa.szCurrentPath2);
    4444             cmp->hwndParent = hwnd;
    4445             cmp->dcd.hwndParent = hwnd;
    4446             WinDlgBox(HWND_DESKTOP,
    4447                       HWND_DESKTOP,
    4448                       CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    4449           }
    4450         }
    4451         else {
    4452 
    4453           CHAR szPath1[CCHMAXPATH];
    4454           CHAR szPath2[CCHMAXPATH];
    4455           runemf2(SEPARATE,
    4456                   HWND_DESKTOP, pszSrcFile, __LINE__,
    4457                   NULL, NULL,
    4458                   "%s %s %s",
    4459                   dircompare,
    4460                   BldQuotedFileName(szPath1, wa.szCurrentPath1),
    4461                   BldQuotedFileName(szPath2, wa.szCurrentPath2));
    4462         }
     4450                    hwnd,
     4451                    WalkTwoCmpDlgProc,
     4452                    FM3ModHandle,
     4453                    WALK2_FRAME,
     4454                    MPFROMP(&wa)) &&
     4455          !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
     4456        if (!*dircompare) {
     4457
     4458          COMPARE *cmp;
     4459
     4460          cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
     4461          if (cmp) {
     4462            cmp->size = sizeof(COMPARE);
     4463            strcpy(cmp->leftdir, wa.szCurrentPath1);
     4464            strcpy(cmp->rightdir, wa.szCurrentPath2);
     4465            cmp->hwndParent = hwnd;
     4466            cmp->dcd.hwndParent = hwnd;
     4467            WinDlgBox(HWND_DESKTOP,
     4468                      HWND_DESKTOP,
     4469                      CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
     4470          }
     4471        }
     4472        else {
     4473
     4474          CHAR szPath1[CCHMAXPATH];
     4475          CHAR szPath2[CCHMAXPATH];
     4476          runemf2(SEPARATE,
     4477                  HWND_DESKTOP, pszSrcFile, __LINE__,
     4478                  NULL, NULL,
     4479                  "%s %s %s",
     4480                  dircompare,
     4481                  BldQuotedFileName(szPath1, wa.szCurrentPath1),
     4482                  BldQuotedFileName(szPath2, wa.szCurrentPath2));
     4483        }
    44634484      }
    44644485    }
     
    44724493  case IDM_CLI:
    44734494    if (fSplitStatus &&
    4474         hwndStatus2 &&
    4475         !WinIsWindow(WinQueryAnchorBlock(hwnd),
    4476                      WinWindowFromID(hwndStatus2, COMMAND_LINE)))
     4495        hwndStatus2 &&
     4496        !WinIsWindow(WinQueryAnchorBlock(hwnd),
     4497                     WinWindowFromID(hwndStatus2, COMMAND_LINE)))
    44774498      PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
    44784499    break;
     
    44874508      bstrip(temp);
    44884509      if (*temp &&
    4489           !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
    4490         if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
    4491           add_udir(TRUE, path);
    4492           if (fUdirsChanged)
    4493             save_udirs();
    4494           WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4495         }
    4496         else {
    4497           if (!remove_udir(path))
    4498             Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
    4499           else {
    4500             if (fUdirsChanged)
    4501               save_udirs();
    4502             WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4503           }
    4504         }
     4510          !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
     4511        if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
     4512          add_udir(TRUE, path);
     4513          if (fUdirsChanged)
     4514            save_udirs();
     4515          WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4516        }
     4517        else {
     4518          if (!remove_udir(path))
     4519            Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
     4520          else {
     4521            if (fUdirsChanged)
     4522              save_udirs();
     4523            WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4524          }
     4525        }
    45054526      }
    45064527    }
     
    45174538      // Ignore request if blank or attempting to using illegal name
    45184539      if (*szStateName && stricmp(szStateName, GetPString(IDS_STATETEXT))) {
    4519         if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
    4520           // Save
    4521           INT nSaved = SaveDirCnrState(hwnd, szStateName);
    4522           if (nSaved > 0) {
    4523             INT ret = add_setup(szStateName);
    4524             if (ret == 0) {
    4525               WinSendMsg(hwndStatelist, LM_INSERTITEM,
    4526                         MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    4527               save_setups();
    4528             }
    4529             else if (ret != 1) {
    4530               saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4531                      GetPString(IDS_WARNINGTEXT),
    4532                      "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    4533               WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4534             }
    4535           }
    4536           else {
    4537             saymsg(MB_ENTER | MB_ICONASTERISK,
    4538                    hwnd,
    4539                    GetPString(IDS_WARNINGTEXT),
    4540                    nSaved == 0 ?
    4541                      "Nothing to save" :
    4542                      "State data save failed");
    4543             WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4544           }
    4545         }
    4546         else {
    4547           // Delete
    4548           ULONG numsaves = 0, size, x;
    4549           CHAR s[STATE_NAME_MAX_BYTES + 80];
    4550 
    4551           INT ret = remove_setup(szStateName);
    4552           if (ret == 1)
    4553             save_setups();
    4554           sprintf(s, "%s.NumDirsLastTime", szStateName);
    4555           size = sizeof(ULONG);
    4556           if (!PrfQueryProfileData(fmprof,
    4557                                    FM3Str,
    4558                                    s,
    4559                                    (PVOID)&numsaves,
    4560                                    &size)) {
    4561             saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4562                    GetPString(IDS_WARNINGTEXT),
    4563                    GetPString(IDS_DOESNTEXISTTEXT), szStateName);
    4564           }
    4565           else if (!size)
    4566             Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    4567           else {
    4568             PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4569             for (x = 0; x < numsaves; x++) {
    4570               sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4571               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4572               sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4573               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4574               sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4575               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4576               sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4577               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4578               sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4579               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4580               sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
    4581               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4582               sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
    4583               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4584               sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
    4585               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4586               sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
    4587               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4588               sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
    4589               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4590               sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
    4591               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4592               sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
    4593               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4594               sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
    4595               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4596               sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
    4597               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4598               sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
    4599               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4600               sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
    4601               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4602             }
    4603             sprintf(s, "%s.LastTreePos", szStateName);
    4604             PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4605             sprintf(s, "%s.MySizeLastTime", szStateName);
    4606             PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4607           }
    4608           PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
    4609         }
     4540        if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
     4541          // Save
     4542          INT nSaved = SaveDirCnrState(hwnd, szStateName);
     4543          if (nSaved > 0) {
     4544            INT ret = add_setup(szStateName);
     4545            if (ret == 0) {
     4546              WinSendMsg(hwndStatelist, LM_INSERTITEM,
     4547                        MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
     4548              save_setups();
     4549            }
     4550            else if (ret != 1) {
     4551              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4552                     GetPString(IDS_WARNINGTEXT),
     4553                     "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
     4554              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4555            }
     4556          }
     4557          else {
     4558            saymsg(MB_ENTER | MB_ICONASTERISK,
     4559                   hwnd,
     4560                   GetPString(IDS_WARNINGTEXT),
     4561                   nSaved == 0 ?
     4562                     "Nothing to save" :
     4563                     "State data save failed");
     4564            WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4565          }
     4566        }
     4567        else {
     4568          // Delete
     4569          ULONG numsaves = 0, size, x;
     4570          CHAR s[STATE_NAME_MAX_BYTES + 80];
     4571
     4572          INT ret = remove_setup(szStateName);
     4573          if (ret == 1)
     4574            save_setups();
     4575          sprintf(s, "%s.NumDirsLastTime", szStateName);
     4576          size = sizeof(ULONG);
     4577          if (!PrfQueryProfileData(fmprof,
     4578                                   FM3Str,
     4579                                   s,
     4580                                   (PVOID)&numsaves,
     4581                                   &size)) {
     4582            saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4583                   GetPString(IDS_WARNINGTEXT),
     4584                   GetPString(IDS_DOESNTEXISTTEXT), szStateName);
     4585          }
     4586          else if (!size)
     4587            Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     4588          else {
     4589            PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     4590            for (x = 0; x < numsaves; x++) {
     4591              sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
     4592              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4593              sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
     4594              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4595              sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
     4596              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4597              sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
     4598              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4599              sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
     4600              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4601              sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
     4602              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4603              sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
     4604              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4605              sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
     4606              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4607              sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
     4608              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4609              sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
     4610              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4611              sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
     4612              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4613              sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
     4614              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4615              sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
     4616              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4617              sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
     4618              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4619              sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
     4620              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4621              sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
     4622              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4623            }
     4624            sprintf(s, "%s.LastTreePos", szStateName);
     4625            PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4626            sprintf(s, "%s.MySizeLastTime", szStateName);
     4627            PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4628          }
     4629          PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     4630        }
    46104631      }
    46114632    }
     
    46204641      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    46214642      if (swp.fl & SWP_MAXIMIZE) {
    4622         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
    4623                    MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    4624         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     4643        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
     4644                   MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     4645        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    46254646      }
    46264647      WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
     
    46304651      swpD.cy -= (icz + bsz);
    46314652      if (swp.x == swpD.x && swp.y == swpD.y &&
    4632           swp.cx == swpD.cx && swp.cy == swpD.cy &&
    4633           // fixme to be #defined someday
    4634           WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
    4635           WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
    4636         swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
    4637         swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
    4638         swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
    4639         swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
     4653          swp.cx == swpD.cx && swp.cy == swpD.cy &&
     4654          // fixme to be #defined someday
     4655          WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
     4656          WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
     4657        swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
     4658        swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
     4659        swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
     4660        swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
    46404661      }
    46414662      else {
    4642         WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
    4643         WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
    4644         WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
    4645         WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
     4663        WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
     4664        WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
     4665        WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
     4666        WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
    46464667      }
    46474668      WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
    4648                       swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
     4669                      swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
    46494670    }
    46504671    break;
     
    46524673  case IDM_BLINK:
    46534674    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4654                     SWP_MINIMIZE);
     4675                    SWP_MINIMIZE);
    46554676    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4656                     SWP_RESTORE | SWP_ZORDER);
     4677                    SWP_RESTORE | SWP_ZORDER);
    46574678    break;
    46584679
     
    46624683
    46634684      if (hwndTop)
    4664         WinSetFocus(HWND_DESKTOP, hwndTop);
     4685        WinSetFocus(HWND_DESKTOP, hwndTop);
    46654686    }
    46664687    break;
     
    46754696  case IDM_QUICKSETTINGS:
    46764697    WinDlgBox(HWND_DESKTOP,
    4677               hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
     4698              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
    46784699    break;
    46794700
     
    46814702  case IDM_VIEWINFS:
    46824703    WinDlgBox(HWND_DESKTOP,
    4683               HWND_DESKTOP,
    4684               ViewInfProc,
    4685               FM3ModHandle,
    4686               VINF_FRAME,
    4687               ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
    4688                MPFROMP(NullStr) : MPVOID));
     4704              HWND_DESKTOP,
     4705              ViewInfProc,
     4706              FM3ModHandle,
     4707              VINF_FRAME,
     4708              ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
     4709               MPFROMP(NullStr) : MPVOID));
    46894710    break;
    46904711
     
    46964717      TopWindowName(hwnd, (HWND) 0, newpath);
    46974718      if (WinDlgBox(HWND_DESKTOP,
    4698                     hwnd,
    4699                     WalkAllDlgProc,
    4700                     FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
    4701         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
     4719                    hwnd,
     4720                    WalkAllDlgProc,
     4721                    FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
     4722        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
    47024723    }
    47034724    break;
     
    47204741      if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    47214742
    4722         RECTL rcl;
    4723         ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
    4724 
    4725         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4726         rcl.yBottom += icz;
    4727         rcl.yTop -= icz;
    4728         rcl.xLeft += icz;
    4729         rcl.xRight -= icz;
    4730         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4743        RECTL rcl;
     4744        ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
     4745
     4746        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4747        rcl.yBottom += icz;
     4748        rcl.yTop -= icz;
     4749        rcl.xLeft += icz;
     4750        rcl.xRight -= icz;
     4751        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    47314752      }
    47324753      else {
    47334754
    4734         RECTL rcl;
    4735 
    4736         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4737         rcl.yBottom += 8;
    4738         rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
    4739         rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
    4740         rcl.xRight -= 8;
    4741         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4755        RECTL rcl;
     4756
     4757        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4758        rcl.yBottom += 8;
     4759        rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
     4760        rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
     4761        rcl.xRight -= 8;
     4762        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    47424763      }
    47434764      switch (SHORT1FROMMP(mp1)) {
    47444765      case IDM_HELPCONTEXT:
    4745         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4746                    MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
    4747         break;
     4766        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4767                   MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
     4768        break;
    47484769
    47494770      case IDM_HELPMOUSE:
    4750         if (hwndHelp)
    4751           WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4752                      MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
    4753         break;
     4771        if (hwndHelp)
     4772          WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4773                     MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
     4774        break;
    47544775
    47554776      case IDM_HELPPIX:
    4756         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4757                    MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
    4758         break;
     4777        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4778                   MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
     4779        break;
    47594780
    47604781      case IDM_HELPTUTOR:
    4761         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4762                    MPFROM2SHORT(HELP_TUTORIAL, 0),
    4763                    MPFROMSHORT(HM_RESOURCEID));
    4764         break;
     4782        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4783                   MPFROM2SHORT(HELP_TUTORIAL, 0),
     4784                   MPFROMSHORT(HM_RESOURCEID));
     4785        break;
    47654786
    47664787      case IDM_HELPHINTS:
    4767         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4768                    MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
    4769         break;
     4788        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4789                   MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
     4790        break;
    47704791
    47714792      case IDM_HELPGENERAL:
    4772         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4773                    MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
    4774         break;
     4793        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4794                   MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
     4795        break;
    47754796      case IDM_HELPKEYS:
    4776         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4777                    MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
    4778         break;
     4797        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4798                   MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
     4799        break;
    47794800
    47804801      case IDM_HELP:
    47814802      case IDM_HELPCONTENTS:
    4782         WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
    4783         break;
     4803        WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
     4804        break;
    47844805
    47854806      case IDM_HELPUSERLIST:
    4786         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4787                    MPFROM2SHORT(HELP_USERLISTS, 0),
    4788                    MPFROMSHORT(HM_RESOURCEID));
    4789         break;
     4807        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4808                   MPFROM2SHORT(HELP_USERLISTS, 0),
     4809                   MPFROMSHORT(HM_RESOURCEID));
     4810        break;
    47904811      }
    47914812    }
     
    47984819  case IDM_ABOUT:
    47994820    WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
    4800               ABT_FRAME, MPVOID);
     4821              ABT_FRAME, MPVOID);
    48014822    break;
    48024823
     
    48124833
    48134834      if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
    4814                            (PVOID) & version, (ULONG) sizeof(version))) {
    4815         if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
    4816           if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
    4817             palette = "<WP_HIRESCLRPAL>";
    4818           else
    4819             palette = "<WP_LORESCLRPAL>";
    4820         }
     4835                           (PVOID) & version, (ULONG) sizeof(version))) {
     4836        if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
     4837          if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
     4838            palette = "<WP_HIRESCLRPAL>";
     4839          else
     4840            palette = "<WP_LORESCLRPAL>";
     4841        }
    48214842      }
    48224843      OpenObject(palette, Default, hwnd);
     
    48344855      hWPSObject = WinQueryObject("<WP_SCHPAL>");
    48354856      if (hWPSObject != NULLHANDLE)
    4836         WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
    4837                         "Spring:PM_Spring,Summer:PM_Summer,"
    4838                         "System:PM_System,Windows:PM_Windows;"
    4839                         "OPEN=DEFAULT");
     4857        WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
     4858                        "Spring:PM_Spring,Summer:PM_Summer,"
     4859                        "System:PM_System,Windows:PM_Windows;"
     4860                        "OPEN=DEFAULT");
    48404861    }
    48414862    break;
     
    48484869  case IDM_SYSINFO:
    48494870    WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
    4850               SYS_FRAME, NULL);
     4871              SYS_FRAME, NULL);
    48514872    break;
    48524873#endif
     
    48584879
    48594880      if (hwndTree)
    4860         pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
    4861                                     MPFROMLONG(CMA_FIRST),
    4862                                     MPFROMSHORT(CRA_CURSORED));
     4881        pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
     4882                                    MPFROMLONG(CMA_FIRST),
     4883                                    MPFROMSHORT(CRA_CURSORED));
    48634884      if (pci && (INT) pci != -1) {
    4864         strcpy(path, pci->pszFileName);
    4865         MakeValidDir(path);
     4885        strcpy(path, pci->pszFileName);
     4886        MakeValidDir(path);
    48664887      }
    48674888      else
    4868         save_dir2(path);
     4889        save_dir2(path);
    48694890      WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
    4870                 BAT_FRAME, MPFROMP(path));
     4891                BAT_FRAME, MPFROMP(path));
    48714892    }
    48724893    break;
     
    48824903      TopWindowName(hwnd, (HWND) 0, path);
    48834904      if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
    4884         env = GetCmdSpec(TRUE);
     4905        env = GetCmdSpec(TRUE);
    48854906      else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
    4886         env = "WINOS2.COM";
    4887         type = SEPARATE | FULLSCREEN;
     4907        env = "WINOS2.COM";
     4908        type = SEPARATE | FULLSCREEN;
    48884909      }
    48894910      runemf2(type, hwnd, pszSrcFile, __LINE__,
    4890               path, NULL, "%s", env);
     4911              path, NULL, "%s", env);
    48914912    }
    48924913    break;
     
    48944915  case IDM_KILLPROC:
    48954916    WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
    4896               KILL_FRAME, NULL);
     4917              KILL_FRAME, NULL);
    48974918    break;
    48984919
     
    49094930  case IDM_AUTOVIEW:
    49104931    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    4911                 &fAutoView, TRUE, "AutoView");
     4932                &fAutoView, TRUE, "AutoView");
    49124933  AutoChange:
    49134934    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    4914             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     4935            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    49154936    if (fAutoView) {
    49164937
     
    49214942      hwndDir = TopWindowName(hwnd, (HWND) 0, s);
    49224943      if (hwndDir) {
    4923         hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
    4924         if (hwndDir) {
    4925           hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
    4926           if (hwndDir) {
    4927             pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
    4928                                         MPFROMLONG(CMA_FIRST),
    4929                                         MPFROMSHORT(CRA_CURSORED));
    4930             if (pci && (INT) pci != -1 &&
    4931                 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
    4932               WinSendMsg(hwnd,
    4933                         UM_LOADFILE,
    4934                         MPFROMP(pci->pszFileName),
    4935                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    4936                         MPVOID : MPFROMLONG(1));
    4937           }
    4938         }
     4944        hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
     4945        if (hwndDir) {
     4946          hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
     4947          if (hwndDir) {
     4948            pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
     4949                                        MPFROMLONG(CMA_FIRST),
     4950                                        MPFROMSHORT(CRA_CURSORED));
     4951            if (pci && (INT) pci != -1 &&
     4952                (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
     4953              WinSendMsg(hwnd,
     4954                        UM_LOADFILE,
     4955                        MPFROMP(pci->pszFileName),
     4956                        (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
     4957                        MPVOID : MPFROMLONG(1));
     4958          }
     4959        }
    49394960      }
    49404961    }
     
    49434964  case IDM_TEXTTOOLS:
    49444965    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    4945                 &fTextTools, TRUE, "TextTools");
     4966                &fTextTools, TRUE, "TextTools");
    49464967    BuildTools(hwndToolback, TRUE);
    49474968    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    4948             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     4969            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    49494970    break;
    49504971
    49514972  case IDM_TOOLTITLES:
    49524973    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    4953                 &fToolTitles, TRUE, "ToolTitles");
     4974                &fToolTitles, TRUE, "ToolTitles");
    49544975    BuildTools(hwndToolback, TRUE);
    49554976    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    4956             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     4977            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    49574978    break;
    49584979
     
    49644985      MenuInvisible = (MenuInvisible) ? FALSE : TRUE;
    49654986      if (MenuInvisible) {
    4966         WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
    4967         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    4968                                            FID_SYSMENU), IDM_HIDEMENU,
    4969                            GetPString(IDS_UNHIDEMENUTEXT));
     4987        WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
     4988        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     4989                                           FID_SYSMENU), IDM_HIDEMENU,
     4990                           GetPString(IDS_UNHIDEMENUTEXT));
    49704991      }
    49714992      else {
    4972         WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
    4973         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    4974                                            FID_SYSMENU), IDM_HIDEMENU,
    4975                            GetPString(IDS_HIDEMENUTEXT));
     4993        WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
     4994        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     4995                                           FID_SYSMENU), IDM_HIDEMENU,
     4996                           GetPString(IDS_HIDEMENUTEXT));
    49764997      }
    49774998      PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    4978               MPFROMLONG(FCF_MENU), MPVOID);
     4999              MPFROMLONG(FCF_MENU), MPVOID);
    49795000      PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
    4980                           &MenuInvisible, sizeof(BOOL));
     5001                          &MenuInvisible, sizeof(BOOL));
    49815002    }
    49825003    break;
     
    49915012
    49925013      if (Collector)
    4993         already = TRUE;
     5014        already = TRUE;
    49945015      if (!already && !fAutoTile && !fExternalCollector)
    4995         GetNextWindowPos(hwnd, &swp, NULL, NULL);
     5016        GetNextWindowPos(hwnd, &swp, NULL, NULL);
    49965017      hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
    49975018      if (hwndC) {
    4998         if (!already && !fAutoTile && !fExternalCollector)
    4999           WinSetWindowPos(hwndC, HWND_TOP,
    5000                           swp.x, swp.y, swp.cx, swp.cy,
    5001                           SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    5002         else if (fAutoTile && !already)
    5003           TileChildren(hwnd, TRUE);
    5004         WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
    5005                         SWP_ACTIVATE);
    5006         if (SHORT1FROMMP(mp1) == IDM_GREP)
    5007           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5008                   MPFROM2SHORT(IDM_GREP, 0), MPVOID);
    5009         if (SHORT1FROMMP(mp1) == IDM_SEEALL)
    5010           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5011                   MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
     5019        if (!already && !fAutoTile && !fExternalCollector)
     5020          WinSetWindowPos(hwndC, HWND_TOP,
     5021                          swp.x, swp.y, swp.cx, swp.cy,
     5022                          SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     5023        else if (fAutoTile && !already)
     5024          TileChildren(hwnd, TRUE);
     5025        WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
     5026                        SWP_ACTIVATE);
     5027        if (SHORT1FROMMP(mp1) == IDM_GREP)
     5028          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5029                  MPFROM2SHORT(IDM_GREP, 0), MPVOID);
     5030        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     5031          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5032                  MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
    50125033      }
    50135034    }
     
    50205041
    50215042      if (!toolhead || !toolhead->next) {
    5022         firsttool = (toolhead) ? toolhead->id : 0;
    5023         break;
     5043        firsttool = (toolhead) ? toolhead->id : 0;
     5044        break;
    50245045      }
    50255046      tool = find_tool(firsttool);
    50265047      if (!tool)
    5027         tool = toolhead;
     5048        tool = toolhead;
    50285049      if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
    5029         tool = prev_tool(tool, TRUE);
    5030         firsttool = tool->id;
     5050        tool = prev_tool(tool, TRUE);
     5051        firsttool = tool->id;
    50315052      }
    50325053      else {
    5033         tool = next_tool(tool, TRUE);
    5034         firsttool = tool->id;
     5054        tool = next_tool(tool, TRUE);
     5055        firsttool = tool->id;
    50355056      }
    50365057      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5037                                   MAIN_TOOLS));
     5058                                  MAIN_TOOLS));
    50385059    }
    50395060    break;
     
    50455066  case IDM_TOOLBAR:
    50465067    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5047                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
     5068                IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    50485069    BuildTools(hwndToolback, TRUE);
    50495070    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5050                                   MAIN_TOOLS), fToolbar);
     5071                                  MAIN_TOOLS), fToolbar);
    50515072    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    5052                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5073               WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50535074    if (fDrivebar)
    50545075      WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5055                                         MAIN_DRIVES), NULL, TRUE);
     5076                                        MAIN_DRIVES), NULL, TRUE);
    50565077    break;
    50575078
    50585079  case IDM_DRIVEBAR:
    50595080    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5060                 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
     5081                IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
    50615082    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5062                                   MAIN_DRIVES), fDrivebar);
     5083                                  MAIN_DRIVES), fDrivebar);
    50635084    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5064             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5085            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50655086    PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    50665087    break;
     
    50685089  case IDM_USERLIST:
    50695090    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5070                 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
     5091                SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
    50715092    WinShowWindow(hwndUserlist, fUserComboBox);
    50725093    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5073             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5094            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50745095    PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    50755096    PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    50835104    WinSetWindowText(hwndAttr, NullStr);
    50845105    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5085                 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
     5106                SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
    50865107    if (fMoreButtons) {
    50875108
     
    50915112
    50925113      if (hwndTemp) {
    5093         WinSetFocus(HWND_DESKTOP, hwnd);
    5094         WinSetFocus(HWND_DESKTOP, hwndTemp);
     5114        WinSetFocus(HWND_DESKTOP, hwnd);
     5115        WinSetFocus(HWND_DESKTOP, hwndTemp);
    50955116      }
    50965117    }
    50975118    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5098             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5119            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50995120    break;
    51005121
    51015122  case IDM_TOGGLEDRAGDIALOG:
    51025123    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5103                 IDM_TOGGLEDRAGDIALOG,
    5104                 &fDragndropDlg,
    5105                 TRUE,
    5106                 "Drag&DropDlg");
     5124                IDM_TOGGLEDRAGDIALOG,
     5125                &fDragndropDlg,
     5126                TRUE,
     5127                "Drag&DropDlg");
    51075128    break;
    51085129
    51095130  case IDM_SYNCUPDATES:
    51105131    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5111                 IDM_SYNCUPDATES,
    5112                 &fSyncUpdates,
    5113                 TRUE,
    5114                 "SyncUpdates");
     5132                IDM_SYNCUPDATES,
     5133                &fSyncUpdates,
     5134                TRUE,
     5135                "SyncUpdates");
    51155136    break;
    51165137
     
    51225143      WinQueryWindowPos(hwnd, &swp);
    51235144      WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
    5124                       SWP_MOVE);
     5145                      SWP_MOVE);
    51255146    }
    51265147    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5127                 &fFreeTree, TRUE, "FreeTree");
     5148                &fFreeTree, TRUE, "FreeTree");
    51285149    if (fAutoTile)
    51295150      TileChildren(hwnd, TRUE);
     
    51325153  case IDM_AUTOTILE:
    51335154    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5134                 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
     5155                SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
    51355156    if (fAutoTile)
    51365157      TileChildren(hwnd, TRUE);
     
    51395160  case IDM_TILEBACKWARDS:
    51405161    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5141                 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
     5162                SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
    51425163    if (fAutoTile)
    51435164      TileChildren(hwnd, TRUE);
     
    51845205  default:
    51855206    if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
    5186                        SHORT1FROMMP(mp1))) {
     5207                       SHORT1FROMMP(mp1))) {
    51875208      if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    5188           SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    5189 
    5190         INT x;
    5191         HWND hwndCnr;
    5192 
    5193         if (!cmdloaded)
    5194           load_commands();
    5195         hwndCnr = TopWindow(hwnd, (HWND) 0);
    5196         hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
    5197                                     UM_CONTAINERHWND, MPVOID, MPVOID);
    5198         if (!hwndCnr) {
    5199           Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
    5200           break;
    5201         }
    5202         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    5203         if (x >= 0) {
    5204           x++;
    5205           RunCommand(hwndCnr, x);
    5206           if (fUnHilite) {
    5207 
    5208             PCNRITEM pci;
    5209             DIRCNRDATA *dcd = NULL;
    5210 
    5211             // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
    5212             if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
    5213               dcd = INSTDATA(hwndCnr);
    5214             pci = (PCNRITEM) WinSendMsg(hwndCnr,
    5215                                         CM_QUERYRECORDEMPHASIS,
    5216                                         MPFROMLONG(CMA_FIRST),
    5217                                         MPFROMSHORT(CRA_CURSORED));
    5218             if (pci && (INT) pci != -1 &&
    5219                 (pci->rc.flRecordAttr & CRA_SELECTED))
    5220             {
    5221               UnHilite(hwnd,
    5222                        TRUE,
    5223                        dcd ? &dcd->lastselection : NULL,
    5224                        dcd ? dcd ->ulItemsToUnHilite : 0);
    5225             }
    5226           }
    5227         }
     5209          SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
     5210
     5211        INT x;
     5212        HWND hwndCnr;
     5213
     5214        if (!cmdloaded)
     5215          load_commands();
     5216        hwndCnr = TopWindow(hwnd, (HWND) 0);
     5217        hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     5218                                    UM_CONTAINERHWND, MPVOID, MPVOID);
     5219        if (!hwndCnr) {
     5220          Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
     5221          break;
     5222        }
     5223        x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     5224        if (x >= 0) {
     5225          x++;
     5226          RunCommand(hwndCnr, x);
     5227          if (fUnHilite) {
     5228
     5229            PCNRITEM pci;
     5230            DIRCNRDATA *dcd = NULL;
     5231
     5232            // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
     5233            if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     5234              dcd = INSTDATA(hwndCnr);
     5235            pci = (PCNRITEM) WinSendMsg(hwndCnr,
     5236                                        CM_QUERYRECORDEMPHASIS,
     5237                                        MPFROMLONG(CMA_FIRST),
     5238                                        MPFROMSHORT(CRA_CURSORED));
     5239            if (pci && (INT) pci != -1 &&
     5240                (pci->rc.flRecordAttr & CRA_SELECTED))
     5241            {
     5242              UnHilite(hwnd,
     5243                       TRUE,
     5244                       dcd ? &dcd->lastselection : NULL,
     5245                       dcd ? dcd ->ulItemsToUnHilite : 0);
     5246            }
     5247          }
     5248        }
    52285249      }
    52295250      else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    5230                SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
    5231         if (!qtloaded)
    5232           load_quicktools();
    5233         if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
    5234           if (fToolsChanged)
    5235             save_tools(NULL);
    5236           if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
    5237             load_tools(NULL);
    5238           else {
    5239             strcpy(lasttoolbox,
    5240                    quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    5241             PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
    5242           }
    5243           BuildTools(hwndToolback, TRUE);
    5244         }
     5251               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
     5252        if (!qtloaded)
     5253          load_quicktools();
     5254        if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
     5255          if (fToolsChanged)
     5256            save_tools(NULL);
     5257          if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
     5258            load_tools(NULL);
     5259          else {
     5260            strcpy(lasttoolbox,
     5261                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
     5262            PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
     5263          }
     5264          BuildTools(hwndToolback, TRUE);
     5265        }
    52455266      }
    52465267      else {
    52475268
    5248         HWND hwndActive;
    5249 
    5250         hwndActive = TopWindow(hwnd, (HWND) 0);
    5251         if (hwndActive)
    5252           PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    5253                   WM_COMMAND, mp1, mp2);
     5269        HWND hwndActive;
     5270
     5271        hwndActive = TopWindow(hwnd, (HWND) 0);
     5272        if (hwndActive)
     5273          PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     5274                  WM_COMMAND, mp1, mp2);
    52545275      }
    52555276    }
     
    52605281
    52615282static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
    5262                                    MPARAM mp2)
     5283                                   MPARAM mp2)
    52635284{
    52645285  TID tid;
     
    52835304    if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
    52845305      Runtime_Error(pszSrcFile, __LINE__,
    5285                     GetPString(IDS_COULDNTSTARTTHREADTEXT));
     5306                    GetPString(IDS_COULDNTSTARTTHREADTEXT));
    52865307      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    52875308      return 0;
     
    53025323
    53035324    if (!WinCreateWindow(hwndFrame,
    5304                         WC_BUTTON,
    5305                         "I",
    5306                         WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
    5307                         ((swp.cx -
    5308                            WinQuerySysValue(HWND_DESKTOP,
    5309                                             SV_CXMINMAXBUTTON)) -
    5310                           WinQuerySysValue(HWND_DESKTOP,
    5311                                            SV_CXMINMAXBUTTON) / 2) -
    5312                         WinQuerySysValue(HWND_DESKTOP,
    5313                                           SV_CXSIZEBORDER),
    5314                         (swp.cy - WinQuerySysValue(HWND_DESKTOP,
    5315                                                     SV_CYMINMAXBUTTON)) -
    5316                         WinQuerySysValue(HWND_DESKTOP,
    5317                                           SV_CYSIZEBORDER),
    5318                         WinQuerySysValue(HWND_DESKTOP,
    5319                                           SV_CXMINMAXBUTTON) / 2,
    5320                         WinQuerySysValue(HWND_DESKTOP,
    5321                                           SV_CYMINMAXBUTTON),
    5322                         hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
     5325                        WC_BUTTON,
     5326                        "I",
     5327                        WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
     5328                        ((swp.cx -
     5329                           WinQuerySysValue(HWND_DESKTOP,
     5330                                            SV_CXMINMAXBUTTON)) -
     5331                          WinQuerySysValue(HWND_DESKTOP,
     5332                                           SV_CXMINMAXBUTTON) / 2) -
     5333                        WinQuerySysValue(HWND_DESKTOP,
     5334                                          SV_CXSIZEBORDER),
     5335                        (swp.cy - WinQuerySysValue(HWND_DESKTOP,
     5336                                                    SV_CYMINMAXBUTTON)) -
     5337                        WinQuerySysValue(HWND_DESKTOP,
     5338                                          SV_CYSIZEBORDER),
     5339                        WinQuerySysValue(HWND_DESKTOP,
     5340                                          SV_CXMINMAXBUTTON) / 2,
     5341                        WinQuerySysValue(HWND_DESKTOP,
     5342                                          SV_CYMINMAXBUTTON),
     5343                        hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
    53235344      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    53245345    }
    53255346    else {
    53265347      WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
    5327                         IdealButtonProc);
     5348                        IdealButtonProc);
    53285349      SetPresParams(WinWindowFromID(hwndFrame,
    5329                                     IDM_IDEALSIZE),
    5330                     NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
     5350                                    IDM_IDEALSIZE),
     5351                    NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
    53315352    }
    53325353
    53335354    hwndTmp = WinCreateWindow(hwndFrame,
    5334                               WC_BUTTON,
    5335                               "#1019",
    5336                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5337                               BS_BITMAP,
    5338                               swp.cx - 46,
    5339                               swp.y + 2,
    5340                               24,
    5341                               22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
     5355                              WC_BUTTON,
     5356                              "#1019",
     5357                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5358                              BS_BITMAP,
     5359                              swp.cx - 46,
     5360                              swp.y + 2,
     5361                              24,
     5362                              22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
    53425363    if (!hwndTmp)
    53435364      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    53445365
    53455366    hwndTmp = WinCreateWindow(hwndFrame,
    5346                               WC_BUTTON,
    5347                               "#3062",
    5348                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5349                               BS_BITMAP,
    5350                               swp.cx - 22,
    5351                               swp.y + 2,
    5352                               24,
    5353                               22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
     5367                              WC_BUTTON,
     5368                              "#3062",
     5369                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5370                              BS_BITMAP,
     5371                              swp.cx - 22,
     5372                              swp.y + 2,
     5373                              24,
     5374                              22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
    53545375    if (!hwndTmp)
    53555376      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    53565377
    53575378    hwndUserlist = WinCreateWindow(hwndFrame,
    5358                                    WC_COMBOBOX,
    5359                                    (PSZ) NULL,
    5360                                    WS_VISIBLE | CBS_DROPDOWN |
    5361                                    LS_HORZSCROLL,
    5362                                    (swp.x +
    5363                                     WinQuerySysValue(HWND_DESKTOP,
    5364                                                      SV_CXSIZEBORDER) + 48L),
    5365                                    (swp.cy -
    5366                                     WinQuerySysValue(HWND_DESKTOP,
    5367                                                      SV_CYSIZEBORDER)) - 60,
    5368                                    ((swp.cx -
    5369                                      (WinQuerySysValue(HWND_DESKTOP,
    5370                                                        SV_CXSIZEBORDER) *
    5371                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5372                                    MAIN_USERLIST, NULL, NULL);
     5379                                   WC_COMBOBOX,
     5380                                   (PSZ) NULL,
     5381                                   WS_VISIBLE | CBS_DROPDOWN |
     5382                                   LS_HORZSCROLL,
     5383                                   (swp.x +
     5384                                    WinQuerySysValue(HWND_DESKTOP,
     5385                                                     SV_CXSIZEBORDER) + 48L),
     5386                                   (swp.cy -
     5387                                    WinQuerySysValue(HWND_DESKTOP,
     5388                                                     SV_CYSIZEBORDER)) - 60,
     5389                                   ((swp.cx -
     5390                                     (WinQuerySysValue(HWND_DESKTOP,
     5391                                                       SV_CXSIZEBORDER) *
     5392                                      2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5393                                   MAIN_USERLIST, NULL, NULL);
    53735394    if (!hwndUserlist)
    53745395      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    53755396    hwndCmdlist = WinCreateWindow(hwndFrame,
    5376                                   WC_COMBOBOX,
    5377                                   (PSZ) NULL,
    5378                                   WS_VISIBLE | CBS_DROPDOWN |
    5379                                   LS_HORZSCROLL,
    5380                                   (swp.x +
    5381                                    WinQuerySysValue(HWND_DESKTOP,
    5382                                                     SV_CXSIZEBORDER) + 48L),
    5383                                   (swp.cy -
    5384                                    WinQuerySysValue(HWND_DESKTOP,
    5385                                                     SV_CYSIZEBORDER)) - 60,
    5386                                   ((swp.cx -
    5387                                     (WinQuerySysValue(HWND_DESKTOP,
    5388                                                       SV_CXSIZEBORDER) * 2)) -
    5389                                    64L), 60L, hwndFrame, HWND_TOP,
    5390                                   MAIN_CMDLIST, NULL, NULL);
     5397                                  WC_COMBOBOX,
     5398                                  (PSZ) NULL,
     5399                                  WS_VISIBLE | CBS_DROPDOWN |
     5400                                  LS_HORZSCROLL,
     5401                                  (swp.x +
     5402                                   WinQuerySysValue(HWND_DESKTOP,
     5403                                                    SV_CXSIZEBORDER) + 48L),
     5404                                  (swp.cy -
     5405                                   WinQuerySysValue(HWND_DESKTOP,
     5406                                                    SV_CYSIZEBORDER)) - 60,
     5407                                  ((swp.cx -
     5408                                    (WinQuerySysValue(HWND_DESKTOP,
     5409                                                      SV_CXSIZEBORDER) * 2)) -
     5410                                   64L), 60L, hwndFrame, HWND_TOP,
     5411                                  MAIN_CMDLIST, NULL, NULL);
    53915412    if (!hwndCmdlist)
    53925413      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    53935414    WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    53945415    hwndStatelist = WinCreateWindow(hwndFrame,
    5395                                     WC_COMBOBOX,
    5396                                     (PSZ) NULL,
    5397                                     WS_VISIBLE | CBS_DROPDOWN |
    5398                                     LS_HORZSCROLL,
    5399                                     (swp.x +
    5400                                      WinQuerySysValue(HWND_DESKTOP,
    5401                                                       SV_CXSIZEBORDER) + 48L),
    5402                                     (swp.cy -
    5403                                      WinQuerySysValue(HWND_DESKTOP,
    5404                                                       SV_CYSIZEBORDER)) - 60,
    5405                                     ((swp.cx -
    5406                                       (WinQuerySysValue(HWND_DESKTOP,
    5407                                                         SV_CXSIZEBORDER) *
    5408                                        2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5409                                     MAIN_SETUPLIST, NULL, NULL);
     5416                                    WC_COMBOBOX,
     5417                                    (PSZ) NULL,
     5418                                    WS_VISIBLE | CBS_DROPDOWN |
     5419                                    LS_HORZSCROLL,
     5420                                    (swp.x +
     5421                                     WinQuerySysValue(HWND_DESKTOP,
     5422                                                      SV_CXSIZEBORDER) + 48L),
     5423                                    (swp.cy -
     5424                                     WinQuerySysValue(HWND_DESKTOP,
     5425                                                      SV_CYSIZEBORDER)) - 60,
     5426                                    ((swp.cx -
     5427                                      (WinQuerySysValue(HWND_DESKTOP,
     5428                                                        SV_CXSIZEBORDER) *
     5429                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5430                                    MAIN_SETUPLIST, NULL, NULL);
    54105431    if (!hwndStatelist)
    54115432      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54125433
    54135434    hwndDrivelist = WinCreateWindow(hwndFrame,
    5414                                     WC_COMBOBOX,
    5415                                     (PSZ) NULL,
    5416                                     WS_VISIBLE | CBS_DROPDOWN,
    5417                                     (swp.x +
    5418                                      WinQuerySysValue(HWND_DESKTOP,
    5419                                                       SV_CXSIZEBORDER)),
    5420                                     (swp.cy -
    5421                                      WinQuerySysValue(HWND_DESKTOP,
    5422                                                       SV_CYSIZEBORDER)) - 60,
    5423                                     48L,
    5424                                     60L,
    5425                                     hwndFrame,
    5426                                     HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
     5435                                    WC_COMBOBOX,
     5436                                    (PSZ) NULL,
     5437                                    WS_VISIBLE | CBS_DROPDOWN,
     5438                                    (swp.x +
     5439                                     WinQuerySysValue(HWND_DESKTOP,
     5440                                                      SV_CXSIZEBORDER)),
     5441                                    (swp.cy -
     5442                                     WinQuerySysValue(HWND_DESKTOP,
     5443                                                      SV_CYSIZEBORDER)) - 60,
     5444                                    48L,
     5445                                    60L,
     5446                                    hwndFrame,
     5447                                    HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
    54275448    if (!hwndDrivelist)
    54285449      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54295450    SetPresParams(hwndDrivelist,
    5430                   NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
     5451                  NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
    54315452    hwndButtonlist = WinCreateWindow(hwndFrame,
    5432                                      WC_COMBOBOX,
    5433                                      (PSZ) NULL,
    5434                                      WS_VISIBLE | CBS_DROPDOWN |
    5435                                      LS_HORZSCROLL,
    5436                                      (swp.cx -
    5437                                       WinQuerySysValue(HWND_DESKTOP,
    5438                                                        SV_CXSIZEBORDER)) -
    5439                                      164L,
    5440                                      (swp.cy -
    5441                                       WinQuerySysValue(HWND_DESKTOP,
    5442                                                        SV_CYSIZEBORDER)) - 60,
    5443                                      164L, 60L, hwndFrame, HWND_TOP,
    5444                                      MAIN_BUTTONLIST, NULL, NULL);
     5453                                     WC_COMBOBOX,
     5454                                     (PSZ) NULL,
     5455                                     WS_VISIBLE | CBS_DROPDOWN |
     5456                                     LS_HORZSCROLL,
     5457                                     (swp.cx -
     5458                                      WinQuerySysValue(HWND_DESKTOP,
     5459                                                       SV_CXSIZEBORDER)) -
     5460                                     164L,
     5461                                     (swp.cy -
     5462                                      WinQuerySysValue(HWND_DESKTOP,
     5463                                                       SV_CYSIZEBORDER)) - 60,
     5464                                     164L, 60L, hwndFrame, HWND_TOP,
     5465                                     MAIN_BUTTONLIST, NULL, NULL);
    54455466    if (!hwndButtonlist)
    54465467      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54475468    WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5448                EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     5469               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    54495470    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5450                EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
     5471               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    54515472    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5452                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5473               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    54535474    WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5454                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5475               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    54555476    WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5456                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5477               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    54575478
    54585479    oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5459                                 DropDownListProc);
     5480                                DropDownListProc);
    54605481    WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5461                     QWL_USER, (PVOID) oldproc);
     5482                    QWL_USER, (PVOID) oldproc);
    54625483    oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5463                                 DropDownListProc);
     5484                                DropDownListProc);
    54645485    WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5465                     QWL_USER, (PVOID) oldproc);
     5486                    QWL_USER, (PVOID) oldproc);
    54665487    oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5467                                 DropDownListProc);
     5488                                DropDownListProc);
    54685489    WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5469                     QWL_USER, (PVOID) oldproc);
     5490                    QWL_USER, (PVOID) oldproc);
    54705491    oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5471                                 DropDownListProc);
     5492                                DropDownListProc);
    54725493    WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5473                     QWL_USER, (PVOID) oldproc);
     5494                    QWL_USER, (PVOID) oldproc);
    54745495    oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5475                                 DropDownListProc);
     5496                                DropDownListProc);
    54765497    WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5477                     QWL_USER, (PVOID) oldproc);
     5498                    QWL_USER, (PVOID) oldproc);
    54785499    oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
    54795500    WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
     
    54875508    WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
    54885509    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5489                                 ChildFrameButtonProc);
     5510                                ChildFrameButtonProc);
    54905511    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5491                     QWL_USER, (PVOID) oldproc);
     5512                    QWL_USER, (PVOID) oldproc);
    54925513    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5493                                 ChildFrameButtonProc);
     5514                                ChildFrameButtonProc);
    54945515    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5495                     QWL_USER, (PVOID) oldproc);
     5516                    QWL_USER, (PVOID) oldproc);
    54965517    hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
    54975518    WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
     
    55065527    hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
    55075528    idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
    5508                                         MM_ITEMIDFROMPOSITION,
    5509                                         MPVOID, MPVOID));
     5529                                        MM_ITEMIDFROMPOSITION,
     5530                                        MPVOID, MPVOID));
    55105531    WinSendMsg(hwndSysMenu,
    5511                MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
     5532               MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
    55125533    hwndSysSubMenu = mit.hwndSubMenu;
    55135534    mi.iPosition = MIT_END;
     
    55185539    mi.id = IDM_IDEALSIZE;
    55195540    WinSendMsg(hwndSysSubMenu,
    5520                MM_INSERTITEM,
    5521                MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
     5541               MM_INSERTITEM,
     5542               MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
    55225543    mi.afStyle = MIS_TEXT;
    55235544    mi.id = IDM_HIDEMENU;
    55245545    WinSendMsg(hwndSysSubMenu,
    5525                MM_INSERTITEM,
    5526                MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
     5546               MM_INSERTITEM,
     5547               MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
    55275548    SetSysMenu(hwndSysMenu);
    55285549
    55295550    size = sizeof(BOOL);
    55305551    if (PrfQueryProfileData(fmprof,
    5531                             FM3Str,
    5532                             "MenuInvisible", &temp, &size) && size && temp)
     5552                            FM3Str,
     5553                            "MenuInvisible", &temp, &size) && size && temp)
    55335554      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
    55345555    size = sizeof(BOOL);
    55355556    if (PrfQueryProfileData(fmprof,
    5536                             FM3Str, "FreeTree", &temp, &size) && size && temp)
     5557                            FM3Str, "FreeTree", &temp, &size) && size && temp)
    55375558      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
    55385559    size = sizeof(BOOL);
    55395560    if (PrfQueryProfileData(fmprof,
    5540                             FM3Str,
    5541                             "AutoTile", &temp, &size) && size && !temp)
     5561                            FM3Str,
     5562                            "AutoTile", &temp, &size) && size && !temp)
    55425563      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
    55435564    size = sizeof(BOOL);
    55445565    if (PrfQueryProfileData(fmprof,
    5545                             FM3Str, "Toolbar", &temp, &size) && size && !temp)
     5566                            FM3Str, "Toolbar", &temp, &size) && size && !temp)
    55465567      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
    55475568
     
    55685589      hwndTree = StartTreeCnr(hwnd, 0);
    55695590      if (!hwndTree)
    5570         WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     5591        WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    55715592      else {
    5572         if (!fSaveState ||
    5573             !PrfQueryProfileData(fmprof,
    5574                                 FM3Str,
    5575                                 "LastTreePos",
    5576                                 &swp, &size) || size != sizeof(SWP)) {
    5577 
    5578           INT ratio, height = 0;
    5579 
    5580           if (!fNoTreeGap)
    5581             height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    5582           size = sizeof(ratio);
    5583           if (!PrfQueryProfileData(fmprof,
    5584                                    FM3Str,
    5585                                    "TreeWindowRatio",
    5586                                    (PVOID) & ratio,
    5587                                    &size) || size < sizeof(ratio))
    5588             ratio = 400;
    5589           WinSetWindowPos(hwndTree,
    5590                           HWND_TOP,
    5591                           0,
    5592                           height,
    5593                           (swp.cx * 100) / ratio,
    5594                           swp.cy - height,
    5595                           SWP_SHOW | SWP_SIZE | SWP_MOVE |
    5596                           SWP_ACTIVATE | SWP_ZORDER);
    5597         }
    5598         else
    5599           WinSetWindowPos(hwndTree,
    5600                           HWND_TOP,
    5601                           swp.x,
    5602                           swp.y,
    5603                           swp.cx,
    5604                           swp.cy,
    5605                           swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
    5606                           SWP_ZORDER | SWP_ACTIVATE);
     5593        if (!fSaveState ||
     5594            !PrfQueryProfileData(fmprof,
     5595                                FM3Str,
     5596                                "LastTreePos",
     5597                                &swp, &size) || size != sizeof(SWP)) {
     5598
     5599          INT ratio, height = 0;
     5600
     5601          if (!fNoTreeGap)
     5602            height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     5603          size = sizeof(ratio);
     5604          if (!PrfQueryProfileData(fmprof,
     5605                                   FM3Str,
     5606                                   "TreeWindowRatio",
     5607                                   (PVOID) & ratio,
     5608                                   &size) || size < sizeof(ratio))
     5609            ratio = 400;
     5610          WinSetWindowPos(hwndTree,
     5611                          HWND_TOP,
     5612                          0,
     5613                          height,
     5614                          (swp.cx * 100) / ratio,
     5615                          swp.cy - height,
     5616                          SWP_SHOW | SWP_SIZE | SWP_MOVE |
     5617                          SWP_ACTIVATE | SWP_ZORDER);
     5618        }
     5619        else
     5620          WinSetWindowPos(hwndTree,
     5621                          HWND_TOP,
     5622                          swp.x,
     5623                          swp.y,
     5624                          swp.cx,
     5625                          swp.cy,
     5626                          swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
     5627                          SWP_ZORDER | SWP_ACTIVATE);
    56075628      }
    56085629      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5609                                   MAIN_TOOLS));
     5630                                  MAIN_TOOLS));
    56105631    }
    56115632    PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
     
    56255646
    56265647      for (x = 1; x < argc; x++) {
    5627         if (*argv[x] == '/' || *argv[x] == ';')
    5628           continue;
    5629         if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
    5630           OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
     5648        if (*argv[x] == '/' || *argv[x] == ';')
     5649          continue;
     5650        if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
     5651          OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
    56315652      }
    56325653    }
     
    56465667      hwndActive = TopWindow(hwnd, hwndTree);
    56475668      if (hwndActive)
    5648         WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
     5669        WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
    56495670    }
    56505671    if (fStartMinimized || fReminimize)
     
    56765697  case WM_CONTROLPOINTER:
    56775698    if (!fNoFinger &&
    5678         (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
    5679         SHORT1FROMMP(mp1) == IDM_USERLIST))
     5699        (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
     5700        SHORT1FROMMP(mp1) == IDM_USERLIST))
    56805701      return MRFROMLONG(hptrFinger);
    56815702    break;
     
    57175738    if (mp1) {
    57185739      if (fUserComboBox)
    5719         WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5720                         (CHAR *) mp1);
     5740        WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
     5741                        (CHAR *) mp1);
    57215742      if (add_udir(FALSE, (CHAR *) mp1)) {
    5722         if (fUserComboBox && fAutoAddDirs) {
    5723           WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5724                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5725                      MPFROMP((CHAR *) mp1));
    5726         }
     5743        if (fUserComboBox && fAutoAddDirs) {
     5744          WinSendMsg(hwndUserlist, LM_INSERTITEM,
     5745                     MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5746                     MPFROMP((CHAR *) mp1));
     5747        }
    57275748      }
    57285749    }
     
    57565777      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    57575778      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    5758         WinStoreWindowPos(FM2Str,
    5759                           "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
    5760         if (!fNoSaveState && fSaveState)
    5761           SaveDirCnrState(hwnd, FM2_STATE_AT_CLOSE);
     5779        WinStoreWindowPos(FM2Str,
     5780                          "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
     5781        if (!fNoSaveState && fSaveState)
     5782          SaveDirCnrState(hwnd, FM2_STATE_AT_CLOSE);
    57625783      }
    57635784    }
     
    57695790    case 1:
    57705791      {
    5771         HWND hwndCurrent;
    5772         ULONG wmsg;
    5773 
    5774         wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
    5775         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5776         PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
    5777                                                        FID_CLIENT), wmsg,
    5778                                        MPVOID, MPVOID), mp1, mp2);
     5792        HWND hwndCurrent;
     5793        ULONG wmsg;
     5794
     5795        wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
     5796        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5797        PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
     5798                                                       FID_CLIENT), wmsg,
     5799                                       MPVOID, MPVOID), mp1, mp2);
    57795800      }
    57805801      break;
     
    57945815       */
    57955816      {
    5796         HWND hwndMenu, hwndSubMenu;
    5797         MENUITEM mi;
    5798 
    5799         hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
    5800         memset(&mi, 0, sizeof(mi));
    5801         mi.iPosition = MIT_END;
    5802         mi.afStyle = MIS_TEXT;
    5803         if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
    5804                         MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
    5805           break;
    5806         hwndSubMenu = mi.hwndSubMenu;
    5807         SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
     5817        HWND hwndMenu, hwndSubMenu;
     5818        MENUITEM mi;
     5819
     5820        hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
     5821        memset(&mi, 0, sizeof(mi));
     5822        mi.iPosition = MIT_END;
     5823        mi.afStyle = MIS_TEXT;
     5824        if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
     5825                        MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
     5826          break;
     5827        hwndSubMenu = mi.hwndSubMenu;
     5828        SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
    58085829      }
    58095830      break;
     
    58115832    default:
    58125833      {
    5813         HWND hwndCurrent;
    5814 
    5815         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5816         if (hwndCurrent)
    5817           WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
     5834        HWND hwndCurrent;
     5835
     5836        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5837        if (hwndCurrent)
     5838          WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
    58185839      }
    58195840      break;
     
    58235844  case UM_ADDTOMENU:
    58245845    AddToMenu((CHAR *) mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5825                                             FID_MENU));
     5846                                            FID_MENU));
    58265847    return 0;
    58275848
     
    58365857      info = cmdhead;
    58375858      while (info) {
    5838         WinSendMsg(hwndCmdlist, LM_INSERTITEM,
    5839                    MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
    5840         info = info->next;
     5859        WinSendMsg(hwndCmdlist, LM_INSERTITEM,
     5860                   MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
     5861        info = info->next;
    58415862      }
    58425863    }
     
    58625883      ulSearchCount = 1;
    58635884      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    5864                         &findbuf, sizeof(FILEFINDBUF3),
    5865                         &ulSearchCount, FIL_STANDARD)) {
    5866         do {
    5867           priority_bumped();
    5868           if (!foundit) {
    5869             thisone = FALSE;
    5870             p = strrchr(lasttoolbox, '\\');
    5871             if (!p)
    5872               p = lasttoolbox;
    5873             else
    5874               p++;
    5875             if (!stricmp(findbuf.achName, p))
    5876               thisone = TRUE;
    5877           }
    5878           p = strrchr(findbuf.achName, '.');
    5879           if (p)
    5880             *p = 0;
    5881           sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
    5882                                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5883                                        MPFROMP(findbuf.achName));
    5884           if (!foundit && thisone && sSelect >= 0) {
    5885             WinSendMsg(hwndButtonlist, LM_SELECTITEM,
    5886                        MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
    5887             foundit = TRUE;
    5888           }
    5889         }
    5890         while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
    5891                             &ulSearchCount));
    5892         DosFindClose(hDir);
    5893         priority_bumped();
     5885                        &findbuf, sizeof(FILEFINDBUF3),
     5886                        &ulSearchCount, FIL_STANDARD)) {
     5887        do {
     5888          priority_bumped();
     5889          if (!foundit) {
     5890            thisone = FALSE;
     5891            p = strrchr(lasttoolbox, '\\');
     5892            if (!p)
     5893              p = lasttoolbox;
     5894            else
     5895              p++;
     5896            if (!stricmp(findbuf.achName, p))
     5897              thisone = TRUE;
     5898          }
     5899          p = strrchr(findbuf.achName, '.');
     5900          if (p)
     5901            *p = 0;
     5902          sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
     5903                                       MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5904                                       MPFROMP(findbuf.achName));
     5905          if (!foundit && thisone && sSelect >= 0) {
     5906            WinSendMsg(hwndButtonlist, LM_SELECTITEM,
     5907                       MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
     5908            foundit = TRUE;
     5909          }
     5910        }
     5911        while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
     5912                            &ulSearchCount));
     5913        DosFindClose(hDir);
     5914        priority_bumped();
    58945915      }
    58955916      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     
    59105931
    59115932      if (!loadedudirs)
    5912         load_udirs();
     5933        load_udirs();
    59135934      DosError(FERR_DISABLEHARDERR);
    59145935      DosQCurDisk(&ulDriveNum, &ulDriveMap);
    59155936      info = udirhead;
    59165937      while (info) {
    5917         if (IsFullName(info->path) &&
    5918             !(driveflags[toupper(*info->path) - 'A'] &
    5919               (DRIVE_IGNORE | DRIVE_INVALID))) {
    5920           DosError(FERR_DISABLEHARDERR);
    5921           hDir = HDIR_CREATE;
    5922           ulSearchCount = 1;
    5923           if (!IsRoot(info->path))
    5924             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    5925                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    5926                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    5927                               &findbuf, sizeof(FILEFINDBUF3),
    5928                               &ulSearchCount, FIL_STANDARD);
    5929           else {
    5930             rc = 0;
    5931             findbuf.attrFile = FILE_DIRECTORY;
    5932           }
    5933           priority_bumped();
    5934           if (!rc) {
    5935             if (!IsRoot(info->path))
    5936               DosFindClose(hDir);
    5937             if (findbuf.attrFile & FILE_DIRECTORY)
    5938               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5939                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5940                         MPFROMP(info->path));
    5941             else {
    5942               temp = info->next;
    5943               remove_udir(info->path);
    5944               info = temp;
    5945               continue;
    5946             }
    5947           }
    5948           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    5949             temp = info->next;
    5950             remove_udir(info->path);
    5951             info = temp;
    5952             continue;
    5953           }
    5954         }
    5955         info = info->next;
     5938        if (IsFullName(info->path) &&
     5939            !(driveflags[toupper(*info->path) - 'A'] &
     5940              (DRIVE_IGNORE | DRIVE_INVALID))) {
     5941          DosError(FERR_DISABLEHARDERR);
     5942          hDir = HDIR_CREATE;
     5943          ulSearchCount = 1;
     5944          if (!IsRoot(info->path))
     5945            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     5946                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     5947                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     5948                              &findbuf, sizeof(FILEFINDBUF3),
     5949                              &ulSearchCount, FIL_STANDARD);
     5950          else {
     5951            rc = 0;
     5952            findbuf.attrFile = FILE_DIRECTORY;
     5953          }
     5954          priority_bumped();
     5955          if (!rc) {
     5956            if (!IsRoot(info->path))
     5957              DosFindClose(hDir);
     5958            if (findbuf.attrFile & FILE_DIRECTORY)
     5959              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     5960                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5961                        MPFROMP(info->path));
     5962            else {
     5963              temp = info->next;
     5964              remove_udir(info->path);
     5965              info = temp;
     5966              continue;
     5967            }
     5968          }
     5969          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     5970            temp = info->next;
     5971            remove_udir(info->path);
     5972            info = temp;
     5973            continue;
     5974          }
     5975        }
     5976        info = info->next;
    59565977      }
    59575978      info = ldirhead;
    59585979      while (info) {
    5959         if (IsFullName(info->path) &&
    5960             !(driveflags[toupper(*info->path) - 'A'] &
    5961               (DRIVE_IGNORE | DRIVE_INVALID))) {
    5962           DosError(FERR_DISABLEHARDERR);
    5963           hDir = HDIR_CREATE;
    5964           ulSearchCount = 1;
    5965           if (!IsRoot(info->path))
    5966             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    5967                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    5968                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    5969                               &findbuf, sizeof(FILEFINDBUF3),
    5970                               &ulSearchCount, FIL_STANDARD);
    5971           else {
    5972             rc = 0;
    5973             findbuf.attrFile = FILE_DIRECTORY;
    5974           }
    5975           priority_bumped();
    5976           if (!rc) {
    5977             if (!IsRoot(info->path))
    5978               DosFindClose(hDir);
    5979             if (findbuf.attrFile & FILE_DIRECTORY)
    5980               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5981                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5982                         MPFROMP(info->path));
    5983             else {
    5984               temp = info->next;
    5985               remove_udir(info->path);
    5986               info = temp;
    5987               continue;
    5988             }
    5989           }
    5990           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    5991             temp = info->next;
    5992             remove_udir(info->path);
    5993             info = temp;
    5994             continue;
    5995           }
    5996         }
    5997         info = info->next;
     5980        if (IsFullName(info->path) &&
     5981            !(driveflags[toupper(*info->path) - 'A'] &
     5982              (DRIVE_IGNORE | DRIVE_INVALID))) {
     5983          DosError(FERR_DISABLEHARDERR);
     5984          hDir = HDIR_CREATE;
     5985          ulSearchCount = 1;
     5986          if (!IsRoot(info->path))
     5987            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     5988                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     5989                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     5990                              &findbuf, sizeof(FILEFINDBUF3),
     5991                              &ulSearchCount, FIL_STANDARD);
     5992          else {
     5993            rc = 0;
     5994            findbuf.attrFile = FILE_DIRECTORY;
     5995          }
     5996          priority_bumped();
     5997          if (!rc) {
     5998            if (!IsRoot(info->path))
     5999              DosFindClose(hDir);
     6000            if (findbuf.attrFile & FILE_DIRECTORY)
     6001              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6002                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6003                        MPFROMP(info->path));
     6004            else {
     6005              temp = info->next;
     6006              remove_udir(info->path);
     6007              info = temp;
     6008              continue;
     6009            }
     6010          }
     6011          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6012            temp = info->next;
     6013            remove_udir(info->path);
     6014            info = temp;
     6015            continue;
     6016          }
     6017        }
     6018        info = info->next;
    59986019      }
    59996020      WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6000                 MPFROM2SHORT(0, 0),
    6001                 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
     6021                MPFROM2SHORT(0, 0),
     6022                MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
    60026023      WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
    60036024    }
     
    60136034  case WM_SIZE:
    60146035    ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
    6015                    SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
     6036                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
    60166037    break;
    60176038
     
    60276048      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    60286049      if (hps) {
    6029         WinQueryWindowRect(hwnd, &rcl);
    6030         WinFillRect(hps, &rcl, CLR_PALEGRAY);
    6031         WinEndPaint(hps);
     6050        WinQueryWindowRect(hwnd, &rcl);
     6051        WinFillRect(hps, &rcl, CLR_PALEGRAY);
     6052        WinEndPaint(hps);
    60326053      }
    60336054    }
     
    60436064      switch (SHORT2FROMMP(mp1)) {
    60446065      case CBN_ENTER:
    6045         {
    6046           HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6047                                         SHORT1FROMMP(mp1));
    6048           CHAR path[CCHMAXPATH];
    6049           ULONG ul;
    6050 
    6051           switch (SHORT1FROMMP(mp1)) {
    6052           case MAIN_USERLIST:
    6053             ul = CCHMAXPATH;
    6054             break;
    6055           case MAIN_SETUPLIST:
    6056             ul = STATE_NAME_MAX_BYTES;
    6057             break;
    6058           default:
    6059             ul = 13;                    // fixme to not be hardcoded
    6060           }
    6061 
    6062           SetShiftState();
    6063           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    6064           bstrip(path);
    6065           if (*path) {
    6066             if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
    6067               if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
    6068                 if (!LastDir ||
    6069                     !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
    6070                                 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
    6071                   save_dir2(path);
    6072                 if (!PMMkDir(hwnd, path, TRUE)) {
    6073                   WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
    6074                   break;
    6075                 }
    6076               }
    6077               if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
    6078 
    6079                 HWND hwndDir;
    6080 
    6081                 if ((fUserListSwitches &&
    6082                      !(shiftstate & KC_SHIFT)) ||
    6083                     (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
    6084                   hwndDir = FindDirCnr(hwnd);
    6085                   if (hwndDir) {
    6086                     WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
    6087                     break;
    6088                   }
    6089                 }
    6090                 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
    6091               }
    6092             }
    6093             else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
    6094               ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    6095                                                           FID_CLIENT),
    6096                                           TREE_CNR), path, FALSE, TRUE);
    6097               WinSetFocus(HWND_DESKTOP, hwndTree);
    6098             }
    6099             else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
    6100               strcat(path, ".TLS");
    6101               load_tools(path);
    6102               PrfWriteProfileString(fmprof,
    6103                                     FM3Str, "LastToolBox", lasttoolbox);
    6104               BuildTools(hwndToolback, TRUE);
    6105               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
    6106             }
    6107             else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    6108 
    6109               CHAR szKey[80];
    6110               ULONG size, numsaves = 0;
    6111 
    6112               SetShiftState();
    6113               size = sizeof(ULONG);
    6114               sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
    6115               if (!PrfQueryProfileData(fmprof,
    6116                                        FM3Str,
    6117                                        szKey,
    6118                                        (PVOID)&numsaves,
    6119                                        &size))
    6120               {
    6121                 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
    6122                   saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    6123                          GetPString(IDS_WARNINGTEXT),
    6124                          GetPString(IDS_DOESNTEXISTTEXT), path);
    6125                 }
    6126                 else {
    6127                   Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
    6128                              IDS_PRFQUERYPROFILEDATA);
    6129                 }
    6130               }
    6131               else if (!numsaves)
    6132                 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    6133               else {
    6134                 if ((shiftstate & KC_SHIFT) == 0)
    6135                   PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2L));
    6136                 {
    6137                   char *temp;
    6138 
    6139                   temp = xstrdup(path, pszSrcFile, __LINE__);
    6140                   if (!temp) {
    6141                     if ((shiftstate & KC_SHIFT) != 0 || fAutoTile)
    6142                       PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID,
    6143                               MPFROMLONG(1));
    6144                   }
    6145                   else {
    6146                     if (!PostMsg
    6147                         (MainObjectHwnd, UM_RESTORE, MPFROMP(temp), MPVOID))
    6148                       free(temp);
    6149                   }
    6150                 }
    6151               }
    6152               // fixme to hold restored state name for a while
    6153               // WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));    // 15 Apr 07 SHL
    6154             }
    6155             else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
    6156 
    6157               SHORT sSelect;
    6158 
    6159               sSelect = (SHORT) WinSendMsg(hwndCmdlist,
    6160                                            LM_QUERYSELECTION,
    6161                                            MPFROMSHORT(LIT_FIRST), MPVOID);
    6162               if (sSelect >= 0)
    6163                 WinPostMsg(hwnd,
    6164                            WM_COMMAND,
    6165                            MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
    6166                            MPVOID);
    6167               WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    6168             }
    6169           }
    6170         }
    6171         break;
     6066        {
     6067          HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     6068                                        SHORT1FROMMP(mp1));
     6069          CHAR path[CCHMAXPATH];
     6070          ULONG ul;
     6071
     6072          switch (SHORT1FROMMP(mp1)) {
     6073          case MAIN_USERLIST:
     6074            ul = CCHMAXPATH;
     6075            break;
     6076          case MAIN_SETUPLIST:
     6077            ul = STATE_NAME_MAX_BYTES;
     6078            break;
     6079          default:
     6080            ul = 13;                    // fixme to not be hardcoded
     6081          }
     6082
     6083          SetShiftState();
     6084          WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
     6085          bstrip(path);
     6086          if (*path) {
     6087            if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
     6088              if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
     6089                if (!LastDir ||
     6090                    !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
     6091                                UM_CONTAINERDIR, MPFROMP(path), MPVOID))
     6092                  save_dir2(path);
     6093                if (!PMMkDir(hwnd, path, TRUE)) {
     6094                  WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
     6095                  break;
     6096                }
     6097              }
     6098              if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
     6099
     6100                HWND hwndDir;
     6101
     6102                if ((fUserListSwitches &&
     6103                     !(shiftstate & KC_SHIFT)) ||
     6104                    (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
     6105                  hwndDir = FindDirCnr(hwnd);
     6106                  if (hwndDir) {
     6107                    WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
     6108                    break;
     6109                  }
     6110                }
     6111                OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
     6112              }
     6113            }
     6114            else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
     6115              ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
     6116                                                          FID_CLIENT),
     6117                                          TREE_CNR), path, FALSE, TRUE);
     6118              WinSetFocus(HWND_DESKTOP, hwndTree);
     6119            }
     6120            else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
     6121              strcat(path, ".TLS");
     6122              load_tools(path);
     6123              PrfWriteProfileString(fmprof,
     6124                                    FM3Str, "LastToolBox", lasttoolbox);
     6125              BuildTools(hwndToolback, TRUE);
     6126              WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     6127            }
     6128            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
     6129              CHAR szKey[80];
     6130              ULONG size, numsaves = 0;
     6131
     6132              SetShiftState();
     6133              size = sizeof(ULONG);
     6134              sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
     6135              if (!PrfQueryProfileData(fmprof,
     6136                                       FM3Str,
     6137                                       szKey,
     6138                                       (PVOID)&numsaves,
     6139                                       &size))
     6140              {
     6141                if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
     6142                  saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     6143                         GetPString(IDS_WARNINGTEXT),
     6144                         GetPString(IDS_DOESNTEXISTTEXT), path);
     6145                }
     6146                else {
     6147                  Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
     6148                             IDS_PRFQUERYPROFILEDATA);
     6149                }
     6150              }
     6151              else if (!numsaves)
     6152                Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     6153              else {
     6154                char *pszStateName;
     6155                if ((shiftstate & KC_SHIFT) == 0)
     6156                  PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
     6157                pszStateName = xstrdup(path, pszSrcFile, __LINE__);
     6158                if (!pszStateName) {
     6159                  // Fall back if out of memory - already complained
     6160                  if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
     6161                    // Autotile requested or forced
     6162                    PostMsg(MainObjectHwnd,
     6163                            UM_RESTORE,
     6164                            MPVOID,
     6165                            MPFROMLONG(1));             // Autotile
     6166                  }
     6167                }
     6168                else if (!PostMsg(MainObjectHwnd,
     6169                                  UM_RESTORE,
     6170                                  MPFROMP(pszStateName),
     6171                                  MPVOID)) {
     6172                  free(pszStateName);
     6173                }
     6174              }
     6175            }
     6176            else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
     6177
     6178              SHORT sSelect;
     6179
     6180              sSelect = (SHORT) WinSendMsg(hwndCmdlist,
     6181                                           LM_QUERYSELECTION,
     6182                                           MPFROMSHORT(LIT_FIRST), MPVOID);
     6183              if (sSelect >= 0)
     6184                WinPostMsg(hwnd,
     6185                           WM_COMMAND,
     6186                           MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
     6187                           MPVOID);
     6188              WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
     6189            }
     6190          }
     6191        }
     6192        break;
    61726193
    61736194      default:
    6174         break;
     6195        break;
    61756196      }
    61766197      break;
     
    61926213  case WM_CLOSE:
    61936214    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6194                WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     6215               WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    61956216    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    61966217    fAmClosing = TRUE;
    61976218    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6198                WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
     6219               WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
    61996220    if (CloseChildren(hwnd)) {
    62006221      fAmClosing = FALSE;
    62016222      if (fAutoTile)
    6202         PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
     6223        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
    62036224      return 0;
    62046225    }
    62056226    if (hwndTree) {
    62066227      if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
    6207         WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
     6228        WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    62086229    }
    62096230    DosSleep(1);
     
    62176238  case UM_RESTORE:
    62186239    {
    6219       char *temp;
    6220 
    6221       temp = xstrdup(GetPString(IDS_FM2TEMPTEXT), pszSrcFile, __LINE__);
    6222       if (temp) {
    6223         if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(temp), MPVOID))
    6224           free(temp);
     6240      // Try to restore saved shutdown state
     6241      char *pszDefaultStateName = xstrdup(FM2_STATE_AT_CLOSE, pszSrcFile, __LINE__);
     6242      if (pszDefaultStateName) {
     6243        if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
     6244          // 05 Feb 08 SHL fixme to complain?
     6245          free(pszDefaultStateName);
    62256246      }
    62266247    }
     
    62316252    if (mp1)
    62326253      return MRFROMLONG(OpenDirCnr((HWND) 0,
    6233                                    hwndMain,
    6234                                    hwndTree, (BOOL) mp2, (char *)mp1));
     6254                                   hwndMain,
     6255                                   hwndTree, (BOOL) mp2, (char *)mp1));
    62356256    return 0;
    62366257
Note: See TracChangeset for help on using the changeset viewer.