Changeset 1335 for trunk/dll/mainwnd.c


Ignore:
Timestamp:
Dec 13, 2008, 12:49:02 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: Add exception handlers to all threads using xbeginthread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r1333 r1335  
     1
    12/***********************************************************************
    23
     
    5960  07 Jul 08 JBS Ticket 242: Delete obsolete INI keys when re-saving a state
    6061  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    61                 all the details view settings (both the global variables and those in the
    62                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     62                all the details view settings (both the global variables and those in the
     63                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    6364  12 Jul 08 JBS Ticket 246: Allow saved directory container states to have no directory containers
    64                 (i.e. just a directory tree container).
    65                 18 Jul 08 SHL Use new Fortify feature to avoid spurious reports
     65                (i.e. just a directory tree container).
     66                18 Jul 08 SHL Use new Fortify feature to avoid spurious reports
    6667  19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
    6768  26 Aug 08 GKY Require unique ID plus text and help strings for all tools save toolbar on button delete
     
    7172  29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
    7273  04 Dec 08 GKY Use event semaphore to prevent scan of "last" directory container prior to
    73                 tree scan completion; prevents duplicate directory names in tree.
     74                tree scan completion; prevents duplicate directory names in tree.
     75  10 Dec 08 SHL Integrate exception handler support
    7476
    7577***********************************************************************/
     
    7880#include <string.h>
    7981#include <ctype.h>
    80 #include <process.h>                    // _beginthread
     82// #include <process.h>                 // _beginthread
    8183
    8284#define INCL_DOS
     
    112114#include "cmdline.h"                    // CmdLine2DlgProc, save_cmdlines
    113115#include "common.h"                     // CommonCreateMainChildren, CommonDriveCmd, CommonMainWndProc
    114                                         // CommonTextButton
     116                                        // CommonTextButton
    115117#include "notify.h"                     // DoNotify, HideNote, ShowNote
    116118#include "draglist.h"                   // DragOne
     
    120122#include "fm2cmd.h"                     // FM2Command
    121123#include "misc.h"                       // FindDirCnr, FixSwitchList, PaintSTextWindow,
    122                                         // SetConditionalCascade, SetMenuCheck, SetSysMenu
    123                                         // SwitchCommand, CheckMenu, DrawTargetEmphasis
    124                                         // IsFm2Window
     124                                        // SetConditionalCascade, SetMenuCheck, SetSysMenu
     125                                        // SwitchCommand, CheckMenu, DrawTargetEmphasis
     126                                        // IsFm2Window
    125127#include "instant.h"                    // InstantDlgProc
    126128#include "killproc.h"                   // KillDlgProc
     
    132134#include "viewinf.h"                    // ViewInfProc
    133135#include "walkem.h"                     // WalkDlgProc, WalkTwoCmpDlgProc, add_setup, add_udir
    134                                         // fill_setups_list, free_ldir, free_udirs, load_udirs
    135                                         // remove_setup, remove_udir, save_setups, save_udirs
     136                                        // fill_setups_list, free_ldir, free_udirs, load_udirs
     137                                        // remove_setup, remove_udir, save_setups, save_udirs
    136138#include "winlist.h"                    // WindowList
    137139#include "cmdline.h"                    // add_cmdline
     
    152154#include "fortify.h"
    153155#include "filldir.h"                    // StubbyScanCount
     156#include "excputil.h"                   // xbeginthread
    154157
    155158static BOOL CloseDirCnrChildren(HWND hwndClient);
     
    209212
    210213static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    211                                           MPARAM mp2)
     214                                          MPARAM mp2)
    212215{
    213216  switch (msg) {
     
    238241      *dv = 0;
    239242      WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
    240                                         id + 50), sizeof(dv), dv);
     243                                        id + 50), sizeof(dv), dv);
    241244      d = toupper(*dv);
    242245      if (isalpha(d) && d > 'B' &&
    243           !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
    244                                    DRIVE_SLOW)) &&
    245           (!hwndBubble ||
    246            WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    247           !WinQueryCapture(HWND_DESKTOP)) {
    248 
    249         FSALLOCATE fsa;
    250         CHAR s[90], szQty[38];
    251         ULONG ulPctFree;
    252         ULONGLONG ullFreeQty;
    253 
    254         if (!DosQueryFSInfo((d - 'A') + 1,
    255                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    256           ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
    257             (fsa.cSectorUnit * fsa.cbSector);
    258           ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
    259             (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
    260           CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
    261           sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
    262         }
    263         if ((!hwndBubble ||
    264              WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    265             !WinQueryCapture(HWND_DESKTOP))
    266           WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
     246          !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
     247                                   DRIVE_SLOW)) &&
     248          (!hwndBubble ||
     249           WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     250          !WinQueryCapture(HWND_DESKTOP)) {
     251
     252        FSALLOCATE fsa;
     253        CHAR s[90], szQty[38];
     254        ULONG ulPctFree;
     255        ULONGLONG ullFreeQty;
     256
     257        if (!DosQueryFSInfo((d - 'A') + 1,
     258                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     259          ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
     260            (fsa.cSectorUnit * fsa.cbSector);
     261          ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
     262            (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
     263          CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
     264          sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
     265        }
     266        if ((!hwndBubble ||
     267             WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     268            !WinQueryCapture(HWND_DESKTOP))
     269          WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
    267270      }
    268271    }
     
    275278
    276279      if (DosQuerySysInfo(QSV_BOOT_DRIVE,
    277                           QSV_BOOT_DRIVE,
    278                           (PVOID) & bd, (ULONG) sizeof(ULONG)))
    279         bd = 3L;
     280                          QSV_BOOT_DRIVE,
     281                          (PVOID) & bd, (ULONG) sizeof(ULONG)))
     282        bd = 3L;
    280283      *s = (CHAR) bd + '@';
    281284      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    282285      if (!mp1) {
    283         s[3] = 0;
    284         WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
     286        s[3] = 0;
     287        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    285288      }
    286289      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
     
    340343      DosError(FERR_DISABLEHARDERR);
    341344      WinRegisterClass(hab2,
    342                        (PSZ) WC_OBJECTWINDOW,
    343                        MainObjectWndProc, 0, sizeof(PVOID));
     345                       (PSZ) WC_OBJECTWINDOW,
     346                       MainObjectWndProc, 0, sizeof(PVOID));
    344347      MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
    345                                        WC_OBJECTWINDOW,
    346                                        (PSZ) NULL,
    347                                        0,
    348                                        0L,
    349                                        0L,
    350                                        0L,
    351                                        0L,
    352                                        0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
     348                                       WC_OBJECTWINDOW,
     349                                       (PSZ) NULL,
     350                                       0,
     351                                       0L,
     352                                       0L,
     353                                       0L,
     354                                       0L,
     355                                       0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
    353356      if (!MainObjectHwnd)
    354         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
    355                    IDS_WINCREATEWINDOW);
     357        Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
     358                   IDS_WINCREATEWINDOW);
    356359      else {
    357         WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
     360        WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
    358361#       ifdef FORTIFY
    359         Fortify_EnterScope();
     362        Fortify_EnterScope();
    360363#       endif
    361         while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
    362           WinDispatchMsg(hab2, &qmsg2);
    363         WinDestroyWindow(MainObjectHwnd);
     364        while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
     365          WinDispatchMsg(hab2, &qmsg2);
     366        WinDestroyWindow(MainObjectHwnd);
    364367#       ifdef FORTIFY
    365         Fortify_LeaveScope();
     368        Fortify_LeaveScope();
    366369#       endif
    367370      }
     
    373376
    374377static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
    375                                         MPARAM mp2)
     378                                        MPARAM mp2)
    376379{
    377380  switch (msg) {
     
    393396    while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    394397      if (hwndC != exclude) {
    395         id = WinQueryWindowUShort(hwndC, QWS_ID);
    396         if (id)
    397           break;
     398        id = WinQueryWindowUShort(hwndC, QWS_ID);
     399        if (id)
     400          break;
    398401      }
    399402    }
     
    415418      henum = WinBeginEnumWindows(hwndMain);
    416419      while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    417         //saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
    418         if (hwndC != exclude && hwndC != hwndTree) {
    419           id = WinQueryWindowUShort(hwndC, QWS_ID);
    420           if (id) {
    421             hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
    422             if (hwndClient) {
    423               hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
    424               if (hwndDir) {
    425                 if (fLookInDir) {
    426                   pci = (PCNRITEM) WinSendMsg(hwndDir,
    427                                               CM_QUERYRECORDEMPHASIS,
    428                                               MPFROMLONG(CMA_FIRST),
    429                                               MPFROMSHORT(CRA_CURSORED));
    430                   if (pci && (INT) pci != -1)
    431                     break;
    432                 }
    433                 if (WinSendMsg(hwndClient,
    434                                UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
    435                   MakeValidDir(ret);
    436                   //saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
    437                   WinEndEnumWindows(henum);
    438                   return hwndC;
    439                 }
    440               }
    441             }
    442           }
    443         }
     420        //saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
     421        if (hwndC != exclude && hwndC != hwndTree) {
     422          id = WinQueryWindowUShort(hwndC, QWS_ID);
     423          if (id) {
     424            hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
     425            if (hwndClient) {
     426              hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
     427              if (hwndDir) {
     428                if (fLookInDir) {
     429                  pci = (PCNRITEM) WinSendMsg(hwndDir,
     430                                              CM_QUERYRECORDEMPHASIS,
     431                                              MPFROMLONG(CMA_FIRST),
     432                                              MPFROMSHORT(CRA_CURSORED));
     433                  if (pci && (INT) pci != -1)
     434                    break;
     435                }
     436                if (WinSendMsg(hwndClient,
     437                               UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
     438                  MakeValidDir(ret);
     439                  //saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
     440                  WinEndEnumWindows(henum);
     441                  return hwndC;
     442                }
     443              }
     444            }
     445          }
     446        }
    444447      }
    445448      WinEndEnumWindows(henum);
    446449      if (!pci || (INT) pci == -1) {
    447         hwndC = hwndTree;
    448         pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
    449                                                                     FID_CLIENT),
    450                                                     TREE_CNR),
    451                                     CM_QUERYRECORDEMPHASIS,
    452                                     MPFROMLONG(CMA_FIRST),
    453                                     MPFROMSHORT(CRA_CURSORED));
     450        hwndC = hwndTree;
     451        pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
     452                                                                    FID_CLIENT),
     453                                                    TREE_CNR),
     454                                    CM_QUERYRECORDEMPHASIS,
     455                                    MPFROMLONG(CMA_FIRST),
     456                                    MPFROMSHORT(CRA_CURSORED));
    454457      }
    455458      if (pci && (INT) pci != -1) {
    456         strcpy(ret, pci->pszFileName);
    457         MakeValidDir(ret);
     459        strcpy(ret, pci->pszFileName);
     460        MakeValidDir(ret);
    458461      }
    459462      else
    460         strcpy(ret, pFM2SaveDirectory);
     463        strcpy(ret, pFM2SaveDirectory);
    461464    }
    462465  }
     
    476479      hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    477480      if (hwndDir)
    478         ret++;
     481        ret++;
    479482    }
    480483  }
     
    494497      hwndC = WinWindowFromID(hwndF, FID_CLIENT);
    495498      if (hwndC) {
    496         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    497         if (hwndDir) {
    498           *retstr = 0;
    499           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
    500           if (*retstr && !stricmp(retstr, directory)) {
    501             if (restore)
    502               WinSetWindowPos(hwndF,
    503                               HWND_TOP,
    504                               0,
    505                               0,
    506                               0,
    507                               0,
    508                               SWP_RESTORE | SWP_SHOW |
    509                               SWP_ACTIVATE | SWP_ZORDER);
    510             break;
    511           }
    512         }
     499        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     500        if (hwndDir) {
     501          *retstr = 0;
     502          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
     503          if (*retstr && !stricmp(retstr, directory)) {
     504            if (restore)
     505              WinSetWindowPos(hwndF,
     506                              HWND_TOP,
     507                              0,
     508                              0,
     509                              0,
     510                              0,
     511                              SWP_RESTORE | SWP_SHOW |
     512                              SWP_ACTIVATE | SWP_ZORDER);
     513            break;
     514          }
     515        }
    513516      }
    514517    }
     
    577580    while (tool) {
    578581      if (!(tool->flags & T_INVISIBLE)) {
    579         swp[x].x = butx;
    580         if (fTextTools || (tool->flags & T_TEXT)) {
    581           butx += 55L;
    582           swp[x].cx = 54L;
    583           swp[x].cy = 24L;
    584           swp[x].y = 3L;
    585         }
    586         else
    587           butx += 33L;
    588         if (tool->flags & T_SEPARATOR)
    589           butx += 12;
     582        swp[x].x = butx;
     583        if (fTextTools || (tool->flags & T_TEXT)) {
     584          butx += 55L;
     585          swp[x].cx = 54L;
     586          swp[x].cy = 24L;
     587          swp[x].y = 3L;
     588        }
     589        else
     590          butx += 33L;
     591        if (tool->flags & T_SEPARATOR)
     592          butx += 12;
    590593      }
    591594      else
    592         swp[x].fl = noattrib;
     595        swp[x].fl = noattrib;
    593596      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    594597      x++;
     
    599602      swp[x].x = butx;
    600603      if (!(tool->flags & T_INVISIBLE)) {
    601         if (fTextTools || (tool->flags & T_TEXT)) {
    602           butx += 55L;
    603           swp[x].cx = 54L;
    604           swp[x].cy = 24L;
    605           swp[x].y = 3L;
    606         }
    607         else
    608           butx += 33L;
    609         if (tool->flags & T_SEPARATOR)
    610           butx += 12;
     604        if (fTextTools || (tool->flags & T_TEXT)) {
     605          butx += 55L;
     606          swp[x].cx = 54L;
     607          swp[x].cy = 24L;
     608          swp[x].y = 3L;
     609        }
     610        else
     611          butx += 33L;
     612        if (tool->flags & T_SEPARATOR)
     613          butx += 12;
    611614      }
    612615      else
    613         swp[x].fl = noattrib;
     616        swp[x].fl = noattrib;
    614617      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    615618      x++;
     
    619622    if (!fTextTools && fToolTitles) {
    620623      for (x = 2L; x < numtools + 2L; x++) {
    621         if (fTextTools || !fToolTitles)
    622           swp[x].fl = noattrib;
    623         else {
    624           tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
    625           if (tool && (tool->flags & T_TEXT))
    626             swp[x].fl = noattrib;
    627           else {
    628             swp[x].hwndInsertBehind = HWND_TOP;
    629             swp[x].y = 1L;
    630             swp[x].cy = 10L;
    631           }
    632         }
    633         swp[x].hwnd = WinWindowFromID(hwnd,
    634                                       WinQueryWindowUShort(swp[x].hwnd,
    635                                                            QWS_ID) + 25000);
     624        if (fTextTools || !fToolTitles)
     625          swp[x].fl = noattrib;
     626        else {
     627          tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
     628          if (tool && (tool->flags & T_TEXT))
     629            swp[x].fl = noattrib;
     630          else {
     631            swp[x].hwndInsertBehind = HWND_TOP;
     632            swp[x].y = 1L;
     633            swp[x].cy = 10L;
     634          }
     635        }
     636        swp[x].hwnd = WinWindowFromID(hwnd,
     637                                      WinQueryWindowUShort(swp[x].hwnd,
     638                                                           QWS_ID) + 25000);
    636639      }
    637640      WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
     
    643646
    644647static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
    645                                         MPARAM mp2)
     648                                        MPARAM mp2)
    646649{
    647650  PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
     
    681684      id = WinQueryWindowUShort(hwndParent, QWS_ID);
    682685      if (SHORT1FROMMP(mp2)) {
    683         // If getting focus 1st time - save original accelerator
    684         if (haccelSaved == NULLHANDLE) {
    685           haccelSaved = WinQueryAccelTable(hab, hwndFrame);
    686           if (haccelSaved == NULLHANDLE)
    687             Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
    688           // else
    689             // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
    690         }
    691         if (haccelSaved != NULLHANDLE) {
    692           switch (id) {
    693           case MAIN_DRIVELIST:
    694             if (haccelDriveList == NULLHANDLE) {
    695                 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
    696                 if (haccelDriveList == NULLHANDLE)
    697                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    698             }
    699             if (haccelDriveList != NULLHANDLE) {
    700               if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
    701                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    702               // else
    703                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
    704             }
    705             break;
    706           case MAIN_SETUPLIST:
    707             if (haccelSetupList == NULLHANDLE) {
    708                 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
    709                 if (haccelSetupList == NULLHANDLE)
    710                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    711             }
    712             if (haccelSetupList != NULLHANDLE) {
    713               if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
    714                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    715               // else
    716                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
    717             }
    718             break;
    719           case MAIN_CMDLIST:
    720             if (haccelCmdList == NULLHANDLE) {
    721                 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
    722                 if (haccelCmdList == NULLHANDLE)
    723                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    724             }
    725             if (haccelCmdList != NULLHANDLE) {
    726               if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
    727                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    728               // else
    729                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
    730             }
    731             break;
    732           case MAIN_USERLIST:
    733             if (haccelUserList == NULLHANDLE) {
    734                 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
    735                 if (haccelUserList == NULLHANDLE)
    736                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    737             }
    738             if (haccelUserList != NULLHANDLE) {
    739               if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
    740                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    741               // else
    742                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
    743             }
    744             break;
    745           case MAIN_BUTTONLIST:
    746             if (haccelButtonList == NULLHANDLE) {
    747                 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
    748                 if (haccelButtonList == NULLHANDLE)
    749                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    750             }
    751             if (haccelButtonList != NULLHANDLE) {
    752               if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
    753                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    754               // else
    755                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
    756             }
    757             break;
    758           } // switch
    759         }
     686        // If getting focus 1st time - save original accelerator
     687        if (haccelSaved == NULLHANDLE) {
     688          haccelSaved = WinQueryAccelTable(hab, hwndFrame);
     689          if (haccelSaved == NULLHANDLE)
     690            Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
     691          // else
     692            // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
     693        }
     694        if (haccelSaved != NULLHANDLE) {
     695          switch (id) {
     696          case MAIN_DRIVELIST:
     697            if (haccelDriveList == NULLHANDLE) {
     698                haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
     699                if (haccelDriveList == NULLHANDLE)
     700                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     701            }
     702            if (haccelDriveList != NULLHANDLE) {
     703              if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
     704                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     705              // else
     706                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
     707            }
     708            break;
     709          case MAIN_SETUPLIST:
     710            if (haccelSetupList == NULLHANDLE) {
     711                haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
     712                if (haccelSetupList == NULLHANDLE)
     713                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     714            }
     715            if (haccelSetupList != NULLHANDLE) {
     716              if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
     717                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     718              // else
     719                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
     720            }
     721            break;
     722          case MAIN_CMDLIST:
     723            if (haccelCmdList == NULLHANDLE) {
     724                haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
     725                if (haccelCmdList == NULLHANDLE)
     726                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     727            }
     728            if (haccelCmdList != NULLHANDLE) {
     729              if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
     730                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     731              // else
     732                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
     733            }
     734            break;
     735          case MAIN_USERLIST:
     736            if (haccelUserList == NULLHANDLE) {
     737                haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
     738                if (haccelUserList == NULLHANDLE)
     739                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     740            }
     741            if (haccelUserList != NULLHANDLE) {
     742              if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
     743                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     744              // else
     745                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
     746            }
     747            break;
     748          case MAIN_BUTTONLIST:
     749            if (haccelButtonList == NULLHANDLE) {
     750                haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
     751                if (haccelButtonList == NULLHANDLE)
     752                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     753            }
     754            if (haccelButtonList != NULLHANDLE) {
     755              if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
     756                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     757              // else
     758                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
     759            }
     760            break;
     761          } // switch
     762        }
    760763      }
    761764      else {
    762         // Losing focus
    763         switch (id) {
    764         case MAIN_DRIVELIST:
    765         case MAIN_SETUPLIST:
    766         case MAIN_CMDLIST:
    767         case MAIN_USERLIST:
    768         case MAIN_BUTTONLIST:
    769           if (haccelSaved != NULLHANDLE) {
    770             if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
    771               Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    772             // else
    773               // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
    774           }
    775           break;
    776         } // switch
     765        // Losing focus
     766        switch (id) {
     767        case MAIN_DRIVELIST:
     768        case MAIN_SETUPLIST:
     769        case MAIN_CMDLIST:
     770        case MAIN_USERLIST:
     771        case MAIN_BUTTONLIST:
     772          if (haccelSaved != NULLHANDLE) {
     773            if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
     774              Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     775            // else
     776              // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
     777          }
     778          break;
     779        } // switch
    777780      }
    778781    }
     
    784787
    785788      if (hwndMenu)
    786         WinDestroyWindow(hwndMenu);
     789        WinDestroyWindow(hwndMenu);
    787790      hwndMenu = (HWND) 0;
    788791      id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
    789792      switch (id) {
    790793      case MAIN_CMDLIST:
    791         WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    792                                                                 QW_PARENT),
    793                                                   QW_PARENT),
    794                                    FID_CLIENT),
    795                    WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
    796         break;
     794        WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     795                                                                QW_PARENT),
     796                                                  QW_PARENT),
     797                                   FID_CLIENT),
     798                   WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
     799        break;
    797800      case MAIN_USERLIST:
    798801      case MAIN_SETUPLIST:
    799         hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    800         if (hwndMenu)
    801           PopupMenu(hwnd,
    802                     WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    803                                                                   QW_PARENT),
    804                                                    QW_PARENT),
    805                                     FID_CLIENT), hwndMenu);
    806         break;
     802        hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     803        if (hwndMenu)
     804          PopupMenu(hwnd,
     805                    WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     806                                                                  QW_PARENT),
     807                                                   QW_PARENT),
     808                                    FID_CLIENT), hwndMenu);
     809        break;
    807810      default:
    808         ret = FALSE;
    809         break;
     811        ret = FALSE;
     812        break;
    810813      } // switch
    811814      return ret;
     
    816819      switch (SHORT1FROMMP(mp1)) {
    817820      case CBID_EDIT:
    818         id = WinQueryWindowUShort(hwnd, QWS_ID);
    819         switch (SHORT2FROMMP(mp1)) {
    820         case EN_SETFOCUS:
    821           switch (id) {
    822           case MAIN_CMDLIST:
    823             WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
    824             break;
    825           case MAIN_SETUPLIST:
    826             WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
    827             break;
    828           case MAIN_USERLIST:
    829             WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
    830             break;
    831           case MAIN_DRIVELIST:
    832             WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
    833             break;
    834           case MAIN_BUTTONLIST:
    835             WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
    836             break;
    837           default:
    838             break;
    839           }
    840           break;
    841 
    842         default:
    843           break;
    844         }
     821        id = WinQueryWindowUShort(hwnd, QWS_ID);
     822        switch (SHORT2FROMMP(mp1)) {
     823        case EN_SETFOCUS:
     824          switch (id) {
     825          case MAIN_CMDLIST:
     826            WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
     827            break;
     828          case MAIN_SETUPLIST:
     829            WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
     830            break;
     831          case MAIN_USERLIST:
     832            WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
     833            break;
     834          case MAIN_DRIVELIST:
     835            WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
     836            break;
     837          case MAIN_BUTTONLIST:
     838            WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
     839            break;
     840          default:
     841            break;
     842          }
     843          break;
     844
     845        default:
     846          break;
     847        }
    845848      }
    846849      break;
     
    855858    // 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);
    856859    if (id == CBID_EDIT &&
    857         WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
    858         MAIN_USERLIST) {
     860        WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
     861        MAIN_USERLIST) {
    859862
    860863      CHAR path[CCHMAXPATH];
     
    865868      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
    866869      if (*path && !IsRoot(path))
    867         DragOne(hwnd, (HWND) 0, path, FALSE);
     870        DragOne(hwnd, (HWND) 0, path, FALSE);
    868871      return 0;
    869872    }
     
    874877    if (id == MAIN_USERLIST) {
    875878      if (!emphasized) {
    876         emphasized = TRUE;
    877         DrawTargetEmphasis(hwnd, emphasized);
     879        emphasized = TRUE;
     880        DrawTargetEmphasis(hwnd, emphasized);
    878881      }
    879882      if (AcceptOneDrop(hwnd, mp1, mp2))
    880         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     883        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    881884      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    882885    }
     
    887890    if (id == MAIN_USERLIST) {
    888891      if (emphasized) {
    889         emphasized = FALSE;
    890         DrawTargetEmphasis(hwnd, emphasized);
     892        emphasized = FALSE;
     893        DrawTargetEmphasis(hwnd, emphasized);
    891894      }
    892895    }
     
    908911
    909912      if (emphasized) {
    910         emphasized = FALSE;
    911         DrawTargetEmphasis(hwnd, emphasized);
     913        emphasized = FALSE;
     914        DrawTargetEmphasis(hwnd, emphasized);
    912915      }
    913916      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    914         MakeValidDir(szFrom);
    915         WinSetWindowText(hwnd, szFrom);
    916         PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    917                                                               QW_PARENT),
    918                                                QW_PARENT),
    919                                 FID_CLIENT),
    920                 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
    921         return 0;
     917        MakeValidDir(szFrom);
     918        WinSetWindowText(hwnd, szFrom);
     919        PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     920                                                              QW_PARENT),
     921                                               QW_PARENT),
     922                                FID_CLIENT),
     923                UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
     924        return 0;
    922925      }
    923926    }
     
    940943       (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
    941944    if ((!hwndBubble ||
    942         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    943         !WinQueryCapture(HWND_DESKTOP))
     945        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     946        !WinQueryCapture(HWND_DESKTOP))
    944947      MakeBubble(hwnd, above, help);
    945948  }
     
    962965      /* don't bring up help if window isn't active */
    963966      if (!WinIsChild(hwnd, hwndActive))
    964         return;
     967        return;
    965968    }
    966969    hwndActive = WinQueryFocus(HWND_DESKTOP);
     
    968971      /* don't bring up help if a menu is active */
    969972      if (!strcmp(ucClassname, "#4"))
    970         return;
     973        return;
    971974    }
    972975  }
    973976
    974977  hwndBubble = WinCreateWindow(HWND_DESKTOP,
    975                                WC_BUBBLE,
    976                                help,
    977                                WS_CLIPSIBLINGS | SS_TEXT |
    978                                DT_CENTER | DT_VCENTER,
    979                                0,
    980                                0,
    981                                0,
    982                                0,
    983                                HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
     978                               WC_BUBBLE,
     979                               help,
     980                               WS_CLIPSIBLINGS | SS_TEXT |
     981                               DT_CENTER | DT_VCENTER,
     982                               0,
     983                               0,
     984                               0,
     985                               0,
     986                               HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
    984987  if (!hwndBubble)
    985988    Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    986                IDS_WINCREATEWINDOW);
     989               IDS_WINCREATEWINDOW);
    987990  else {
    988991    HPS hps;
     
    10041007      pp = strchr(p, '\r');
    10051008      if (pp) {
    1006         wp = pp;
    1007         *pp = 0;
    1008         pp++;
     1009        wp = pp;
     1010        *pp = 0;
     1011        pp++;
    10091012      }
    10101013      GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    10111014      tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
    10121015      if (tptl.y)
    1013         tptl.y += extra;
     1016        tptl.y += extra;
    10141017      else
    1015         extra = aptl[TXTBOX_TOPLEFT].y / 4;
     1018        extra = aptl[TXTBOX_TOPLEFT].y / 4;
    10161019      tptl.y += aptl[TXTBOX_TOPLEFT].y;
    10171020      if (wp)
    1018         *wp = '\r';
     1021        *wp = '\r';
    10191022      p = pp;
    10201023    }
     
    10261029      sy = ptl.y + swp.cy + 4;
    10271030      if (sy + tptl.y + 12 > lyScreen) {
    1028         above = FALSE;
    1029         sy = ptl.y - (tptl.y + 14);
     1031        above = FALSE;
     1032        sy = ptl.y - (tptl.y + 14);
    10301033      }
    10311034    }
     
    10431046      sy = ptl.y + swp.cy + 4;
    10441047      if (sy + tptl.y + 12 > lyScreen)
    1045         sy = 0;
     1048        sy = 0;
    10461049    }
    10471050    WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
    1048                     tptl.x + 14,
    1049                     tptl.y + 12,
    1050                     SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
    1051                     SWP_MOVE | SWP_SIZE);
     1051                    tptl.x + 14,
     1052                    tptl.y + 12,
     1053                    SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
     1054                    SWP_MOVE | SWP_SIZE);
    10521055  }
    10531056}
     
    10751078      WinQueryPointerPos(HWND_DESKTOP, &ptl);
    10761079      if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
    1077           WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
    1078         WinDestroyWindow(hwnd);
     1080          WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
     1081        WinDestroyWindow(hwnd);
    10791082    }
    10801083    return 0;
     
    10901093      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    10911094      if (hps) {
    1092         WinQueryWindowPos(hwnd, &swp);
    1093         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
    1094         GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
    1095         GpiSetBackMix(hps, BM_LEAVEALONE);
    1096         GpiSetMix(hps, FM_OVERPAINT);
    1097         ptl.x = ptl.y = 0;
    1098         GpiMove(hps, &ptl);
    1099         ptl.x = swp.cx - 1;
    1100         ptl.y = swp.cy - 1;
    1101         GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
    1102         tlen = WinQueryWindowTextLength(hwnd);
    1103         if (tlen) {
    1104           s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
    1105           if (s) {
    1106             WinQueryWindowText(hwnd, tlen + 1, s);
    1107             if (*s) {
    1108               p = s;
    1109               y = swp.cy - 3;
    1110               extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
    1111               GpiSetColor(hps, 0);
    1112               GpiSetMix(hps, FM_OVERPAINT);
    1113               while (p && *p) {
    1114                 wp = NULL;
    1115                 pp = strchr(p, '\r');
    1116                 if (pp) {
    1117                   wp = pp;
    1118                   *pp = 0;
    1119                   pp++;
    1120                 }
    1121                 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    1122                 ptl.x = 7;
    1123                 y -= aptl[TXTBOX_TOPLEFT].y;
    1124                 if (p != s)
    1125                   y -= extra;
    1126                 ptl.y = y;
    1127                 GpiCharStringAt(hps, &ptl, strlen(p), p);
    1128                 if (wp)
    1129                   *wp = '\r';
    1130                 p = pp;
    1131               }
    1132             }
    1133             free(s);
    1134           }
    1135         }
    1136         if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
    1137           GpiSetColor(hps, CLR_WHITE);
    1138           ptl.x = 1;
    1139           ptl.y = 1;
    1140           GpiMove(hps, &ptl);
    1141           ptl.y = swp.cy - 2;
    1142           GpiLine(hps, &ptl);
    1143           ptl.x = swp.cx - 2;
    1144           GpiLine(hps, &ptl);
    1145           ptl.x = 2;
    1146           ptl.y = 2;
    1147           GpiMove(hps, &ptl);
    1148           ptl.y = swp.cy - 3;
    1149           GpiLine(hps, &ptl);
    1150           ptl.x = swp.cx - 3;
    1151           GpiLine(hps, &ptl);
    1152           GpiSetColor(hps, CLR_BROWN);
    1153           ptl.x = 1;
    1154           ptl.y = 1;
    1155           GpiMove(hps, &ptl);
    1156           ptl.x = swp.cx - 2;
    1157           GpiLine(hps, &ptl);
    1158           ptl.y = swp.cy - 2;
    1159           GpiLine(hps, &ptl);
    1160           ptl.x = 2;
    1161           ptl.y = 2;
    1162           GpiMove(hps, &ptl);
    1163           ptl.x = swp.cx - 3;
    1164           GpiLine(hps, &ptl);
    1165           ptl.y = swp.cy - 3;
    1166           GpiLine(hps, &ptl);
    1167         }
    1168         WinEndPaint(hps);
     1095        WinQueryWindowPos(hwnd, &swp);
     1096        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
     1097        GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
     1098        GpiSetBackMix(hps, BM_LEAVEALONE);
     1099        GpiSetMix(hps, FM_OVERPAINT);
     1100        ptl.x = ptl.y = 0;
     1101        GpiMove(hps, &ptl);
     1102        ptl.x = swp.cx - 1;
     1103        ptl.y = swp.cy - 1;
     1104        GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     1105        tlen = WinQueryWindowTextLength(hwnd);
     1106        if (tlen) {
     1107          s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
     1108          if (s) {
     1109            WinQueryWindowText(hwnd, tlen + 1, s);
     1110            if (*s) {
     1111              p = s;
     1112              y = swp.cy - 3;
     1113              extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
     1114              GpiSetColor(hps, 0);
     1115              GpiSetMix(hps, FM_OVERPAINT);
     1116              while (p && *p) {
     1117                wp = NULL;
     1118                pp = strchr(p, '\r');
     1119                if (pp) {
     1120                  wp = pp;
     1121                  *pp = 0;
     1122                  pp++;
     1123                }
     1124                GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
     1125                ptl.x = 7;
     1126                y -= aptl[TXTBOX_TOPLEFT].y;
     1127                if (p != s)
     1128                  y -= extra;
     1129                ptl.y = y;
     1130                GpiCharStringAt(hps, &ptl, strlen(p), p);
     1131                if (wp)
     1132                  *wp = '\r';
     1133                p = pp;
     1134              }
     1135            }
     1136            free(s);
     1137          }
     1138        }
     1139        if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
     1140          GpiSetColor(hps, CLR_WHITE);
     1141          ptl.x = 1;
     1142          ptl.y = 1;
     1143          GpiMove(hps, &ptl);
     1144          ptl.y = swp.cy - 2;
     1145          GpiLine(hps, &ptl);
     1146          ptl.x = swp.cx - 2;
     1147          GpiLine(hps, &ptl);
     1148          ptl.x = 2;
     1149          ptl.y = 2;
     1150          GpiMove(hps, &ptl);
     1151          ptl.y = swp.cy - 3;
     1152          GpiLine(hps, &ptl);
     1153          ptl.x = swp.cx - 3;
     1154          GpiLine(hps, &ptl);
     1155          GpiSetColor(hps, CLR_BROWN);
     1156          ptl.x = 1;
     1157          ptl.y = 1;
     1158          GpiMove(hps, &ptl);
     1159          ptl.x = swp.cx - 2;
     1160          GpiLine(hps, &ptl);
     1161          ptl.y = swp.cy - 2;
     1162          GpiLine(hps, &ptl);
     1163          ptl.x = 2;
     1164          ptl.y = 2;
     1165          GpiMove(hps, &ptl);
     1166          ptl.x = swp.cx - 3;
     1167          GpiLine(hps, &ptl);
     1168          ptl.y = swp.cy - 3;
     1169          GpiLine(hps, &ptl);
     1170        }
     1171        WinEndPaint(hps);
    11691172      }
    11701173    }
     
    11931196      switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
    11941197      case MAIN_LED:
    1195         hps = WinGetPS(hwnd);
    1196         hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
    1197         if (!fBlueLED) {
    1198           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
    1199           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
    1200         }
    1201         else {
    1202           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
    1203           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
    1204         }
    1205         if (hbmLEDoff && hbmLEDon)
    1206           WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
    1207         else {
    1208           if (hbmLEDoff)
    1209             GpiDeleteBitmap(hbmLEDoff);
    1210           if (hbmLEDon)
    1211             GpiDeleteBitmap(hbmLEDon);
    1212         }
    1213         if (hbmold &&
    1214             hbmLEDon &&
    1215             hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
    1216           GpiDeleteBitmap(hbmold);
    1217         if (hps)
    1218           WinReleasePS(hps);
    1219         break;
     1198        hps = WinGetPS(hwnd);
     1199        hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
     1200        if (!fBlueLED) {
     1201          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
     1202          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
     1203        }
     1204        else {
     1205          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
     1206          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
     1207        }
     1208        if (hbmLEDoff && hbmLEDon)
     1209          WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
     1210        else {
     1211          if (hbmLEDoff)
     1212            GpiDeleteBitmap(hbmLEDoff);
     1213          if (hbmLEDon)
     1214            GpiDeleteBitmap(hbmLEDon);
     1215        }
     1216        if (hbmold &&
     1217            hbmLEDon &&
     1218            hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
     1219          GpiDeleteBitmap(hbmold);
     1220        if (hps)
     1221          WinReleasePS(hps);
     1222        break;
    12201223      default:
    1221         SetPresParams(hwnd,
    1222                       &RGBGREY,
    1223                       &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    1224         break;
     1224        SetPresParams(hwnd,
     1225                      &RGBGREY,
     1226                      &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     1227        break;
    12251228      }
    12261229      return mr;
     
    12461249  case WM_BUTTON1CLICK:
    12471250    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1248             WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
     1251            WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
    12491252    break;
    12501253
    12511254  case WM_BUTTON2CLICK:
    12521255    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1253             WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
     1256            WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
    12541257    break;
    12551258
     
    12571260  case WM_BUTTON3CLICK:
    12581261    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1259             WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     1262            WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    12601263    break;
    12611264  }
     
    12801283    if (fToolbarHelp) {
    12811284      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    1282           && !WinQueryCapture(HWND_DESKTOP)) {
    1283         id = WinQueryWindowUShort(hwnd, QWS_ID);
    1284         tool = find_tool(id);
    1285         if (tool && tool->help && *tool->help) {
    1286 
    1287           char s[128];
    1288 
    1289           strcpy(s, tool->help);
    1290           if (tool->flags & T_DROPABLE)
    1291             strcat(s, GetPString(IDS_DROPONMETEXT));
    1292           MakeBubble(hwnd, FALSE, s);
    1293         }
     1285          && !WinQueryCapture(HWND_DESKTOP)) {
     1286        id = WinQueryWindowUShort(hwnd, QWS_ID);
     1287        tool = find_tool(id);
     1288        if (tool && tool->help && *tool->help) {
     1289
     1290          char s[128];
     1291
     1292          strcpy(s, tool->help);
     1293          if (tool->flags & T_DROPABLE)
     1294            strcat(s, GetPString(IDS_DROPONMETEXT));
     1295          MakeBubble(hwnd, FALSE, s);
     1296        }
    12941297      }
    12951298    }
     
    13001303    case IDM_HELP:
    13011304      if (hwndHelp)
    1302         WinSendMsg(hwndHelp,
    1303                    HM_DISPLAY_HELP,
    1304                    MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
     1305        WinSendMsg(hwndHelp,
     1306                   HM_DISPLAY_HELP,
     1307                   MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
    13051308      break;
    13061309
     
    13081311    case IDM_HIDETOOL:                  /* hide tool */
    13091312      if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
    1310         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1313        id = WinQueryWindowUShort(hwnd, QWS_ID);
    13111314      else
    1312         id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
    1313                                 PickToolProc, FM3ModHandle,
    1314                                 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
     1315        id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
     1316                                PickToolProc, FM3ModHandle,
     1317                                PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
    13151318      if (id) {
    1316         tool = find_tool(id);
    1317         if (tool) {
    1318           tool->flags |= T_INVISIBLE;
    1319           save_tools(NULL);
    1320         }
     1319        tool = find_tool(id);
     1320        if (tool) {
     1321          tool->flags |= T_INVISIBLE;
     1322          save_tools(NULL);
     1323        }
    13211324      }
    13221325      break;
     
    13251328      tool = toolhead;
    13261329      while (tool) {
    1327         tool->flags &= (~T_INVISIBLE);
    1328         tool = tool->next;
     1330        tool->flags &= (~T_INVISIBLE);
     1331        tool = tool->next;
    13291332      }
    13301333      save_tools(NULL);
     
    13341337    case IDM_DELETETOOL:                /* delete button */
    13351338      if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
    1336         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1339        id = WinQueryWindowUShort(hwnd, QWS_ID);
    13371340      else
    1338         id =
    1339           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1340                              PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
     1341        id =
     1342          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1343                             PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
    13411344      if (id)
    1342         PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
    1343                 MPFROM2SHORT(id, 0), MPVOID);
     1345        PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
     1346                MPFROM2SHORT(id, 0), MPVOID);
    13441347      return 0;
    13451348
     
    13471350    case IDM_EDITTOOL:                  /* edit button */
    13481351      if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
    1349         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1352        id = WinQueryWindowUShort(hwnd, QWS_ID);
    13501353      else
    1351         id =
    1352           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1353                              PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
     1354        id =
     1355          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1356                             PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
    13541357      if (id) {
    1355         tool = find_tool(id);
    1356         if (tool) {
    1357           if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1358                         ADDBTN_FRAME, (PVOID) tool))
    1359             WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1360                                                                      QW_PARENT),
    1361                                                       QW_PARENT), FID_CLIENT),
    1362                        WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1363                        MPFROM2SHORT(id, 0));
    1364         }
     1358        tool = find_tool(id);
     1359        if (tool) {
     1360          if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
     1361                        ADDBTN_FRAME, (PVOID) tool))
     1362            WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1363                                                                     QW_PARENT),
     1364                                                      QW_PARENT), FID_CLIENT),
     1365                       WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1366                       MPFROM2SHORT(id, 0));
     1367        }
    13651368      }
    13661369      break;
     
    13681371    case IDM_ADDTOOL:                   /* add tool */
    13691372      id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1370                               ADDBTN_FRAME, MPVOID);
     1373                              ADDBTN_FRAME, MPVOID);
    13711374      if (id && id != (USHORT) - 1)
    1372         WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1373                                                                 QW_PARENT),
    1374                                                   QW_PARENT), FID_CLIENT),
    1375                    WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1376                    MPFROM2SHORT(id, 0));
     1375        WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1376                                                                QW_PARENT),
     1377                                                  QW_PARENT), FID_CLIENT),
     1378                   WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1379                   MPFROM2SHORT(id, 0));
    13771380      break;
    13781381
    13791382    case IDM_REORDERTOOLS:              /* reorder tools */
    13801383      WinDlgBox(HWND_DESKTOP,
    1381                 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
     1384                hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
    13821385      break;
    13831386
     
    13851388    case IDM_LOADTOOLS:
    13861389      if (WinDlgBox(HWND_DESKTOP,
    1387                     hwnd,
    1388                     ToolIODlgProc,
    1389                     FM3ModHandle,
    1390                     SVBTN_FRAME,
    1391                     (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    1392                     "TRUE" : NULL))
    1393         PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     1390                    hwnd,
     1391                    ToolIODlgProc,
     1392                    FM3ModHandle,
     1393                    SVBTN_FRAME,
     1394                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
     1395                    "TRUE" : NULL))
     1396        PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    13941397      break;
    13951398    }
     
    14251428      tool = find_tool(id);
    14261429      if (!tool) {
    1427         DrgFreeDraginfo(pDInfo);
    1428         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1430        DrgFreeDraginfo(pDInfo);
     1431        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    14291432      }
    14301433      if (!(tool->flags & T_DROPABLE)) {
    1431         DrgFreeDraginfo(pDInfo);
    1432         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1434        DrgFreeDraginfo(pDInfo);
     1435        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    14331436      }
    14341437      {
    1435         PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
    1436 
    1437         pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
    1438                                      0);        /* Index to DRAGITEM */
    1439         if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
    1440                         DRM_OS2FILE,   /* mechanisms and data */
    1441                         NULL)) {       /* formats */
    1442           if (!(tool->flags & T_EMPHASIZED)) {
    1443             tool->flags |= T_EMPHASIZED;
    1444             DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1445             DrgFreeDraginfo(pDInfo);
    1446           }
    1447           return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
    1448                                DO_MOVE));       /* Move operation valid */
    1449         }
    1450         DrgFreeDraginfo(pDInfo);
     1438        PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
     1439
     1440        pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
     1441                                     0);        /* Index to DRAGITEM */
     1442        if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
     1443                        DRM_OS2FILE,   /* mechanisms and data */
     1444                        NULL)) {       /* formats */
     1445          if (!(tool->flags & T_EMPHASIZED)) {
     1446            tool->flags |= T_EMPHASIZED;
     1447            DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1448            DrgFreeDraginfo(pDInfo);
     1449          }
     1450          return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
     1451                               DO_MOVE));       /* Move operation valid */
     1452        }
     1453        DrgFreeDraginfo(pDInfo);
    14511454      }
    14521455    }
     
    14651468    if (tool && (tool->flags & T_DROPABLE)) {
    14661469      if (tool->flags & T_EMPHASIZED) {
    1467         tool->flags &= (~T_EMPHASIZED);
    1468         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1470        tool->flags &= (~T_EMPHASIZED);
     1471        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    14691472      }
    14701473    }
     
    14791482
    14801483      if (tool->flags & T_EMPHASIZED) {
    1481         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1482         tool->flags &= (~T_EMPHASIZED);
     1484        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1485        tool->flags &= (~T_EMPHASIZED);
    14831486      }
    14841487      memset(&cdi, 0, sizeof(cdi));
     
    14871490      CheckPmDrgLimit(cdi.pDragInfo);
    14881491      if (li) {
    1489         li->type = id;
    1490         if (!li->list || !li->list[0])
    1491           FreeListInfo(li);
    1492         else {
    1493           HWND hwndActive;
    1494 
    1495           hwndActive = TopWindow(hwndMain, (HWND) 0);
    1496           if (hwndActive) {
    1497             if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
    1498               FreeListInfo(li);
    1499           }
    1500           else
    1501             FreeListInfo(li);
    1502         }
     1492        li->type = id;
     1493        if (!li->list || !li->list[0])
     1494          FreeListInfo(li);
     1495        else {
     1496          HWND hwndActive;
     1497
     1498          hwndActive = TopWindow(hwndMain, (HWND) 0);
     1499          if (hwndActive) {
     1500            if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
     1501              FreeListInfo(li);
     1502          }
     1503          else
     1504            FreeListInfo(li);
     1505        }
    15031506      }
    15041507    }
     
    15381541    if (!fTextTools) {
    15391542      if (!(tool->flags & T_MYICON)) {
    1540         hwndTool = WinCreateWindow(hwndT,
    1541                                    WC_TOOLBUTTONS,
    1542                                    s,
    1543                                    BS_NOPOINTERFOCUS |
    1544                                    BS_BITMAP | BS_PUSHBUTTON,
    1545                                    ctrlxpos,
    1546                                    14,
    1547                                    32,
    1548                                    32, hwndT, HWND_TOP, tool->id, NULL, NULL);
     1543        hwndTool = WinCreateWindow(hwndT,
     1544                                   WC_TOOLBUTTONS,
     1545                                   s,
     1546                                   BS_NOPOINTERFOCUS |
     1547                                   BS_BITMAP | BS_PUSHBUTTON,
     1548                                   ctrlxpos,
     1549                                   14,
     1550                                   32,
     1551                                   32, hwndT, HWND_TOP, tool->id, NULL, NULL);
    15491552      }
    15501553      if (!hwndTool) {
    1551         HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
    1552 
    1553         if (hbm) {
    1554           BTNCDATA btc;
    1555 
    1556           memset(&btc, 0, sizeof(btc));
    1557           btc.cb = sizeof(btc);
    1558           btc.hImage = hbm;
    1559           hwndTool = WinCreateWindow(hwndT,
    1560                                      WC_TOOLBUTTONS,
    1561                                      NullStr,
    1562                                      BS_NOPOINTERFOCUS |
    1563                                      BS_BITMAP | BS_PUSHBUTTON,
    1564                                      ctrlxpos,
    1565                                      14,
    1566                                      32,
    1567                                      32,
    1568                                      hwndT, HWND_TOP, tool->id, &btc, NULL);
    1569           if (!hwndTool)
    1570             GpiDeleteBitmap(hbm);
    1571         }
     1554        HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
     1555
     1556        if (hbm) {
     1557          BTNCDATA btc;
     1558
     1559          memset(&btc, 0, sizeof(btc));
     1560          btc.cb = sizeof(btc);
     1561          btc.hImage = hbm;
     1562          hwndTool = WinCreateWindow(hwndT,
     1563                                     WC_TOOLBUTTONS,
     1564                                     NullStr,
     1565                                     BS_NOPOINTERFOCUS |
     1566                                     BS_BITMAP | BS_PUSHBUTTON,
     1567                                     ctrlxpos,
     1568                                     14,
     1569                                     32,
     1570                                     32,
     1571                                     hwndT, HWND_TOP, tool->id, &btc, NULL);
     1572          if (!hwndTool)
     1573            GpiDeleteBitmap(hbm);
     1574        }
    15721575      }
    15731576      if (hwndTool)
    1574         tool->flags &= (~T_TEXT);
     1577        tool->flags &= (~T_TEXT);
    15751578    }
    15761579    if (!hwndTool) {
    15771580      hwndTool = WinCreateWindow(hwndT,
    1578                                 WC_TOOLBUTTONS,
    1579                                 (!tool->text && tool->id >= IDM_COMMANDSTART
    1580                                   && tool->id <
    1581                                   IDM_QUICKTOOLSTART) ? command_title(tool->
    1582                                                                       id -
    1583                                                                       IDM_COMMANDSTART)
    1584                                 : tool->text,
    1585                                 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
    1586                                 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
    1587                                 NULL);
     1581                                WC_TOOLBUTTONS,
     1582                                (!tool->text && tool->id >= IDM_COMMANDSTART
     1583                                  && tool->id <
     1584                                  IDM_QUICKTOOLSTART) ? command_title(tool->
     1585                                                                      id -
     1586                                                                      IDM_COMMANDSTART)
     1587                                : tool->text,
     1588                                BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
     1589                                2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
     1590                                NULL);
    15881591      if (!hwndTool)
    1589         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1590                    IDS_WINCREATEWINDOW);
     1592        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1593                   IDS_WINCREATEWINDOW);
    15911594      tool->flags |= T_TEXT;
    15921595    }
    15931596    if (fToolTitles && !fTextTools) {
    15941597      hwndTool = WinCreateWindow(hwndT,
    1595                                 WC_STATIC,
    1596                                 tool->text,
    1597                                 SS_TEXT | DT_LEFT | DT_VCENTER,
    1598                                 ctrlxpos,
    1599                                 1,
    1600                                 32,
    1601                                 10,
    1602                                 hwndT,
    1603                                 HWND_TOP, tool->id + 25000, NULL, NULL);
     1598                                WC_STATIC,
     1599                                tool->text,
     1600                                SS_TEXT | DT_LEFT | DT_VCENTER,
     1601                                ctrlxpos,
     1602                                1,
     1603                                32,
     1604                                10,
     1605                                hwndT,
     1606                                HWND_TOP, tool->id + 25000, NULL, NULL);
    16041607      if (!hwndTool)
    1605         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1606                    IDS_WINCREATEWINDOW);
     1608        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1609                   IDS_WINCREATEWINDOW);
    16071610      else {
    1608         SetPresParams(hwndTool,
    1609                       &RGBGREY,
    1610                       &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
     1611        SetPresParams(hwndTool,
     1612                      &RGBGREY,
     1613                      &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
    16111614      }
    16121615    }
    16131616    ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
    16141617    SetPresParams(WinWindowFromID(hwndT, tool->id),
    1615                   NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
     1618                  NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
    16161619    tool = tool->next;
    16171620  }                                     // while tool
    16181621
    16191622  hwndTool = WinCreateWindow(hwndT,
    1620                              WC_BUTTON,
    1621                              "#6010",
    1622                              BS_NOPOINTERFOCUS |
    1623                              BS_BITMAP | BS_PUSHBUTTON,
    1624                              1,
    1625                              19,
    1626                              14,
    1627                              13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
     1623                             WC_BUTTON,
     1624                             "#6010",
     1625                             BS_NOPOINTERFOCUS |
     1626                             BS_BITMAP | BS_PUSHBUTTON,
     1627                             1,
     1628                             19,
     1629                             14,
     1630                             13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
    16281631  if (!hwndTool)
    16291632    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1630                IDS_WINCREATEWINDOW);
     1633               IDS_WINCREATEWINDOW);
    16311634  hwndTool =
    16321635    WinCreateWindow(hwndT, WC_BUTTON, "#6011",
    1633                     BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
    1634                     13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
     1636                    BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
     1637                    13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
    16351638  if (!hwndTool)
    16361639    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1637                IDS_WINCREATEWINDOW);
     1640               IDS_WINCREATEWINDOW);
    16381641  if (resize)
    16391642    ResizeTools(hwndT);
     
    16411644
    16421645static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
    1643                                         MPARAM mp2)
     1646                                        MPARAM mp2)
    16441647{
    16451648  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    16581661
    16591662      if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
    1660         break;
     1663        break;
    16611664      if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
    1662         WinDestroyWindow(hwnd);
     1665        WinDestroyWindow(hwnd);
    16631666    }
    16641667    break;
     
    16701673      pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    16711674      if (pszCmdLine) {
    1672         lbup = TRUE;
    1673         if (WinDlgBox(HWND_DESKTOP,
    1674                         hwnd,
    1675                       CmdLine2DlgProc,
    1676                       FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
    1677           lstrip(pszCmdLine);
    1678         WinSetWindowText(hwnd, pszCmdLine);
    1679         }
    1680         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    1681         PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
    1682         free(pszCmdLine);
     1675        lbup = TRUE;
     1676        if (WinDlgBox(HWND_DESKTOP,
     1677                        hwnd,
     1678                      CmdLine2DlgProc,
     1679                      FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
     1680          lstrip(pszCmdLine);
     1681        WinSetWindowText(hwnd, pszCmdLine);
     1682        }
     1683        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     1684        PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
     1685        free(pszCmdLine);
    16831686      }
    16841687    }
     
    16971700    case COMMAND_BUTTON:
    16981701      if (!lbup)
    1699         PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1702        PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    17001703      break;
    17011704    }
     
    17161719      bstrip(cl + len);
    17171720      if (strlen(cl) > len) {
    1718         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    1719                    UM_SETUP, MPFROMP(cl + len), MPVOID);
    1720         WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
    1721         bstrip(directory);
    1722         if (*directory && (IsRoot(directory) || !IsFile(directory))) {
    1723           if (!FM2Command(directory, cl + len)) {
    1724             hwndCnr = TopWindow(hwndMain, (HWND) 0);
    1725             if (hwndCnr) {
    1726               hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
    1727               if (hwndCnr) {
    1728                 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
    1729                 if (hwndCnr)
    1730                   list = BuildList(hwndCnr);
    1731               }
    1732             }
    1733             WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
    1734             if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
    1735               save_cmdlines(FALSE);
    1736             ExecOnList(hwndCnr,
    1737                        cl,
    1738                        WINDOWED | ((fKeepCmdLine) ?
    1739                                    SEPARATEKEEP : SEPARATE),
    1740                        directory, list, NULL, pszSrcFile, __LINE__);
    1741             xfree(list, pszSrcFile, __LINE__);
    1742             WinDestroyWindow(hwnd);
    1743             break;
    1744           }
    1745         }
     1721        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
     1722                   UM_SETUP, MPFROMP(cl + len), MPVOID);
     1723        WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
     1724        bstrip(directory);
     1725        if (*directory && (IsRoot(directory) || !IsFile(directory))) {
     1726          if (!FM2Command(directory, cl + len)) {
     1727            hwndCnr = TopWindow(hwndMain, (HWND) 0);
     1728            if (hwndCnr) {
     1729              hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
     1730              if (hwndCnr) {
     1731                hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
     1732                if (hwndCnr)
     1733                  list = BuildList(hwndCnr);
     1734              }
     1735            }
     1736            WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
     1737            if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
     1738              save_cmdlines(FALSE);
     1739            ExecOnList(hwndCnr,
     1740                       cl,
     1741                       WINDOWED | ((fKeepCmdLine) ?
     1742                                   SEPARATEKEEP : SEPARATE),
     1743                       directory, list, NULL, pszSrcFile, __LINE__);
     1744            xfree(list, pszSrcFile, __LINE__);
     1745            WinDestroyWindow(hwnd);
     1746            break;
     1747          }
     1748        }
    17461749      }
    17471750      WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     
    17521755    if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
    17531756      if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
    1754         if ((SHORT1FROMMP(mp2) & 255) == '\r')
    1755           PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
    1756         else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
    1757           WinDestroyWindow(hwnd);
    1758         else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
    1759           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1757        if ((SHORT1FROMMP(mp2) & 255) == '\r')
     1758          PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
     1759        else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
     1760          WinDestroyWindow(hwnd);
     1761        else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
     1762          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    17601763      }
    17611764    }
    17621765    else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
    1763              ((SHORT2FROMMP(mp2) == VK_UP ||
    1764                SHORT2FROMMP(mp2) == VK_DOWN) ||
    1765               (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
     1766             ((SHORT2FROMMP(mp2) == VK_UP ||
     1767               SHORT2FROMMP(mp2) == VK_DOWN) ||
     1768              (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
    17661769      return 0;
    17671770    break;
     
    17891792      rgb.bRed = (BYTE)128;
    17901793      SetPresParams(hwnd,
    1791                     &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
     1794                    &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
    17921795      SetTargetDir(hwnd, TRUE);
    17931796    }
     
    18191822  case WM_CONTROLPOINTER:
    18201823    if (!fNoFinger &&
    1821         (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
    1822         SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
     1824        (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
     1825        SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
    18231826      return MRFROMLONG(hptrFinger);
    18241827    break;
     
    18301833      *dv = 0;
    18311834      WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
    1832                         2, dv);
     1835                        2, dv);
    18331836      if (isalpha(*dv)) {
    18341837
    1835         HWND hwndActive;
    1836 
    1837         dv[1] = ':';
    1838         dv[2] = '\\';
    1839         dv[3] = 0;
    1840         hwndActive = TopWindow(hwnd, (HWND) 0);
    1841         if (hwndActive)
    1842           WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    1843                      UM_DRIVECMD, MPFROMP(dv), MPVOID);
     1838        HWND hwndActive;
     1839
     1840        dv[1] = ':';
     1841        dv[2] = '\\';
     1842        dv[3] = 0;
     1843        hwndActive = TopWindow(hwnd, (HWND) 0);
     1844        if (hwndActive)
     1845          WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     1846                     UM_DRIVECMD, MPFROMP(dv), MPVOID);
    18441847      }
    18451848    }
     
    18691872  case WM_MOUSEMOVE:
    18701873    if (fDrivebarHelp &&
    1871         (!hwndBubble ||
    1872         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1873         !WinQueryCapture(HWND_DESKTOP)) {
     1874        (!hwndBubble ||
     1875        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1876        !WinQueryCapture(HWND_DESKTOP)) {
    18741877      id = WinQueryWindowUShort(hwnd, QWS_ID);
    18751878      if (helpid != id) {
    1876         helpid = id;
    1877         PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
     1879        helpid = id;
     1880        PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
    18781881      }
    18791882      else
    1880         helpid = 0;
     1883        helpid = 0;
    18811884    }
    18821885    break;
     
    18851888    if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
    18861889      if ((char *)mp1 &&
    1887           (!hwndBubble ||
    1888            WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1889           !WinQueryCapture(HWND_DESKTOP)) {
    1890 
    1891         RECTL rcl;
    1892         POINTL ptl;
    1893 
    1894         WinQueryPointerPos(HWND_DESKTOP, &ptl);
    1895         WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
    1896         WinQueryWindowRect(hwnd, &rcl);
    1897         if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
    1898           BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
     1890          (!hwndBubble ||
     1891           WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1892          !WinQueryCapture(HWND_DESKTOP)) {
     1893
     1894        RECTL rcl;
     1895        POINTL ptl;
     1896
     1897        WinQueryPointerPos(HWND_DESKTOP, &ptl);
     1898        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
     1899        WinQueryWindowRect(hwnd, &rcl);
     1900        if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
     1901          BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
    18991902      }
    19001903    }
     
    19151918    *szDrv = 0;
    19161919    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1917                                        id + 50), sizeof(szDrv), szDrv);
     1920                                       id + 50), sizeof(szDrv), szDrv);
    19181921    if (isalpha(*szDrv)) {
    19191922      hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
    19201923      if (hwndMenu) {
    1921         BOOL rdy;
    1922         CHAR chDrv = *szDrv;
    1923         UINT iDrv;
    1924 
    1925         strcpy(szDrv + 2, "\\");
    1926         MakeValidDir(szDrv);
    1927         // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
    1928         rdy = toupper(*szDrv) == toupper(chDrv);
    1929         iDrv = toupper(*szDrv) - 'A';
    1930         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    1931           WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
    1932 
    1933         if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
    1934           WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
    1935           WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
    1936           WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
    1937           WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
    1938         }
    1939         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
    1940           WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
    1941           WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
    1942           WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
    1943         }
    1944         if (!rdy) {
    1945           WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
    1946           WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
    1947           WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
    1948           WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
    1949           WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
    1950         }
    1951         /* fixme to be gone?
    1952           if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
    1953             WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
    1954           }
    1955         */
    1956         PopupMenu(hwnd, hwnd, hwndMenu);
     1924        BOOL rdy;
     1925        CHAR chDrv = *szDrv;
     1926        UINT iDrv;
     1927
     1928        strcpy(szDrv + 2, "\\");
     1929        MakeValidDir(szDrv);
     1930        // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
     1931        rdy = toupper(*szDrv) == toupper(chDrv);
     1932        iDrv = toupper(*szDrv) - 'A';
     1933        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
     1934          WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
     1935
     1936        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
     1937          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     1938          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     1939          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     1940          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     1941        }
     1942        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
     1943          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     1944          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     1945          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     1946        }
     1947        if (!rdy) {
     1948          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     1949          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     1950          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     1951          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     1952          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     1953        }
     1954        /* fixme to be gone?
     1955          if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     1956            WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     1957          }
     1958        */
     1959        PopupMenu(hwnd, hwnd, hwndMenu);
    19571960      }
    19581961    }
     
    19691972    *szDrv = 0;
    19701973    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1971                                        id + 50), sizeof(szDrv), szDrv);
     1974                                       id + 50), sizeof(szDrv), szDrv);
    19721975    if (isalpha(*szDrv)) {
    19731976      strcat(szDrv, "\\");
    19741977      if (!FindDirCnrByName(szDrv, TRUE))
    1975         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
     1978        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
    19761979    }
    19771980    break;
     
    19851988    *szDrv = 0;
    19861989    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1987                                        id + 50), sizeof(szDrv), szDrv);
     1990                                       id + 50), sizeof(szDrv), szDrv);
    19881991    if (isalpha(*szDrv)) {
    19891992      strcat(szDrv, "\\");
     
    19961999    *szDrv = 0;
    19972000    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1998                                        id + 50), sizeof(szDrv), szDrv);
     2001                                       id + 50), sizeof(szDrv), szDrv);
    19992002    if (isalpha(*szDrv) &&
    2000         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2003        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    20012004      if (!emphasized) {
    2002         emphasized = TRUE;
    2003         DrawTargetEmphasis(hwnd, emphasized);
     2005        emphasized = TRUE;
     2006        DrawTargetEmphasis(hwnd, emphasized);
    20042007      }
    20052008      if (AcceptOneDrop(hwnd, mp1, mp2))
    2006         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     2009        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    20072010      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    20082011    }
     
    20132016    *szDrv = 0;
    20142017    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2015                                        id + 50), sizeof(szDrv), szDrv);
     2018                                       id + 50), sizeof(szDrv), szDrv);
    20162019    if (isalpha(*szDrv) &&
    2017         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2020        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    20182021      if (emphasized) {
    2019         emphasized = FALSE;
    2020         DrawTargetEmphasis(hwnd, emphasized);
     2022        emphasized = FALSE;
     2023        DrawTargetEmphasis(hwnd, emphasized);
    20212024      }
    20222025    }
     
    20272030    *szDrv = 0;
    20282031    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2029                                        id + 50), sizeof(szDrv), szDrv);
     2032                                       id + 50), sizeof(szDrv), szDrv);
    20302033    if (isalpha(*szDrv) &&
    2031         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2034        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    20322035      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
    20332036      return 0;
     
    20392042    *szDrv = 0;
    20402043    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2041                                        id + 50), sizeof(szDrv), szDrv);
     2044                                       id + 50), sizeof(szDrv), szDrv);
    20422045    if (isalpha(*szDrv) &&
    2043         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2046        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    20442047
    20452048      CNRDRAGINFO cnd;
     
    20482051
    20492052      if (emphasized) {
    2050         emphasized = FALSE;
    2051         DrawTargetEmphasis(hwnd, emphasized);
     2053        emphasized = FALSE;
     2054        DrawTargetEmphasis(hwnd, emphasized);
    20522055      }
    20532056      memset(&cnd, 0, sizeof(cnd));
     
    20552058      cnd.pRecord = NULL;
    20562059      li = DoFileDrop(hwnd,
    2057                       NULL,
    2058                       TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
     2060                      NULL,
     2061                      TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
    20592062      CheckPmDrgLimit(cnd.pDragInfo);
    20602063      if (li) {
    2061         strcpy(li->targetpath, szDrv);
    2062         strcat(li->targetpath, "\\");
    2063         if (li->list && li->list[0] && IsRoot(li->list[0]))
    2064           li->type = DO_LINK;
    2065         else if (fDragndropDlg && (!*li->arcname || !li->info)) {
    2066 
    2067           CHECKLIST cl;
    2068 
    2069           memset(&cl, 0, sizeof(cl));
    2070           cl.size = sizeof(cl);
    2071           cl.flags = li->type;
    2072           cl.list = li->list;
    2073           cl.cmd = li->type;
    2074           cl.prompt = li->targetpath;
    2075           li->type = WinDlgBox(HWND_DESKTOP,
    2076                                hwndMain,
    2077                                DropListProc,
    2078                                FM3ModHandle, DND_FRAME, MPFROMP(&cl));
    2079           if (li->type == DID_ERROR)
    2080                   Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
    2081                             "Drag & Drop Dialog");
    2082           if (!li->type) {
    2083             FreeListInfo(li);
    2084             return 0;
    2085           }
    2086           li->list = cl.list;
    2087           if (!li->list || !li->list[0]) {
    2088             FreeListInfo(li);
    2089             return 0;
    2090           }
    2091         }
    2092         else {
    2093           if (!WinDlgBox(HWND_DESKTOP,
    2094                         hwndMain,
    2095                         WalkDlgProc,
    2096                         FM3ModHandle,
    2097                         WALK_FRAME,
    2098                         MPFROMP(li->targetpath)) || !*li->targetpath) {
    2099             FreeListInfo(li);
    2100             return 0;
    2101           }
    2102         }
    2103         switch (li->type) {
    2104         case DND_LAUNCH:
    2105           strcat(li->targetpath, " %a");
    2106           ExecOnList(hwndMain,
    2107                      li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
    2108                      pszSrcFile, __LINE__);
    2109           FreeList(li->list);
    2110           li->list = NULL;
    2111           break;
    2112         case DO_LINK:
    2113           if (fLinkSetsIcon) {
    2114             li->type = IDM_SETICON;
    2115             action = UM_MASSACTION;
    2116           }
    2117           else
    2118             li->type = IDM_COMPARE;
    2119           break;
    2120         case DND_EXTRACT:
    2121           if (*li->targetpath && !IsFile(li->targetpath))
    2122             li->type = IDM_EXTRACT;
    2123           break;
    2124         case DND_MOVE:
    2125           li->type = IDM_MOVE;
    2126           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2127             action = UM_MASSACTION;
    2128             li->type = IDM_ARCHIVEM;
    2129           }
    2130           break;
    2131         case DND_WILDMOVE:
    2132           li->type = IDM_WILDMOVE;
    2133           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2134             action = UM_MASSACTION;
    2135             li->type = IDM_ARCHIVEM;
    2136           }
    2137           break;
    2138         case DND_OBJECT:
    2139           li->type = IDM_OBJECT;
    2140           action = UM_MASSACTION;
    2141           break;
    2142         case DND_SHADOW:
    2143           li->type = IDM_SHADOW;
    2144           action = UM_MASSACTION;
    2145           break;
    2146         case DND_COMPARE:
    2147           li->type = IDM_COMPARE;
    2148           break;
    2149         case DND_SETICON:
    2150           action = UM_MASSACTION;
    2151           li->type = IDM_SETICON;
    2152           break;
    2153         case DND_COPY:
    2154           li->type = IDM_COPY;
    2155           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2156             action = UM_MASSACTION;
    2157             li->type = IDM_ARCHIVE;
    2158           }
    2159           break;
    2160         case DND_WILDCOPY:
    2161           li->type = IDM_WILDCOPY;
    2162           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2163             action = UM_MASSACTION;
    2164             li->type = IDM_ARCHIVE;
    2165           }
    2166           break;
    2167         default:
    2168           if (*li->arcname && li->info) {
    2169             action = UM_MASSACTION;
    2170             li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
    2171               IDM_FAKEEXTRACT;
    2172           }
    2173           else if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2174             action = UM_MASSACTION;
    2175             li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
    2176           }
    2177           else
    2178             li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    2179           break;
    2180         }
    2181         if (!li->list || !li->list[0])
    2182           FreeListInfo(li);
    2183         else
    2184           WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
     2064        strcpy(li->targetpath, szDrv);
     2065        strcat(li->targetpath, "\\");
     2066        if (li->list && li->list[0] && IsRoot(li->list[0]))
     2067          li->type = DO_LINK;
     2068        else if (fDragndropDlg && (!*li->arcname || !li->info)) {
     2069
     2070          CHECKLIST cl;
     2071
     2072          memset(&cl, 0, sizeof(cl));
     2073          cl.size = sizeof(cl);
     2074          cl.flags = li->type;
     2075          cl.list = li->list;
     2076          cl.cmd = li->type;
     2077          cl.prompt = li->targetpath;
     2078          li->type = WinDlgBox(HWND_DESKTOP,
     2079                               hwndMain,
     2080                               DropListProc,
     2081                               FM3ModHandle, DND_FRAME, MPFROMP(&cl));
     2082          if (li->type == DID_ERROR)
     2083                  Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
     2084                            "Drag & Drop Dialog");
     2085          if (!li->type) {
     2086            FreeListInfo(li);
     2087            return 0;
     2088          }
     2089          li->list = cl.list;
     2090          if (!li->list || !li->list[0]) {
     2091            FreeListInfo(li);
     2092            return 0;
     2093          }
     2094        }
     2095        else {
     2096          if (!WinDlgBox(HWND_DESKTOP,
     2097                        hwndMain,
     2098                        WalkDlgProc,
     2099                        FM3ModHandle,
     2100                        WALK_FRAME,
     2101                        MPFROMP(li->targetpath)) || !*li->targetpath) {
     2102            FreeListInfo(li);
     2103            return 0;
     2104          }
     2105        }
     2106        switch (li->type) {
     2107        case DND_LAUNCH:
     2108          strcat(li->targetpath, " %a");
     2109          ExecOnList(hwndMain,
     2110                     li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
     2111                     pszSrcFile, __LINE__);
     2112          FreeList(li->list);
     2113          li->list = NULL;
     2114          break;
     2115        case DO_LINK:
     2116          if (fLinkSetsIcon) {
     2117            li->type = IDM_SETICON;
     2118            action = UM_MASSACTION;
     2119          }
     2120          else
     2121            li->type = IDM_COMPARE;
     2122          break;
     2123        case DND_EXTRACT:
     2124          if (*li->targetpath && !IsFile(li->targetpath))
     2125            li->type = IDM_EXTRACT;
     2126          break;
     2127        case DND_MOVE:
     2128          li->type = IDM_MOVE;
     2129          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2130            action = UM_MASSACTION;
     2131            li->type = IDM_ARCHIVEM;
     2132          }
     2133          break;
     2134        case DND_WILDMOVE:
     2135          li->type = IDM_WILDMOVE;
     2136          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2137            action = UM_MASSACTION;
     2138            li->type = IDM_ARCHIVEM;
     2139          }
     2140          break;
     2141        case DND_OBJECT:
     2142          li->type = IDM_OBJECT;
     2143          action = UM_MASSACTION;
     2144          break;
     2145        case DND_SHADOW:
     2146          li->type = IDM_SHADOW;
     2147          action = UM_MASSACTION;
     2148          break;
     2149        case DND_COMPARE:
     2150          li->type = IDM_COMPARE;
     2151          break;
     2152        case DND_SETICON:
     2153          action = UM_MASSACTION;
     2154          li->type = IDM_SETICON;
     2155          break;
     2156        case DND_COPY:
     2157          li->type = IDM_COPY;
     2158          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2159            action = UM_MASSACTION;
     2160            li->type = IDM_ARCHIVE;
     2161          }
     2162          break;
     2163        case DND_WILDCOPY:
     2164          li->type = IDM_WILDCOPY;
     2165          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2166            action = UM_MASSACTION;
     2167            li->type = IDM_ARCHIVE;
     2168          }
     2169          break;
     2170        default:
     2171          if (*li->arcname && li->info) {
     2172            action = UM_MASSACTION;
     2173            li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
     2174              IDM_FAKEEXTRACT;
     2175          }
     2176          else if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2177            action = UM_MASSACTION;
     2178            li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
     2179          }
     2180          else
     2181            li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
     2182          break;
     2183        }
     2184        if (!li->list || !li->list[0])
     2185          FreeListInfo(li);
     2186        else
     2187          WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
    21852188      }
    21862189      return 0;
     
    22162219    for (x = 0; x < 26; x++) {
    22172220      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    2218         if (x > 1) {
    2219           if (driveflags[x] & DRIVE_CDROM)
    2220             iconid = CDROM_ICON;
    2221           else
    2222             iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
    2223               REMOVABLE_ICON :
    2224                      (driveflags[x] & DRIVE_VIRTUAL) ?
    2225                       VIRTUAL_ICON :
    2226               (driveflags[x] & DRIVE_REMOTE) ?
    2227               REMOTE_ICON :
    2228                      (driveflags[x] & DRIVE_RAMDISK) ?
    2229                       RAMDISK_ICON :
    2230                      (driveflags[x] & DRIVE_ZIPSTREAM) ?
    2231                       ZIPSTREAM_ICON :DRIVE_ICON;
    2232         }
    2233         else
    2234           iconid = FLOPPY_ICON;
    2235         sprintf(s, "#%lu", iconid);
    2236         hwndB = WinCreateWindow(hwndT,
    2237                                 WC_DRIVEBUTTONS,
    2238                                 s,
    2239                                 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
    2240                                 0,
    2241                                 0,
    2242                                 28,
    2243                                 18,
    2244                                 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
    2245         if (!hwndB)
    2246           Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2247                      IDS_WINCREATEWINDOW);
    2248         else {
    2249           WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2250           sprintf(s, "%c:", (CHAR) x + 'A');
    2251           hwndB = WinCreateWindow(hwndT,
    2252                                   WC_STATIC,
    2253                                   s,
    2254                                   SS_TEXT | DT_LEFT | DT_VCENTER,
    2255                                   0,
    2256                                   0,
    2257                                   10,
    2258                                   18,
    2259                                   hwndT,
    2260                                   HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
    2261           if (!hwndB)
    2262             Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2263                        IDS_WINCREATEWINDOW);
    2264           else {
    2265             SetPresParams(hwndB,
    2266                           &RGBGREY,
    2267                           &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    2268             WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2269           }
    2270           y++;
    2271         }
     2221        if (x > 1) {
     2222          if (driveflags[x] & DRIVE_CDROM)
     2223            iconid = CDROM_ICON;
     2224          else
     2225            iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
     2226              REMOVABLE_ICON :
     2227                     (driveflags[x] & DRIVE_VIRTUAL) ?
     2228                      VIRTUAL_ICON :
     2229              (driveflags[x] & DRIVE_REMOTE) ?
     2230              REMOTE_ICON :
     2231                     (driveflags[x] & DRIVE_RAMDISK) ?
     2232                      RAMDISK_ICON :
     2233                     (driveflags[x] & DRIVE_ZIPSTREAM) ?
     2234                      ZIPSTREAM_ICON :DRIVE_ICON;
     2235        }
     2236        else
     2237          iconid = FLOPPY_ICON;
     2238        sprintf(s, "#%lu", iconid);
     2239        hwndB = WinCreateWindow(hwndT,
     2240                                WC_DRIVEBUTTONS,
     2241                                s,
     2242                                BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
     2243                                0,
     2244                                0,
     2245                                28,
     2246                                18,
     2247                                hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
     2248        if (!hwndB)
     2249          Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2250                     IDS_WINCREATEWINDOW);
     2251        else {
     2252          WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2253          sprintf(s, "%c:", (CHAR) x + 'A');
     2254          hwndB = WinCreateWindow(hwndT,
     2255                                  WC_STATIC,
     2256                                  s,
     2257                                  SS_TEXT | DT_LEFT | DT_VCENTER,
     2258                                  0,
     2259                                  0,
     2260                                  10,
     2261                                  18,
     2262                                  hwndT,
     2263                                  HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
     2264          if (!hwndB)
     2265            Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2266                       IDS_WINCREATEWINDOW);
     2267          else {
     2268            SetPresParams(hwndB,
     2269                          &RGBGREY,
     2270                          &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     2271            WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2272          }
     2273          y++;
     2274        }
    22722275      }
    22732276    }                                   // for
    22742277  }                                     // if drivebar
    22752278  PostMsg(WinQueryWindow(hwndT, QW_PARENT),
    2276           WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2279          WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22772280}
    22782281
     
    22902293    WinQueryWindowRect(hwndT, &rcl);
    22912294    xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
    2292                                              SV_CYSIZEBORDER) * 2) + 2);
     2295                                             SV_CYSIZEBORDER) * 2) + 2);
    22932296  }
    22942297  henum = WinBeginEnumWindows(hwndT);
     
    22992302      ctrlxsize = 28;
    23002303    WinSetWindowPos(hwndB,
    2301                     HWND_TOP,
    2302                     ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
     2304                    HWND_TOP,
     2305                    ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
    23032306    ctrlxpos += (ctrlxsize + 2);
    23042307    if (ctrlxsize == 10) {
    23052308      if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
    2306                             256 : 0)) > xwidth) {
    2307         ctrlxpos = 2;
    2308         ctrlypos += 18;
    2309         DriveLines++;
     2309                            256 : 0)) > xwidth) {
     2310        ctrlxpos = 2;
     2311        ctrlypos += 18;
     2312        DriveLines++;
    23102313      }
    23112314    }
     
    23262329
    23272330      SetPresParams(hwnd,
    2328                     &RGBGREY,
    2329                     &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
     2331                    &RGBGREY,
     2332                    &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
    23302333      return mr;
    23312334    }
     
    23372340
    23382341      cbRetLen = WinQueryPresParam(hwnd,
    2339                                    (ULONG) mp1,
    2340                                    0,
    2341                                    &AttrFound,
    2342                                    (ULONG) sizeof(AttrValue), &AttrValue, 0);
     2342                                   (ULONG) mp1,
     2343                                   0,
     2344                                   &AttrFound,
     2345                                   (ULONG) sizeof(AttrValue), &AttrValue, 0);
    23432346      if (cbRetLen) {
    2344         PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2345                 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2347        PostMsg(WinQueryWindow(hwnd, QW_PARENT),
     2348                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    23462349      }
    23472350    }
     
    23602363      WinQueryWindowPos(hwndTree, &swp);
    23612364      if (!(swp.fl & SWP_MAXIMIZE))
    2362         fl |= SWP_RESTORE;
     2365        fl |= SWP_RESTORE;
    23632366      WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
    23642367    }
     
    23932396
    23942397      if (fOtherHelp) {
    2395         if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    2396             && !WinQueryCapture(HWND_DESKTOP)) {
    2397           switch (id) {
    2398           case IDM_ATTRS:
    2399             if (WinQueryWindowTextLength(hwnd))
    2400               s = GetPString(IDS_ATTRSBUTTONHELP);
    2401             break;
    2402           case IDM_INFO:
    2403             if (WinQueryWindowTextLength(hwnd))
    2404               s = GetPString(IDS_INFOBUTTONHELP);
    2405             break;
    2406           case IDM_RENAME:
    2407             if (WinQueryWindowTextLength(hwnd))
    2408               s = GetPString(IDS_NAMEBUTTONHELP);
    2409             break;
    2410           case MAIN_STATUS2:
    2411             if (!hwndE)
    2412               s = GetPString(IDS_STATUS2HELP);
    2413             break;
    2414           default:
    2415             break;
    2416           }
    2417           if (s)
    2418             MakeBubble(hwnd, FALSE, s);
    2419           else if (hwndBubble)
    2420             WinDestroyWindow(hwndBubble);
    2421         }
     2398        if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
     2399            && !WinQueryCapture(HWND_DESKTOP)) {
     2400          switch (id) {
     2401          case IDM_ATTRS:
     2402            if (WinQueryWindowTextLength(hwnd))
     2403              s = GetPString(IDS_ATTRSBUTTONHELP);
     2404            break;
     2405          case IDM_INFO:
     2406            if (WinQueryWindowTextLength(hwnd))
     2407              s = GetPString(IDS_INFOBUTTONHELP);
     2408            break;
     2409          case IDM_RENAME:
     2410            if (WinQueryWindowTextLength(hwnd))
     2411              s = GetPString(IDS_NAMEBUTTONHELP);
     2412            break;
     2413          case MAIN_STATUS2:
     2414            if (!hwndE)
     2415              s = GetPString(IDS_STATUS2HELP);
     2416            break;
     2417          default:
     2418            break;
     2419          }
     2420          if (s)
     2421            MakeBubble(hwnd, FALSE, s);
     2422          else if (hwndBubble)
     2423            WinDestroyWindow(hwndBubble);
     2424        }
    24222425      }
    24232426      switch (id) {
     
    24262429      case IDM_RENAME:
    24272430      case MAIN_STATUS2:
    2428         return CommonTextProc(hwnd, msg, mp1, mp2);
     2431        return CommonTextProc(hwnd, msg, mp1, mp2);
    24292432      default:
    2430         break;
     2433        break;
    24312434      }
    24322435    }
     
    24512454      case IDM_RENAME:
    24522455      case MAIN_STATUS2:
    2453         return CommonTextButton(hwnd, msg, mp1, mp2);
     2456        return CommonTextButton(hwnd, msg, mp1, mp2);
    24542457      default:
    2455         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    2456         break;
     2458        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     2459        break;
    24572460      }
    24582461    }
     
    24662469      id = WinQueryWindowUShort(hwnd, QWS_ID);
    24672470      if (id == MAIN_STATUS2 && hwndE)
    2468         WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2471        WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    24692472      else
    2470         return CommonTextButton(hwnd, msg, mp1, mp2);
     2473        return CommonTextButton(hwnd, msg, mp1, mp2);
    24712474    }
    24722475    break;
     
    24782481      id = WinQueryWindowUShort(hwnd, QWS_ID);
    24792482      if (id == MAIN_STATUS) {
    2480         if (SHORT2FROMMP(mp2) & KC_CTRL)
    2481           PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2482                                   FID_CLIENT),
    2483                   WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    2484         else if (hwndTree)
    2485           PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
     2483        if (SHORT2FROMMP(mp2) & KC_CTRL)
     2484          PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2485                                  FID_CLIENT),
     2486                  WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     2487        else if (hwndTree)
     2488          PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
    24862489      }
    24872490    }
     
    24962499      if (id == MAIN_STATUS2 && !hwndE) {
    24972500
    2498         SWP swp;
    2499         CHAR directory[CCHMAXPATH];
    2500         PFNWP oldproce;
    2501 
    2502         *directory = 0;
    2503         TopWindowName(hwndMain, (HWND) 0, directory);
    2504         WinQueryWindowPos(hwnd, &swp);
    2505         hwndB = WinCreateWindow(hwnd,
    2506                                 WC_BUTTON,
    2507                                 "+",
    2508                                 WS_VISIBLE | BS_PUSHBUTTON |
    2509                                 BS_NOPOINTERFOCUS,
    2510                                 swp.cx - swp.cy,
    2511                                 0,
    2512                                 swp.cy,
    2513                                 swp.cy,
    2514                                 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
    2515         if (!hwndB)
    2516           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2517         hwndE = WinCreateWindow(hwnd,
    2518                                 WC_ENTRYFIELD,
    2519                                 NULL,
    2520                                 WS_VISIBLE | ES_AUTOSCROLL,
    2521                                 0,
    2522                                 0,
    2523                                 swp.cx - swp.cy,
    2524                                 swp.cy,
    2525                                 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
    2526         if (!hwndE)
    2527           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2528         if (!hwndE || !hwndB) {
    2529           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2530           return 0;
    2531         }
    2532         WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
    2533         WinSetWindowText(hwndStatus, directory);
    2534         if (*lastcmd)
    2535           WinSetWindowText(hwndE, lastcmd);
    2536         else
    2537           WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
    2538         oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
    2539         if (oldproce)
    2540           WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
    2541         PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
    2542         PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
    2543         return 0;
     2501        SWP swp;
     2502        CHAR directory[CCHMAXPATH];
     2503        PFNWP oldproce;
     2504
     2505        *directory = 0;
     2506        TopWindowName(hwndMain, (HWND) 0, directory);
     2507        WinQueryWindowPos(hwnd, &swp);
     2508        hwndB = WinCreateWindow(hwnd,
     2509                                WC_BUTTON,
     2510                                "+",
     2511                                WS_VISIBLE | BS_PUSHBUTTON |
     2512                                BS_NOPOINTERFOCUS,
     2513                                swp.cx - swp.cy,
     2514                                0,
     2515                                swp.cy,
     2516                                swp.cy,
     2517                                hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
     2518        if (!hwndB)
     2519          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2520        hwndE = WinCreateWindow(hwnd,
     2521                                WC_ENTRYFIELD,
     2522                                NULL,
     2523                                WS_VISIBLE | ES_AUTOSCROLL,
     2524                                0,
     2525                                0,
     2526                                swp.cx - swp.cy,
     2527                                swp.cy,
     2528                                hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
     2529        if (!hwndE)
     2530          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2531        if (!hwndE || !hwndB) {
     2532          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2533          return 0;
     2534        }
     2535        WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
     2536        WinSetWindowText(hwndStatus, directory);
     2537        if (*lastcmd)
     2538          WinSetWindowText(hwndE, lastcmd);
     2539        else
     2540          WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
     2541        oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
     2542        if (oldproce)
     2543          WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
     2544        PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
     2545        PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     2546        return 0;
    25442547      }
    25452548      if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
    2546         switch (id) {
    2547         case IDM_ATTRS:
    2548           id = IDM_SORTSIZE;
    2549           break;
    2550         case IDM_INFO:
    2551           id = IDM_SORTLWDATE;
    2552           break;
    2553         case IDM_RENAME:
    2554           id = IDM_SORTFILENAME;
    2555           break;
    2556         }
     2549        switch (id) {
     2550        case IDM_ATTRS:
     2551          id = IDM_SORTSIZE;
     2552          break;
     2553        case IDM_INFO:
     2554          id = IDM_SORTLWDATE;
     2555          break;
     2556        case IDM_RENAME:
     2557          id = IDM_SORTFILENAME;
     2558          break;
     2559        }
    25572560      }
    25582561      PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2559               WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
     2562              WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
    25602563    }
    25612564    return 0;
     
    25712574      case IDM_RENAME:
    25722575      case MAIN_STATUS2:
    2573         PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
    2574         break;
     2576        PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
     2577        break;
    25752578      default:
    2576         PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
    2577         break;
     2579        PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
     2580        break;
    25782581      }
    25792582      if (id == IDM_RENAME) {
    25802583
    2581         HPS hps;
    2582 
    2583         hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    2584         if (hps) {
    2585           PaintSTextWindow(hwnd, hps);
    2586           WinEndPaint(hps);
    2587         }
    2588         return 0;
     2584        HPS hps;
     2585
     2586        hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
     2587        if (hps) {
     2588          PaintSTextWindow(hwnd, hps);
     2589          WinEndPaint(hps);
     2590        }
     2591        return 0;
    25892592      }
    25902593    }
     
    26192622  case UM_COMMAND:
    26202623    return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2621                                       FID_CLIENT), msg, mp1, mp2);
     2624                                      FID_CLIENT), msg, mp1, mp2);
    26222625
    26232626  case WM_PAINT:
     
    26322635      hps = WinBeginPaint(hwnd, (HPS)0, NULL);
    26332636      if (hps) {
    2634         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
    2635         WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
    2636                           sizeof(lColor), &lColor, 0);
    2637         if (!lColor)
    2638           lColor = CLR_PALEGRAY;
    2639         WinQueryWindowRect(hwnd, &rcl);
    2640         WinFillRect(hps, &rcl, lColor);
    2641         WinEndPaint(hps);
     2637        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
     2638        WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
     2639                          sizeof(lColor), &lColor, 0);
     2640        if (!lColor)
     2641          lColor = CLR_PALEGRAY;
     2642        WinQueryWindowRect(hwnd, &rcl);
     2643        WinFillRect(hps, &rcl, lColor);
     2644        WinEndPaint(hps);
    26422645      }
    26432646
     
    26582661      tool = find_tool(id);
    26592662      if (tool) {
    2660         del_tool(tool);
    2661         WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
    2662         if (fToolTitles)
    2663           WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
    2664         ResizeTools(hwnd);
    2665         save_tools(NULL);
     2663        del_tool(tool);
     2664        WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
     2665        if (fToolTitles)
     2666          WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
     2667        ResizeTools(hwnd);
     2668        save_tools(NULL);
    26662669      }
    26672670    }
     
    26772680
    26782681      id = (USHORT) WinDlgBox(HWND_DESKTOP,
    2679                               hwnd,
    2680                               AddToolProc,
    2681                               FM3ModHandle, ADDBTN_FRAME, MPVOID);
     2682                              hwnd,
     2683                              AddToolProc,
     2684                              FM3ModHandle, ADDBTN_FRAME, MPVOID);
    26822685      if (id && id != (USHORT) - 1)
    2683         WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2684                                    FID_CLIENT),
    2685                    WM_COMMAND,
    2686                    MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
     2686        WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2687                                   FID_CLIENT),
     2688                   WM_COMMAND,
     2689                   MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
    26872690    }
    26882691    break;
     
    26902693  case WM_CONTEXTMENU:
    26912694    if (WinDlgBox(HWND_DESKTOP,
    2692                   hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
     2695                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    26932696      PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
    26942697    return MRFROMSHORT(TRUE);
     
    27132716  if (pswp) {
    27142717    if (WinQueryWindowPos(hwndTree, &swp) &&
    2715         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
     2718        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
    27162719      pswp->x = swp.cx;
    27172720      pswp->cx -= swp.cx;
     
    27202723  if (prectl) {
    27212724    if (WinQueryWindowPos(hwndTree, &swp) &&
    2722         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
    2723         WinQueryWindowRect(hwndTree, &rectl)) {
     2725        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
     2726        WinQueryWindowRect(hwndTree, &rectl)) {
    27242727      prectl->xLeft = rectl.xRight;
    27252728      prectl->xRight -= rectl.xRight;
     
    27732776    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    27742777      if (swp.x < swpT.cx) {
    2775         swp.x = swpT.cx;
    2776         if (swp.x + swp.cx > swpC.cx)
    2777           swp.cx = swpC.cx - swp.x;
    2778         if (swp.cx > 24)
    2779           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    2780                           SWP_SIZE | SWP_MOVE | SWP_SHOW);
     2778        swp.x = swpT.cx;
     2779        if (swp.x + swp.cx > swpC.cx)
     2780          swp.cx = swpC.cx - swp.x;
     2781        if (swp.cx > 24)
     2782          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     2783                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
    27812784      }
    27822785    }
     
    27982801      WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    27992802      WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    2800                       SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
     2803                      SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
    28012804    }
    28022805  }
     
    28202823    if (hwndNext) {
    28212824      if (!WinQueryWindowUShort(hwndNext, QWS_ID))
    2822         continue;
     2825        continue;
    28232826      if (next)
    2824         break;
     2827        break;
    28252828      if (hwndNext == hwndActive) {
    2826         if (!previous && hwndPrev) {
    2827           hwndNext = hwndPrev;
    2828           break;
    2829         }
    2830         else if (previous)
    2831           next = TRUE;
     2829        if (!previous && hwndPrev) {
     2830          hwndNext = hwndPrev;
     2831          break;
     2832        }
     2833        else if (previous)
     2834          next = TRUE;
    28322835      }
    28332836      hwndPrev = hwndNext;
     
    28352838    else {
    28362839      if ((!next && previous) || once)
    2837         break;
     2840        break;
    28382841      else if (!previous) {
    2839         hwndNext = hwndPrev;
    2840         break;
     2842        hwndNext = hwndPrev;
     2843        break;
    28412844      }
    28422845      else
    2843         once = next = TRUE;
     2846        once = next = TRUE;
    28442847    }
    28452848  }
     
    28482851  if (hwndNext && hwndNext != hwndActive) {
    28492852    WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
    2850                     SWP_ZORDER | SWP_ACTIVATE);
     2853                    SWP_ZORDER | SWP_ACTIVATE);
    28512854    WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
    2852                     0, 0, SWP_ZORDER);
     2855                    0, 0, SWP_ZORDER);
    28532856  }
    28542857}
     
    28652868    if (hwndChild != hwndTree) {
    28662869      WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2867                 WM_SAVEAPPLICATION, MPVOID, MPVOID);
     2870                WM_SAVEAPPLICATION, MPVOID, MPVOID);
    28682871      if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2869                      WM_CLOSE, MPVOID, MPVOID)) {
    2870         ret = TRUE;
    2871         break;
     2872                     WM_CLOSE, MPVOID, MPVOID)) {
     2873        ret = TRUE;
     2874        break;
    28722875      }
    28732876    }
     
    28922895      hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
    28932896      if (hwndTemp) {
    2894         hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
    2895         if (hwndDir) {
    2896           WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2897                      WM_CLOSE, MPVOID, MPVOID);
    2898           ret = TRUE;
    2899         }
     2897        hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
     2898        if (hwndDir) {
     2899          WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
     2900                     WM_CLOSE, MPVOID, MPVOID);
     2901          ret = TRUE;
     2902        }
    29002903      }
    29012904    }
     
    29532956      hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
    29542957      if (hwndC) {
    2955         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    2956         if (hwndDir) {
    2957           WinQueryWindowPos(hwndChild, &swp);
    2958           *szDir = 0;
    2959           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
    2960           if (*szDir) {
    2961            // If saving shutdown state skip no prescan drives
    2962             if (fIsShutDownState &&
    2963                 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    2964               continue;
    2965             }
    2966             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2967             PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    2968                                 sizeof(SWP));
    2969             dcd =
    2970               WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2971             if (dcd) {
    2972               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2973               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2974                                   sizeof(INT));
    2975               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2976               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2977                                   sizeof(MASK));
    2978               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    2979               flWindowAttr = dcd->flWindowAttr;
    2980               if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
    2981                 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    2982                 if (dcd->lastattr) {
    2983                   if (dcd->lastattr & CV_TEXT)
    2984                     flWindowAttr |= CV_TEXT;
    2985                   else if (dcd->lastattr & CV_DETAIL)
    2986                     flWindowAttr |= CV_DETAIL;
    2987                   else if (dcd->lastattr & CV_ICON)
    2988                     flWindowAttr |= CV_ICON;
    2989                   else
    2990                     flWindowAttr |= CV_NAME;
    2991                 }
    2992                 else
    2993                   flWindowAttr |= CV_NAME;
    2994               }
    2995               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    2996                                   sizeof(ULONG));
    2997               sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
    2998               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
    2999                                   sizeof(BOOL));
    3000               sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
    3001               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
    3002                                   sizeof(BOOL));
    3003               sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
    3004               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
    3005                                   sizeof(BOOL));
    3006               sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
    3007               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
    3008                                   sizeof(BOOL));
    3009               sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
    3010               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
    3011                                   sizeof(BOOL));
    3012               sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
    3013               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
    3014                                   sizeof(BOOL));
    3015               sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
    3016               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
    3017                                   sizeof(BOOL));
    3018               sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
    3019               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
    3020                                   sizeof(BOOL));
    3021               sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
    3022               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
    3023                                   sizeof(BOOL));
    3024               sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
    3025               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
    3026                                   sizeof(BOOL));
    3027               sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
    3028               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
    3029                                   sizeof(BOOL));
    3030               sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
    3031               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
    3032                                   sizeof(BOOL));
    3033               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    3034               SavePresParams(hwndDir, szKey);
    3035             }
    3036             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    3037             PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    3038           }
    3039         }
     2958        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     2959        if (hwndDir) {
     2960          WinQueryWindowPos(hwndChild, &swp);
     2961          *szDir = 0;
     2962          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
     2963          if (*szDir) {
     2964           // If saving shutdown state skip no prescan drives
     2965            if (fIsShutDownState &&
     2966                driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     2967              continue;
     2968            }
     2969            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2970            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
     2971                                sizeof(SWP));
     2972            dcd =
     2973              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
     2974            if (dcd) {
     2975              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2976              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
     2977                                  sizeof(INT));
     2978              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2979              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
     2980                                  sizeof(MASK));
     2981              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2982              flWindowAttr = dcd->flWindowAttr;
     2983              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     2984                flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     2985                if (dcd->lastattr) {
     2986                  if (dcd->lastattr & CV_TEXT)
     2987                    flWindowAttr |= CV_TEXT;
     2988                  else if (dcd->lastattr & CV_DETAIL)
     2989                    flWindowAttr |= CV_DETAIL;
     2990                  else if (dcd->lastattr & CV_ICON)
     2991                    flWindowAttr |= CV_ICON;
     2992                  else
     2993                    flWindowAttr |= CV_NAME;
     2994                }
     2995                else
     2996                  flWindowAttr |= CV_NAME;
     2997              }
     2998              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2999                                  sizeof(ULONG));
     3000              sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
     3001              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
     3002                                  sizeof(BOOL));
     3003              sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
     3004              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
     3005                                  sizeof(BOOL));
     3006              sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
     3007              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
     3008                                  sizeof(BOOL));
     3009              sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
     3010              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
     3011                                  sizeof(BOOL));
     3012              sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
     3013              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
     3014                                  sizeof(BOOL));
     3015              sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
     3016              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
     3017                                  sizeof(BOOL));
     3018              sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
     3019              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
     3020                                  sizeof(BOOL));
     3021              sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
     3022              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
     3023                                  sizeof(BOOL));
     3024              sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
     3025              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
     3026                                  sizeof(BOOL));
     3027              sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
     3028              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
     3029                                  sizeof(BOOL));
     3030              sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
     3031              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
     3032                                  sizeof(BOOL));
     3033              sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
     3034              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
     3035                                  sizeof(BOOL));
     3036              sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
     3037              SavePresParams(hwndDir, szKey);
     3038            }
     3039            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     3040            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     3041          }
     3042        }
    30403043      }
    30413044    }
     
    31223125    if (hwnd) {
    31233126      if (WinQueryWindowPos(hwnd, &swp)) {
    3124         if (pswp->x > swp.cx)
    3125           pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
    3126         if (pswp->y > swp.cy)
    3127           pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
    3128         if (pswp->x + pswp->cx > swp.cx)
    3129           pswp->cx = swp.cx - pswp->x;
    3130         if (pswp->y + pswp->cy > swp.cy)
    3131           pswp->cy = swp.cy - pswp->y;
     3127        if (pswp->x > swp.cx)
     3128          pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
     3129        if (pswp->y > swp.cy)
     3130          pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
     3131        if (pswp->x + pswp->cx > swp.cx)
     3132          pswp->cx = swp.cx - pswp->x;
     3133        if (pswp->y + pswp->cy > swp.cy)
     3134          pswp->cy = swp.cy - pswp->y;
    31323135      }
    31333136    }
     
    31963199  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    31973200  if (!PrfQueryProfileData(fmprof,
    3198                            FM3Str,
    3199                            szKey,
    3200                            (PVOID) &swpO,
    3201                            &size) ||
     3201                           FM3Str,
     3202                           szKey,
     3203                           (PVOID) &swpO,
     3204                           &size) ||
    32023205      size != sizeof(SWP) || !swp.cx || !swp.cy)
    32033206  {
     
    32273230      swp.fl &= (~SWP_ACTIVATE);
    32283231      WinSetWindowPos(hwndTree,
    3229                       HWND_TOP,
    3230                       swp.x,
    3231                       swp.y,
    3232                       swp.cx,
    3233                       swp.cy,
    3234                       swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     3232                      HWND_TOP,
     3233                      swp.x,
     3234                      swp.y,
     3235                      swp.cx,
     3236                      swp.cy,
     3237                      swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    32353238    }
    32363239    else {
    32373240      WinSetWindowPos(hwndTree,
    3238                       HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3241                      HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    32393242      WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
    32403243      WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
     
    32463249  size = sizeof(ULONG);
    32473250  if (PrfQueryProfileData(fmprof,
    3248                           FM3Str, szKey, (PVOID) &numsaves, &size)) {
     3251                          FM3Str, szKey, (PVOID) &numsaves, &size)) {
    32493252    if (fDeleteState)
    32503253      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     
    32533256      size = sizeof(SWP);
    32543257      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3255         if (fDeleteState)
    3256           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3257         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    3258         size = sizeof(szDir);
    3259         if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    3260           // If restoring shutdown state and drive marked no prescan
    3261           // bypass window restore
    3262           if (fIsShutDownState &&
    3263               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3264             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3265             continue;
    3266           }
    3267           if (fDeleteState)
    3268             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3269           localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
    3270           sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
    3271           size = sizeof(BOOL);
    3272           if (PrfQueryProfileData(fmprof,
    3273                                   FM3Str,
    3274                                   szKey,
    3275                                   (PVOID) &localdcd.ds.detailslongname,
    3276                                   &size))
    3277           {
    3278             if (fDeleteState)
    3279               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3280           }
    3281           localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
    3282           sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
    3283           size = sizeof(BOOL);
    3284           if (PrfQueryProfileData(fmprof,
    3285                                   FM3Str,
    3286                                   szKey,
    3287                                   (PVOID) &localdcd.ds.detailssubject,
    3288                                   &size))
    3289           {
    3290             if (fDeleteState)
    3291               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3292           }
    3293           localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
    3294           sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
    3295           size = sizeof(BOOL);
    3296           if (PrfQueryProfileData(fmprof,
    3297                                   FM3Str,
    3298                                   szKey,
    3299                                   (PVOID) &localdcd.ds.detailsea,
    3300                                   &size))
    3301           {
    3302             if (fDeleteState)
    3303               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3304           }
    3305           localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
    3306           sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
    3307           size = sizeof(BOOL);
    3308           if (PrfQueryProfileData(fmprof,
    3309                                   FM3Str,
    3310                                   szKey,
    3311                                   (PVOID) &localdcd.ds.detailssize,
    3312                                   &size))
    3313           {
    3314             if (fDeleteState)
    3315               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3316           }
    3317           localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
    3318           sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
    3319           size = sizeof(BOOL);
    3320           if (PrfQueryProfileData(fmprof,
    3321                                   FM3Str,
    3322                                   szKey,
    3323                                   (PVOID) &localdcd.ds.detailsicon,
    3324                                   &size))
    3325           {
    3326             if (fDeleteState)
    3327               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3328           }
    3329           localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
    3330           sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
    3331           size = sizeof(BOOL);
    3332           if (PrfQueryProfileData(fmprof,
    3333                                   FM3Str,
    3334                                   szKey,
    3335                                   (PVOID) &localdcd.ds.detailsattr,
    3336                                   &size))
    3337           {
    3338             if (fDeleteState)
    3339               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3340           }
    3341           localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
    3342           sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
    3343           size = sizeof(BOOL);
    3344           if (PrfQueryProfileData(fmprof,
    3345                                   FM3Str,
    3346                                   szKey,
    3347                                   (PVOID) &localdcd.ds.detailscrdate,
    3348                                   &size))
    3349           {
    3350             if (fDeleteState)
    3351               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3352           }
    3353           localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
    3354           sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
    3355           size = sizeof(BOOL);
    3356           if (PrfQueryProfileData(fmprof,
    3357                                   FM3Str,
    3358                                   szKey,
    3359                                   (PVOID) &localdcd.ds.detailscrtime,
    3360                                   &size))
    3361           {
    3362             if (fDeleteState)
    3363               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3364           }
    3365           localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
    3366           sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
    3367           size = sizeof(BOOL);
    3368           if (PrfQueryProfileData(fmprof,
    3369                                   FM3Str,
    3370                                   szKey,
    3371                                   (PVOID) &localdcd.ds.detailslwdate,
    3372                                   &size))
    3373           {
    3374             if (fDeleteState)
    3375               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3376           }
    3377           localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
    3378           sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
    3379           size = sizeof(BOOL);
    3380           if (PrfQueryProfileData(fmprof,
    3381                                   FM3Str,
    3382                                   szKey,
    3383                                   (PVOID) &localdcd.ds.detailslwtime,
    3384                                   &size))
    3385           {
    3386             if (fDeleteState)
    3387               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3388           }
    3389           localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
    3390           sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
    3391           size = sizeof(BOOL);
    3392           if (PrfQueryProfileData(fmprof,
    3393                                   FM3Str,
    3394                                   szKey,
    3395                                   (PVOID) &localdcd.ds.detailsladate,
    3396                                   &size))
    3397           {
    3398             if (fDeleteState)
    3399               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3400           }
    3401           localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
    3402           sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
    3403           size = sizeof(BOOL);
    3404           if (PrfQueryProfileData(fmprof,
    3405                                   FM3Str,
    3406                                   szKey,
    3407                                   (PVOID) &localdcd.ds.detailslatime,
    3408                                   &size))
    3409           {
    3410             if (fDeleteState)
    3411               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3412           }
    3413           hwndDir = (HWND) WinSendMsg(hwndClient,
    3414                                       UM_SETDIR,
    3415                                       MPFROMP(szDir), MPFROMLONG(1));
    3416           if (hwndDir) {
    3417             hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
    3418             if (hwndC) {
    3419               HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
    3420               if (!hwndPPSave) {
    3421                 hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
    3422                                              WC_CONTAINER,
    3423                                              NULL,
    3424                                              CCS_AUTOPOSITION | CCS_MINIICONS |
    3425                                              CCS_MINIRECORDCORE | ulCnrType,
    3426                                              0,
    3427                                              0,
    3428                                              0,
    3429                                              0,
    3430                                              hwndCnr,
    3431                                              HWND_TOP, (ULONG) -1, NULL, NULL);
    3432                 CopyPresParams(hwndPPSave, hwndC);
    3433                 RestorePresParams(hwndPPSave, "DirCnr");
    3434               }
    3435               sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3436               RestorePresParams(hwndCnr, szKey);
    3437               dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    3438               if (dcd) {
    3439                 dcd->ds.detailslongname = localdcd.ds.detailslongname;
    3440                 dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
    3441                 dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
    3442                 dcd->ds.detailsea       = localdcd.ds.detailsea      ;
    3443                 dcd->ds.detailssize     = localdcd.ds.detailssize    ;
    3444                 dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
    3445                 dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
    3446                 dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
    3447                 dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
    3448                 dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
    3449                 dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
    3450                 dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
    3451                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    3452                 size = sizeof(INT);
    3453                 if (PrfQueryProfileData(fmprof,
    3454                                         FM3Str,
    3455                                         szKey,
    3456                                         (PVOID) &dcd->sortFlags,
    3457                                         &size)) {
    3458                   if (!dcd->sortFlags)
    3459                     dcd->sortFlags = SORT_PATHNAME;
    3460                 }
    3461                 if (fDeleteState)
    3462                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3463                 size = sizeof(MASK);
    3464                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    3465                 if (PrfQueryProfileData(fmprof,
    3466                                         FM3Str,
    3467                                         szKey,
    3468                                         (PVOID) &dcd->mask, &size)) {
    3469                   if (*dcd->mask.szMask)
    3470                     WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3471                                UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
    3472                 }
    3473                 *(dcd->mask.prompt) = 0;
    3474                 if (fDeleteState)
    3475                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3476                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    3477                 if (!noview) {
    3478                   size = sizeof(ULONG);
    3479                   if (PrfQueryProfileData(fmprof,
    3480                                           FM3Str,
    3481                                           szKey,
    3482                                           (PVOID) &dcd->flWindowAttr,
    3483                                           &size)) {
    3484 
    3485                     CNRINFO cnri;
    3486 
    3487                     memset(&cnri, 0, sizeof(CNRINFO));
    3488                     cnri.cb = sizeof(CNRINFO);
    3489                     if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3490                                    CM_QUERYCNRINFO,
    3491                                    MPFROMP(&cnri),
    3492                                    MPFROMLONG(sizeof(CNRINFO)))) {
    3493                       cnri.flWindowAttr = dcd->flWindowAttr;
    3494                       WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3495                                 CM_SETCNRINFO,
    3496                                 MPFROMP(&cnri),
    3497                                 MPFROMLONG(CMA_FLWINDOWATTR));
    3498                     }
    3499                   }
    3500                 }
    3501                 if (fDeleteState)
    3502                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3503                   if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    3504                     WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
    3505               }
    3506             }
    3507             fRestored = TRUE;
    3508             swp.hwnd = hwndDir;
    3509             TransformSwp(&swp, xtrans, ytrans);
    3510             if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3511               WinSetWindowPos(hwndDir,
    3512                               HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    3513               WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
    3514               WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
    3515               WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
    3516               WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
    3517             } else
    3518               WinSetWindowPos(hwndDir,
    3519                               HWND_TOP,
    3520                               swp.x,
    3521                               swp.y,
    3522                               swp.cx,
    3523                               swp.cy,
    3524                               swp.fl | SWP_MOVE |
    3525                               SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
    3526                               SWP_ACTIVATE);
    3527           }
    3528         }
     3258        if (fDeleteState)
     3259          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3260        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3261        size = sizeof(szDir);
     3262        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     3263          // If restoring shutdown state and drive marked no prescan
     3264          // bypass window restore
     3265          if (fIsShutDownState &&
     3266              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     3267            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3268            continue;
     3269          }
     3270          if (fDeleteState)
     3271            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3272          localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
     3273          sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
     3274          size = sizeof(BOOL);
     3275          if (PrfQueryProfileData(fmprof,
     3276                                  FM3Str,
     3277                                  szKey,
     3278                                  (PVOID) &localdcd.ds.detailslongname,
     3279                                  &size))
     3280          {
     3281            if (fDeleteState)
     3282              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3283          }
     3284          localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
     3285          sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
     3286          size = sizeof(BOOL);
     3287          if (PrfQueryProfileData(fmprof,
     3288                                  FM3Str,
     3289                                  szKey,
     3290                                  (PVOID) &localdcd.ds.detailssubject,
     3291                                  &size))
     3292          {
     3293            if (fDeleteState)
     3294              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3295          }
     3296          localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
     3297          sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
     3298          size = sizeof(BOOL);
     3299          if (PrfQueryProfileData(fmprof,
     3300                                  FM3Str,
     3301                                  szKey,
     3302                                  (PVOID) &localdcd.ds.detailsea,
     3303                                  &size))
     3304          {
     3305            if (fDeleteState)
     3306              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3307          }
     3308          localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
     3309          sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
     3310          size = sizeof(BOOL);
     3311          if (PrfQueryProfileData(fmprof,
     3312                                  FM3Str,
     3313                                  szKey,
     3314                                  (PVOID) &localdcd.ds.detailssize,
     3315                                  &size))
     3316          {
     3317            if (fDeleteState)
     3318              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3319          }
     3320          localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
     3321          sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
     3322          size = sizeof(BOOL);
     3323          if (PrfQueryProfileData(fmprof,
     3324                                  FM3Str,
     3325                                  szKey,
     3326                                  (PVOID) &localdcd.ds.detailsicon,
     3327                                  &size))
     3328          {
     3329            if (fDeleteState)
     3330              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3331          }
     3332          localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
     3333          sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
     3334          size = sizeof(BOOL);
     3335          if (PrfQueryProfileData(fmprof,
     3336                                  FM3Str,
     3337                                  szKey,
     3338                                  (PVOID) &localdcd.ds.detailsattr,
     3339                                  &size))
     3340          {
     3341            if (fDeleteState)
     3342              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3343          }
     3344          localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
     3345          sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
     3346          size = sizeof(BOOL);
     3347          if (PrfQueryProfileData(fmprof,
     3348                                  FM3Str,
     3349                                  szKey,
     3350                                  (PVOID) &localdcd.ds.detailscrdate,
     3351                                  &size))
     3352          {
     3353            if (fDeleteState)
     3354              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3355          }
     3356          localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
     3357          sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
     3358          size = sizeof(BOOL);
     3359          if (PrfQueryProfileData(fmprof,
     3360                                  FM3Str,
     3361                                  szKey,
     3362                                  (PVOID) &localdcd.ds.detailscrtime,
     3363                                  &size))
     3364          {
     3365            if (fDeleteState)
     3366              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3367          }
     3368          localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
     3369          sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
     3370          size = sizeof(BOOL);
     3371          if (PrfQueryProfileData(fmprof,
     3372                                  FM3Str,
     3373                                  szKey,
     3374                                  (PVOID) &localdcd.ds.detailslwdate,
     3375                                  &size))
     3376          {
     3377            if (fDeleteState)
     3378              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3379          }
     3380          localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
     3381          sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
     3382          size = sizeof(BOOL);
     3383          if (PrfQueryProfileData(fmprof,
     3384                                  FM3Str,
     3385                                  szKey,
     3386                                  (PVOID) &localdcd.ds.detailslwtime,
     3387                                  &size))
     3388          {
     3389            if (fDeleteState)
     3390              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3391          }
     3392          localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
     3393          sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
     3394          size = sizeof(BOOL);
     3395          if (PrfQueryProfileData(fmprof,
     3396                                  FM3Str,
     3397                                  szKey,
     3398                                  (PVOID) &localdcd.ds.detailsladate,
     3399                                  &size))
     3400          {
     3401            if (fDeleteState)
     3402              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3403          }
     3404          localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
     3405          sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
     3406          size = sizeof(BOOL);
     3407          if (PrfQueryProfileData(fmprof,
     3408                                  FM3Str,
     3409                                  szKey,
     3410                                  (PVOID) &localdcd.ds.detailslatime,
     3411                                  &size))
     3412          {
     3413            if (fDeleteState)
     3414              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3415          }
     3416          hwndDir = (HWND) WinSendMsg(hwndClient,
     3417                                      UM_SETDIR,
     3418                                      MPFROMP(szDir), MPFROMLONG(1));
     3419          if (hwndDir) {
     3420            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     3421            if (hwndC) {
     3422              HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
     3423              if (!hwndPPSave) {
     3424                hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
     3425                                             WC_CONTAINER,
     3426                                             NULL,
     3427                                             CCS_AUTOPOSITION | CCS_MINIICONS |
     3428                                             CCS_MINIRECORDCORE | ulCnrType,
     3429                                             0,
     3430                                             0,
     3431                                             0,
     3432                                             0,
     3433                                             hwndCnr,
     3434                                             HWND_TOP, (ULONG) -1, NULL, NULL);
     3435                CopyPresParams(hwndPPSave, hwndC);
     3436                RestorePresParams(hwndPPSave, "DirCnr");
     3437              }
     3438              sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
     3439              RestorePresParams(hwndCnr, szKey);
     3440              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
     3441              if (dcd) {
     3442                dcd->ds.detailslongname = localdcd.ds.detailslongname;
     3443                dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
     3444                dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
     3445                dcd->ds.detailsea       = localdcd.ds.detailsea      ;
     3446                dcd->ds.detailssize     = localdcd.ds.detailssize    ;
     3447                dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
     3448                dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
     3449                dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
     3450                dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
     3451                dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
     3452                dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
     3453                dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
     3454                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3455                size = sizeof(INT);
     3456                if (PrfQueryProfileData(fmprof,
     3457                                        FM3Str,
     3458                                        szKey,
     3459                                        (PVOID) &dcd->sortFlags,
     3460                                        &size)) {
     3461                  if (!dcd->sortFlags)
     3462                    dcd->sortFlags = SORT_PATHNAME;
     3463                }
     3464                if (fDeleteState)
     3465                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3466                size = sizeof(MASK);
     3467                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3468                if (PrfQueryProfileData(fmprof,
     3469                                        FM3Str,
     3470                                        szKey,
     3471                                        (PVOID) &dcd->mask, &size)) {
     3472                  if (*dcd->mask.szMask)
     3473                    WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3474                               UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
     3475                }
     3476                *(dcd->mask.prompt) = 0;
     3477                if (fDeleteState)
     3478                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3479                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3480                if (!noview) {
     3481                  size = sizeof(ULONG);
     3482                  if (PrfQueryProfileData(fmprof,
     3483                                          FM3Str,
     3484                                          szKey,
     3485                                          (PVOID) &dcd->flWindowAttr,
     3486                                          &size)) {
     3487
     3488                    CNRINFO cnri;
     3489
     3490                    memset(&cnri, 0, sizeof(CNRINFO));
     3491                    cnri.cb = sizeof(CNRINFO);
     3492                    if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3493                                   CM_QUERYCNRINFO,
     3494                                   MPFROMP(&cnri),
     3495                                   MPFROMLONG(sizeof(CNRINFO)))) {
     3496                      cnri.flWindowAttr = dcd->flWindowAttr;
     3497                      WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3498                                CM_SETCNRINFO,
     3499                                MPFROMP(&cnri),
     3500                                MPFROMLONG(CMA_FLWINDOWATTR));
     3501                    }
     3502                  }
     3503                }
     3504                if (fDeleteState)
     3505                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3506                  if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
     3507                    WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     3508              }
     3509            }
     3510            fRestored = TRUE;
     3511            swp.hwnd = hwndDir;
     3512            TransformSwp(&swp, xtrans, ytrans);
     3513            if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3514              WinSetWindowPos(hwndDir,
     3515                              HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3516              WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
     3517              WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
     3518              WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
     3519              WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
     3520            } else
     3521              WinSetWindowPos(hwndDir,
     3522                              HWND_TOP,
     3523                              swp.x,
     3524                              swp.y,
     3525                              swp.cx,
     3526                              swp.cy,
     3527                              swp.fl | SWP_MOVE |
     3528                              SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
     3529                              SWP_ACTIVATE);
     3530          }
     3531        }
    35293532      }
    35303533    } // for
     
    35553558    if (ulNumMinChildren) {
    35563559      if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
    3557         (*ulNumMinChildren)++;
     3560        (*ulNumMinChildren)++;
    35583561    }
    35593562  }
     
    35633566
    35643567VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
    3565                       ULONG * ulNumMinChildrenR)
     3568                      ULONG * ulNumMinChildrenR)
    35663569{
    35673570  register ULONG ulCnt;
     
    36273630    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    36283631      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3629         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3632        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    36303633      if (swp.x != 0)
    3631         swp.x = 0;
     3634        swp.x = 0;
    36323635      if (swp.y < 0)
    3633         swp.y = 0;
     3636        swp.y = 0;
    36343637      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3635         swp.cx = Rectl.xRight - Rectl.xLeft;
     3638        swp.cx = Rectl.xRight - Rectl.xLeft;
    36363639      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3637                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3640                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    36383641    }
    36393642  }
     
    36473650      GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
    36483651      WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3649                       SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
    3650                       SWP_ZORDER | SWP_ACTIVATE);
     3652                      SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
     3653                      SWP_ZORDER | SWP_ACTIVATE);
    36513654      ulCnt++;
    36523655    }
     
    37013704    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    37023705      if (swp.y < 0)
    3703         swp.y = 0;
     3706        swp.y = 0;
    37043707      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3705         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3708        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    37063709      if (swp.x != 0)
    3707         swp.x = 0;
     3710        swp.x = 0;
    37083711      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3709         swp.cx = Rectl.xRight - Rectl.xLeft;
     3712        swp.cx = Rectl.xRight - Rectl.xLeft;
    37103713      WinSetWindowPos(hwndTree,
    3711                       HWND_TOP,
    3712                       swp.x,
    3713                       swp.y,
    3714                       swp.cx,
    3715                       swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3714                      HWND_TOP,
     3715                      swp.x,
     3716                      swp.y,
     3717                      swp.cx,
     3718                      swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    37163719      WinQueryWindowPos(hwndTree, &swp);
    37173720    }
     
    37383741
    37393742      for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
    3740         if ((ulNumRows - ulCurRow) <= ulExtraCols)
    3741           ulNumCols++;
    3742         for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
    3743           ulWidth = Rectl.xRight / ulNumCols;
    3744 
    3745           while (hwndChild) {
    3746             id = WinQueryWindowUShort(hwndChild, QWS_ID);
    3747             if (id && (id != TREE_FRAME || fFreeTree)) {
    3748               WinQueryWindowPos(hwndChild, &swp);
    3749               if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3750                 break;
    3751             }
    3752             hwndChild = WinGetNextWindow(henum);
    3753           }
    3754 
    3755           if (hwndChild) {
    3756             if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
    3757               WinGetMaxPosition(hwndChild, &swp);
    3758               WinSetWindowPos(hwndChild,
    3759                               HWND_TOP,
    3760                               swp.x,
    3761                               swp.y,
    3762                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3763               WinSetWindowUShort(hwndChild,
    3764                                 QWS_XRESTORE,
    3765                                 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
    3766               WinSetWindowUShort(hwndChild,
    3767                                 QWS_YRESTORE,
    3768                                 (USHORT) (Rectl.yTop -
    3769                                            (ulHeight * (ulCurRow + 1))));
    3770               WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    3771               WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
    3772             }
    3773             else
    3774               WinSetWindowPos(hwndChild,
    3775                               HWND_TOP,
    3776                               (ulWidth * ulCurCol) + Rectl.xLeft,
    3777                               Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    3778                               ulWidth,
    3779                               ulHeight,
    3780                               SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    3781             hwndChild = WinGetNextWindow(henum);
    3782           }
    3783         }
    3784         if ((ulNumRows - ulCurRow) <= ulExtraCols) {
    3785           ulNumCols--;
    3786           ulExtraCols--;
    3787         }
     3743        if ((ulNumRows - ulCurRow) <= ulExtraCols)
     3744          ulNumCols++;
     3745        for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
     3746          ulWidth = Rectl.xRight / ulNumCols;
     3747
     3748          while (hwndChild) {
     3749            id = WinQueryWindowUShort(hwndChild, QWS_ID);
     3750            if (id && (id != TREE_FRAME || fFreeTree)) {
     3751              WinQueryWindowPos(hwndChild, &swp);
     3752              if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3753                break;
     3754            }
     3755            hwndChild = WinGetNextWindow(henum);
     3756          }
     3757
     3758          if (hwndChild) {
     3759            if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
     3760              WinGetMaxPosition(hwndChild, &swp);
     3761              WinSetWindowPos(hwndChild,
     3762                              HWND_TOP,
     3763                              swp.x,
     3764                              swp.y,
     3765                              swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3766              WinSetWindowUShort(hwndChild,
     3767                                QWS_XRESTORE,
     3768                                (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
     3769              WinSetWindowUShort(hwndChild,
     3770                                QWS_YRESTORE,
     3771                                (USHORT) (Rectl.yTop -
     3772                                           (ulHeight * (ulCurRow + 1))));
     3773              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
     3774              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     3775            }
     3776            else
     3777              WinSetWindowPos(hwndChild,
     3778                              HWND_TOP,
     3779                              (ulWidth * ulCurCol) + Rectl.xLeft,
     3780                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
     3781                              ulWidth,
     3782                              ulHeight,
     3783                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3784            hwndChild = WinGetNextWindow(henum);
     3785          }
     3786        }
     3787        if ((ulNumRows - ulCurRow) <= ulExtraCols) {
     3788          ulNumCols--;
     3789          ulExtraCols--;
     3790        }
    37883791      }
    37893792    }
     
    37953798
    37963799static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
    3797                            SHORT newcx, SHORT newcy)
     3800                           SHORT newcx, SHORT newcy)
    37983801{
    37993802  /*
     
    38133816    while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
    38143817      if (!WinQueryWindowUShort(hwndChild, QWS_ID))
    3815         continue;
     3818        continue;
    38163819      if (WinQueryWindowPos(hwndChild, &swp)) {
    3817         if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
    3818           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3819           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3820           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3821           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3822         }
    3823         else if (swp.fl & SWP_MAXIMIZE) {
    3824           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3825           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3826           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3827           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3828         }
    3829         cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
    3830         cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
    3831         x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
    3832         y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
    3833         if (x < 0)
    3834           x = 0;
    3835         if (y < 0)
    3836           y = 0;
    3837         ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
    3838         uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
    3839         ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
    3840         ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
    3841         if (ux + ucx > newcx)
    3842           ucx = newcx - ux;
    3843         if (uy + ucy > newcy)
    3844           ucy = newcy - uy;
    3845 
    3846         if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
    3847           WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
    3848                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3849         else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3850           WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
    3851           WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    3852           WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    3853                           SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
    3854           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3855           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3856           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3857           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3858         }
    3859         else {
    3860           WinGetMaxPosition(hwndChild, &swp);
    3861           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3862                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3863           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3864           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3865           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3866           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3867         }
     3820        if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
     3821          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3822          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3823          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3824          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3825        }
     3826        else if (swp.fl & SWP_MAXIMIZE) {
     3827          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3828          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3829          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3830          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3831        }
     3832        cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
     3833        cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
     3834        x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
     3835        y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
     3836        if (x < 0)
     3837          x = 0;
     3838        if (y < 0)
     3839          y = 0;
     3840        ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
     3841        uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
     3842        ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
     3843        ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
     3844        if (ux + ucx > newcx)
     3845          ucx = newcx - ux;
     3846        if (uy + ucy > newcy)
     3847          ucy = newcy - uy;
     3848
     3849        if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
     3850          WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
     3851                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3852        else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3853          WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
     3854          WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
     3855          WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
     3856                          SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
     3857          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3858          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3859          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3860          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3861        }
     3862        else {
     3863          WinGetMaxPosition(hwndChild, &swp);
     3864          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     3865                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3866          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3867          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3868          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3869          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3870        }
    38683871      }
    38693872    }
     
    38813884
    38823885      if (!fNoTreeGap) {
    3883         INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    3884         if (swp.y < height)
    3885           swp.y = height;        // Force bottom to position
     3886        INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     3887        if (swp.y < height)
     3888          swp.y = height;        // Force bottom to position
    38863889      }
    38873890      else
    3888         swp.y = 0;                // Force bottom to position
     3891        swp.y = 0;                // Force bottom to position
    38893892
    38903893      swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    38913894      if (swp.cy < 0)
    3892         swp.cy = 0;
     3895        swp.cy = 0;
    38933896
    38943897      if (swp.x != 0)
    3895         swp.x = 0;                // Left align
     3898        swp.x = 0;                // Left align
    38963899
    38973900      // AdjustSizeOfClient can return bogus xRight values - fixme someday
    38983901      if (Rectl.xRight >= Rectl.xLeft) {
    3899         if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3900           swp.cx = Rectl.xRight - Rectl.xLeft;
     3902        if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
     3903          swp.cx = Rectl.xRight - Rectl.xLeft;
    39013904      }
    39023905      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3903                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3906                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    39043907    }
    39053908  }
     
    39293932
    39303933static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
    3931                                              ULONG msg,
    3932                                              MPARAM mp1, MPARAM mp2)
     3934                                             ULONG msg,
     3935                                             MPARAM mp1, MPARAM mp2)
    39333936{
    39343937  USHORT id;
     
    39443947    if (fOtherHelp) {
    39453948      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    3946           && !WinQueryCapture(HWND_DESKTOP)) {
    3947         id = WinQueryWindowUShort(hwnd, QWS_ID);
    3948         switch (id) {
    3949         case IDM_OPENWALK:
    3950           MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
    3951           break;
    3952         case IDM_USERLIST:
    3953           MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
    3954           break;
    3955         }
     3949          && !WinQueryCapture(HWND_DESKTOP)) {
     3950        id = WinQueryWindowUShort(hwnd, QWS_ID);
     3951        switch (id) {
     3952        case IDM_OPENWALK:
     3953          MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
     3954          break;
     3955        case IDM_USERLIST:
     3956          MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
     3957          break;
     3958        }
    39563959      }
    39573960    }
     
    39673970      switch (id) {
    39683971      case IDM_OPENWALK:
    3969         switch (msg) {
    3970         case WM_BUTTON2CLICK:
    3971           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3972               (KC_ALT | KC_SHIFT | KC_CTRL))
    3973             cmd = IDM_GREP;
    3974           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3975             CascadeChildren(hwndMain);
     3972        switch (msg) {
     3973        case WM_BUTTON2CLICK:
     3974          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3975              (KC_ALT | KC_SHIFT | KC_CTRL))
     3976            cmd = IDM_GREP;
     3977          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3978            CascadeChildren(hwndMain);
    39763979
    39773980#ifdef NEVER
    3978           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3979             cmd = IDM_SYSINFO;
     3981          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3982            cmd = IDM_SYSINFO;
    39803983#endif
    39813984
    3982           else if (shiftstate & KC_SHIFT)
    3983             cmd = IDM_WINDOWDLG;
    3984           else if (shiftstate & KC_CTRL)
    3985             cmd = IDM_SEEALL;
    3986           else if (shiftstate & KC_ALT)
    3987             TileChildren(hwndMain, TRUE);
    3988           else
    3989             cmd = IDM_WALKDIR;
    3990           break;
    3991         case WM_BUTTON3CLICK:
    3992           TileChildren(hwndMain, TRUE);
    3993           break;
    3994         }
    3995         break;
     3985          else if (shiftstate & KC_SHIFT)
     3986            cmd = IDM_WINDOWDLG;
     3987          else if (shiftstate & KC_CTRL)
     3988            cmd = IDM_SEEALL;
     3989          else if (shiftstate & KC_ALT)
     3990            TileChildren(hwndMain, TRUE);
     3991          else
     3992            cmd = IDM_WALKDIR;
     3993          break;
     3994        case WM_BUTTON3CLICK:
     3995          TileChildren(hwndMain, TRUE);
     3996          break;
     3997        }
     3998        break;
    39963999      case IDM_USERLIST:
    3997         switch (msg) {
    3998         case WM_BUTTON2CLICK:
    3999           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    4000               (KC_ALT | KC_SHIFT | KC_CTRL))
    4001             cmd = IDM_COLORPALETTE;
    4002           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    4003             cmd = IDM_HIDEMENU;
    4004           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    4005             cmd = IDM_NOTEBOOK;
    4006           else if (shiftstate & KC_SHIFT)
    4007             cmd = IDM_TOOLTITLES;
    4008           else if (shiftstate & KC_CTRL)
    4009             cmd = IDM_TEXTTOOLS;
    4010           else if (shiftstate & KC_ALT)
    4011             cmd = IDM_FONTPALETTE;
    4012           else
    4013             cmd = IDM_TOOLBAR;
    4014           break;
    4015         case WM_BUTTON3CLICK:
    4016           cmd = IDM_DRIVEBAR;
    4017           break;
    4018         }
    4019         break;
     4000        switch (msg) {
     4001        case WM_BUTTON2CLICK:
     4002          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     4003              (KC_ALT | KC_SHIFT | KC_CTRL))
     4004            cmd = IDM_COLORPALETTE;
     4005          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     4006            cmd = IDM_HIDEMENU;
     4007          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     4008            cmd = IDM_NOTEBOOK;
     4009          else if (shiftstate & KC_SHIFT)
     4010            cmd = IDM_TOOLTITLES;
     4011          else if (shiftstate & KC_CTRL)
     4012            cmd = IDM_TEXTTOOLS;
     4013          else if (shiftstate & KC_ALT)
     4014            cmd = IDM_FONTPALETTE;
     4015          else
     4016            cmd = IDM_TOOLBAR;
     4017          break;
     4018        case WM_BUTTON3CLICK:
     4019          cmd = IDM_DRIVEBAR;
     4020          break;
     4021        }
     4022        break;
    40204023      }                                 // switch id
    40214024
    40224025      if (cmd) {
    4023         PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
    4024                 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
     4026        PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
     4027                WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
    40254028      }
    40264029    }
     
    40314034    if (id == IDM_OPENWALK) {
    40324035      if (!emphasized) {
    4033         emphasized = TRUE;
    4034         DrawTargetEmphasis(hwnd, emphasized);
     4036        emphasized = TRUE;
     4037        DrawTargetEmphasis(hwnd, emphasized);
    40354038      }
    40364039      if (AcceptOneDrop(hwnd, mp1, mp2))
    4037         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     4040        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    40384041    }
    40394042    return MRFROM2SHORT(DOR_NEVERDROP, 0);
     
    40554058
    40564059      if (emphasized) {
    4057         emphasized = FALSE;
    4058         DrawTargetEmphasis(hwnd, emphasized);
     4060        emphasized = FALSE;
     4061        DrawTargetEmphasis(hwnd, emphasized);
    40594062      }
    40604063      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    4061         if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
    4062           OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
    4063         }
     4064        if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
     4065          OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
     4066        }
    40644067      }
    40654068    }
     
    40744077
    40754078static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    4076                                         MPARAM mp2)
     4079                                        MPARAM mp2)
    40774080{
    40784081  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    40864089      pswp = (SWP *) mp1;
    40874090      if (fDataMin && !fAmClosing) {
    4088         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    4089 
    4090           SWP swp;
    4091 
    4092           WinQueryWindowPos(hwnd, &swp);
    4093           PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
    4094           HideNote();
    4095         }
    4096         else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    4097           if (DataHwnd)
    4098             PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
    4099         }
     4091        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
     4092
     4093          SWP swp;
     4094
     4095          WinQueryWindowPos(hwnd, &swp);
     4096          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     4097          HideNote();
     4098        }
     4099        else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
     4100          if (DataHwnd)
     4101            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     4102        }
    41004103      }
    41014104      if (!fAmClosing) {
    4102         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    4103           HideNote();
     4105        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
     4106          HideNote();
    41044107      }
    41054108    }
     
    41244127  case WM_CONTROL:
    41254128    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
    4126                       mp2);
     4129                      mp2);
    41274130
    41284131  case WM_COMMAND:
     
    41444147
    41454148      if (mr && mp2) {
    4146         prectl = (PRECTL) mp1;
    4147         if (prectl->yBottom != prectl->yTop) {
    4148           {
    4149             HPS hps;
    4150             POINTL aptl[TXTBOX_COUNT];
    4151 
    4152             hps = WinGetPS(hwndStatus);
    4153             if (hps) {
    4154               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4155               bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4156               WinReleasePS(hps);
    4157             }
    4158           }
    4159           prectl->yBottom += (sheight + 4);
    4160           prectl->yTop -= (sheight + 4);
    4161           if (fMoreButtons) {
    4162 
    4163             HPS hps;
    4164             POINTL aptl[TXTBOX_COUNT];
    4165 
    4166             hps = WinGetPS(hwndName);
    4167             if (hps) {
    4168               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4169               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4170               WinReleasePS(hps);
    4171             }
    4172             prectl->yBottom += (bheight + 4);
    4173             prectl->yTop -= (bheight + 4);
    4174           }
    4175           if (fToolbar) {
    4176             if (!fTextTools)
    4177               prectl->yTop -= ((fToolTitles) ? 50 : 40);
    4178             else
    4179               prectl->yTop -= 32;
    4180           }
    4181           if (fDrivebar) {
    4182             ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
    4183                         ((prectl->xRight -
    4184                            (WinQuerySysValue(HWND_DESKTOP,
    4185                                              SV_CYSIZEBORDER) * 2)) - 4));
    4186             prectl->yTop -= (16 * (DriveLines * 18));
    4187           }
    4188           if (fUserComboBox) {
    4189             if (!aheight) {
    4190 
    4191               SWP swpTemp;
    4192 
    4193               WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4194                                 &swpTemp);
    4195               aheight = swpTemp.cy;
    4196             }
    4197             prectl->yTop -= (aheight + 6L);
    4198           }
    4199           if (fAutoView) {
    4200             AutoviewHeight = min(AutoviewHeight,
    4201                                 (prectl->yTop - prectl->yBottom) - 116);
    4202             AutoviewHeight = max(AutoviewHeight, 36);
    4203             prectl->yBottom += (AutoviewHeight + 6);
    4204           }
    4205         }
     4149        prectl = (PRECTL) mp1;
     4150        if (prectl->yBottom != prectl->yTop) {
     4151          {
     4152            HPS hps;
     4153            POINTL aptl[TXTBOX_COUNT];
     4154
     4155            hps = WinGetPS(hwndStatus);
     4156            if (hps) {
     4157              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4158              bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4159              WinReleasePS(hps);
     4160            }
     4161          }
     4162          prectl->yBottom += (sheight + 4);
     4163          prectl->yTop -= (sheight + 4);
     4164          if (fMoreButtons) {
     4165
     4166            HPS hps;
     4167            POINTL aptl[TXTBOX_COUNT];
     4168
     4169            hps = WinGetPS(hwndName);
     4170            if (hps) {
     4171              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4172              bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4173              WinReleasePS(hps);
     4174            }
     4175            prectl->yBottom += (bheight + 4);
     4176            prectl->yTop -= (bheight + 4);
     4177          }
     4178          if (fToolbar) {
     4179            if (!fTextTools)
     4180              prectl->yTop -= ((fToolTitles) ? 50 : 40);
     4181            else
     4182              prectl->yTop -= 32;
     4183          }
     4184          if (fDrivebar) {
     4185            ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     4186                        ((prectl->xRight -
     4187                           (WinQuerySysValue(HWND_DESKTOP,
     4188                                             SV_CYSIZEBORDER) * 2)) - 4));
     4189            prectl->yTop -= (16 * (DriveLines * 18));
     4190          }
     4191          if (fUserComboBox) {
     4192            if (!aheight) {
     4193
     4194              SWP swpTemp;
     4195
     4196              WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4197                                &swpTemp);
     4198              aheight = swpTemp.cy;
     4199            }
     4200            prectl->yTop -= (aheight + 6L);
     4201          }
     4202          if (fAutoView) {
     4203            AutoviewHeight = min(AutoviewHeight,
     4204                                (prectl->yTop - prectl->yBottom) - 116);
     4205            AutoviewHeight = max(AutoviewHeight, 36);
     4206            prectl->yBottom += (AutoviewHeight + 6);
     4207          }
     4208        }
    42064209      }
    42074210      return mr;
     
    42274230      pswp = (PSWP) mp1;
    42284231      {
    4229         SHORT x;
    4230 
    4231         for (x = 0; x < soldCount; x++) {
    4232           if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
    4233             pswpClient = pswp;
    4234             break;
    4235           }
    4236           pswp++;
    4237         }
     4232        SHORT x;
     4233
     4234        for (x = 0; x < soldCount; x++) {
     4235          if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
     4236            pswpClient = pswp;
     4237            break;
     4238          }
     4239          pswp++;
     4240        }
    42384241      }
    42394242
    42404243      {
    4241         HPS hps;
    4242         POINTL aptl[TXTBOX_COUNT];
    4243 
    4244         hps = WinGetPS(hwndStatus);
    4245         if (hps) {
    4246           GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4247           bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4248           WinReleasePS(hps);
    4249         }
    4250         if (fMoreButtons) {
    4251           hps = WinGetPS(hwndName);
    4252           if (hps) {
    4253             GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4254             bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4255             WinReleasePS(hps);
    4256           }
    4257         }
     4244        HPS hps;
     4245        POINTL aptl[TXTBOX_COUNT];
     4246
     4247        hps = WinGetPS(hwndStatus);
     4248        if (hps) {
     4249          GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4250          bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4251          WinReleasePS(hps);
     4252        }
     4253        if (fMoreButtons) {
     4254          hps = WinGetPS(hwndName);
     4255          if (hps) {
     4256            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4257            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4258            WinReleasePS(hps);
     4259          }
     4260        }
    42584261      }
    42594262      pswpNew = (PSWP) mp1 + soldCount;
     
    42654268      pswpNew->y = swpClient.y + 2;
    42664269      if (!fSplitStatus)
    4267         width = swpClient.cx - (16 + (sheight * 2) + 4);
     4270        width = swpClient.cx - (16 + (sheight * 2) + 4);
    42684271      else
    4269         width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
     4272        width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
    42704273      width = max(width, 10);
    42714274      if (fSplitStatus)
    4272         pswpNew->cx = width - 6;
     4275        pswpNew->cx = width - 6;
    42734276      else
    4274         pswpNew->cx = width - 8;
     4277        pswpNew->cx = width - 8;
    42754278      pswpNew->cy = sheight;
    42764279      pswpClient->y = pswpNew->y + pswpNew->cy + 3;
     
    42794282
    42804283      if (fSplitStatus) {
    4281         pswpNew = (PSWP) mp1 + (soldCount + 1);
    4282         *pswpNew = *pswpClient;
    4283         pswpNew->hwnd = hwndStatus2;
    4284         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4285         pswpNew->x = width + 8;
    4286         pswpNew->y = swpClient.y + 2;
    4287         pswpNew->cx = width - 6;
    4288         pswpNew->cy = sheight;
    4289         sCount++;
     4284        pswpNew = (PSWP) mp1 + (soldCount + 1);
     4285        *pswpNew = *pswpClient;
     4286        pswpNew->hwnd = hwndStatus2;
     4287        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4288        pswpNew->x = width + 8;
     4289        pswpNew->y = swpClient.y + 2;
     4290        pswpNew->cx = width - 6;
     4291        pswpNew->cy = sheight;
     4292        sCount++;
    42904293      }
    42914294      else {
    4292         WinShowWindow(hwndStatus2, FALSE);
    4293         WinSetWindowText(hwndStatus2, NullStr);
     4295        WinShowWindow(hwndStatus2, FALSE);
     4296        WinSetWindowText(hwndStatus2, NullStr);
    42944297      }
    42954298
    42964299      if (fToolbar) {
    4297         if (fTextTools)
    4298           theight = 32L;
    4299         else if (!fToolTitles)
    4300           theight = 40L;
    4301         pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
    4302         *pswpNew = *pswpClient;
    4303         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
    4304         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4305         pswpNew->x = swpClient.x + 2;
    4306         pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    4307         pswpNew->cx = swpClient.cx - 4;
    4308         pswpNew->cy = theight - 4;
    4309         pswpClient->cy -= theight;
    4310         sCount++;
     4300        if (fTextTools)
     4301          theight = 32L;
     4302        else if (!fToolTitles)
     4303          theight = 40L;
     4304        pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
     4305        *pswpNew = *pswpClient;
     4306        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     4307        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4308        pswpNew->x = swpClient.x + 2;
     4309        pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
     4310        pswpNew->cx = swpClient.cx - 4;
     4311        pswpNew->cy = theight - 4;
     4312        pswpClient->cy -= theight;
     4313        sCount++;
    43114314      }
    43124315      else
    4313         WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     4316        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
    43144317
    43154318      if (fDrivebar) {
    4316         ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
    4317         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4318                                 (fSplitStatus != FALSE) +
    4319                                 (fToolbar != FALSE));
    4320         *pswpNew = *pswpClient;
    4321         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
    4322         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4323         pswpNew->x = swpClient.x + 2;
    4324         dheight += ((dheight - 2) * DriveLines);
    4325         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    4326         if (fToolbar)
    4327           pswpNew->y -= theight;
    4328         pswpNew->cx = swpClient.cx - 4;
    4329         pswpNew->cy = dheight - 4;
    4330         pswpClient->cy -= dheight;
    4331         sCount++;
     4319        ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
     4320        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4321                                (fSplitStatus != FALSE) +
     4322                                (fToolbar != FALSE));
     4323        *pswpNew = *pswpClient;
     4324        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     4325        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4326        pswpNew->x = swpClient.x + 2;
     4327        dheight += ((dheight - 2) * DriveLines);
     4328        pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
     4329        if (fToolbar)
     4330          pswpNew->y -= theight;
     4331        pswpNew->cx = swpClient.cx - 4;
     4332        pswpNew->cy = dheight - 4;
     4333        pswpClient->cy -= dheight;
     4334        sCount++;
    43324335      }
    43334336      else
    4334         WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
     4337        WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
    43354338
    43364339      if (fAutoView) {
    4337         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4338                                 (fToolbar != FALSE) +
    4339                                 (fDrivebar != FALSE) +
    4340                                 (fSplitStatus != FALSE));
    4341         *pswpNew = *pswpClient;
    4342         pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    4343         pswpNew->x = pswpClient->x + 3;
    4344         pswpNew->y = pswpClient->y + 3;
    4345         if (fMoreButtons)
    4346           pswpNew->y += (bheight + 4);
    4347         pswpNew->cx = pswpClient->cx - 6;
    4348         AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
    4349         AutoviewHeight = max(AutoviewHeight, 36);
    4350         pswpNew->cy = AutoviewHeight;
    4351         pswpClient->y += (AutoviewHeight + 6);
    4352         pswpClient->cy -= (AutoviewHeight + 6);
    4353         sCount++;
    4354         WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     4340        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4341                                (fToolbar != FALSE) +
     4342                                (fDrivebar != FALSE) +
     4343                                (fSplitStatus != FALSE));
     4344        *pswpNew = *pswpClient;
     4345        pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     4346        pswpNew->x = pswpClient->x + 3;
     4347        pswpNew->y = pswpClient->y + 3;
     4348        if (fMoreButtons)
     4349          pswpNew->y += (bheight + 4);
     4350        pswpNew->cx = pswpClient->cx - 6;
     4351        AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
     4352        AutoviewHeight = max(AutoviewHeight, 36);
     4353        pswpNew->cy = AutoviewHeight;
     4354        pswpClient->y += (AutoviewHeight + 6);
     4355        pswpClient->cy -= (AutoviewHeight + 6);
     4356        sCount++;
     4357        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
    43554358      }
    43564359      else {
    4357         WinShowWindow(hwndAutoview, FALSE);
    4358         WinShowWindow(hwndAutoMLE, FALSE);
     4360        WinShowWindow(hwndAutoview, FALSE);
     4361        WinShowWindow(hwndAutoMLE, FALSE);
    43594362      }
    43604363
    43614364      pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4362                               (fToolbar != FALSE) +
    4363                               (fDrivebar != FALSE) +
    4364                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4365                              (fToolbar != FALSE) +
     4366                              (fDrivebar != FALSE) +
     4367                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43654368      *pswpNew = *pswpClient;
    43664369      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
     
    43714374      sCount++;
    43724375      pswpNew = (PSWP) mp1 + (soldCount + 2 +
    4373                               (fToolbar != FALSE) +
    4374                               (fDrivebar != FALSE) +
    4375                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4376                              (fToolbar != FALSE) +
     4377                              (fDrivebar != FALSE) +
     4378                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43764379      *pswpNew = *pswpClient;
    43774380      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
     
    43824385      sCount++;
    43834386      pswpNew = (PSWP) mp1 + (soldCount + 3 +
    4384                               (fToolbar != FALSE) +
    4385                               (fDrivebar != FALSE) +
    4386                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4387                              (fToolbar != FALSE) +
     4388                              (fDrivebar != FALSE) +
     4389                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43874390      *pswpNew = *pswpClient;
    43884391      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
     
    43934396      sCount++;
    43944397      pswpNew = (PSWP) mp1 + (soldCount + 4 +
    4395                               (fToolbar != FALSE) +
    4396                               (fDrivebar != FALSE) +
    4397                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4398                              (fToolbar != FALSE) +
     4399                              (fDrivebar != FALSE) +
     4400                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43984401      *pswpNew = *pswpClient;
    43994402      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     
    44044407      sCount++;
    44054408      if (fUserComboBox) {
    4406         if (!aheight) {
    4407 
    4408           SWP swpTemp;
    4409 
    4410           WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4411                             &swpTemp);
    4412           aheight = swpTemp.cy;
    4413         }
    4414         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4415                                 (fToolbar != FALSE) +
    4416                                 (fSplitStatus != FALSE) +
    4417                                 (fDrivebar != FALSE) + (fAutoView != FALSE));
    4418         *pswpNew = *pswpClient;
    4419         pswpNew->hwnd = hwndDrivelist;
    4420         pswpNew->x = swpClient.x;
    4421         pswpNew->cx = 48;
    4422         pswpClient->cy -= (aheight + 6L);
    4423         pswpNew->y = pswpClient->y;
    4424         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4425         sCount++;
    4426         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4427                                 (fToolbar != FALSE) +
    4428                                 (fDrivebar != FALSE) +
    4429                                 (fSplitStatus != FALSE) +
    4430                                 (fAutoView != FALSE));
    4431         *pswpNew = *pswpClient;
    4432         pswpNew->hwnd = hwndStatelist;
    4433         pswpNew->x = swpClient.x + 48;
    4434         pswpNew->cx = (swpClient.cx - 48) / 7;
    4435         pswpNew->y = pswpClient->y;
    4436         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4437         sCount++;
    4438         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4439                                 (fToolbar != FALSE) +
    4440                                 (fDrivebar != FALSE) +
    4441                                 (fSplitStatus != FALSE) +
    4442                                 (fAutoView != FALSE));
    4443         *pswpNew = *pswpClient;
    4444         pswpNew->hwnd = hwndCmdlist;
    4445         pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
    4446         pswpNew->cx = (swpClient.cx - 48) / 5 +
    4447           ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
    4448         pswpNew->y = pswpClient->y;
    4449         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4450         sCount++;
    4451         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4452                                 (fToolbar != FALSE) +
    4453                                 (fDrivebar != FALSE) +
    4454                                 (fSplitStatus != FALSE) +
    4455                                 (fAutoView != FALSE));
    4456         *pswpNew = *pswpClient;
    4457         pswpNew->hwnd = hwndUserlist;
    4458         pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
    4459         pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
    4460           ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
    4461         pswpNew->y = pswpClient->y;
    4462         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4463         sCount++;
    4464         if (fToolbar) {
    4465           pswpNew = (PSWP) mp1 + (soldCount + 9 +
    4466                                   (fToolbar != FALSE) +
    4467                                   (fDrivebar != FALSE) +
    4468                                   (fSplitStatus != FALSE) +
    4469                                   (fAutoView != FALSE));
    4470           *pswpNew = *pswpClient;
    4471           pswpNew->hwnd = hwndButtonlist;
    4472           pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
    4473           pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
    4474           pswpNew->y = pswpClient->y;
    4475           pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4476           sCount++;
    4477         }
    4478         else
    4479           WinShowWindow(hwndButtonlist, FALSE);
     4409        if (!aheight) {
     4410
     4411          SWP swpTemp;
     4412
     4413          WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4414                            &swpTemp);
     4415          aheight = swpTemp.cy;
     4416        }
     4417        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4418                                (fToolbar != FALSE) +
     4419                                (fSplitStatus != FALSE) +
     4420                                (fDrivebar != FALSE) + (fAutoView != FALSE));
     4421        *pswpNew = *pswpClient;
     4422        pswpNew->hwnd = hwndDrivelist;
     4423        pswpNew->x = swpClient.x;
     4424        pswpNew->cx = 48;
     4425        pswpClient->cy -= (aheight + 6L);
     4426        pswpNew->y = pswpClient->y;
     4427        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4428        sCount++;
     4429        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4430                                (fToolbar != FALSE) +
     4431                                (fDrivebar != FALSE) +
     4432                                (fSplitStatus != FALSE) +
     4433                                (fAutoView != FALSE));
     4434        *pswpNew = *pswpClient;
     4435        pswpNew->hwnd = hwndStatelist;
     4436        pswpNew->x = swpClient.x + 48;
     4437        pswpNew->cx = (swpClient.cx - 48) / 7;
     4438        pswpNew->y = pswpClient->y;
     4439        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4440        sCount++;
     4441        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4442                                (fToolbar != FALSE) +
     4443                                (fDrivebar != FALSE) +
     4444                                (fSplitStatus != FALSE) +
     4445                                (fAutoView != FALSE));
     4446        *pswpNew = *pswpClient;
     4447        pswpNew->hwnd = hwndCmdlist;
     4448        pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
     4449        pswpNew->cx = (swpClient.cx - 48) / 5 +
     4450          ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
     4451        pswpNew->y = pswpClient->y;
     4452        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4453        sCount++;
     4454        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4455                                (fToolbar != FALSE) +
     4456                                (fDrivebar != FALSE) +
     4457                                (fSplitStatus != FALSE) +
     4458                                (fAutoView != FALSE));
     4459        *pswpNew = *pswpClient;
     4460        pswpNew->hwnd = hwndUserlist;
     4461        pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
     4462        pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
     4463          ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
     4464        pswpNew->y = pswpClient->y;
     4465        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4466        sCount++;
     4467        if (fToolbar) {
     4468          pswpNew = (PSWP) mp1 + (soldCount + 9 +
     4469                                  (fToolbar != FALSE) +
     4470                                  (fDrivebar != FALSE) +
     4471                                  (fSplitStatus != FALSE) +
     4472                                  (fAutoView != FALSE));
     4473          *pswpNew = *pswpClient;
     4474          pswpNew->hwnd = hwndButtonlist;
     4475          pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
     4476          pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
     4477          pswpNew->y = pswpClient->y;
     4478          pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4479          sCount++;
     4480        }
     4481        else
     4482          WinShowWindow(hwndButtonlist, FALSE);
    44804483      }
    44814484      else {
    4482         WinShowWindow(hwndUserlist, FALSE);
    4483         WinShowWindow(hwndDrivelist, FALSE);
    4484         WinShowWindow(hwndStatelist, FALSE);
    4485         WinShowWindow(hwndButtonlist, FALSE);
    4486         WinShowWindow(hwndCmdlist, FALSE);
     4485        WinShowWindow(hwndUserlist, FALSE);
     4486        WinShowWindow(hwndDrivelist, FALSE);
     4487        WinShowWindow(hwndStatelist, FALSE);
     4488        WinShowWindow(hwndButtonlist, FALSE);
     4489        WinShowWindow(hwndCmdlist, FALSE);
    44874490      }
    44884491      {
    4489         PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
    4490         SHORT x;
    4491 
    4492         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4493                                 (fToolbar != FALSE) +
    4494                                 (fDrivebar != FALSE) +
    4495                                 (fSplitStatus != FALSE) +
    4496                                 (fAutoView != FALSE) +
    4497                                 ((fUserComboBox != FALSE) * 4) +
    4498                                 (fUserComboBox != FALSE &&
    4499                                 fToolbar != FALSE));
    4500         pswp = (PSWP) mp1;
    4501         for (x = 0; x < soldCount; x++) {
    4502           if (!pswpTitlebar &&
    4503               WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
    4504             pswpTitlebar = pswp;
    4505           else if (!pswpMinbutton &&
    4506                    WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
    4507             pswpMinbutton = pswp;
    4508           if (pswpTitlebar && pswpMinbutton)
    4509             break;
    4510           pswp++;
    4511         }
    4512         if (pswpMinbutton && pswpTitlebar) {
    4513           *pswpNew = *pswpMinbutton;
    4514           pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
    4515           pswpNew->cy = pswpMinbutton->cy + 3;
    4516           pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
    4517           pswpTitlebar->cx -= (pswpNew->cx - 1);
    4518           pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
    4519           pswpNew->y = pswpMinbutton->y - 1;
    4520           sCount++;
    4521         }
    4522         else
    4523           WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
     4492        PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
     4493        SHORT x;
     4494
     4495        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4496                                (fToolbar != FALSE) +
     4497                                (fDrivebar != FALSE) +
     4498                                (fSplitStatus != FALSE) +
     4499                                (fAutoView != FALSE) +
     4500                                ((fUserComboBox != FALSE) * 4) +
     4501                                (fUserComboBox != FALSE &&
     4502                                fToolbar != FALSE));
     4503        pswp = (PSWP) mp1;
     4504        for (x = 0; x < soldCount; x++) {
     4505          if (!pswpTitlebar &&
     4506              WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
     4507            pswpTitlebar = pswp;
     4508          else if (!pswpMinbutton &&
     4509                   WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
     4510            pswpMinbutton = pswp;
     4511          if (pswpTitlebar && pswpMinbutton)
     4512            break;
     4513          pswp++;
     4514        }
     4515        if (pswpMinbutton && pswpTitlebar) {
     4516          *pswpNew = *pswpMinbutton;
     4517          pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
     4518          pswpNew->cy = pswpMinbutton->cy + 3;
     4519          pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
     4520          pswpTitlebar->cx -= (pswpNew->cx - 1);
     4521          pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
     4522          pswpNew->y = pswpMinbutton->y - 1;
     4523          sCount++;
     4524        }
     4525        else
     4526          WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
    45244527      }
    45254528
    45264529      if (fMoreButtons) {
    45274530
    4528         LONG lastx;
    4529 
    4530         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4531                                 (fToolbar != FALSE) +
    4532                                 (fDrivebar != FALSE) +
    4533                                 (fSplitStatus != FALSE) +
    4534                                 (fAutoView != FALSE) +
    4535                                 ((fUserComboBox != FALSE) * 4) +
    4536                                 (fUserComboBox != FALSE &&
    4537                                 fToolbar != FALSE));
    4538         *pswpNew = *pswpClient;
    4539         pswpNew->hwnd = hwndName;
    4540         pswpNew->x = swpClient.x + 3;
    4541         pswpNew->y = swpClient.y + (sheight + 6);
    4542         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    4543         lastx = pswpNew->x + pswpNew->cx;
    4544         pswpNew->cy = bheight;
    4545         pswpClient->y += (bheight + 4);
    4546         pswpClient->cy -= (bheight + 4);
    4547         sCount++;
    4548         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4549                                 (fToolbar != FALSE) +
    4550                                 (fDrivebar != FALSE) +
    4551                                 (fSplitStatus != FALSE) +
    4552                                 (fAutoView != FALSE) +
    4553                                 ((fUserComboBox != FALSE) * 4) +
    4554                                 (fUserComboBox != FALSE &&
    4555                                 fToolbar != FALSE));
    4556         *pswpNew = *pswpClient;
    4557         pswpNew->hwnd = hwndDate;
    4558         pswpNew->x = lastx + 3;
    4559         pswpNew->y = swpClient.y + (sheight + 6);
    4560         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    4561         lastx = pswpNew->x + pswpNew->cx;
    4562         pswpNew->cy = bheight;
    4563         sCount++;
    4564         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4565                                 (fToolbar != FALSE) +
    4566                                 (fDrivebar != FALSE) +
    4567                                 (fSplitStatus != FALSE) +
    4568                                 (fAutoView != FALSE) +
    4569                                 ((fUserComboBox != FALSE) * 4) +
    4570                                 (fUserComboBox != FALSE &&
    4571                                 fToolbar != FALSE));
    4572         *pswpNew = *pswpClient;
    4573         pswpNew->hwnd = hwndAttr;
    4574         pswpNew->x = lastx + 3;
    4575         pswpNew->y = swpClient.y + (sheight + 6);
    4576         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    4577         pswpNew->cy = bheight;
    4578         sCount++;
     4531        LONG lastx;
     4532
     4533        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4534                                (fToolbar != FALSE) +
     4535                                (fDrivebar != FALSE) +
     4536                                (fSplitStatus != FALSE) +
     4537                                (fAutoView != FALSE) +
     4538                                ((fUserComboBox != FALSE) * 4) +
     4539                                (fUserComboBox != FALSE &&
     4540                                fToolbar != FALSE));
     4541        *pswpNew = *pswpClient;
     4542        pswpNew->hwnd = hwndName;
     4543        pswpNew->x = swpClient.x + 3;
     4544        pswpNew->y = swpClient.y + (sheight + 6);
     4545        pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     4546        lastx = pswpNew->x + pswpNew->cx;
     4547        pswpNew->cy = bheight;
     4548        pswpClient->y += (bheight + 4);
     4549        pswpClient->cy -= (bheight + 4);
     4550        sCount++;
     4551        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4552                                (fToolbar != FALSE) +
     4553                                (fDrivebar != FALSE) +
     4554                                (fSplitStatus != FALSE) +
     4555                                (fAutoView != FALSE) +
     4556                                ((fUserComboBox != FALSE) * 4) +
     4557                                (fUserComboBox != FALSE &&
     4558                                fToolbar != FALSE));
     4559        *pswpNew = *pswpClient;
     4560        pswpNew->hwnd = hwndDate;
     4561        pswpNew->x = lastx + 3;
     4562        pswpNew->y = swpClient.y + (sheight + 6);
     4563        pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     4564        lastx = pswpNew->x + pswpNew->cx;
     4565        pswpNew->cy = bheight;
     4566        sCount++;
     4567        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4568                                (fToolbar != FALSE) +
     4569                                (fDrivebar != FALSE) +
     4570                                (fSplitStatus != FALSE) +
     4571                                (fAutoView != FALSE) +
     4572                                ((fUserComboBox != FALSE) * 4) +
     4573                                (fUserComboBox != FALSE &&
     4574                                fToolbar != FALSE));
     4575        *pswpNew = *pswpClient;
     4576        pswpNew->hwnd = hwndAttr;
     4577        pswpNew->x = lastx + 3;
     4578        pswpNew->y = swpClient.y + (sheight + 6);
     4579        pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
     4580        pswpNew->cy = bheight;
     4581        sCount++;
    45794582      }
    45804583      else {
    4581         WinShowWindow(hwndAttr, FALSE);
    4582         WinShowWindow(hwndName, FALSE);
    4583         WinShowWindow(hwndDate, FALSE);
     4584        WinShowWindow(hwndAttr, FALSE);
     4585        WinShowWindow(hwndName, FALSE);
     4586        WinShowWindow(hwndDate, FALSE);
    45844587      }
    45854588      return MRFROMSHORT(sCount);
     
    45944597      sCount += 6;
    45954598      if (fSplitStatus)
    4596         sCount++;
     4599        sCount++;
    45974600      if (fToolbar)
    4598         sCount++;
     4601        sCount++;
    45994602      if (fUserComboBox) {
    4600         sCount += 4;
    4601         if (fToolbar)
    4602           sCount++;
     4603        sCount += 4;
     4604        if (fToolbar)
     4605          sCount++;
    46034606      }
    46044607      if (fDrivebar)
    4605         sCount++;
     4608        sCount++;
    46064609      if (fAutoView)
    4607         sCount++;
     4610        sCount++;
    46084611      if (fMoreButtons)
    4609         sCount += 3;
     4612        sCount += 3;
    46104613      return MRFROMSHORT(sCount);
    46114614    }
     
    46284631      // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
    46294632      if (hwnd != NULLHANDLE) {
    4630         HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
    4631         USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
    4632         switch (id) {
    4633         case MAIN_SETUPLIST:
    4634         case MAIN_USERLIST:
    4635         case MAIN_CMDLIST:
    4636           // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
    4637           WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
    4638         }
     4633        HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
     4634        USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
     4635        switch (id) {
     4636        case MAIN_SETUPLIST:
     4637        case MAIN_USERLIST:
     4638        case MAIN_CMDLIST:
     4639          // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
     4640          WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
     4641        }
    46394642      }
    46404643    }
     
    46654668      wa.size = sizeof(wa);
    46664669      pci =
    4667         (PCNRITEM)
    4668         WinSendMsg(WinWindowFromID
    4669                    (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
    4670                    CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
    4671                    MPFROMSHORT(CRA_CURSORED));
     4670        (PCNRITEM)
     4671        WinSendMsg(WinWindowFromID
     4672                   (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
     4673                   CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
     4674                   MPFROMSHORT(CRA_CURSORED));
    46724675      if (pci && (INT) pci != -1) {
    4673         strcpy(wa.szCurrentPath1, pci->pszFileName);
    4674         MakeValidDir(wa.szCurrentPath1);
     4676        strcpy(wa.szCurrentPath1, pci->pszFileName);
     4677        MakeValidDir(wa.szCurrentPath1);
    46754678      }
    46764679      else
    4677         strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
     4680        strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
    46784681      TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
    46794682      if (!*wa.szCurrentPath2)
    4680         strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
     4683        strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
    46814684      MakeValidDir(wa.szCurrentPath2);
    46824685      if (WinDlgBox(HWND_DESKTOP,
    4683                     hwnd,
    4684                     WalkTwoCmpDlgProc,
    4685                     FM3ModHandle,
    4686                     WALK2_FRAME,
    4687                     MPFROMP(&wa)) &&
    4688           !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
    4689         if (!*dircompare) {
    4690 
    4691           COMPARE *cmp;
    4692 
    4693           cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    4694           if (cmp) {
    4695             cmp->size = sizeof(COMPARE);
    4696             strcpy(cmp->leftdir, wa.szCurrentPath1);
    4697             strcpy(cmp->rightdir, wa.szCurrentPath2);
    4698             cmp->hwndParent = hwnd;
    4699             cmp->dcd.hwndParent = hwnd;
    4700             WinDlgBox(HWND_DESKTOP,
    4701                       HWND_DESKTOP,
    4702                       CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    4703           }
    4704         }
    4705         else {
    4706 
    4707           CHAR szPath1[CCHMAXPATH];
    4708           CHAR szPath2[CCHMAXPATH];
    4709           runemf2(SEPARATE,
    4710                   HWND_DESKTOP, pszSrcFile, __LINE__,
    4711                   NULL, NULL,
    4712                   "%s %s %s",
    4713                   dircompare,
    4714                   BldQuotedFileName(szPath1, wa.szCurrentPath1),
    4715                   BldQuotedFileName(szPath2, wa.szCurrentPath2));
    4716         }
     4686                    hwnd,
     4687                    WalkTwoCmpDlgProc,
     4688                    FM3ModHandle,
     4689                    WALK2_FRAME,
     4690                    MPFROMP(&wa)) &&
     4691          !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
     4692        if (!*dircompare) {
     4693
     4694          COMPARE *cmp;
     4695
     4696          cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
     4697          if (cmp) {
     4698            cmp->size = sizeof(COMPARE);
     4699            strcpy(cmp->leftdir, wa.szCurrentPath1);
     4700            strcpy(cmp->rightdir, wa.szCurrentPath2);
     4701            cmp->hwndParent = hwnd;
     4702            cmp->dcd.hwndParent = hwnd;
     4703            WinDlgBox(HWND_DESKTOP,
     4704                      HWND_DESKTOP,
     4705                      CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
     4706          }
     4707        }
     4708        else {
     4709
     4710          CHAR szPath1[CCHMAXPATH];
     4711          CHAR szPath2[CCHMAXPATH];
     4712          runemf2(SEPARATE,
     4713                  HWND_DESKTOP, pszSrcFile, __LINE__,
     4714                  NULL, NULL,
     4715                  "%s %s %s",
     4716                  dircompare,
     4717                  BldQuotedFileName(szPath1, wa.szCurrentPath1),
     4718                  BldQuotedFileName(szPath2, wa.szCurrentPath2));
     4719        }
    47174720      }
    47184721    }
     
    47264729  case IDM_CLI:
    47274730    if (fSplitStatus &&
    4728         hwndStatus2 &&
    4729         !WinIsWindow(WinQueryAnchorBlock(hwnd),
    4730                      WinWindowFromID(hwndStatus2, COMMAND_LINE)))
     4731        hwndStatus2 &&
     4732        !WinIsWindow(WinQueryAnchorBlock(hwnd),
     4733                     WinWindowFromID(hwndStatus2, COMMAND_LINE)))
    47314734      PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
    47324735    break;
     
    47414744      bstrip(temp);
    47424745      if (*temp &&
    4743           !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
    4744         if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
    4745           add_udir(TRUE, path);
    4746           if (fUdirsChanged)
    4747             save_udirs();
    4748           WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4749         }
    4750         else {
    4751           if (!remove_udir(path))
    4752             Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
    4753           else {
    4754             if (fUdirsChanged)
    4755               save_udirs();
    4756             WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4757           }
    4758         }
     4746          !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
     4747        if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
     4748          add_udir(TRUE, path);
     4749          if (fUdirsChanged)
     4750            save_udirs();
     4751          WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4752        }
     4753        else {
     4754          if (!remove_udir(path))
     4755            Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
     4756          else {
     4757            if (fUdirsChanged)
     4758              save_udirs();
     4759            WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4760          }
     4761        }
    47594762      }
    47604763    }
     
    47714774      // Complain if attempting to use reserved name
    47724775      if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
    4773           stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
     4776          stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
    47744777      {
    4775         saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4776                GetPString(IDS_WARNINGTEXT),
    4777                "\"%s\" is a reserved state name", szStateName);
     4778        saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4779               GetPString(IDS_WARNINGTEXT),
     4780               "\"%s\" is a reserved state name", szStateName);
    47784781      }
    47794782      // Ignore request if blank
    47804783      else if (*szStateName) {
    4781         BOOL fAbortOperation = FALSE;
    4782         if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
    4783         {
    4784           if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
    4785               GetPString(IDS_WARNINGTEXT),
    4786               GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
    4787               fAbortOperation = TRUE;
    4788         }
    4789         if (!fAbortOperation) {
    4790           if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
    4791             // Save
    4792             INT nSaved = SaveDirCnrState(hwnd, szStateName);
    4793             if (nSaved >= 0) {
    4794               INT ret = add_setup(szStateName);
    4795               if (ret == 0) {
    4796                 WinSendMsg(hwndStatelist, LM_INSERTITEM,
    4797                            MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    4798                 save_setups();
    4799               }
    4800               else if (ret != 1) {
    4801                 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4802                        GetPString(IDS_WARNINGTEXT),
    4803                        "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    4804                 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4805               }
    4806             }
    4807             else {
    4808               saymsg(MB_ENTER | MB_ICONASTERISK,
    4809                      hwnd,
    4810                      GetPString(IDS_WARNINGTEXT),
    4811                      "State data save failed");
    4812               WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4813             }
    4814           }
    4815           else {
    4816             // Delete
    4817             ULONG numsaves = 0, size, x;
    4818             CHAR s[STATE_NAME_MAX_BYTES + 80];
    4819 
    4820             INT ret = remove_setup(szStateName);
    4821             if (ret == 1)
    4822               save_setups();
    4823             sprintf(s, "%s.NumDirsLastTime", szStateName);
    4824             size = sizeof(ULONG);
    4825             if (!PrfQueryProfileData(fmprof,
    4826                                      FM3Str,
    4827                                      s,
    4828                                      (PVOID)&numsaves,
    4829                                      &size)) {
    4830               saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4831                      GetPString(IDS_WARNINGTEXT),
    4832                      GetPString(IDS_DOESNTEXISTTEXT), szStateName);
    4833             }
    4834             else if (!size)
    4835               Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    4836             else {
    4837               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4838               for (x = 0; x < numsaves; x++) {
    4839                 sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4840                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4841                 sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4842                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4843                 sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4844                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4845                 sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4846                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4847                 sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4848                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4849                 sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
    4850                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4851                 sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
    4852                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4853                 sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
    4854                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4855                 sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
    4856                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4857                 sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
    4858                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4859                 sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
    4860                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4861                 sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
    4862                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4863                 sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
    4864                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4865                 sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
    4866                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4867                 sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
    4868                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4869                 sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
    4870                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4871                 sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
    4872                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4873                 sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
    4874                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4875                 sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
    4876                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4877               }
    4878               sprintf(s, "%s.LastTreePos", szStateName);
    4879               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4880               sprintf(s, "%s.MySizeLastTime", szStateName);
    4881               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4882             }
    4883             PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
    4884           }
    4885         }
     4784        BOOL fAbortOperation = FALSE;
     4785        if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
     4786        {
     4787          if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
     4788              GetPString(IDS_WARNINGTEXT),
     4789              GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
     4790              fAbortOperation = TRUE;
     4791        }
     4792        if (!fAbortOperation) {
     4793          if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
     4794            // Save
     4795            INT nSaved = SaveDirCnrState(hwnd, szStateName);
     4796            if (nSaved >= 0) {
     4797              INT ret = add_setup(szStateName);
     4798              if (ret == 0) {
     4799                WinSendMsg(hwndStatelist, LM_INSERTITEM,
     4800                           MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
     4801                save_setups();
     4802              }
     4803              else if (ret != 1) {
     4804                saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4805                       GetPString(IDS_WARNINGTEXT),
     4806                       "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
     4807                WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4808              }
     4809            }
     4810            else {
     4811              saymsg(MB_ENTER | MB_ICONASTERISK,
     4812                     hwnd,
     4813                     GetPString(IDS_WARNINGTEXT),
     4814                     "State data save failed");
     4815              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4816            }
     4817          }
     4818          else {
     4819            // Delete
     4820            ULONG numsaves = 0, size, x;
     4821            CHAR s[STATE_NAME_MAX_BYTES + 80];
     4822
     4823            INT ret = remove_setup(szStateName);
     4824            if (ret == 1)
     4825              save_setups();
     4826            sprintf(s, "%s.NumDirsLastTime", szStateName);
     4827            size = sizeof(ULONG);
     4828            if (!PrfQueryProfileData(fmprof,
     4829                                     FM3Str,
     4830                                     s,
     4831                                     (PVOID)&numsaves,
     4832                                     &size)) {
     4833              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4834                     GetPString(IDS_WARNINGTEXT),
     4835                     GetPString(IDS_DOESNTEXISTTEXT), szStateName);
     4836            }
     4837            else if (!size)
     4838              Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     4839            else {
     4840              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     4841              for (x = 0; x < numsaves; x++) {
     4842                sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
     4843                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4844                sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
     4845                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4846                sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
     4847                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4848                sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
     4849                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4850                sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
     4851                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4852                sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
     4853                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4854                sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
     4855                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4856                sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
     4857                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4858                sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
     4859                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4860                sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
     4861                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4862                sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
     4863                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4864                sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
     4865                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4866                sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
     4867                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4868                sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
     4869                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4870                sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
     4871                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4872                sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
     4873                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4874                sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
     4875                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4876                sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
     4877                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4878                sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
     4879                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4880              }
     4881              sprintf(s, "%s.LastTreePos", szStateName);
     4882              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4883              sprintf(s, "%s.MySizeLastTime", szStateName);
     4884              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4885            }
     4886            PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     4887          }
     4888        }
    48864889      }
    48874890    }
     
    48964899      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    48974900      if (swp.fl & SWP_MAXIMIZE) {
    4898         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
    4899                    MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    4900         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     4901        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
     4902                   MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     4903        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    49014904      }
    49024905      WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
     
    49064909      swpD.cy -= (icz + bsz);
    49074910      if (swp.x == swpD.x && swp.y == swpD.y &&
    4908           swp.cx == swpD.cx && swp.cy == swpD.cy &&
    4909           // fixme to be #defined someday
    4910           WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
    4911           WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
    4912         swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
    4913         swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
    4914         swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
    4915         swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
     4911          swp.cx == swpD.cx && swp.cy == swpD.cy &&
     4912          // fixme to be #defined someday
     4913          WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
     4914          WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
     4915        swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
     4916        swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
     4917        swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
     4918        swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
    49164919      }
    49174920      else {
    4918         WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
    4919         WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
    4920         WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
    4921         WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
     4921        WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
     4922        WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
     4923        WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
     4924        WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
    49224925      }
    49234926      WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
    4924                       swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
     4927                      swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
    49254928    }
    49264929    break;
     
    49284931  case IDM_BLINK:
    49294932    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4930                     SWP_MINIMIZE);
     4933                    SWP_MINIMIZE);
    49314934    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4932                     SWP_RESTORE | SWP_ZORDER);
     4935                    SWP_RESTORE | SWP_ZORDER);
    49334936    break;
    49344937
     
    49384941
    49394942      if (hwndTop)
    4940         WinSetFocus(HWND_DESKTOP, hwndTop);
     4943        WinSetFocus(HWND_DESKTOP, hwndTop);
    49414944    }
    49424945    break;
     
    49604963  case IDM_QUICKSETTINGS:
    49614964    WinDlgBox(HWND_DESKTOP,
    4962               hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
     4965              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
    49634966    break;
    49644967
     
    49664969  case IDM_VIEWINFS:
    49674970    WinDlgBox(HWND_DESKTOP,
    4968               HWND_DESKTOP,
    4969               ViewInfProc,
    4970               FM3ModHandle,
    4971               VINF_FRAME,
    4972               ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
    4973                MPFROMP(NullStr) : MPVOID));
     4971              HWND_DESKTOP,
     4972              ViewInfProc,
     4973              FM3ModHandle,
     4974              VINF_FRAME,
     4975              ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
     4976               MPFROMP(NullStr) : MPVOID));
    49744977    break;
    49754978
     
    49814984      TopWindowName(hwnd, (HWND) 0, newpath);
    49824985      if (WinDlgBox(HWND_DESKTOP,
    4983                     hwnd,
    4984                     WalkAllDlgProc,
    4985                     FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
    4986         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
     4986                    hwnd,
     4987                    WalkAllDlgProc,
     4988                    FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
     4989        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
    49874990    }
    49884991    break;
     
    50055008      if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    50065009
    5007         RECTL rcl;
    5008         ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
    5009 
    5010         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    5011         rcl.yBottom += icz;
    5012         rcl.yTop -= icz;
    5013         rcl.xLeft += icz;
    5014         rcl.xRight -= icz;
    5015         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     5010        RECTL rcl;
     5011        ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
     5012
     5013        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     5014        rcl.yBottom += icz;
     5015        rcl.yTop -= icz;
     5016        rcl.xLeft += icz;
     5017        rcl.xRight -= icz;
     5018        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    50165019      }
    50175020      else {
    50185021
    5019         RECTL rcl;
    5020 
    5021         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    5022         rcl.yBottom += 8;
    5023         rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
    5024         rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
    5025         rcl.xRight -= 8;
    5026         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     5022        RECTL rcl;
     5023
     5024        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     5025        rcl.yBottom += 8;
     5026        rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
     5027        rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
     5028        rcl.xRight -= 8;
     5029        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    50275030      }
    50285031      switch (SHORT1FROMMP(mp1)) {
    50295032      case IDM_HELPCONTEXT:
    5030         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5031                    MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
    5032         break;
     5033        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5034                   MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
     5035        break;
    50335036
    50345037      case IDM_HELPMOUSE:
    5035         if (hwndHelp)
    5036           WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5037                      MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
    5038         break;
     5038        if (hwndHelp)
     5039          WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5040                     MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
     5041        break;
    50395042
    50405043      case IDM_HELPPIX:
    5041         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5042                    MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
    5043         break;
     5044        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5045                   MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
     5046        break;
    50445047
    50455048      case IDM_HELPTUTOR:
    5046         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5047                    MPFROM2SHORT(HELP_TUTORIAL, 0),
    5048                    MPFROMSHORT(HM_RESOURCEID));
    5049         break;
     5049        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5050                   MPFROM2SHORT(HELP_TUTORIAL, 0),
     5051                   MPFROMSHORT(HM_RESOURCEID));
     5052        break;
    50505053
    50515054      case IDM_HELPHINTS:
    5052         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5053                    MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
    5054         break;
     5055        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5056                   MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
     5057        break;
    50555058
    50565059      case IDM_HELPGENERAL:
    5057         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5058                    MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
    5059         break;
     5060        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5061                   MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
     5062        break;
    50605063      case IDM_HELPKEYS:
    5061         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5062                    MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
    5063         break;
     5064        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5065                   MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
     5066        break;
    50645067
    50655068      case IDM_HELP:
    50665069      case IDM_HELPCONTENTS:
    5067         WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
    5068         break;
     5070        WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
     5071        break;
    50695072
    50705073      case IDM_HELPUSERLIST:
    5071         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5072                    MPFROM2SHORT(HELP_USERLISTS, 0),
    5073                    MPFROMSHORT(HM_RESOURCEID));
    5074         break;
     5074        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5075                   MPFROM2SHORT(HELP_USERLISTS, 0),
     5076                   MPFROMSHORT(HM_RESOURCEID));
     5077        break;
    50755078      }
    50765079    }
     
    50835086  case IDM_ABOUT:
    50845087    WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
    5085               ABT_FRAME, MPVOID);
     5088              ABT_FRAME, MPVOID);
    50865089    break;
    50875090
     
    50975100
    50985101      if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
    5099                            (PVOID) & version, (ULONG) sizeof(version))) {
    5100         if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
    5101           if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
    5102             palette = "<WP_HIRESCLRPAL>";
    5103           else
    5104             palette = "<WP_LORESCLRPAL>";
    5105         }
     5102                           (PVOID) & version, (ULONG) sizeof(version))) {
     5103        if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
     5104          if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
     5105            palette = "<WP_HIRESCLRPAL>";
     5106          else
     5107            palette = "<WP_LORESCLRPAL>";
     5108        }
    51065109      }
    51075110      OpenObject(palette, Default, hwnd);
     
    51195122      hWPSObject = WinQueryObject("<WP_SCHPAL>");
    51205123      if (hWPSObject != NULLHANDLE)
    5121         WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
    5122                         "Spring:PM_Spring,Summer:PM_Summer,"
    5123                         "System:PM_System,Windows:PM_Windows;"
    5124                         "OPEN=DEFAULT");
     5124        WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
     5125                        "Spring:PM_Spring,Summer:PM_Summer,"
     5126                        "System:PM_System,Windows:PM_Windows;"
     5127                        "OPEN=DEFAULT");
    51255128    }
    51265129    break;
     
    51335136  case IDM_SYSINFO:
    51345137    WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
    5135               SYS_FRAME, NULL);
     5138              SYS_FRAME, NULL);
    51365139    break;
    51375140#endif
     
    51435146
    51445147      if (hwndTree)
    5145         pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
    5146                                     MPFROMLONG(CMA_FIRST),
    5147                                     MPFROMSHORT(CRA_CURSORED));
     5148        pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
     5149                                    MPFROMLONG(CMA_FIRST),
     5150                                    MPFROMSHORT(CRA_CURSORED));
    51485151      if (pci && (INT) pci != -1) {
    5149         strcpy(path, pci->pszFileName);
    5150         MakeValidDir(path);
     5152        strcpy(path, pci->pszFileName);
     5153        MakeValidDir(path);
    51515154      }
    51525155      else
    5153         strcpy(path, pFM2SaveDirectory);
     5156        strcpy(path, pFM2SaveDirectory);
    51545157      WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
    5155                 BAT_FRAME, MPFROMP(path));
     5158                BAT_FRAME, MPFROMP(path));
    51565159    }
    51575160    break;
     
    51675170      TopWindowName(hwnd, (HWND) 0, path);
    51685171      if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
    5169         env = GetCmdSpec(TRUE);
     5172        env = GetCmdSpec(TRUE);
    51705173      else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
    5171         env = "WINOS2.COM";
    5172         type = SEPARATE | FULLSCREEN;
     5174        env = "WINOS2.COM";
     5175        type = SEPARATE | FULLSCREEN;
    51735176      }
    51745177      runemf2(type, hwnd, pszSrcFile, __LINE__,
    5175               path, NULL, "%s", env);
     5178              path, NULL, "%s", env);
    51765179    }
    51775180    break;
     
    51795182  case IDM_KILLPROC:
    51805183    WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
    5181               KILL_FRAME, NULL);
     5184              KILL_FRAME, NULL);
    51825185    break;
    51835186
     
    51945197  case IDM_AUTOVIEW:
    51955198    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5196                 &fAutoView, TRUE, "AutoView");
     5199                &fAutoView, TRUE, "AutoView");
    51975200  AutoChange:
    51985201    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5199             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5202            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52005203    if (fAutoView) {
    52015204
     
    52065209      hwndDir = TopWindowName(hwnd, (HWND) 0, s);
    52075210      if (hwndDir) {
    5208         hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
    5209         if (hwndDir) {
    5210           hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
    5211           if (hwndDir) {
    5212             pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
    5213                                         MPFROMLONG(CMA_FIRST),
    5214                                         MPFROMSHORT(CRA_CURSORED));
    5215             if (pci && (INT) pci != -1 &&
    5216                 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
    5217               WinSendMsg(hwnd,
    5218                         UM_LOADFILE,
    5219                         MPFROMP(pci->pszFileName),
    5220                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    5221                         MPVOID : MPFROMLONG(1));
    5222           }
    5223         }
     5211        hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
     5212        if (hwndDir) {
     5213          hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
     5214          if (hwndDir) {
     5215            pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
     5216                                        MPFROMLONG(CMA_FIRST),
     5217                                        MPFROMSHORT(CRA_CURSORED));
     5218            if (pci && (INT) pci != -1 &&
     5219                (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
     5220              WinSendMsg(hwnd,
     5221                        UM_LOADFILE,
     5222                        MPFROMP(pci->pszFileName),
     5223                        (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
     5224                        MPVOID : MPFROMLONG(1));
     5225          }
     5226        }
    52245227      }
    52255228    }
     
    52285231  case IDM_TEXTTOOLS:
    52295232    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5230                 &fTextTools, TRUE, "TextTools");
     5233                &fTextTools, TRUE, "TextTools");
    52315234    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    52325235    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5233             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5236            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52345237    break;
    52355238
    52365239  case IDM_TOOLTITLES:
    52375240    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5238                 &fToolTitles, TRUE, "ToolTitles");
     5241                &fToolTitles, TRUE, "ToolTitles");
    52395242    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    52405243    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5241             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5244            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52425245    break;
    52435246
     
    52475250      MenuInvisible = MenuInvisible ? FALSE : TRUE;
    52485251      if (MenuInvisible) {
    5249         WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
    5250         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5251                                            FID_SYSMENU), IDM_HIDEMENU,
    5252                            GetPString(IDS_UNHIDEMENUTEXT));
     5252        WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
     5253        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5254                                           FID_SYSMENU), IDM_HIDEMENU,
     5255                           GetPString(IDS_UNHIDEMENUTEXT));
    52535256      }
    52545257      else {
    5255         WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
    5256         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5257                                            FID_SYSMENU), IDM_HIDEMENU,
    5258                            GetPString(IDS_HIDEMENUTEXT));
     5258        WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
     5259        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5260                                           FID_SYSMENU), IDM_HIDEMENU,
     5261                           GetPString(IDS_HIDEMENUTEXT));
    52595262      }
    52605263      PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5261               MPFROMLONG(FCF_MENU), MPVOID);
     5264              MPFROMLONG(FCF_MENU), MPVOID);
    52625265      PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
    5263                           &MenuInvisible, sizeof(BOOL));
     5266                          &MenuInvisible, sizeof(BOOL));
    52645267    }
    52655268    break;
     
    52745277
    52755278      if (Collector)
    5276         already = TRUE;
     5279        already = TRUE;
    52775280      if (!already && !fAutoTile && !fExternalCollector)
    5278         GetNextWindowPos(hwnd, &swp, NULL, NULL);
     5281        GetNextWindowPos(hwnd, &swp, NULL, NULL);
    52795282      hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
    52805283      if (hwndC) {
    5281         if (!already && !fAutoTile && !fExternalCollector)
    5282           WinSetWindowPos(hwndC, HWND_TOP,
    5283                           swp.x, swp.y, swp.cx, swp.cy,
    5284                           SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    5285         else if (fAutoTile && !already)
    5286           TileChildren(hwnd, TRUE);
    5287         WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
    5288                         SWP_ACTIVATE);
    5289         if (SHORT1FROMMP(mp1) == IDM_GREP)
    5290           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5291                   MPFROM2SHORT(IDM_GREP, 0), MPVOID);
    5292         if (SHORT1FROMMP(mp1) == IDM_SEEALL)
    5293           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5294                   MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
     5284        if (!already && !fAutoTile && !fExternalCollector)
     5285          WinSetWindowPos(hwndC, HWND_TOP,
     5286                          swp.x, swp.y, swp.cx, swp.cy,
     5287                          SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     5288        else if (fAutoTile && !already)
     5289          TileChildren(hwnd, TRUE);
     5290        WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
     5291                        SWP_ACTIVATE);
     5292        if (SHORT1FROMMP(mp1) == IDM_GREP)
     5293          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5294                  MPFROM2SHORT(IDM_GREP, 0), MPVOID);
     5295        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     5296          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5297                  MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
    52955298      }
    52965299    }
     
    53035306
    53045307      if (!toolhead || !toolhead->next) {
    5305         firsttool = (toolhead) ? toolhead->id : 0;
    5306         break;
     5308        firsttool = (toolhead) ? toolhead->id : 0;
     5309        break;
    53075310      }
    53085311      tool = find_tool(firsttool);
    53095312      if (!tool)
    5310         tool = toolhead;
     5313        tool = toolhead;
    53115314      if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
    5312         tool = prev_tool(tool, TRUE);
    5313         firsttool = tool->id;
     5315        tool = prev_tool(tool, TRUE);
     5316        firsttool = tool->id;
    53145317      }
    53155318      else {
    5316         tool = next_tool(tool, TRUE);
    5317         firsttool = tool->id;
     5319        tool = next_tool(tool, TRUE);
     5320        firsttool = tool->id;
    53185321      }
    53195322      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5320                                   MAIN_TOOLS));
     5323                                  MAIN_TOOLS));
    53215324    }
    53225325    break;
     
    53285331  case IDM_TOOLBAR:
    53295332    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5330                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
     5333                IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    53315334    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    53325335    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5333                                   MAIN_TOOLS), fToolbar);
     5336                                  MAIN_TOOLS), fToolbar);
    53345337    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    5335                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5338               WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53365339    if (fDrivebar)
    53375340      WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5338                                         MAIN_DRIVES), NULL, TRUE);
     5341                                        MAIN_DRIVES), NULL, TRUE);
    53395342    break;
    53405343
    53415344  case IDM_DRIVEBAR:
    53425345    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5343                 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
     5346                IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
    53445347    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5345                                   MAIN_DRIVES), fDrivebar);
     5348                                  MAIN_DRIVES), fDrivebar);
    53465349    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5347             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5350            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53485351    PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    53495352    break;
     
    53515354  case IDM_USERLIST:
    53525355    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5353                 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
     5356                SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
    53545357    WinShowWindow(hwndUserlist, fUserComboBox);
    53555358    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5356             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5359            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53575360    PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    53585361    PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    53665369    WinSetWindowText(hwndAttr, NullStr);
    53675370    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5368                 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
     5371                SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
    53695372    if (fMoreButtons) {
    53705373
     
    53745377
    53755378      if (hwndTemp) {
    5376         WinSetFocus(HWND_DESKTOP, hwnd);
    5377         WinSetFocus(HWND_DESKTOP, hwndTemp);
     5379        WinSetFocus(HWND_DESKTOP, hwnd);
     5380        WinSetFocus(HWND_DESKTOP, hwndTemp);
    53785381      }
    53795382    }
    53805383    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5381             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5384            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53825385    break;
    53835386
    53845387  case IDM_TOGGLEDRAGDIALOG:
    53855388    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5386                 IDM_TOGGLEDRAGDIALOG,
    5387                 &fDragndropDlg,
    5388                 TRUE,
    5389                 "Drag&DropDlg");
     5389                IDM_TOGGLEDRAGDIALOG,
     5390                &fDragndropDlg,
     5391                TRUE,
     5392                "Drag&DropDlg");
    53905393    break;
    53915394
    53925395  case IDM_SYNCUPDATES:
    53935396    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5394                 IDM_SYNCUPDATES,
    5395                 &fSyncUpdates,
    5396                 TRUE,
    5397                 "SyncUpdates");
     5397                IDM_SYNCUPDATES,
     5398                &fSyncUpdates,
     5399                TRUE,
     5400                "SyncUpdates");
    53985401    break;
    53995402
     
    54055408      WinQueryWindowPos(hwnd, &swp);
    54065409      WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
    5407                       SWP_MOVE);
     5410                      SWP_MOVE);
    54085411    }
    54095412    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5410                 &fFreeTree, TRUE, "FreeTree");
     5413                &fFreeTree, TRUE, "FreeTree");
    54115414    if (fAutoTile)
    54125415      TileChildren(hwnd, TRUE);
     
    54155418  case IDM_AUTOTILE:
    54165419    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5417                 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
     5420                SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
    54185421    if (fAutoTile)
    54195422      TileChildren(hwnd, TRUE);
     
    54225425  case IDM_TILEBACKWARDS:
    54235426    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5424                 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
     5427                SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
    54255428    if (fAutoTile)
    54265429      TileChildren(hwnd, TRUE);
     
    54675470  default:
    54685471    if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
    5469                        SHORT1FROMMP(mp1))) {
     5472                       SHORT1FROMMP(mp1))) {
    54705473      if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    5471           SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    5472 
    5473         INT x;
    5474         HWND hwndCnr;
    5475 
    5476         if (!cmdloaded)
    5477           load_commands();
    5478         hwndCnr = TopWindow(hwnd, (HWND) 0);
    5479         hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
    5480                                     UM_CONTAINERHWND, MPVOID, MPVOID);
    5481         if (!hwndCnr) {
    5482           Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
    5483           break;
    5484         }
    5485         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    5486         if (x >= 0) {
    5487           x++;
    5488           RunCommand(hwndCnr, x);
    5489           if (fUnHilite) {
    5490 
    5491             PCNRITEM pci;
    5492             DIRCNRDATA *dcd = NULL;
    5493 
    5494             // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
    5495             if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
    5496               dcd = INSTDATA(hwndCnr);
    5497             pci = (PCNRITEM) WinSendMsg(hwndCnr,
    5498                                         CM_QUERYRECORDEMPHASIS,
    5499                                         MPFROMLONG(CMA_FIRST),
    5500                                         MPFROMSHORT(CRA_CURSORED));
    5501             if (pci && (INT) pci != -1 &&
    5502                 (pci->rc.flRecordAttr & CRA_SELECTED))
    5503             {
    5504               UnHilite(hwnd,
    5505                        TRUE,
    5506                        dcd ? &dcd->lastselection : NULL,
    5507                        dcd ? dcd ->ulItemsToUnHilite : 0);
    5508             }
    5509           }
    5510         }
     5474          SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
     5475
     5476        INT x;
     5477        HWND hwndCnr;
     5478
     5479        if (!cmdloaded)
     5480          load_commands();
     5481        hwndCnr = TopWindow(hwnd, (HWND) 0);
     5482        hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     5483                                    UM_CONTAINERHWND, MPVOID, MPVOID);
     5484        if (!hwndCnr) {
     5485          Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
     5486          break;
     5487        }
     5488        x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     5489        if (x >= 0) {
     5490          x++;
     5491          RunCommand(hwndCnr, x);
     5492          if (fUnHilite) {
     5493
     5494            PCNRITEM pci;
     5495            DIRCNRDATA *dcd = NULL;
     5496
     5497            // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
     5498            if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     5499              dcd = INSTDATA(hwndCnr);
     5500            pci = (PCNRITEM) WinSendMsg(hwndCnr,
     5501                                        CM_QUERYRECORDEMPHASIS,
     5502                                        MPFROMLONG(CMA_FIRST),
     5503                                        MPFROMSHORT(CRA_CURSORED));
     5504            if (pci && (INT) pci != -1 &&
     5505                (pci->rc.flRecordAttr & CRA_SELECTED))
     5506            {
     5507              UnHilite(hwnd,
     5508                       TRUE,
     5509                       dcd ? &dcd->lastselection : NULL,
     5510                       dcd ? dcd ->ulItemsToUnHilite : 0);
     5511            }
     5512          }
     5513        }
    55115514      }
    55125515      else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    5513                SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
    5514         if (!qtloaded)
    5515           load_quicktools();
    5516         if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
    5517           if (fToolsChanged)
    5518             save_tools(NULL);
    5519           if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
    5520             load_tools(NULL);
    5521           else {
    5522             strcpy(lasttoolbar,
    5523                    quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
    5524             PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
    5525           }
    5526           PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    5527         }
     5516               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
     5517        if (!qtloaded)
     5518          load_quicktools();
     5519        if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
     5520          if (fToolsChanged)
     5521            save_tools(NULL);
     5522          if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
     5523            load_tools(NULL);
     5524          else {
     5525            strcpy(lasttoolbar,
     5526                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
     5527            PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
     5528          }
     5529          PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     5530        }
    55285531      }
    55295532      else {
    55305533
    5531         HWND hwndActive;
    5532 
    5533         hwndActive = TopWindow(hwnd, (HWND) 0);
    5534         if (hwndActive)
    5535           PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    5536                   WM_COMMAND, mp1, mp2);
     5534        HWND hwndActive;
     5535
     5536        hwndActive = TopWindow(hwnd, (HWND) 0);
     5537        if (hwndActive)
     5538          PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     5539                  WM_COMMAND, mp1, mp2);
    55375540      }
    55385541    }
     
    55435546
    55445547static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
    5545                                    MPARAM mp2)
     5548                                   MPARAM mp2)
    55465549{
    55475550  TID tid;
     
    55645567    WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
    55655568    WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
    5566     if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
    5567       Runtime_Error(pszSrcFile, __LINE__,
    5568                     GetPString(IDS_COULDNTSTARTTHREADTEXT));
     5569    if (xbeginthread(MakeMainObjWin,
     5570                     245760,
     5571                     MPVOID,
     5572                     pszSrcFile,
     5573                     __LINE__) == -1)
     5574    {
    55695575      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    55705576      return 0;
     
    55855591
    55865592    if (!WinCreateWindow(hwndFrame,
    5587                         WC_BUTTON,
    5588                         "I",
    5589                         WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
    5590                         ((swp.cx -
    5591                            WinQuerySysValue(HWND_DESKTOP,
    5592                                             SV_CXMINMAXBUTTON)) -
    5593                           WinQuerySysValue(HWND_DESKTOP,
    5594                                            SV_CXMINMAXBUTTON) / 2) -
    5595                         WinQuerySysValue(HWND_DESKTOP,
    5596                                           SV_CXSIZEBORDER),
    5597                         (swp.cy - WinQuerySysValue(HWND_DESKTOP,
    5598                                                     SV_CYMINMAXBUTTON)) -
    5599                         WinQuerySysValue(HWND_DESKTOP,
    5600                                           SV_CYSIZEBORDER),
    5601                         WinQuerySysValue(HWND_DESKTOP,
    5602                                           SV_CXMINMAXBUTTON) / 2,
    5603                         WinQuerySysValue(HWND_DESKTOP,
    5604                                           SV_CYMINMAXBUTTON),
    5605                         hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
     5593                        WC_BUTTON,
     5594                        "I",
     5595                        WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
     5596                        ((swp.cx -
     5597                           WinQuerySysValue(HWND_DESKTOP,
     5598                                            SV_CXMINMAXBUTTON)) -
     5599                          WinQuerySysValue(HWND_DESKTOP,
     5600                                           SV_CXMINMAXBUTTON) / 2) -
     5601                        WinQuerySysValue(HWND_DESKTOP,
     5602                                          SV_CXSIZEBORDER),
     5603                        (swp.cy - WinQuerySysValue(HWND_DESKTOP,
     5604                                                    SV_CYMINMAXBUTTON)) -
     5605                        WinQuerySysValue(HWND_DESKTOP,
     5606                                          SV_CYSIZEBORDER),
     5607                        WinQuerySysValue(HWND_DESKTOP,
     5608                                          SV_CXMINMAXBUTTON) / 2,
     5609                        WinQuerySysValue(HWND_DESKTOP,
     5610                                          SV_CYMINMAXBUTTON),
     5611                        hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
    56065612      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56075613    }
    56085614    else {
    56095615      WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
    5610                         IdealButtonProc);
     5616                        IdealButtonProc);
    56115617      SetPresParams(WinWindowFromID(hwndFrame,
    5612                                     IDM_IDEALSIZE),
    5613                     NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
     5618                                    IDM_IDEALSIZE),
     5619                    NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
    56145620    }
    56155621
    56165622    hwndTmp = WinCreateWindow(hwndFrame,
    5617                               WC_BUTTON,
    5618                               "#1019",
    5619                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5620                               BS_BITMAP,
    5621                               swp.cx - 46,
    5622                               swp.y + 2,
    5623                               24,
    5624                               22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
     5623                              WC_BUTTON,
     5624                              "#1019",
     5625                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5626                              BS_BITMAP,
     5627                              swp.cx - 46,
     5628                              swp.y + 2,
     5629                              24,
     5630                              22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
    56255631    if (!hwndTmp)
    56265632      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56275633
    56285634    hwndTmp = WinCreateWindow(hwndFrame,
    5629                               WC_BUTTON,
    5630                               "#3062",
    5631                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5632                               BS_BITMAP,
    5633                               swp.cx - 22,
    5634                               swp.y + 2,
    5635                               24,
    5636                               22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
     5635                              WC_BUTTON,
     5636                              "#3062",
     5637                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5638                              BS_BITMAP,
     5639                              swp.cx - 22,
     5640                              swp.y + 2,
     5641                              24,
     5642                              22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
    56375643    if (!hwndTmp)
    56385644      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56395645
    56405646    hwndUserlist = WinCreateWindow(hwndFrame,
    5641                                    WC_COMBOBOX,
    5642                                    (PSZ) NULL,
    5643                                    WS_VISIBLE | CBS_DROPDOWN |
    5644                                    LS_HORZSCROLL,
    5645                                    (swp.x +
    5646                                     WinQuerySysValue(HWND_DESKTOP,
    5647                                                      SV_CXSIZEBORDER) + 48L),
    5648                                    (swp.cy -
    5649                                     WinQuerySysValue(HWND_DESKTOP,
    5650                                                      SV_CYSIZEBORDER)) - 60,
    5651                                    ((swp.cx -
    5652                                      (WinQuerySysValue(HWND_DESKTOP,
    5653                                                        SV_CXSIZEBORDER) *
    5654                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5655                                    MAIN_USERLIST, NULL, NULL);
     5647                                   WC_COMBOBOX,
     5648                                   (PSZ) NULL,
     5649                                   WS_VISIBLE | CBS_DROPDOWN |
     5650                                   LS_HORZSCROLL,
     5651                                   (swp.x +
     5652                                    WinQuerySysValue(HWND_DESKTOP,
     5653                                                     SV_CXSIZEBORDER) + 48L),
     5654                                   (swp.cy -
     5655                                    WinQuerySysValue(HWND_DESKTOP,
     5656                                                     SV_CYSIZEBORDER)) - 60,
     5657                                   ((swp.cx -
     5658                                     (WinQuerySysValue(HWND_DESKTOP,
     5659                                                       SV_CXSIZEBORDER) *
     5660                                      2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5661                                   MAIN_USERLIST, NULL, NULL);
    56565662    if (!hwndUserlist)
    56575663      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56585664    hwndCmdlist = WinCreateWindow(hwndFrame,
    5659                                   WC_COMBOBOX,
    5660                                   (PSZ) NULL,
    5661                                   WS_VISIBLE | CBS_DROPDOWN |
    5662                                   LS_HORZSCROLL,
    5663                                   (swp.x +
    5664                                    WinQuerySysValue(HWND_DESKTOP,
    5665                                                     SV_CXSIZEBORDER) + 48L),
    5666                                   (swp.cy -
    5667                                    WinQuerySysValue(HWND_DESKTOP,
    5668                                                     SV_CYSIZEBORDER)) - 60,
    5669                                   ((swp.cx -
    5670                                     (WinQuerySysValue(HWND_DESKTOP,
    5671                                                       SV_CXSIZEBORDER) * 2)) -
    5672                                    64L), 60L, hwndFrame, HWND_TOP,
    5673                                   MAIN_CMDLIST, NULL, NULL);
     5665                                  WC_COMBOBOX,
     5666                                  (PSZ) NULL,
     5667                                  WS_VISIBLE | CBS_DROPDOWN |
     5668                                  LS_HORZSCROLL,
     5669                                  (swp.x +
     5670                                   WinQuerySysValue(HWND_DESKTOP,
     5671                                                    SV_CXSIZEBORDER) + 48L),
     5672                                  (swp.cy -
     5673                                   WinQuerySysValue(HWND_DESKTOP,
     5674                                                    SV_CYSIZEBORDER)) - 60,
     5675                                  ((swp.cx -
     5676                                    (WinQuerySysValue(HWND_DESKTOP,
     5677                                                      SV_CXSIZEBORDER) * 2)) -
     5678                                   64L), 60L, hwndFrame, HWND_TOP,
     5679                                  MAIN_CMDLIST, NULL, NULL);
    56745680    if (!hwndCmdlist)
    56755681      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56765682    WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    56775683    hwndStatelist = WinCreateWindow(hwndFrame,
    5678                                     WC_COMBOBOX,
    5679                                     (PSZ) NULL,
    5680                                     WS_VISIBLE | CBS_DROPDOWN |
    5681                                     LS_HORZSCROLL,
    5682                                     (swp.x +
    5683                                      WinQuerySysValue(HWND_DESKTOP,
    5684                                                       SV_CXSIZEBORDER) + 48L),
    5685                                     (swp.cy -
    5686                                      WinQuerySysValue(HWND_DESKTOP,
    5687                                                       SV_CYSIZEBORDER)) - 60,
    5688                                     ((swp.cx -
    5689                                       (WinQuerySysValue(HWND_DESKTOP,
    5690                                                         SV_CXSIZEBORDER) *
    5691                                        2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5692                                     MAIN_SETUPLIST, NULL, NULL);
     5684                                    WC_COMBOBOX,
     5685                                    (PSZ) NULL,
     5686                                    WS_VISIBLE | CBS_DROPDOWN |
     5687                                    LS_HORZSCROLL,
     5688                                    (swp.x +
     5689                                     WinQuerySysValue(HWND_DESKTOP,
     5690                                                      SV_CXSIZEBORDER) + 48L),
     5691                                    (swp.cy -
     5692                                     WinQuerySysValue(HWND_DESKTOP,
     5693                                                      SV_CYSIZEBORDER)) - 60,
     5694                                    ((swp.cx -
     5695                                      (WinQuerySysValue(HWND_DESKTOP,
     5696                                                        SV_CXSIZEBORDER) *
     5697                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5698                                    MAIN_SETUPLIST, NULL, NULL);
    56935699    if (!hwndStatelist)
    56945700      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56955701
    56965702    hwndDrivelist = WinCreateWindow(hwndFrame,
    5697                                     WC_COMBOBOX,
    5698                                     (PSZ) NULL,
    5699                                     WS_VISIBLE | CBS_DROPDOWN,
    5700                                     (swp.x +
    5701                                      WinQuerySysValue(HWND_DESKTOP,
    5702                                                       SV_CXSIZEBORDER)),
    5703                                     (swp.cy -
    5704                                      WinQuerySysValue(HWND_DESKTOP,
    5705                                                       SV_CYSIZEBORDER)) - 60,
    5706                                     48L,
    5707                                     60L,
    5708                                     hwndFrame,
    5709                                     HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
     5703                                    WC_COMBOBOX,
     5704                                    (PSZ) NULL,
     5705                                    WS_VISIBLE | CBS_DROPDOWN,
     5706                                    (swp.x +
     5707                                     WinQuerySysValue(HWND_DESKTOP,
     5708                                                      SV_CXSIZEBORDER)),
     5709                                    (swp.cy -
     5710                                     WinQuerySysValue(HWND_DESKTOP,
     5711                                                      SV_CYSIZEBORDER)) - 60,
     5712                                    48L,
     5713                                    60L,
     5714                                    hwndFrame,
     5715                                    HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
    57105716    if (!hwndDrivelist)
    57115717      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    57125718    SetPresParams(hwndDrivelist,
    5713                   NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
     5719                  NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
    57145720    hwndButtonlist = WinCreateWindow(hwndFrame,
    5715                                      WC_COMBOBOX,
    5716                                      (PSZ) NULL,
    5717                                      WS_VISIBLE | CBS_DROPDOWN |
    5718                                      LS_HORZSCROLL,
    5719                                      (swp.cx -
    5720                                       WinQuerySysValue(HWND_DESKTOP,
    5721                                                        SV_CXSIZEBORDER)) -
    5722                                      164L,
    5723                                      (swp.cy -
    5724                                       WinQuerySysValue(HWND_DESKTOP,
    5725                                                        SV_CYSIZEBORDER)) - 60,
    5726                                      164L, 60L, hwndFrame, HWND_TOP,
    5727                                      MAIN_BUTTONLIST, NULL, NULL);
     5721                                     WC_COMBOBOX,
     5722                                     (PSZ) NULL,
     5723                                     WS_VISIBLE | CBS_DROPDOWN |
     5724                                     LS_HORZSCROLL,
     5725                                     (swp.cx -
     5726                                      WinQuerySysValue(HWND_DESKTOP,
     5727                                                       SV_CXSIZEBORDER)) -
     5728                                     164L,
     5729                                     (swp.cy -
     5730                                      WinQuerySysValue(HWND_DESKTOP,
     5731                                                       SV_CYSIZEBORDER)) - 60,
     5732                                     164L, 60L, hwndFrame, HWND_TOP,
     5733                                     MAIN_BUTTONLIST, NULL, NULL);
    57285734    if (!hwndButtonlist)
    57295735      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    57305736    WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5731                EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     5737               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    57325738    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5733                EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
     5739               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    57345740    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5735                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5741               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    57365742    WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5737                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5743               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    57385744    WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5739                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5745               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    57405746
    57415747    oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5742                                 DropDownListProc);
     5748                                DropDownListProc);
    57435749    WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5744                     QWL_USER, (PVOID) oldproc);
     5750                    QWL_USER, (PVOID) oldproc);
    57455751    oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5746                                 DropDownListProc);
     5752                                DropDownListProc);
    57475753    WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5748                     QWL_USER, (PVOID) oldproc);
     5754                    QWL_USER, (PVOID) oldproc);
    57495755    oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5750                                 DropDownListProc);
     5756                                DropDownListProc);
    57515757    WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5752                     QWL_USER, (PVOID) oldproc);
     5758                    QWL_USER, (PVOID) oldproc);
    57535759    oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5754                                 DropDownListProc);
     5760                                DropDownListProc);
    57555761    WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5756                     QWL_USER, (PVOID) oldproc);
     5762                    QWL_USER, (PVOID) oldproc);
    57575763    oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5758                                 DropDownListProc);
     5764                                DropDownListProc);
    57595765    WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5760                     QWL_USER, (PVOID) oldproc);
     5766                    QWL_USER, (PVOID) oldproc);
    57615767    oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
    57625768    WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
     
    57705776    WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
    57715777    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5772                                 ChildFrameButtonProc);
     5778                                ChildFrameButtonProc);
    57735779    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5774                     QWL_USER, (PVOID) oldproc);
     5780                    QWL_USER, (PVOID) oldproc);
    57755781    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5776                                 ChildFrameButtonProc);
     5782                                ChildFrameButtonProc);
    57775783    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5778                     QWL_USER, (PVOID) oldproc);
     5784                    QWL_USER, (PVOID) oldproc);
    57795785    hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
    57805786    WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
     
    57905796    hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
    57915797    idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
    5792                                         MM_ITEMIDFROMPOSITION,
    5793                                         MPVOID, MPVOID));
     5798                                        MM_ITEMIDFROMPOSITION,
     5799                                        MPVOID, MPVOID));
    57945800    WinSendMsg(hwndSysMenu,
    5795                MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
     5801               MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
    57965802    hwndSysSubMenu = mit.hwndSubMenu;
    57975803    mi.iPosition = MIT_END;
     
    58025808    mi.id = IDM_IDEALSIZE;
    58035809    WinSendMsg(hwndSysSubMenu,
    5804                MM_INSERTITEM,
    5805                MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
     5810               MM_INSERTITEM,
     5811               MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
    58065812    mi.afStyle = MIS_TEXT;
    58075813    mi.id = IDM_HIDEMENU;
    58085814    WinSendMsg(hwndSysSubMenu,
    5809                MM_INSERTITEM,
    5810                MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
     5815               MM_INSERTITEM,
     5816               MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
    58115817    SetSysMenu(hwndSysMenu);
    58125818
    58135819    size = sizeof(BOOL);
    58145820    if (PrfQueryProfileData(fmprof,
    5815                             FM3Str,
    5816                             "MenuInvisible", &temp, &size) && size && temp)
     5821                            FM3Str,
     5822                            "MenuInvisible", &temp, &size) && size && temp)
    58175823      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
    58185824    size = sizeof(BOOL);
    58195825    if (PrfQueryProfileData(fmprof,
    5820                             FM3Str, "FreeTree", &temp, &size) && size && temp)
     5826                            FM3Str, "FreeTree", &temp, &size) && size && temp)
    58215827      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
    58225828    size = sizeof(BOOL);
    58235829    if (PrfQueryProfileData(fmprof,
    5824                             FM3Str,
    5825                             "AutoTile", &temp, &size) && size && !temp)
     5830                            FM3Str,
     5831                            "AutoTile", &temp, &size) && size && !temp)
    58265832      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
    58275833    size = sizeof(BOOL);
    58285834    if (PrfQueryProfileData(fmprof,
    5829                             FM3Str, "Toolbar", &temp, &size) && size && !temp)
     5835                            FM3Str, "Toolbar", &temp, &size) && size && !temp)
    58305836      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
    58315837
     
    58505856      hwndTree = StartTreeCnr(hwnd, 4);
    58515857      if (!hwndTree)
    5852         WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     5858        WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    58535859      else {
    5854         if (!fSaveState ||
    5855             !PrfQueryProfileData(fmprof,
    5856                                 FM3Str,
    5857                                 "LastTreePos",
    5858                                 &swp, &size) || size != sizeof(SWP)) {
    5859 
    5860           INT ratio, height = 0;
    5861 
    5862           if (!fNoTreeGap)
    5863             height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    5864           size = sizeof(ratio);
    5865           if (!PrfQueryProfileData(fmprof,
    5866                                    FM3Str,
    5867                                    "TreeWindowRatio",
    5868                                    (PVOID) & ratio,
    5869                                    &size) || size < sizeof(ratio))
    5870             ratio = 400;
    5871           WinSetWindowPos(hwndTree,
    5872                           HWND_TOP,
    5873                           0,
    5874                           height,
    5875                           (swp.cx * 100) / ratio,
    5876                           swp.cy - height,
    5877                           SWP_SHOW | SWP_SIZE | SWP_MOVE |
    5878                           SWP_ACTIVATE | SWP_ZORDER);
    5879         }
    5880         else
    5881           WinSetWindowPos(hwndTree,
    5882                           HWND_TOP,
    5883                           swp.x,
    5884                           swp.y,
    5885                           swp.cx,
    5886                           swp.cy,
    5887                           swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
    5888                           SWP_ZORDER | SWP_ACTIVATE);
     5860        if (!fSaveState ||
     5861            !PrfQueryProfileData(fmprof,
     5862                                FM3Str,
     5863                                "LastTreePos",
     5864                                &swp, &size) || size != sizeof(SWP)) {
     5865
     5866          INT ratio, height = 0;
     5867
     5868          if (!fNoTreeGap)
     5869            height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     5870          size = sizeof(ratio);
     5871          if (!PrfQueryProfileData(fmprof,
     5872                                   FM3Str,
     5873                                   "TreeWindowRatio",
     5874                                   (PVOID) & ratio,
     5875                                   &size) || size < sizeof(ratio))
     5876            ratio = 400;
     5877          WinSetWindowPos(hwndTree,
     5878                          HWND_TOP,
     5879                          0,
     5880                          height,
     5881                          (swp.cx * 100) / ratio,
     5882                          swp.cy - height,
     5883                          SWP_SHOW | SWP_SIZE | SWP_MOVE |
     5884                          SWP_ACTIVATE | SWP_ZORDER);
     5885        }
     5886        else
     5887          WinSetWindowPos(hwndTree,
     5888                          HWND_TOP,
     5889                          swp.x,
     5890                          swp.y,
     5891                          swp.cx,
     5892                          swp.cy,
     5893                          swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
     5894                          SWP_ZORDER | SWP_ACTIVATE);
    58895895      }
    58905896//       ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     
    59005906      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID);
    59015907      if (!add_setup(pszStatename))
    5902         save_setups();
     5908        save_setups();
    59035909    } else {
    59045910      load_tools(NULL);
     
    59145920
    59155921      for (x = 1; x < argc; x++) {
    5916         if (*argv[x] == '/' || *argv[x] == ';')
    5917           continue;
    5918         if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE)) {
    5919           OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
    5920         }
     5922        if (*argv[x] == '/' || *argv[x] == ';')
     5923          continue;
     5924        if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE)) {
     5925          OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
     5926        }
    59215927      }
    59225928    }
     
    59365942      hwndActive = TopWindow(hwnd, hwndTree);
    59375943      if (hwndActive)
    5938         WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
     5944        WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
    59395945    }
    59405946    if (fStartMinimized || fReminimize)
     
    59695975  case WM_CONTROLPOINTER:
    59705976    if (!fNoFinger &&
    5971         (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
    5972         SHORT1FROMMP(mp1) == IDM_USERLIST))
     5977        (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
     5978        SHORT1FROMMP(mp1) == IDM_USERLIST))
    59735979      return MRFROMLONG(hptrFinger);
    59745980    break;
     
    60106016    if (mp1) {
    60116017      if (fUserComboBox)
    6012         WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
    6013                         (CHAR *)mp1);
     6018        WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
     6019                        (CHAR *)mp1);
    60146020      if (add_udir(FALSE, (CHAR *)mp1)) {
    6015         if (fUserComboBox && fAutoAddDirs) {
    6016           WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6017                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6018                      MPFROMP((CHAR *)mp1));
    6019         }
     6021        if (fUserComboBox && fAutoAddDirs) {
     6022          WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6023                     MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6024                     MPFROMP((CHAR *)mp1));
     6025        }
    60206026      }
    60216027    }
     
    60496055      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    60506056      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    6051         WinStoreWindowPos(FM2Str,
    6052                           "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
    6053         if (!fNoSaveState && fSaveState)
    6054           SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
     6057        WinStoreWindowPos(FM2Str,
     6058                          "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
     6059        if (!fNoSaveState && fSaveState)
     6060          SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
    60556061      }
    60566062    }
     
    60626068    case 1:
    60636069      {
    6064         HWND hwndCurrent;
    6065         ULONG wmsg;
    6066 
    6067         wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
    6068         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    6069         PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
    6070                                                        FID_CLIENT), wmsg,
    6071                                        MPVOID, MPVOID), mp1, mp2);
     6070        HWND hwndCurrent;
     6071        ULONG wmsg;
     6072
     6073        wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
     6074        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     6075        PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
     6076                                                       FID_CLIENT), wmsg,
     6077                                       MPVOID, MPVOID), mp1, mp2);
    60726078      }
    60736079      break;
     
    60876093       */
    60886094      {
    6089         HWND hwndMenu, hwndSubMenu;
    6090         MENUITEM mi;
    6091 
    6092         hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
    6093         memset(&mi, 0, sizeof(mi));
    6094         mi.iPosition = MIT_END;
    6095         mi.afStyle = MIS_TEXT;
    6096         if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
    6097                         MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
    6098           break;
    6099         hwndSubMenu = mi.hwndSubMenu;
    6100         SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
     6095        HWND hwndMenu, hwndSubMenu;
     6096        MENUITEM mi;
     6097
     6098        hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
     6099        memset(&mi, 0, sizeof(mi));
     6100        mi.iPosition = MIT_END;
     6101        mi.afStyle = MIS_TEXT;
     6102        if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
     6103                        MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
     6104          break;
     6105        hwndSubMenu = mi.hwndSubMenu;
     6106        SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
    61016107      }
    61026108      break;
     
    61046110    default:
    61056111      {
    6106         HWND hwndCurrent;
    6107 
    6108         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    6109         if (hwndCurrent)
    6110           WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
     6112        HWND hwndCurrent;
     6113
     6114        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     6115        if (hwndCurrent)
     6116          WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
    61116117      }
    61126118      break;
     
    61166122  case UM_ADDTOMENU:
    61176123    AddToMenu((CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6118                                             FID_MENU));
     6124                                            FID_MENU));
    61196125    return 0;
    61206126
     
    61296135      info = cmdhead;
    61306136      while (info) {
    6131         WinSendMsg(hwndCmdlist, LM_INSERTITEM,
    6132                    MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
    6133         info = info->next;
     6137        WinSendMsg(hwndCmdlist, LM_INSERTITEM,
     6138                   MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
     6139        info = info->next;
    61346140      }
    61356141    }
     
    61556161      ulSearchCount = 1;
    61566162      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    6157                         &findbuf, sizeof(FILEFINDBUF3),
    6158                         &ulSearchCount, FIL_STANDARD)) {
    6159         do {
    6160           priority_bumped();
    6161           if (!foundit) {
    6162             thisone = FALSE;
    6163             p = strrchr(lasttoolbar, '\\');
    6164             if (!p)
    6165               p = lasttoolbar;
    6166             else
    6167               p++;
    6168             if (!stricmp(findbuf.achName, p))
    6169               thisone = TRUE;
    6170           }
    6171           p = strrchr(findbuf.achName, '.');
    6172           if (p)
    6173             *p = 0;
    6174           sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
    6175                                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6176                                        MPFROMP(findbuf.achName));
    6177           if (!foundit && thisone && sSelect >= 0) {
    6178             WinSendMsg(hwndButtonlist, LM_SELECTITEM,
    6179                        MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
    6180             foundit = TRUE;
    6181           }
    6182         }
    6183         while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
    6184                             &ulSearchCount));
    6185         DosFindClose(hDir);
    6186         priority_bumped();
     6163                        &findbuf, sizeof(FILEFINDBUF3),
     6164                        &ulSearchCount, FIL_STANDARD)) {
     6165        do {
     6166          priority_bumped();
     6167          if (!foundit) {
     6168            thisone = FALSE;
     6169            p = strrchr(lasttoolbar, '\\');
     6170            if (!p)
     6171              p = lasttoolbar;
     6172            else
     6173              p++;
     6174            if (!stricmp(findbuf.achName, p))
     6175              thisone = TRUE;
     6176          }
     6177          p = strrchr(findbuf.achName, '.');
     6178          if (p)
     6179            *p = 0;
     6180          sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
     6181                                       MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6182                                       MPFROMP(findbuf.achName));
     6183          if (!foundit && thisone && sSelect >= 0) {
     6184            WinSendMsg(hwndButtonlist, LM_SELECTITEM,
     6185                       MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
     6186            foundit = TRUE;
     6187          }
     6188        }
     6189        while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
     6190                            &ulSearchCount));
     6191        DosFindClose(hDir);
     6192        priority_bumped();
    61876193      }
    61886194      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
     
    62036209
    62046210      if (!loadedudirs)
    6205         load_udirs();
     6211        load_udirs();
    62066212      DosError(FERR_DISABLEHARDERR);
    62076213      DosQCurDisk(&ulDriveNum, &ulDriveMap);
    62086214      info = udirhead;
    62096215      while (info) {
    6210         if (IsFullName(info->path) &&
    6211             !(driveflags[toupper(*info->path) - 'A'] &
    6212               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6213           DosError(FERR_DISABLEHARDERR);
    6214           hDir = HDIR_CREATE;
    6215           ulSearchCount = 1;
    6216           if (!IsRoot(info->path))
    6217             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6218                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6219                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6220                               &findbuf, sizeof(FILEFINDBUF3),
    6221                               &ulSearchCount, FIL_STANDARD);
    6222           else {
    6223             rc = 0;
    6224             findbuf.attrFile = FILE_DIRECTORY;
    6225           }
    6226           priority_bumped();
    6227           if (!rc) {
    6228             if (!IsRoot(info->path))
    6229               DosFindClose(hDir);
    6230             if (findbuf.attrFile & FILE_DIRECTORY)
    6231               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6232                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6233                         MPFROMP(info->path));
    6234             else {
    6235               temp = info->next;
    6236               remove_udir(info->path);
    6237               info = temp;
    6238               continue;
    6239             }
    6240           }
    6241           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6242             temp = info->next;
    6243             remove_udir(info->path);
    6244             info = temp;
    6245             continue;
    6246           }
    6247         }
    6248         info = info->next;
     6216        if (IsFullName(info->path) &&
     6217            !(driveflags[toupper(*info->path) - 'A'] &
     6218              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6219          DosError(FERR_DISABLEHARDERR);
     6220          hDir = HDIR_CREATE;
     6221          ulSearchCount = 1;
     6222          if (!IsRoot(info->path))
     6223            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6224                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6225                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6226                              &findbuf, sizeof(FILEFINDBUF3),
     6227                              &ulSearchCount, FIL_STANDARD);
     6228          else {
     6229            rc = 0;
     6230            findbuf.attrFile = FILE_DIRECTORY;
     6231          }
     6232          priority_bumped();
     6233          if (!rc) {
     6234            if (!IsRoot(info->path))
     6235              DosFindClose(hDir);
     6236            if (findbuf.attrFile & FILE_DIRECTORY)
     6237              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6238                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6239                        MPFROMP(info->path));
     6240            else {
     6241              temp = info->next;
     6242              remove_udir(info->path);
     6243              info = temp;
     6244              continue;
     6245            }
     6246          }
     6247          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6248            temp = info->next;
     6249            remove_udir(info->path);
     6250            info = temp;
     6251            continue;
     6252          }
     6253        }
     6254        info = info->next;
    62496255      }
    62506256      info = ldirhead;
    62516257      while (info) {
    6252         if (IsFullName(info->path) &&
    6253             !(driveflags[toupper(*info->path) - 'A'] &
    6254               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6255           DosError(FERR_DISABLEHARDERR);
    6256           hDir = HDIR_CREATE;
    6257           ulSearchCount = 1;
    6258           if (!IsRoot(info->path))
    6259             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6260                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6261                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6262                               &findbuf, sizeof(FILEFINDBUF3),
    6263                               &ulSearchCount, FIL_STANDARD);
    6264           else {
    6265             rc = 0;
    6266             findbuf.attrFile = FILE_DIRECTORY;
    6267           }
    6268           priority_bumped();
    6269           if (!rc) {
    6270             if (!IsRoot(info->path))
    6271               DosFindClose(hDir);
    6272             if (findbuf.attrFile & FILE_DIRECTORY)
    6273               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6274                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6275                         MPFROMP(info->path));
    6276             else {
    6277               temp = info->next;
    6278               remove_udir(info->path);
    6279               info = temp;
    6280               continue;
    6281             }
    6282           }
    6283           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6284             temp = info->next;
    6285             remove_udir(info->path);
    6286             info = temp;
    6287             continue;
    6288           }
    6289         }
    6290         info = info->next;
     6258        if (IsFullName(info->path) &&
     6259            !(driveflags[toupper(*info->path) - 'A'] &
     6260              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6261          DosError(FERR_DISABLEHARDERR);
     6262          hDir = HDIR_CREATE;
     6263          ulSearchCount = 1;
     6264          if (!IsRoot(info->path))
     6265            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6266                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6267                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6268                              &findbuf, sizeof(FILEFINDBUF3),
     6269                              &ulSearchCount, FIL_STANDARD);
     6270          else {
     6271            rc = 0;
     6272            findbuf.attrFile = FILE_DIRECTORY;
     6273          }
     6274          priority_bumped();
     6275          if (!rc) {
     6276            if (!IsRoot(info->path))
     6277              DosFindClose(hDir);
     6278            if (findbuf.attrFile & FILE_DIRECTORY)
     6279              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6280                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6281                        MPFROMP(info->path));
     6282            else {
     6283              temp = info->next;
     6284              remove_udir(info->path);
     6285              info = temp;
     6286              continue;
     6287            }
     6288          }
     6289          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6290            temp = info->next;
     6291            remove_udir(info->path);
     6292            info = temp;
     6293            continue;
     6294          }
     6295        }
     6296        info = info->next;
    62916297      }
    62926298      WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6293                 MPFROM2SHORT(0, 0),
    6294                 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
     6299                MPFROM2SHORT(0, 0),
     6300                MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
    62956301      WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
    62966302    }
     
    63066312  case WM_SIZE:
    63076313    ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
    6308                    SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
     6314                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
    63096315    break;
    63106316
     
    63206326      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    63216327      if (hps) {
    6322         WinQueryWindowRect(hwnd, &rcl);
    6323         WinFillRect(hps, &rcl, CLR_PALEGRAY);
    6324         WinEndPaint(hps);
     6328        WinQueryWindowRect(hwnd, &rcl);
     6329        WinFillRect(hps, &rcl, CLR_PALEGRAY);
     6330        WinEndPaint(hps);
    63256331      }
    63266332    }
     
    63366342      switch (SHORT2FROMMP(mp1)) {
    63376343      case CBN_ENTER:
    6338         {
    6339           HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6340                                         SHORT1FROMMP(mp1));
    6341           CHAR path[CCHMAXPATH];
    6342           ULONG ul;
    6343 
    6344           switch (SHORT1FROMMP(mp1)) {
    6345           case MAIN_USERLIST:
    6346             ul = CCHMAXPATH;
    6347             break;
    6348           case MAIN_SETUPLIST:
    6349             ul = STATE_NAME_MAX_BYTES;
    6350             break;
    6351           default:
    6352             ul = 13;                    // fixme to not be hardcoded
    6353           }
    6354 
    6355           SetShiftState();
    6356           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    6357           bstrip(path);
    6358           if (*path) {
    6359             if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
    6360               if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
    6361                 if (!LastDir ||
    6362                     !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
    6363                                 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
    6364                   strcpy(path, pFM2SaveDirectory);
    6365                 if (!PMMkDir(hwnd, path, TRUE)) {
    6366                   WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
    6367                   break;
    6368                 }
    6369               }
    6370               if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
    6371 
    6372                 HWND hwndDir;
    6373 
    6374                 if ((fUserListSwitches &&
    6375                      !(shiftstate & KC_SHIFT)) ||
    6376                     (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
    6377                   hwndDir = FindDirCnr(hwnd);
    6378                   if (hwndDir) {
    6379                     WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
    6380                     break;
    6381                   }
    6382                 }
    6383                 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
    6384               }
    6385             }
    6386             else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
    6387               ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    6388                                                           FID_CLIENT),
    6389                                           TREE_CNR), path, FALSE, TRUE);
    6390               WinSetFocus(HWND_DESKTOP, hwndTree);
    6391             }
    6392             else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
    6393               strcat(path, ".TLS");
    6394               load_tools(path);
    6395               PrfWriteProfileString(fmprof,
    6396                                     FM3Str, "LastToolbar", lasttoolbar);
    6397               PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    6398               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
    6399             }
    6400             else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    6401               CHAR szKey[80];
    6402               ULONG size, numsaves = 0;
    6403 
    6404               SetShiftState();
    6405               size = sizeof(ULONG);
    6406               sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
    6407               if (!PrfQueryProfileData(fmprof,
    6408                                        FM3Str,
    6409                                        szKey,
    6410                                        (PVOID)&numsaves,
    6411                                        &size))
    6412               {
    6413                 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
    6414                   saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    6415                         GetPString(IDS_WARNINGTEXT),
    6416                         GetPString(IDS_DOESNTEXISTTEXT), path);
    6417                 }
    6418                 else {
    6419                   Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
    6420                              IDS_PRFQUERYPROFILEDATA);
    6421                 }
    6422               }
    6423               else {
    6424                 char *pszStateName;
    6425                 if ((shiftstate & KC_SHIFT) == 0)
    6426                   PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
    6427                 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
    6428                 if (!pszStateName) {
    6429                   // Fall back if out of memory - already complained
    6430                   if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
    6431                     // Autotile requested or forced
    6432                     PostMsg(MainObjectHwnd,
    6433                             UM_RESTORE,
    6434                             MPVOID,
    6435                             MPFROMLONG(1));                // Autotile
    6436                   }
    6437                 }
    6438                 else if (!PostMsg(MainObjectHwnd,
    6439                                   UM_RESTORE,
    6440                                   MPFROMP(pszStateName),
    6441                                   MPVOID)) {
    6442                   free(pszStateName);
    6443                 }
    6444               }
    6445             }
    6446             else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
    6447 
    6448               SHORT sSelect;
    6449 
    6450               sSelect = (SHORT) WinSendMsg(hwndCmdlist,
    6451                                            LM_QUERYSELECTION,
    6452                                            MPFROMSHORT(LIT_FIRST), MPVOID);
    6453               if (sSelect >= 0)
    6454                 WinPostMsg(hwnd,
    6455                            WM_COMMAND,
    6456                            MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
    6457                            MPVOID);
    6458               WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    6459             }
    6460           }
    6461         }
    6462         break;
     6344        {
     6345          HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     6346                                        SHORT1FROMMP(mp1));
     6347          CHAR path[CCHMAXPATH];
     6348          ULONG ul;
     6349
     6350          switch (SHORT1FROMMP(mp1)) {
     6351          case MAIN_USERLIST:
     6352            ul = CCHMAXPATH;
     6353            break;
     6354          case MAIN_SETUPLIST:
     6355            ul = STATE_NAME_MAX_BYTES;
     6356            break;
     6357          default:
     6358            ul = 13;                    // fixme to not be hardcoded
     6359          }
     6360
     6361          SetShiftState();
     6362          WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
     6363          bstrip(path);
     6364          if (*path) {
     6365            if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
     6366              if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
     6367                if (!LastDir ||
     6368                    !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
     6369                                UM_CONTAINERDIR, MPFROMP(path), MPVOID))
     6370                  strcpy(path, pFM2SaveDirectory);
     6371                if (!PMMkDir(hwnd, path, TRUE)) {
     6372                  WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
     6373                  break;
     6374                }
     6375              }
     6376              if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
     6377
     6378                HWND hwndDir;
     6379
     6380                if ((fUserListSwitches &&
     6381                     !(shiftstate & KC_SHIFT)) ||
     6382                    (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
     6383                  hwndDir = FindDirCnr(hwnd);
     6384                  if (hwndDir) {
     6385                    WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
     6386                    break;
     6387                  }
     6388                }
     6389                OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
     6390              }
     6391            }
     6392            else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
     6393              ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
     6394                                                          FID_CLIENT),
     6395                                          TREE_CNR), path, FALSE, TRUE);
     6396              WinSetFocus(HWND_DESKTOP, hwndTree);
     6397            }
     6398            else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
     6399              strcat(path, ".TLS");
     6400              load_tools(path);
     6401              PrfWriteProfileString(fmprof,
     6402                                    FM3Str, "LastToolbar", lasttoolbar);
     6403              PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     6404              WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
     6405            }
     6406            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
     6407              CHAR szKey[80];
     6408              ULONG size, numsaves = 0;
     6409
     6410              SetShiftState();
     6411              size = sizeof(ULONG);
     6412              sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
     6413              if (!PrfQueryProfileData(fmprof,
     6414                                       FM3Str,
     6415                                       szKey,
     6416                                       (PVOID)&numsaves,
     6417                                       &size))
     6418              {
     6419                if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
     6420                  saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     6421                        GetPString(IDS_WARNINGTEXT),
     6422                        GetPString(IDS_DOESNTEXISTTEXT), path);
     6423                }
     6424                else {
     6425                  Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
     6426                             IDS_PRFQUERYPROFILEDATA);
     6427                }
     6428              }
     6429              else {
     6430                char *pszStateName;
     6431                if ((shiftstate & KC_SHIFT) == 0)
     6432                  PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
     6433                pszStateName = xstrdup(path, pszSrcFile, __LINE__);
     6434                if (!pszStateName) {
     6435                  // Fall back if out of memory - already complained
     6436                  if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
     6437                    // Autotile requested or forced
     6438                    PostMsg(MainObjectHwnd,
     6439                            UM_RESTORE,
     6440                            MPVOID,
     6441                            MPFROMLONG(1));                // Autotile
     6442                  }
     6443                }
     6444                else if (!PostMsg(MainObjectHwnd,
     6445                                  UM_RESTORE,
     6446                                  MPFROMP(pszStateName),
     6447                                  MPVOID)) {
     6448                  free(pszStateName);
     6449                }
     6450              }
     6451            }
     6452            else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
     6453
     6454              SHORT sSelect;
     6455
     6456              sSelect = (SHORT) WinSendMsg(hwndCmdlist,
     6457                                           LM_QUERYSELECTION,
     6458                                           MPFROMSHORT(LIT_FIRST), MPVOID);
     6459              if (sSelect >= 0)
     6460                WinPostMsg(hwnd,
     6461                           WM_COMMAND,
     6462                           MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
     6463                           MPVOID);
     6464              WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
     6465            }
     6466          }
     6467        }
     6468        break;
    64636469
    64646470      default:
    6465         break;
     6471        break;
    64666472      }
    64676473      break;
     
    64836489  case WM_CLOSE:
    64846490    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6485                WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     6491               WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    64866492    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    64876493    fAmClosing = TRUE;
    64886494    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6489                WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
     6495               WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
    64906496    if (CloseChildren(hwnd)) {
    64916497      fAmClosing = FALSE;
    64926498      if (fAutoTile)
    6493         PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
     6499        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
    64946500      return 0;
    64956501    }
    64966502    if (hwndTree) {
    64976503      if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
    6498         WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
     6504        WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    64996505    }
    65006506    DosSleep(1);
     
    65106516      // Try to restore saved shutdown state
    65116517      char *pszDefaultStateName = xstrdup(GetPString(IDS_SHUTDOWNSTATE),
    6512                                           pszSrcFile, __LINE__);
     6518                                          pszSrcFile, __LINE__);
    65136519      if (pszDefaultStateName) {
    6514         if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
    6515           // 05 Feb 08 SHL fixme to complain?
    6516           free(pszDefaultStateName);
     6520        if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
     6521          // 05 Feb 08 SHL fixme to complain?
     6522          free(pszDefaultStateName);
    65176523      }
    65186524    }
     
    65236529    if (mp1)
    65246530      return MRFROMLONG(OpenDirCnr((HWND) 0,
    6525                                    hwndMain,
    6526                                    hwndTree, (BOOL) mp2, (char *)mp1));
     6531                                   hwndMain,
     6532                                   hwndTree, (BOOL) mp2, (char *)mp1));
    65276533    return 0;
    65286534
Note: See TracChangeset for help on using the changeset viewer.