Changeset 1209 for trunk/dll/mainwnd.c


Ignore:
Timestamp:
Sep 13, 2008, 8:51:06 AM (17 years ago)
Author:
John Small
Message:

Ticket 187: Move data declarations/definitions out of fm3dll.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd.c

    r1181 r1209  
    5959  07 Jul 08 JBS Ticket 242: Delete obsolete INI keys when re-saving a state
    6060  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.
     61                all the details view settings (both the global variables and those in the
     62                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    6363  12 Jul 08 JBS Ticket 246: Allow saved directory container states to have no directory containers
    64                 (i.e. just a directory tree container).
     64                (i.e. just a directory tree container).
    6565                18 Jul 08 SHL Use new Fortify feature to avoid spurious reports
    6666  19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
     
    7575#include <string.h>
    7676#include <ctype.h>
    77 #include <process.h>                    // _beginthread
     77#include <process.h>                    // _beginthread
    7878
    7979#define INCL_DOS
    8080#define INCL_WIN
    81 #define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
     81#define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
    8282#define INCL_WINHELP
    8383#define INCL_GPI
     
    8585
    8686#include "fm3dll.h"
     87#include "grep.h"                       // Data declaration(s)
     88#include "autoview.h"                   // Data declaration(s)
     89#include "dircnrs.h"                    // Data declaration(s)
     90#include "info.h"                       // Data declaration(s)
     91#include "defview.h"                    // Data declaration(s)
     92#include "init.h"                       // Data declaration(s)
    8793#include "fm3dlg.h"
    8894#include "fm3str.h"
     
    9096#include "comp.h"
    9197#include "datamin.h"
    92 #include "pathutil.h"                   // BldQuotedFileName
    93 #include "errutil.h"                    // Dos_Error...
    94 #include "strutil.h"                    // GetPString
    95 #include "notebook.h"                   // CfgDlgProc CfgMenuInit
    96 #include "command.h"                    // LINKCMDS
    97 #include "avl.h"                        // free_archivers
    98 #include "walkem.h"                     // free_setups...
    99 #include "key.h"                        // AboutDlgProc
    100 #include "menu.h"                       // AddToMenu
     98#include "pathutil.h"                   // BldQuotedFileName
     99#include "errutil.h"                    // Dos_Error...
     100#include "strutil.h"                    // GetPString
     101#include "notebook.h"                   // CfgDlgProc CfgMenuInit
     102#include "command.h"                    // LINKCMDS
     103#include "avl.h"                        // free_archivers
     104#include "walkem.h"                     // free_setups...
     105#include "key.h"                        // AboutDlgProc
     106#include "menu.h"                       // AddToMenu
    101107#include "mainwnd.h"
    102 #include "cmdline.h"                    // CmdLine2DlgProc, save_cmdlines
    103 #include "common.h"                     // CommonCreateMainChildren, CommonDriveCmd, CommonMainWndProc
    104                                         // CommonTextButton
    105 #include "notify.h"                     // DoNotify, HideNote, ShowNote
    106 #include "draglist.h"                   // DragOne
    107 #include "chklist.h"                    // DropListProc
    108 #include "avv.h"                        // EditArchiverDefinition
    109 #include "assoc.h"                      // EditAssociations
    110 #include "fm2cmd.h"                     // FM2Command
    111 #include "misc.h"                       // FindDirCnr, FixSwitchList, PaintSTextWindow,
    112                                         // SetConditionalCascade, SetMenuCheck, SetSysMenu
    113                                         // SwitchCommand, CheckMenu, DrawTargetEmphasis
    114                                         // IsFm2Window
    115 #include "instant.h"                    // InstantDlgProc
    116 #include "killproc.h"                   // KillDlgProc
    117 #include "loadbmp.h"                    // LoadBitmapFromFileNum
    118 #include "presparm.h"                   // SavePresParams
    119 #include "treecnr.h"                    // ShowTreeRec, StartTreeCnr
    120 #include "inis.h"                       // StartIniEditor
    121 #include "sysinfo.h"                    // SysInfoDlgProc
    122 #include "viewinf.h"                    // ViewInfProc
    123 #include "walkem.h"                     // WalkDlgProc, WalkTwoCmpDlgProc, add_setup, add_udir
    124                                         // fill_setups_list, free_ldir, free_udirs, load_udirs
    125                                         // remove_setup, remove_udir, save_setups, save_udirs
    126 #include "winlist.h"                    // WindowList
    127 #include "cmdline.h"                    // add_cmdline
    128 #include "assoc.h"                      // free_associations
    129 #include "droplist.h"                   // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
    130 #include "common.h"                     // CommonTextProc
    131 #include "presparm.h"                   // CopyPresParams
    132 #include "systemf.h"                    // ExecOnList
    133 #include "shadow.h"                     // OpenObject
    134 #include "mkdir.h"                      // PMMkDir
    135 #include "collect.h"                    // StartCollector
    136 #include "select.h"                     // UnHilite
    137 #include "strips.h"                     // bstrip
    138 #include "commafmt.h"                   // CommaFmtULL
    139 #include "valid.h"                      // IsFullName
    140 #include "dirs.h"                       // save_dir2
    141 #include "wrappers.h"                   // xfree
     108#include "cmdline.h"                    // CmdLine2DlgProc, save_cmdlines
     109#include "common.h"                     // CommonCreateMainChildren, CommonDriveCmd, CommonMainWndProc
     110                                        // CommonTextButton
     111#include "notify.h"                     // DoNotify, HideNote, ShowNote
     112#include "draglist.h"                   // DragOne
     113#include "chklist.h"                    // DropListProc
     114#include "avv.h"                        // EditArchiverDefinition
     115#include "assoc.h"                      // EditAssociations
     116#include "fm2cmd.h"                     // FM2Command
     117#include "misc.h"                       // FindDirCnr, FixSwitchList, PaintSTextWindow,
     118                                        // SetConditionalCascade, SetMenuCheck, SetSysMenu
     119                                        // SwitchCommand, CheckMenu, DrawTargetEmphasis
     120                                        // IsFm2Window
     121#include "instant.h"                    // InstantDlgProc
     122#include "killproc.h"                   // KillDlgProc
     123#include "loadbmp.h"                    // LoadBitmapFromFileNum
     124#include "presparm.h"                   // SavePresParams
     125#include "treecnr.h"                    // ShowTreeRec, StartTreeCnr
     126#include "inis.h"                       // StartIniEditor
     127#include "sysinfo.h"                    // SysInfoDlgProc
     128#include "viewinf.h"                    // ViewInfProc
     129#include "walkem.h"                     // WalkDlgProc, WalkTwoCmpDlgProc, add_setup, add_udir
     130                                        // fill_setups_list, free_ldir, free_udirs, load_udirs
     131                                        // remove_setup, remove_udir, save_setups, save_udirs
     132#include "winlist.h"                    // WindowList
     133#include "cmdline.h"                    // add_cmdline
     134#include "assoc.h"                      // free_associations
     135#include "droplist.h"                   // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
     136#include "common.h"                     // CommonTextProc
     137#include "presparm.h"                   // CopyPresParams
     138#include "systemf.h"                    // ExecOnList
     139#include "shadow.h"                     // OpenObject
     140#include "mkdir.h"                      // PMMkDir
     141#include "collect.h"                    // StartCollector
     142#include "select.h"                     // UnHilite
     143#include "strips.h"                     // bstrip
     144#include "commafmt.h"                   // CommaFmtULL
     145#include "valid.h"                      // IsFullName
     146#include "dirs.h"                       // save_dir2
     147#include "wrappers.h"                   // xfree
    142148#include "fortify.h"
    143 
    144 #pragma data_seg(DATA1)
    145 
    146 static PSZ pszSrcFile = __FILE__;
    147 
    148 static USHORT firsttool = 0;
    149149
    150150static BOOL CloseDirCnrChildren(HWND hwndClient);
     
    153153static VOID BuildTools(HWND hwndT, BOOL resize);
    154154
     155// Data definitions
     156#pragma data_seg(GLOBAL1)
     157ULONG DriveLines;
     158HWND MainObjectHwnd;
     159HWND MainPopupMenu;
     160BOOL MenuInvisible;
     161PFNWP PFNWPButton;
     162PFNWP PFNWPStatic;
     163BOOL fAmClosing;
     164BOOL fAutoTile;
     165BOOL fAutoView;
     166BOOL fComments;
     167BOOL fDrivebar;
     168BOOL fFreeTree;
     169BOOL fMoreButtons;
     170BOOL fNoFinger;
     171BOOL fNoSaveState;
     172BOOL fNoTileUpdate;
     173BOOL fRunning;
     174BOOL fSplitStatus;
     175BOOL fTextTools;
     176BOOL fToolTitles;
     177BOOL fToolbar;
     178BOOL fUserComboBox;
     179HBITMAP hbmLEDoff;
     180HBITMAP hbmLEDon;
     181HPOINTER hptrFinger;
     182HWND hwndAutoview;
     183HWND hwndBubble;
     184HWND hwndName;
     185HWND hwndStatelist;
     186HWND hwndToolback;
     187HWND hwndTree;
     188USHORT shiftstate;
     189
     190#pragma data_seg(GLOBAL2)
     191HMODULE FM3ModHandle;
     192CHAR *FM3Str;
     193RGB2 RGBGREY;
     194
     195#pragma data_seg(DATA1)
     196
     197static PSZ pszSrcFile = __FILE__;
     198static USHORT firsttool = 0;
     199static HWND hwndButtonlist;
     200static HWND hwndCmdlist;
     201static HWND hwndDrivelist;
     202static HWND hwndUserlist;
     203
     204
    155205static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    156                                           MPARAM mp2)
     206                                          MPARAM mp2)
    157207{
    158208  switch (msg) {
     
    183233      *dv = 0;
    184234      WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
    185                                         id + 50), sizeof(dv), dv);
     235                                        id + 50), sizeof(dv), dv);
    186236      d = toupper(*dv);
    187237      if (isalpha(d) && d > 'B' &&
    188           !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
    189                                    DRIVE_SLOW)) &&
    190           (!hwndBubble ||
    191            WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    192           !WinQueryCapture(HWND_DESKTOP)) {
    193 
    194         FSALLOCATE fsa;
    195         CHAR s[90], szQty[38];
    196         ULONG ulPctFree;
    197         ULONGLONG ullFreeQty;
    198 
    199         if (!DosQueryFSInfo((d - 'A') + 1,
    200                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    201           ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
    202             (fsa.cSectorUnit * fsa.cbSector);
    203           ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
    204             (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
    205           CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
    206           sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
    207         }
    208         if ((!hwndBubble ||
    209              WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    210             !WinQueryCapture(HWND_DESKTOP))
    211           WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
     238          !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
     239                                   DRIVE_SLOW)) &&
     240          (!hwndBubble ||
     241           WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     242          !WinQueryCapture(HWND_DESKTOP)) {
     243
     244        FSALLOCATE fsa;
     245        CHAR s[90], szQty[38];
     246        ULONG ulPctFree;
     247        ULONGLONG ullFreeQty;
     248
     249        if (!DosQueryFSInfo((d - 'A') + 1,
     250                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     251          ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
     252            (fsa.cSectorUnit * fsa.cbSector);
     253          ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
     254            (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
     255          CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
     256          sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
     257        }
     258        if ((!hwndBubble ||
     259             WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     260            !WinQueryCapture(HWND_DESKTOP))
     261          WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
    212262      }
    213263    }
     
    220270
    221271      if (DosQuerySysInfo(QSV_BOOT_DRIVE,
    222                           QSV_BOOT_DRIVE,
    223                           (PVOID) & bd, (ULONG) sizeof(ULONG)))
    224         bd = 3L;
     272                          QSV_BOOT_DRIVE,
     273                          (PVOID) & bd, (ULONG) sizeof(ULONG)))
     274        bd = 3L;
    225275      *s = (CHAR) bd + '@';
    226276      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    227277      if (!mp1) {
    228         s[3] = 0;
    229         WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
     278        s[3] = 0;
     279        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    230280      }
    231281      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
     
    285335      DosError(FERR_DISABLEHARDERR);
    286336      WinRegisterClass(hab2,
    287                        (PSZ) WC_OBJECTWINDOW,
    288                        MainObjectWndProc, 0, sizeof(PVOID));
     337                       (PSZ) WC_OBJECTWINDOW,
     338                       MainObjectWndProc, 0, sizeof(PVOID));
    289339      MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
    290                                        WC_OBJECTWINDOW,
    291                                        (PSZ) NULL,
    292                                        0,
    293                                        0L,
    294                                        0L,
    295                                        0L,
    296                                        0L,
    297                                        0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
     340                                       WC_OBJECTWINDOW,
     341                                       (PSZ) NULL,
     342                                       0,
     343                                       0L,
     344                                       0L,
     345                                       0L,
     346                                       0L,
     347                                       0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
    298348      if (!MainObjectHwnd)
    299         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
    300                    IDS_WINCREATEWINDOW);
     349        Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
     350                   IDS_WINCREATEWINDOW);
    301351      else {
    302         WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
    303 #       ifdef FORTIFY
    304         Fortify_EnterScope();
    305 #       endif
    306         while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
    307           WinDispatchMsg(hab2, &qmsg2);
    308         WinDestroyWindow(MainObjectHwnd);
    309 #       ifdef FORTIFY
    310         Fortify_LeaveScope();
    311 #       endif
     352        WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
     353#       ifdef FORTIFY
     354        Fortify_EnterScope();
     355#       endif
     356        while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
     357          WinDispatchMsg(hab2, &qmsg2);
     358        WinDestroyWindow(MainObjectHwnd);
     359#       ifdef FORTIFY
     360        Fortify_LeaveScope();
     361#       endif
    312362      }
    313363      WinDestroyMsgQueue(hmq2);
     
    318368
    319369static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
    320                                         MPARAM mp2)
     370                                        MPARAM mp2)
    321371{
    322372  switch (msg) {
     
    338388    while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    339389      if (hwndC != exclude) {
    340         id = WinQueryWindowUShort(hwndC, QWS_ID);
    341         if (id)
    342           break;
     390        id = WinQueryWindowUShort(hwndC, QWS_ID);
     391        if (id)
     392          break;
    343393      }
    344394    }
     
    360410      henum = WinBeginEnumWindows(hwndMain);
    361411      while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    362         // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
    363         if (hwndC != exclude && hwndC != hwndTree) {
    364           id = WinQueryWindowUShort(hwndC, QWS_ID);
    365           if (id) {
    366             hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
    367             if (hwndClient) {
    368               hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
    369               if (hwndDir) {
    370                 if (fLookInDir) {
    371                   pci = (PCNRITEM) WinSendMsg(hwndDir,
    372                                               CM_QUERYRECORDEMPHASIS,
    373                                               MPFROMLONG(CMA_FIRST),
    374                                               MPFROMSHORT(CRA_CURSORED));
    375                   if (pci && (INT) pci != -1)
    376                     break;
    377                 }
    378                 if (WinSendMsg(hwndClient,
    379                                UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
    380                   MakeValidDir(ret);
    381                   // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
    382                   WinEndEnumWindows(henum);
    383                   return hwndC;
    384                 }
    385               }
    386             }
    387           }
    388         }
     412        // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
     413        if (hwndC != exclude && hwndC != hwndTree) {
     414          id = WinQueryWindowUShort(hwndC, QWS_ID);
     415          if (id) {
     416            hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
     417            if (hwndClient) {
     418              hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
     419              if (hwndDir) {
     420                if (fLookInDir) {
     421                  pci = (PCNRITEM) WinSendMsg(hwndDir,
     422                                              CM_QUERYRECORDEMPHASIS,
     423                                              MPFROMLONG(CMA_FIRST),
     424                                              MPFROMSHORT(CRA_CURSORED));
     425                  if (pci && (INT) pci != -1)
     426                    break;
     427                }
     428                if (WinSendMsg(hwndClient,
     429                               UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
     430                  MakeValidDir(ret);
     431                  // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
     432                  WinEndEnumWindows(henum);
     433                  return hwndC;
     434                }
     435              }
     436            }
     437          }
     438        }
    389439      }
    390440      WinEndEnumWindows(henum);
    391441      if (!pci || (INT) pci == -1) {
    392         hwndC = hwndTree;
    393         pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
    394                                                                     FID_CLIENT),
    395                                                     TREE_CNR),
    396                                     CM_QUERYRECORDEMPHASIS,
    397                                     MPFROMLONG(CMA_FIRST),
    398                                     MPFROMSHORT(CRA_CURSORED));
     442        hwndC = hwndTree;
     443        pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
     444                                                                    FID_CLIENT),
     445                                                    TREE_CNR),
     446                                    CM_QUERYRECORDEMPHASIS,
     447                                    MPFROMLONG(CMA_FIRST),
     448                                    MPFROMSHORT(CRA_CURSORED));
    399449      }
    400450      if (pci && (INT) pci != -1) {
    401         strcpy(ret, pci->pszFileName);
    402         MakeValidDir(ret);
     451        strcpy(ret, pci->pszFileName);
     452        MakeValidDir(ret);
    403453      }
    404454      else
    405         strcpy(ret, pFM2SaveDirectory);
     455        strcpy(ret, pFM2SaveDirectory);
    406456    }
    407457  }
     
    421471      hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    422472      if (hwndDir)
    423         ret++;
     473        ret++;
    424474    }
    425475  }
     
    439489      hwndC = WinWindowFromID(hwndF, FID_CLIENT);
    440490      if (hwndC) {
    441         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    442         if (hwndDir) {
    443           *retstr = 0;
    444           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
    445           if (*retstr && !stricmp(retstr, directory)) {
    446             if (restore)
    447               WinSetWindowPos(hwndF,
    448                               HWND_TOP,
    449                               0,
    450                               0,
    451                               0,
    452                               0,
    453                               SWP_RESTORE | SWP_SHOW |
    454                               SWP_ACTIVATE | SWP_ZORDER);
    455             break;
    456           }
    457         }
     491        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     492        if (hwndDir) {
     493          *retstr = 0;
     494          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
     495          if (*retstr && !stricmp(retstr, directory)) {
     496            if (restore)
     497              WinSetWindowPos(hwndF,
     498                              HWND_TOP,
     499                              0,
     500                              0,
     501                              0,
     502                              0,
     503                              SWP_RESTORE | SWP_SHOW |
     504                              SWP_ACTIVATE | SWP_ZORDER);
     505            break;
     506          }
     507        }
    458508      }
    459509    }
     
    522572    while (tool) {
    523573      if (!(tool->flags & T_INVISIBLE)) {
    524         swp[x].x = butx;
    525         if (fTextTools || (tool->flags & T_TEXT)) {
    526           butx += 55L;
    527           swp[x].cx = 54L;
    528           swp[x].cy = 24L;
    529           swp[x].y = 3L;
    530         }
    531         else
    532           butx += 33L;
    533         if (tool->flags & T_SEPARATOR)
    534           butx += 12;
     574        swp[x].x = butx;
     575        if (fTextTools || (tool->flags & T_TEXT)) {
     576          butx += 55L;
     577          swp[x].cx = 54L;
     578          swp[x].cy = 24L;
     579          swp[x].y = 3L;
     580        }
     581        else
     582          butx += 33L;
     583        if (tool->flags & T_SEPARATOR)
     584          butx += 12;
    535585      }
    536586      else
    537         swp[x].fl = noattrib;
     587        swp[x].fl = noattrib;
    538588      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    539589      x++;
     
    544594      swp[x].x = butx;
    545595      if (!(tool->flags & T_INVISIBLE)) {
    546         if (fTextTools || (tool->flags & T_TEXT)) {
    547           butx += 55L;
    548           swp[x].cx = 54L;
    549           swp[x].cy = 24L;
    550           swp[x].y = 3L;
    551         }
    552         else
    553           butx += 33L;
    554         if (tool->flags & T_SEPARATOR)
    555           butx += 12;
     596        if (fTextTools || (tool->flags & T_TEXT)) {
     597          butx += 55L;
     598          swp[x].cx = 54L;
     599          swp[x].cy = 24L;
     600          swp[x].y = 3L;
     601        }
     602        else
     603          butx += 33L;
     604        if (tool->flags & T_SEPARATOR)
     605          butx += 12;
    556606      }
    557607      else
    558         swp[x].fl = noattrib;
     608        swp[x].fl = noattrib;
    559609      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    560610      x++;
     
    564614    if (!fTextTools && fToolTitles) {
    565615      for (x = 2L; x < numtools + 2L; x++) {
    566         if (fTextTools || !fToolTitles)
    567           swp[x].fl = noattrib;
    568         else {
    569           tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
    570           if (tool && (tool->flags & T_TEXT))
    571             swp[x].fl = noattrib;
    572           else {
    573             swp[x].hwndInsertBehind = HWND_TOP;
    574             swp[x].y = 1L;
    575             swp[x].cy = 10L;
    576           }
    577         }
    578         swp[x].hwnd = WinWindowFromID(hwnd,
    579                                       WinQueryWindowUShort(swp[x].hwnd,
    580                                                            QWS_ID) + 25000);
     616        if (fTextTools || !fToolTitles)
     617          swp[x].fl = noattrib;
     618        else {
     619          tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
     620          if (tool && (tool->flags & T_TEXT))
     621            swp[x].fl = noattrib;
     622          else {
     623            swp[x].hwndInsertBehind = HWND_TOP;
     624            swp[x].y = 1L;
     625            swp[x].cy = 10L;
     626          }
     627        }
     628        swp[x].hwnd = WinWindowFromID(hwnd,
     629                                      WinQueryWindowUShort(swp[x].hwnd,
     630                                                           QWS_ID) + 25000);
    581631      }
    582632      WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
     
    588638
    589639static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
    590                                         MPARAM mp2)
     640                                        MPARAM mp2)
    591641{
    592642  PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
     
    626676      id = WinQueryWindowUShort(hwndParent, QWS_ID);
    627677      if (SHORT1FROMMP(mp2)) {
    628         // If getting focus 1st time - save original accelerator
    629         if (haccelSaved == NULLHANDLE) {
    630           haccelSaved = WinQueryAccelTable(hab, hwndFrame);
    631           if (haccelSaved == NULLHANDLE)
    632             Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
    633           // else
    634             // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
    635         }
    636         if (haccelSaved != NULLHANDLE) {
    637           switch (id) {
    638           case MAIN_DRIVELIST:
    639             if (haccelDriveList == NULLHANDLE) {
    640                 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
    641                 if (haccelDriveList == NULLHANDLE)
    642                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    643             }
    644             if (haccelDriveList != NULLHANDLE) {
    645               if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
    646                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    647               // else
    648                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
    649             }
    650             break;
    651           case MAIN_SETUPLIST:
    652             if (haccelSetupList == NULLHANDLE) {
    653                 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
    654                 if (haccelSetupList == NULLHANDLE)
    655                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    656             }
    657             if (haccelSetupList != NULLHANDLE) {
    658               if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
    659                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    660               // else
    661                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
    662             }
    663             break;
    664           case MAIN_CMDLIST:
    665             if (haccelCmdList == NULLHANDLE) {
    666                 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
    667                 if (haccelCmdList == NULLHANDLE)
    668                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    669             }
    670             if (haccelCmdList != NULLHANDLE) {
    671               if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
    672                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    673               // else
    674                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
    675             }
    676             break;
    677           case MAIN_USERLIST:
    678             if (haccelUserList == NULLHANDLE) {
    679                 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
    680                 if (haccelUserList == NULLHANDLE)
    681                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    682             }
    683             if (haccelUserList != NULLHANDLE) {
    684               if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
    685                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    686               // else
    687                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
    688             }
    689             break;
    690           case MAIN_BUTTONLIST:
    691             if (haccelButtonList == NULLHANDLE) {
    692                 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
    693                 if (haccelButtonList == NULLHANDLE)
    694                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    695             }
    696             if (haccelButtonList != NULLHANDLE) {
    697               if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
    698                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    699               // else
    700                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
    701             }
    702             break;
    703           } // switch
    704         }
     678        // If getting focus 1st time - save original accelerator
     679        if (haccelSaved == NULLHANDLE) {
     680          haccelSaved = WinQueryAccelTable(hab, hwndFrame);
     681          if (haccelSaved == NULLHANDLE)
     682            Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
     683          // else
     684            // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
     685        }
     686        if (haccelSaved != NULLHANDLE) {
     687          switch (id) {
     688          case MAIN_DRIVELIST:
     689            if (haccelDriveList == NULLHANDLE) {
     690                haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
     691                if (haccelDriveList == NULLHANDLE)
     692                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     693            }
     694            if (haccelDriveList != NULLHANDLE) {
     695              if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
     696                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     697              // else
     698                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
     699            }
     700            break;
     701          case MAIN_SETUPLIST:
     702            if (haccelSetupList == NULLHANDLE) {
     703                haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
     704                if (haccelSetupList == NULLHANDLE)
     705                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     706            }
     707            if (haccelSetupList != NULLHANDLE) {
     708              if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
     709                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     710              // else
     711                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
     712            }
     713            break;
     714          case MAIN_CMDLIST:
     715            if (haccelCmdList == NULLHANDLE) {
     716                haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
     717                if (haccelCmdList == NULLHANDLE)
     718                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     719            }
     720            if (haccelCmdList != NULLHANDLE) {
     721              if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
     722                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     723              // else
     724                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
     725            }
     726            break;
     727          case MAIN_USERLIST:
     728            if (haccelUserList == NULLHANDLE) {
     729                haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
     730                if (haccelUserList == NULLHANDLE)
     731                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     732            }
     733            if (haccelUserList != NULLHANDLE) {
     734              if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
     735                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     736              // else
     737                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
     738            }
     739            break;
     740          case MAIN_BUTTONLIST:
     741            if (haccelButtonList == NULLHANDLE) {
     742                haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
     743                if (haccelButtonList == NULLHANDLE)
     744                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     745            }
     746            if (haccelButtonList != NULLHANDLE) {
     747              if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
     748                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     749              // else
     750                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
     751            }
     752            break;
     753          } // switch
     754        }
    705755      }
    706756      else {
    707         // Losing focus
    708         switch (id) {
    709         case MAIN_DRIVELIST:
    710         case MAIN_SETUPLIST:
    711         case MAIN_CMDLIST:
    712         case MAIN_USERLIST:
    713         case MAIN_BUTTONLIST:
    714           if (haccelSaved != NULLHANDLE) {
    715             if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
    716               Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    717             // else
    718               // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
    719           }
    720           break;
    721         } // switch
     757        // Losing focus
     758        switch (id) {
     759        case MAIN_DRIVELIST:
     760        case MAIN_SETUPLIST:
     761        case MAIN_CMDLIST:
     762        case MAIN_USERLIST:
     763        case MAIN_BUTTONLIST:
     764          if (haccelSaved != NULLHANDLE) {
     765            if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
     766              Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     767            // else
     768              // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
     769          }
     770          break;
     771        } // switch
    722772      }
    723773    }
     
    729779
    730780      if (hwndMenu)
    731         WinDestroyWindow(hwndMenu);
     781        WinDestroyWindow(hwndMenu);
    732782      hwndMenu = (HWND) 0;
    733783      id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
    734784      switch (id) {
    735785      case MAIN_CMDLIST:
    736         WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    737                                                                 QW_PARENT),
    738                                                   QW_PARENT),
    739                                    FID_CLIENT),
    740                    WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
    741         break;
     786        WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     787                                                                QW_PARENT),
     788                                                  QW_PARENT),
     789                                   FID_CLIENT),
     790                   WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
     791        break;
    742792      case MAIN_USERLIST:
    743793      case MAIN_SETUPLIST:
    744         hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    745         if (hwndMenu)
    746           PopupMenu(hwnd,
    747                     WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    748                                                                   QW_PARENT),
    749                                                    QW_PARENT),
    750                                     FID_CLIENT), hwndMenu);
    751         break;
     794        hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     795        if (hwndMenu)
     796          PopupMenu(hwnd,
     797                    WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     798                                                                  QW_PARENT),
     799                                                   QW_PARENT),
     800                                    FID_CLIENT), hwndMenu);
     801        break;
    752802      default:
    753         ret = FALSE;
    754         break;
     803        ret = FALSE;
     804        break;
    755805      } // switch
    756806      return ret;
     
    761811      switch (SHORT1FROMMP(mp1)) {
    762812      case CBID_EDIT:
    763         id = WinQueryWindowUShort(hwnd, QWS_ID);
    764         switch (SHORT2FROMMP(mp1)) {
    765         case EN_SETFOCUS:
    766           switch (id) {
    767           case MAIN_CMDLIST:
    768             WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
    769             break;
    770           case MAIN_SETUPLIST:
    771             WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
    772             break;
    773           case MAIN_USERLIST:
    774             WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
    775             break;
    776           case MAIN_DRIVELIST:
    777             WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
    778             break;
    779           case MAIN_BUTTONLIST:
    780             WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
    781             break;
    782           default:
    783             break;
    784           }
    785           break;
    786 
    787         default:
    788           break;
    789         }
     813        id = WinQueryWindowUShort(hwnd, QWS_ID);
     814        switch (SHORT2FROMMP(mp1)) {
     815        case EN_SETFOCUS:
     816          switch (id) {
     817          case MAIN_CMDLIST:
     818            WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
     819            break;
     820          case MAIN_SETUPLIST:
     821            WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
     822            break;
     823          case MAIN_USERLIST:
     824            WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
     825            break;
     826          case MAIN_DRIVELIST:
     827            WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
     828            break;
     829          case MAIN_BUTTONLIST:
     830            WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
     831            break;
     832          default:
     833            break;
     834          }
     835          break;
     836
     837        default:
     838          break;
     839        }
    790840      }
    791841      break;
     
    800850    // 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);
    801851    if (id == CBID_EDIT &&
    802         WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
    803         MAIN_USERLIST) {
     852        WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
     853        MAIN_USERLIST) {
    804854
    805855      CHAR path[CCHMAXPATH];
     
    810860      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
    811861      if (*path && !IsRoot(path))
    812         DragOne(hwnd, (HWND) 0, path, FALSE);
     862        DragOne(hwnd, (HWND) 0, path, FALSE);
    813863      return 0;
    814864    }
     
    819869    if (id == MAIN_USERLIST) {
    820870      if (!emphasized) {
    821         emphasized = TRUE;
    822         DrawTargetEmphasis(hwnd, emphasized);
     871        emphasized = TRUE;
     872        DrawTargetEmphasis(hwnd, emphasized);
    823873      }
    824874      if (AcceptOneDrop(hwnd, mp1, mp2))
    825         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     875        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    826876      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    827877    }
     
    832882    if (id == MAIN_USERLIST) {
    833883      if (emphasized) {
    834         emphasized = FALSE;
    835         DrawTargetEmphasis(hwnd, emphasized);
     884        emphasized = FALSE;
     885        DrawTargetEmphasis(hwnd, emphasized);
    836886      }
    837887    }
     
    853903
    854904      if (emphasized) {
    855         emphasized = FALSE;
    856         DrawTargetEmphasis(hwnd, emphasized);
     905        emphasized = FALSE;
     906        DrawTargetEmphasis(hwnd, emphasized);
    857907      }
    858908      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    859         MakeValidDir(szFrom);
    860         WinSetWindowText(hwnd, szFrom);
    861         PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    862                                                               QW_PARENT),
    863                                                QW_PARENT),
    864                                 FID_CLIENT),
    865                 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
    866         return 0;
     909        MakeValidDir(szFrom);
     910        WinSetWindowText(hwnd, szFrom);
     911        PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     912                                                              QW_PARENT),
     913                                               QW_PARENT),
     914                                FID_CLIENT),
     915                UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
     916        return 0;
    867917      }
    868918    }
     
    885935       (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
    886936    if ((!hwndBubble ||
    887         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    888         !WinQueryCapture(HWND_DESKTOP))
     937        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     938        !WinQueryCapture(HWND_DESKTOP))
    889939      MakeBubble(hwnd, above, help);
    890940  }
     
    907957      /* don't bring up help if window isn't active */
    908958      if (!WinIsChild(hwnd, hwndActive))
    909         return;
     959        return;
    910960    }
    911961    hwndActive = WinQueryFocus(HWND_DESKTOP);
     
    913963      /* don't bring up help if a menu is active */
    914964      if (!strcmp(ucClassname, "#4"))
    915         return;
     965        return;
    916966    }
    917967  }
    918968
    919969  hwndBubble = WinCreateWindow(HWND_DESKTOP,
    920                                WC_BUBBLE,
    921                                help,
    922                                WS_CLIPSIBLINGS | SS_TEXT |
    923                                DT_CENTER | DT_VCENTER,
    924                                0,
    925                                0,
    926                                0,
    927                                0,
    928                                HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
     970                               WC_BUBBLE,
     971                               help,
     972                               WS_CLIPSIBLINGS | SS_TEXT |
     973                               DT_CENTER | DT_VCENTER,
     974                               0,
     975                               0,
     976                               0,
     977                               0,
     978                               HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
    929979  if (!hwndBubble)
    930980    Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    931                IDS_WINCREATEWINDOW);
     981               IDS_WINCREATEWINDOW);
    932982  else {
    933983    HPS hps;
     
    949999      pp = strchr(p, '\r');
    9501000      if (pp) {
    951         wp = pp;
    952         *pp = 0;
    953         pp++;
     1001        wp = pp;
     1002        *pp = 0;
     1003        pp++;
    9541004      }
    9551005      GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    9561006      tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
    9571007      if (tptl.y)
    958         tptl.y += extra;
     1008        tptl.y += extra;
    9591009      else
    960         extra = aptl[TXTBOX_TOPLEFT].y / 4;
     1010        extra = aptl[TXTBOX_TOPLEFT].y / 4;
    9611011      tptl.y += aptl[TXTBOX_TOPLEFT].y;
    9621012      if (wp)
    963         *wp = '\r';
     1013        *wp = '\r';
    9641014      p = pp;
    9651015    }
     
    9711021      sy = ptl.y + swp.cy + 4;
    9721022      if (sy + tptl.y + 12 > lyScreen) {
    973         above = FALSE;
    974         sy = ptl.y - (tptl.y + 14);
     1023        above = FALSE;
     1024        sy = ptl.y - (tptl.y + 14);
    9751025      }
    9761026    }
     
    9881038      sy = ptl.y + swp.cy + 4;
    9891039      if (sy + tptl.y + 12 > lyScreen)
    990         sy = 0;
     1040        sy = 0;
    9911041    }
    9921042    WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
    993                     tptl.x + 14,
    994                     tptl.y + 12,
    995                     SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
    996                     SWP_MOVE | SWP_SIZE);
     1043                    tptl.x + 14,
     1044                    tptl.y + 12,
     1045                    SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
     1046                    SWP_MOVE | SWP_SIZE);
    9971047  }
    9981048}
     
    10201070      WinQueryPointerPos(HWND_DESKTOP, &ptl);
    10211071      if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
    1022           WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
    1023         WinDestroyWindow(hwnd);
     1072          WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
     1073        WinDestroyWindow(hwnd);
    10241074    }
    10251075    return 0;
     
    10351085      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    10361086      if (hps) {
    1037         WinQueryWindowPos(hwnd, &swp);
    1038         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
    1039         GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
    1040         GpiSetBackMix(hps, BM_LEAVEALONE);
    1041         GpiSetMix(hps, FM_OVERPAINT);
    1042         ptl.x = ptl.y = 0;
    1043         GpiMove(hps, &ptl);
    1044         ptl.x = swp.cx - 1;
    1045         ptl.y = swp.cy - 1;
    1046         GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
    1047         tlen = WinQueryWindowTextLength(hwnd);
    1048         if (tlen) {
    1049           s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
    1050           if (s) {
    1051             WinQueryWindowText(hwnd, tlen + 1, s);
    1052             if (*s) {
    1053               p = s;
    1054               y = swp.cy - 3;
    1055               extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
    1056               GpiSetColor(hps, 0);
    1057               GpiSetMix(hps, FM_OVERPAINT);
    1058               while (p && *p) {
    1059                 wp = NULL;
    1060                 pp = strchr(p, '\r');
    1061                 if (pp) {
    1062                   wp = pp;
    1063                   *pp = 0;
    1064                   pp++;
    1065                 }
    1066                 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    1067                 ptl.x = 7;
    1068                 y -= aptl[TXTBOX_TOPLEFT].y;
    1069                 if (p != s)
    1070                   y -= extra;
    1071                 ptl.y = y;
    1072                 GpiCharStringAt(hps, &ptl, strlen(p), p);
    1073                 if (wp)
    1074                   *wp = '\r';
    1075                 p = pp;
    1076               }
    1077             }
    1078             free(s);
    1079           }
    1080         }
    1081         if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
    1082           GpiSetColor(hps, CLR_WHITE);
    1083           ptl.x = 1;
    1084           ptl.y = 1;
    1085           GpiMove(hps, &ptl);
    1086           ptl.y = swp.cy - 2;
    1087           GpiLine(hps, &ptl);
    1088           ptl.x = swp.cx - 2;
    1089           GpiLine(hps, &ptl);
    1090           ptl.x = 2;
    1091           ptl.y = 2;
    1092           GpiMove(hps, &ptl);
    1093           ptl.y = swp.cy - 3;
    1094           GpiLine(hps, &ptl);
    1095           ptl.x = swp.cx - 3;
    1096           GpiLine(hps, &ptl);
    1097           GpiSetColor(hps, CLR_BROWN);
    1098           ptl.x = 1;
    1099           ptl.y = 1;
    1100           GpiMove(hps, &ptl);
    1101           ptl.x = swp.cx - 2;
    1102           GpiLine(hps, &ptl);
    1103           ptl.y = swp.cy - 2;
    1104           GpiLine(hps, &ptl);
    1105           ptl.x = 2;
    1106           ptl.y = 2;
    1107           GpiMove(hps, &ptl);
    1108           ptl.x = swp.cx - 3;
    1109           GpiLine(hps, &ptl);
    1110           ptl.y = swp.cy - 3;
    1111           GpiLine(hps, &ptl);
    1112         }
    1113         WinEndPaint(hps);
     1087        WinQueryWindowPos(hwnd, &swp);
     1088        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
     1089        GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
     1090        GpiSetBackMix(hps, BM_LEAVEALONE);
     1091        GpiSetMix(hps, FM_OVERPAINT);
     1092        ptl.x = ptl.y = 0;
     1093        GpiMove(hps, &ptl);
     1094        ptl.x = swp.cx - 1;
     1095        ptl.y = swp.cy - 1;
     1096        GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     1097        tlen = WinQueryWindowTextLength(hwnd);
     1098        if (tlen) {
     1099          s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
     1100          if (s) {
     1101            WinQueryWindowText(hwnd, tlen + 1, s);
     1102            if (*s) {
     1103              p = s;
     1104              y = swp.cy - 3;
     1105              extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
     1106              GpiSetColor(hps, 0);
     1107              GpiSetMix(hps, FM_OVERPAINT);
     1108              while (p && *p) {
     1109                wp = NULL;
     1110                pp = strchr(p, '\r');
     1111                if (pp) {
     1112                  wp = pp;
     1113                  *pp = 0;
     1114                  pp++;
     1115                }
     1116                GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
     1117                ptl.x = 7;
     1118                y -= aptl[TXTBOX_TOPLEFT].y;
     1119                if (p != s)
     1120                  y -= extra;
     1121                ptl.y = y;
     1122                GpiCharStringAt(hps, &ptl, strlen(p), p);
     1123                if (wp)
     1124                  *wp = '\r';
     1125                p = pp;
     1126              }
     1127            }
     1128            free(s);
     1129          }
     1130        }
     1131        if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
     1132          GpiSetColor(hps, CLR_WHITE);
     1133          ptl.x = 1;
     1134          ptl.y = 1;
     1135          GpiMove(hps, &ptl);
     1136          ptl.y = swp.cy - 2;
     1137          GpiLine(hps, &ptl);
     1138          ptl.x = swp.cx - 2;
     1139          GpiLine(hps, &ptl);
     1140          ptl.x = 2;
     1141          ptl.y = 2;
     1142          GpiMove(hps, &ptl);
     1143          ptl.y = swp.cy - 3;
     1144          GpiLine(hps, &ptl);
     1145          ptl.x = swp.cx - 3;
     1146          GpiLine(hps, &ptl);
     1147          GpiSetColor(hps, CLR_BROWN);
     1148          ptl.x = 1;
     1149          ptl.y = 1;
     1150          GpiMove(hps, &ptl);
     1151          ptl.x = swp.cx - 2;
     1152          GpiLine(hps, &ptl);
     1153          ptl.y = swp.cy - 2;
     1154          GpiLine(hps, &ptl);
     1155          ptl.x = 2;
     1156          ptl.y = 2;
     1157          GpiMove(hps, &ptl);
     1158          ptl.x = swp.cx - 3;
     1159          GpiLine(hps, &ptl);
     1160          ptl.y = swp.cy - 3;
     1161          GpiLine(hps, &ptl);
     1162        }
     1163        WinEndPaint(hps);
    11141164      }
    11151165    }
     
    11381188      switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
    11391189      case MAIN_LED:
    1140         hps = WinGetPS(hwnd);
    1141         hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
    1142         if (!fBlueLED) {
    1143           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
    1144           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
    1145         }
    1146         else {
    1147           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
    1148           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
    1149         }
    1150         if (hbmLEDoff && hbmLEDon)
    1151           WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
    1152         else {
    1153           if (hbmLEDoff)
    1154             GpiDeleteBitmap(hbmLEDoff);
    1155           if (hbmLEDon)
    1156             GpiDeleteBitmap(hbmLEDon);
    1157         }
    1158         if (hbmold &&
    1159             hbmLEDon &&
    1160             hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
    1161           GpiDeleteBitmap(hbmold);
    1162         if (hps)
    1163           WinReleasePS(hps);
    1164         break;
     1190        hps = WinGetPS(hwnd);
     1191        hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
     1192        if (!fBlueLED) {
     1193          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
     1194          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
     1195        }
     1196        else {
     1197          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
     1198          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
     1199        }
     1200        if (hbmLEDoff && hbmLEDon)
     1201          WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
     1202        else {
     1203          if (hbmLEDoff)
     1204            GpiDeleteBitmap(hbmLEDoff);
     1205          if (hbmLEDon)
     1206            GpiDeleteBitmap(hbmLEDon);
     1207        }
     1208        if (hbmold &&
     1209            hbmLEDon &&
     1210            hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
     1211          GpiDeleteBitmap(hbmold);
     1212        if (hps)
     1213          WinReleasePS(hps);
     1214        break;
    11651215      default:
    1166         SetPresParams(hwnd,
    1167                       &RGBGREY,
    1168                       &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    1169         break;
     1216        SetPresParams(hwnd,
     1217                      &RGBGREY,
     1218                      &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     1219        break;
    11701220      }
    11711221      return mr;
     
    11911241  case WM_BUTTON1CLICK:
    11921242    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1193             WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
     1243            WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
    11941244    break;
    11951245
    11961246  case WM_BUTTON2CLICK:
    11971247    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1198             WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
     1248            WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
    11991249    break;
    12001250
     
    12021252  case WM_BUTTON3CLICK:
    12031253    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1204             WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     1254            WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    12051255    break;
    12061256  }
     
    12251275    if (fToolbarHelp) {
    12261276      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    1227           && !WinQueryCapture(HWND_DESKTOP)) {
    1228         id = WinQueryWindowUShort(hwnd, QWS_ID);
    1229         tool = find_tool(id);
    1230         if (tool && tool->help && *tool->help) {
    1231 
    1232           char s[128];
    1233 
    1234           strcpy(s, tool->help);
    1235           if (tool->flags & T_DROPABLE)
    1236             strcat(s, GetPString(IDS_DROPONMETEXT));
    1237           MakeBubble(hwnd, FALSE, s);
    1238         }
     1277          && !WinQueryCapture(HWND_DESKTOP)) {
     1278        id = WinQueryWindowUShort(hwnd, QWS_ID);
     1279        tool = find_tool(id);
     1280        if (tool && tool->help && *tool->help) {
     1281
     1282          char s[128];
     1283
     1284          strcpy(s, tool->help);
     1285          if (tool->flags & T_DROPABLE)
     1286            strcat(s, GetPString(IDS_DROPONMETEXT));
     1287          MakeBubble(hwnd, FALSE, s);
     1288        }
    12391289      }
    12401290    }
     
    12451295    case IDM_HELP:
    12461296      if (hwndHelp)
    1247         WinSendMsg(hwndHelp,
    1248                    HM_DISPLAY_HELP,
    1249                    MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
     1297        WinSendMsg(hwndHelp,
     1298                   HM_DISPLAY_HELP,
     1299                   MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
    12501300      break;
    12511301
     
    12531303    case IDM_HIDETOOL:                  /* hide tool */
    12541304      if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
    1255         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1305        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12561306      else
    1257         id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
    1258                                 PickToolProc, FM3ModHandle,
    1259                                 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
     1307        id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
     1308                                PickToolProc, FM3ModHandle,
     1309                                PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
    12601310      if (id) {
    1261         tool = find_tool(id);
    1262         if (tool) {
    1263           tool->flags |= T_INVISIBLE;
     1311        tool = find_tool(id);
     1312        if (tool) {
     1313          tool->flags |= T_INVISIBLE;
    12641314          save_tools(NULL);
    1265         }
     1315        }
    12661316      }
    12671317      break;
     
    12701320      tool = toolhead;
    12711321      while (tool) {
    1272         tool->flags &= (~T_INVISIBLE);
    1273         tool = tool->next;
     1322        tool->flags &= (~T_INVISIBLE);
     1323        tool = tool->next;
    12741324      }
    12751325      save_tools(NULL);
     
    12791329    case IDM_DELETETOOL:                /* delete button */
    12801330      if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
    1281         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1331        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12821332      else
    1283         id =
    1284           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1285                              PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
     1333        id =
     1334          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1335                             PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
    12861336      if (id)
    1287         PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
     1337        PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
    12881338                MPFROM2SHORT(id, 0), MPVOID);
    12891339      return 0;
     
    12921342    case IDM_EDITTOOL:                  /* edit button */
    12931343      if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
    1294         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1344        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12951345      else
    1296         id =
    1297           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1298                              PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
     1346        id =
     1347          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1348                             PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
    12991349      if (id) {
    1300         tool = find_tool(id);
    1301         if (tool) {
    1302           if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1303                         ADDBTN_FRAME, (PVOID) tool))
    1304             WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1305                                                                      QW_PARENT),
    1306                                                       QW_PARENT), FID_CLIENT),
    1307                        WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1308                        MPFROM2SHORT(id, 0));
    1309         }
     1350        tool = find_tool(id);
     1351        if (tool) {
     1352          if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
     1353                        ADDBTN_FRAME, (PVOID) tool))
     1354            WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1355                                                                     QW_PARENT),
     1356                                                      QW_PARENT), FID_CLIENT),
     1357                       WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1358                       MPFROM2SHORT(id, 0));
     1359        }
    13101360      }
    13111361      break;
     
    13131363    case IDM_ADDTOOL:                   /* add tool */
    13141364      id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1315                               ADDBTN_FRAME, MPVOID);
     1365                              ADDBTN_FRAME, MPVOID);
    13161366      if (id && id != (USHORT) - 1)
    1317         WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1318                                                                 QW_PARENT),
    1319                                                   QW_PARENT), FID_CLIENT),
    1320                    WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1321                    MPFROM2SHORT(id, 0));
     1367        WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1368                                                                QW_PARENT),
     1369                                                  QW_PARENT), FID_CLIENT),
     1370                   WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1371                   MPFROM2SHORT(id, 0));
    13221372      break;
    13231373
    13241374    case IDM_REORDERTOOLS:              /* reorder tools */
    13251375      WinDlgBox(HWND_DESKTOP,
    1326                 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
     1376                hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
    13271377      break;
    13281378
     
    13301380    case IDM_LOADTOOLS:
    13311381      if (WinDlgBox(HWND_DESKTOP,
    1332                     hwnd,
    1333                     ToolIODlgProc,
    1334                     FM3ModHandle,
    1335                     SVBTN_FRAME,
    1336                     (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    1337                     "TRUE" : NULL))
     1382                    hwnd,
     1383                    ToolIODlgProc,
     1384                    FM3ModHandle,
     1385                    SVBTN_FRAME,
     1386                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
     1387                    "TRUE" : NULL))
    13381388        PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    13391389      break;
     
    13681418      tool = find_tool(id);
    13691419      if (!tool) {
    1370         DrgFreeDraginfo(pDInfo);
    1371         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1420        DrgFreeDraginfo(pDInfo);
     1421        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13721422      }
    13731423      if (!(tool->flags & T_DROPABLE)) {
    1374         DrgFreeDraginfo(pDInfo);
    1375         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1424        DrgFreeDraginfo(pDInfo);
     1425        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13761426      }
    13771427      {
    1378         PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
    1379 
    1380         pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
    1381                                      0);        /* Index to DRAGITEM */
    1382         if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
    1383                         DRM_OS2FILE,   /* mechanisms and data */
    1384                         NULL)) {       /* formats */
    1385           if (!(tool->flags & T_EMPHASIZED)) {
    1386             tool->flags |= T_EMPHASIZED;
    1387             DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1388             DrgFreeDraginfo(pDInfo);
    1389           }
    1390           return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
    1391                                DO_MOVE));       /* Move operation valid */
    1392         }
    1393         DrgFreeDraginfo(pDInfo);
     1428        PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
     1429
     1430        pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
     1431                                     0);        /* Index to DRAGITEM */
     1432        if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
     1433                        DRM_OS2FILE,   /* mechanisms and data */
     1434                        NULL)) {       /* formats */
     1435          if (!(tool->flags & T_EMPHASIZED)) {
     1436            tool->flags |= T_EMPHASIZED;
     1437            DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1438            DrgFreeDraginfo(pDInfo);
     1439          }
     1440          return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
     1441                               DO_MOVE));       /* Move operation valid */
     1442        }
     1443        DrgFreeDraginfo(pDInfo);
    13941444      }
    13951445    }
     
    14081458    if (tool && (tool->flags & T_DROPABLE)) {
    14091459      if (tool->flags & T_EMPHASIZED) {
    1410         tool->flags &= (~T_EMPHASIZED);
    1411         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1460        tool->flags &= (~T_EMPHASIZED);
     1461        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    14121462      }
    14131463    }
     
    14221472
    14231473      if (tool->flags & T_EMPHASIZED) {
    1424         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1425         tool->flags &= (~T_EMPHASIZED);
     1474        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1475        tool->flags &= (~T_EMPHASIZED);
    14261476      }
    14271477      memset(&cdi, 0, sizeof(cdi));
     
    14301480      CheckPmDrgLimit(cdi.pDragInfo);
    14311481      if (li) {
    1432         li->type = id;
    1433         if (!li->list || !li->list[0])
    1434           FreeListInfo(li);
    1435         else {
    1436           HWND hwndActive;
    1437 
    1438           hwndActive = TopWindow(hwndMain, (HWND) 0);
    1439           if (hwndActive) {
    1440             if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
    1441               FreeListInfo(li);
    1442           }
    1443           else
    1444             FreeListInfo(li);
    1445         }
     1482        li->type = id;
     1483        if (!li->list || !li->list[0])
     1484          FreeListInfo(li);
     1485        else {
     1486          HWND hwndActive;
     1487
     1488          hwndActive = TopWindow(hwndMain, (HWND) 0);
     1489          if (hwndActive) {
     1490            if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
     1491              FreeListInfo(li);
     1492          }
     1493          else
     1494            FreeListInfo(li);
     1495        }
    14461496      }
    14471497    }
     
    14811531    if (!fTextTools) {
    14821532      if (!(tool->flags & T_MYICON)) {
    1483         hwndTool = WinCreateWindow(hwndT,
    1484                                    WC_TOOLBUTTONS,
    1485                                    s,
    1486                                    BS_NOPOINTERFOCUS |
    1487                                    BS_BITMAP | BS_PUSHBUTTON,
    1488                                    ctrlxpos,
    1489                                    14,
    1490                                    32,
    1491                                    32, hwndT, HWND_TOP, tool->id, NULL, NULL);
     1533        hwndTool = WinCreateWindow(hwndT,
     1534                                   WC_TOOLBUTTONS,
     1535                                   s,
     1536                                   BS_NOPOINTERFOCUS |
     1537                                   BS_BITMAP | BS_PUSHBUTTON,
     1538                                   ctrlxpos,
     1539                                   14,
     1540                                   32,
     1541                                   32, hwndT, HWND_TOP, tool->id, NULL, NULL);
    14921542      }
    14931543      if (!hwndTool) {
    1494         HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
    1495 
    1496         if (hbm) {
    1497           BTNCDATA btc;
    1498 
    1499           memset(&btc, 0, sizeof(btc));
    1500           btc.cb = sizeof(btc);
    1501           btc.hImage = hbm;
    1502           hwndTool = WinCreateWindow(hwndT,
    1503                                      WC_TOOLBUTTONS,
    1504                                      NullStr,
    1505                                      BS_NOPOINTERFOCUS |
    1506                                      BS_BITMAP | BS_PUSHBUTTON,
    1507                                      ctrlxpos,
    1508                                      14,
    1509                                      32,
    1510                                      32,
    1511                                      hwndT, HWND_TOP, tool->id, &btc, NULL);
    1512           if (!hwndTool)
    1513             GpiDeleteBitmap(hbm);
    1514         }
     1544        HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
     1545
     1546        if (hbm) {
     1547          BTNCDATA btc;
     1548
     1549          memset(&btc, 0, sizeof(btc));
     1550          btc.cb = sizeof(btc);
     1551          btc.hImage = hbm;
     1552          hwndTool = WinCreateWindow(hwndT,
     1553                                     WC_TOOLBUTTONS,
     1554                                     NullStr,
     1555                                     BS_NOPOINTERFOCUS |
     1556                                     BS_BITMAP | BS_PUSHBUTTON,
     1557                                     ctrlxpos,
     1558                                     14,
     1559                                     32,
     1560                                     32,
     1561                                     hwndT, HWND_TOP, tool->id, &btc, NULL);
     1562          if (!hwndTool)
     1563            GpiDeleteBitmap(hbm);
     1564        }
    15151565      }
    15161566      if (hwndTool)
    1517         tool->flags &= (~T_TEXT);
     1567        tool->flags &= (~T_TEXT);
    15181568    }
    15191569    if (!hwndTool) {
    15201570      hwndTool = WinCreateWindow(hwndT,
    1521                                 WC_TOOLBUTTONS,
    1522                                 (!tool->text && tool->id >= IDM_COMMANDSTART
    1523                                   && tool->id <
    1524                                   IDM_QUICKTOOLSTART) ? command_title(tool->
    1525                                                                       id -
    1526                                                                       IDM_COMMANDSTART)
    1527                                 : tool->text,
    1528                                 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
    1529                                 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
    1530                                 NULL);
     1571                                WC_TOOLBUTTONS,
     1572                                (!tool->text && tool->id >= IDM_COMMANDSTART
     1573                                  && tool->id <
     1574                                  IDM_QUICKTOOLSTART) ? command_title(tool->
     1575                                                                      id -
     1576                                                                      IDM_COMMANDSTART)
     1577                                : tool->text,
     1578                                BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
     1579                                2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
     1580                                NULL);
    15311581      if (!hwndTool)
    1532         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1533                    IDS_WINCREATEWINDOW);
     1582        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1583                   IDS_WINCREATEWINDOW);
    15341584      tool->flags |= T_TEXT;
    15351585    }
    15361586    if (fToolTitles && !fTextTools) {
    15371587      hwndTool = WinCreateWindow(hwndT,
    1538                                 WC_STATIC,
    1539                                 tool->text,
    1540                                 SS_TEXT | DT_LEFT | DT_VCENTER,
    1541                                 ctrlxpos,
    1542                                 1,
    1543                                 32,
    1544                                 10,
    1545                                 hwndT,
    1546                                 HWND_TOP, tool->id + 25000, NULL, NULL);
     1588                                WC_STATIC,
     1589                                tool->text,
     1590                                SS_TEXT | DT_LEFT | DT_VCENTER,
     1591                                ctrlxpos,
     1592                                1,
     1593                                32,
     1594                                10,
     1595                                hwndT,
     1596                                HWND_TOP, tool->id + 25000, NULL, NULL);
    15471597      if (!hwndTool)
    1548         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1549                    IDS_WINCREATEWINDOW);
     1598        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1599                   IDS_WINCREATEWINDOW);
    15501600      else {
    1551         SetPresParams(hwndTool,
    1552                       &RGBGREY,
    1553                       &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
     1601        SetPresParams(hwndTool,
     1602                      &RGBGREY,
     1603                      &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
    15541604      }
    15551605    }
    15561606    ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
    15571607    SetPresParams(WinWindowFromID(hwndT, tool->id),
    1558                   NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
     1608                  NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
    15591609    tool = tool->next;
    15601610  }                                     // while tool
    15611611
    15621612  hwndTool = WinCreateWindow(hwndT,
    1563                              WC_BUTTON,
    1564                              "#6010",
    1565                              BS_NOPOINTERFOCUS |
    1566                              BS_BITMAP | BS_PUSHBUTTON,
    1567                              1,
    1568                              19,
    1569                              14,
    1570                              13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
     1613                             WC_BUTTON,
     1614                             "#6010",
     1615                             BS_NOPOINTERFOCUS |
     1616                             BS_BITMAP | BS_PUSHBUTTON,
     1617                             1,
     1618                             19,
     1619                             14,
     1620                             13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
    15711621  if (!hwndTool)
    15721622    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1573                IDS_WINCREATEWINDOW);
     1623               IDS_WINCREATEWINDOW);
    15741624  hwndTool =
    15751625    WinCreateWindow(hwndT, WC_BUTTON, "#6011",
    1576                     BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
    1577                     13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
     1626                    BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
     1627                    13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
    15781628  if (!hwndTool)
    15791629    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1580                IDS_WINCREATEWINDOW);
     1630               IDS_WINCREATEWINDOW);
    15811631  if (resize)
    15821632    ResizeTools(hwndT);
     
    15841634
    15851635static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
    1586                                         MPARAM mp2)
     1636                                        MPARAM mp2)
    15871637{
    15881638  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    16011651
    16021652      if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
    1603         break;
     1653        break;
    16041654      if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
    1605         WinDestroyWindow(hwnd);
     1655        WinDestroyWindow(hwnd);
    16061656    }
    16071657    break;
     
    16131663      pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    16141664      if (pszCmdLine) {
    1615         lbup = TRUE;
    1616         if (WinDlgBox(HWND_DESKTOP,
    1617                         hwnd,
    1618                       CmdLine2DlgProc,
    1619                       FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
    1620           lstrip(pszCmdLine);
    1621         WinSetWindowText(hwnd, pszCmdLine);
    1622         }
    1623         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    1624         PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
    1625         free(pszCmdLine);
     1665        lbup = TRUE;
     1666        if (WinDlgBox(HWND_DESKTOP,
     1667                        hwnd,
     1668                      CmdLine2DlgProc,
     1669                      FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
     1670          lstrip(pszCmdLine);
     1671        WinSetWindowText(hwnd, pszCmdLine);
     1672        }
     1673        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     1674        PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
     1675        free(pszCmdLine);
    16261676      }
    16271677    }
     
    16401690    case COMMAND_BUTTON:
    16411691      if (!lbup)
    1642         PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1692        PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    16431693      break;
    16441694    }
     
    16591709      bstrip(cl + len);
    16601710      if (strlen(cl) > len) {
    1661         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    1662                    UM_SETUP, MPFROMP(cl + len), MPVOID);
    1663         WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
    1664         bstrip(directory);
    1665         if (*directory && (IsRoot(directory) || !IsFile(directory))) {
    1666           if (!FM2Command(directory, cl + len)) {
    1667             hwndCnr = TopWindow(hwndMain, (HWND) 0);
    1668             if (hwndCnr) {
    1669               hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
    1670               if (hwndCnr) {
    1671                 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
    1672                 if (hwndCnr)
    1673                   list = BuildList(hwndCnr);
    1674               }
    1675             }
    1676             WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
    1677             if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
    1678               save_cmdlines(FALSE);
    1679             ExecOnList(hwndCnr,
    1680                        cl,
    1681                        WINDOWED | ((fKeepCmdLine) ?
    1682                                    SEPARATEKEEP : SEPARATE),
    1683                        directory, list, NULL, pszSrcFile, __LINE__);
    1684             xfree(list, pszSrcFile, __LINE__);
    1685             WinDestroyWindow(hwnd);
    1686             break;
    1687           }
    1688         }
     1711        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
     1712                   UM_SETUP, MPFROMP(cl + len), MPVOID);
     1713        WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
     1714        bstrip(directory);
     1715        if (*directory && (IsRoot(directory) || !IsFile(directory))) {
     1716          if (!FM2Command(directory, cl + len)) {
     1717            hwndCnr = TopWindow(hwndMain, (HWND) 0);
     1718            if (hwndCnr) {
     1719              hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
     1720              if (hwndCnr) {
     1721                hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
     1722                if (hwndCnr)
     1723                  list = BuildList(hwndCnr);
     1724              }
     1725            }
     1726            WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
     1727            if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
     1728              save_cmdlines(FALSE);
     1729            ExecOnList(hwndCnr,
     1730                       cl,
     1731                       WINDOWED | ((fKeepCmdLine) ?
     1732                                   SEPARATEKEEP : SEPARATE),
     1733                       directory, list, NULL, pszSrcFile, __LINE__);
     1734            xfree(list, pszSrcFile, __LINE__);
     1735            WinDestroyWindow(hwnd);
     1736            break;
     1737          }
     1738        }
    16891739      }
    16901740      WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     
    16951745    if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
    16961746      if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
    1697         if ((SHORT1FROMMP(mp2) & 255) == '\r')
    1698           PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
    1699         else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
    1700           WinDestroyWindow(hwnd);
    1701         else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
    1702           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1747        if ((SHORT1FROMMP(mp2) & 255) == '\r')
     1748          PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
     1749        else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
     1750          WinDestroyWindow(hwnd);
     1751        else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
     1752          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    17031753      }
    17041754    }
    17051755    else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
    1706              ((SHORT2FROMMP(mp2) == VK_UP ||
    1707                SHORT2FROMMP(mp2) == VK_DOWN) ||
    1708               (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
     1756             ((SHORT2FROMMP(mp2) == VK_UP ||
     1757               SHORT2FROMMP(mp2) == VK_DOWN) ||
     1758              (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
    17091759      return 0;
    17101760    break;
     
    17321782      rgb.bRed = (BYTE)128;
    17331783      SetPresParams(hwnd,
    1734                     &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
     1784                    &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
    17351785      SetTargetDir(hwnd, TRUE);
    17361786    }
     
    17621812  case WM_CONTROLPOINTER:
    17631813    if (!fNoFinger &&
    1764         (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
    1765         SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
     1814        (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
     1815        SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
    17661816      return MRFROMLONG(hptrFinger);
    17671817    break;
     
    17731823      *dv = 0;
    17741824      WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
    1775                         2, dv);
     1825                        2, dv);
    17761826      if (isalpha(*dv)) {
    17771827
    1778         HWND hwndActive;
    1779 
    1780         dv[1] = ':';
    1781         dv[2] = '\\';
    1782         dv[3] = 0;
    1783         hwndActive = TopWindow(hwnd, (HWND) 0);
    1784         if (hwndActive)
    1785           WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    1786                      UM_DRIVECMD, MPFROMP(dv), MPVOID);
     1828        HWND hwndActive;
     1829
     1830        dv[1] = ':';
     1831        dv[2] = '\\';
     1832        dv[3] = 0;
     1833        hwndActive = TopWindow(hwnd, (HWND) 0);
     1834        if (hwndActive)
     1835          WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     1836                     UM_DRIVECMD, MPFROMP(dv), MPVOID);
    17871837      }
    17881838    }
     
    18121862  case WM_MOUSEMOVE:
    18131863    if (fDrivebarHelp &&
    1814         (!hwndBubble ||
    1815         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1816         !WinQueryCapture(HWND_DESKTOP)) {
     1864        (!hwndBubble ||
     1865        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1866        !WinQueryCapture(HWND_DESKTOP)) {
    18171867      id = WinQueryWindowUShort(hwnd, QWS_ID);
    18181868      if (helpid != id) {
    1819         helpid = id;
    1820         PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
     1869        helpid = id;
     1870        PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
    18211871      }
    18221872      else
    1823         helpid = 0;
     1873        helpid = 0;
    18241874    }
    18251875    break;
     
    18281878    if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
    18291879      if ((char *)mp1 &&
    1830           (!hwndBubble ||
    1831            WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1832           !WinQueryCapture(HWND_DESKTOP)) {
    1833 
    1834         RECTL rcl;
    1835         POINTL ptl;
    1836 
    1837         WinQueryPointerPos(HWND_DESKTOP, &ptl);
    1838         WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
    1839         WinQueryWindowRect(hwnd, &rcl);
    1840         if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
    1841           BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
     1880          (!hwndBubble ||
     1881           WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1882          !WinQueryCapture(HWND_DESKTOP)) {
     1883
     1884        RECTL rcl;
     1885        POINTL ptl;
     1886
     1887        WinQueryPointerPos(HWND_DESKTOP, &ptl);
     1888        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
     1889        WinQueryWindowRect(hwnd, &rcl);
     1890        if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
     1891          BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
    18421892      }
    18431893    }
     
    18581908    *szDrv = 0;
    18591909    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1860                                        id + 50), sizeof(szDrv), szDrv);
     1910                                       id + 50), sizeof(szDrv), szDrv);
    18611911    if (isalpha(*szDrv)) {
    18621912      hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
    18631913      if (hwndMenu) {
    1864         BOOL rdy;
    1865         CHAR chDrv = *szDrv;
    1866         UINT iDrv;
    1867 
    1868         strcpy(szDrv + 2, "\\");
    1869         MakeValidDir(szDrv);
    1870         // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
    1871         rdy = toupper(*szDrv) == toupper(chDrv);
    1872         iDrv = toupper(*szDrv) - 'A';
    1873         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    1874           WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
    1875 
    1876         if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
    1877           WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
    1878           WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
    1879           WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
    1880           WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
    1881         }
    1882         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
    1883           WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
    1884           WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
    1885           WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
    1886         }
    1887         if (!rdy) {
    1888           WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
    1889           WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
    1890           WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
    1891           WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
    1892           WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
    1893         }
    1894         /* fixme to be gone?
    1895           if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
    1896             WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
    1897           }
    1898         */
    1899         PopupMenu(hwnd, hwnd, hwndMenu);
     1914        BOOL rdy;
     1915        CHAR chDrv = *szDrv;
     1916        UINT iDrv;
     1917
     1918        strcpy(szDrv + 2, "\\");
     1919        MakeValidDir(szDrv);
     1920        // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
     1921        rdy = toupper(*szDrv) == toupper(chDrv);
     1922        iDrv = toupper(*szDrv) - 'A';
     1923        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
     1924          WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
     1925
     1926        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
     1927          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     1928          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     1929          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     1930          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     1931        }
     1932        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
     1933          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     1934          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     1935          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     1936        }
     1937        if (!rdy) {
     1938          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     1939          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     1940          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     1941          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     1942          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     1943        }
     1944        /* fixme to be gone?
     1945          if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     1946            WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     1947          }
     1948        */
     1949        PopupMenu(hwnd, hwnd, hwndMenu);
    19001950      }
    19011951    }
     
    19121962    *szDrv = 0;
    19131963    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1914                                        id + 50), sizeof(szDrv), szDrv);
     1964                                       id + 50), sizeof(szDrv), szDrv);
    19151965    if (isalpha(*szDrv)) {
    19161966      strcat(szDrv, "\\");
    19171967      if (!FindDirCnrByName(szDrv, TRUE))
    1918         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
     1968        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
    19191969    }
    19201970    break;
     
    19281978    *szDrv = 0;
    19291979    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1930                                        id + 50), sizeof(szDrv), szDrv);
     1980                                       id + 50), sizeof(szDrv), szDrv);
    19311981    if (isalpha(*szDrv)) {
    19321982      strcat(szDrv, "\\");
     
    19391989    *szDrv = 0;
    19401990    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1941                                        id + 50), sizeof(szDrv), szDrv);
     1991                                       id + 50), sizeof(szDrv), szDrv);
    19421992    if (isalpha(*szDrv) &&
    1943         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1993        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19441994      if (!emphasized) {
    1945         emphasized = TRUE;
    1946         DrawTargetEmphasis(hwnd, emphasized);
     1995        emphasized = TRUE;
     1996        DrawTargetEmphasis(hwnd, emphasized);
    19471997      }
    19481998      if (AcceptOneDrop(hwnd, mp1, mp2))
    1949         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     1999        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    19502000      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    19512001    }
     
    19562006    *szDrv = 0;
    19572007    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1958                                        id + 50), sizeof(szDrv), szDrv);
     2008                                       id + 50), sizeof(szDrv), szDrv);
    19592009    if (isalpha(*szDrv) &&
    1960         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2010        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19612011      if (emphasized) {
    1962         emphasized = FALSE;
    1963         DrawTargetEmphasis(hwnd, emphasized);
     2012        emphasized = FALSE;
     2013        DrawTargetEmphasis(hwnd, emphasized);
    19642014      }
    19652015    }
     
    19702020    *szDrv = 0;
    19712021    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1972                                        id + 50), sizeof(szDrv), szDrv);
     2022                                       id + 50), sizeof(szDrv), szDrv);
    19732023    if (isalpha(*szDrv) &&
    1974         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2024        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19752025      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
    19762026      return 0;
     
    19822032    *szDrv = 0;
    19832033    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1984                                        id + 50), sizeof(szDrv), szDrv);
     2034                                       id + 50), sizeof(szDrv), szDrv);
    19852035    if (isalpha(*szDrv) &&
    1986         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     2036        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19872037
    19882038      CNRDRAGINFO cnd;
     
    19912041
    19922042      if (emphasized) {
    1993         emphasized = FALSE;
    1994         DrawTargetEmphasis(hwnd, emphasized);
     2043        emphasized = FALSE;
     2044        DrawTargetEmphasis(hwnd, emphasized);
    19952045      }
    19962046      memset(&cnd, 0, sizeof(cnd));
     
    19982048      cnd.pRecord = NULL;
    19992049      li = DoFileDrop(hwnd,
    2000                       NULL,
    2001                       TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
     2050                      NULL,
     2051                      TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
    20022052      CheckPmDrgLimit(cnd.pDragInfo);
    20032053      if (li) {
    2004         strcpy(li->targetpath, szDrv);
    2005         strcat(li->targetpath, "\\");
    2006         if (li->list && li->list[0] && IsRoot(li->list[0]))
    2007           li->type = DO_LINK;
    2008         else if (fDragndropDlg && (!*li->arcname || !li->info)) {
    2009 
    2010           CHECKLIST cl;
    2011 
    2012           memset(&cl, 0, sizeof(cl));
    2013           cl.size = sizeof(cl);
    2014           cl.flags = li->type;
    2015           cl.list = li->list;
    2016           cl.cmd = li->type;
    2017           cl.prompt = li->targetpath;
    2018           li->type = WinDlgBox(HWND_DESKTOP,
    2019                                hwndMain,
    2020                                DropListProc,
    2021                                FM3ModHandle, DND_FRAME, MPFROMP(&cl));
    2022           if (li->type == DID_ERROR)
    2023                   Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
    2024                             "Drag & Drop Dialog");
    2025           if (!li->type) {
    2026             FreeListInfo(li);
    2027             return 0;
    2028           }
    2029           li->list = cl.list;
    2030           if (!li->list || !li->list[0]) {
    2031             FreeListInfo(li);
    2032             return 0;
    2033           }
    2034         }
    2035         else {
    2036           if (!WinDlgBox(HWND_DESKTOP,
    2037                         hwndMain,
    2038                         WalkDlgProc,
    2039                         FM3ModHandle,
    2040                         WALK_FRAME,
    2041                         MPFROMP(li->targetpath)) || !*li->targetpath) {
    2042             FreeListInfo(li);
    2043             return 0;
    2044           }
    2045         }
    2046         switch (li->type) {
    2047         case DND_LAUNCH:
    2048           strcat(li->targetpath, " %a");
    2049           ExecOnList(hwndMain,
    2050                      li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
    2051                      pszSrcFile, __LINE__);
    2052           FreeList(li->list);
    2053           li->list = NULL;
    2054           break;
    2055         case DO_LINK:
    2056           if (fLinkSetsIcon) {
    2057             li->type = IDM_SETICON;
    2058             action = UM_MASSACTION;
    2059           }
    2060           else
    2061             li->type = IDM_COMPARE;
    2062           break;
    2063         case DND_EXTRACT:
    2064           if (*li->targetpath && !IsFile(li->targetpath))
    2065             li->type = IDM_EXTRACT;
    2066           break;
    2067         case DND_MOVE:
    2068           li->type = IDM_MOVE;
    2069           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2070             action = UM_MASSACTION;
    2071             li->type = IDM_ARCHIVEM;
    2072           }
    2073           break;
    2074         case DND_WILDMOVE:
    2075           li->type = IDM_WILDMOVE;
    2076           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2077             action = UM_MASSACTION;
    2078             li->type = IDM_ARCHIVEM;
    2079           }
    2080           break;
    2081         case DND_OBJECT:
    2082           li->type = IDM_OBJECT;
    2083           action = UM_MASSACTION;
    2084           break;
    2085         case DND_SHADOW:
    2086           li->type = IDM_SHADOW;
    2087           action = UM_MASSACTION;
    2088           break;
    2089         case DND_COMPARE:
    2090           li->type = IDM_COMPARE;
    2091           break;
    2092         case DND_SETICON:
    2093           action = UM_MASSACTION;
    2094           li->type = IDM_SETICON;
    2095           break;
    2096         case DND_COPY:
    2097           li->type = IDM_COPY;
    2098           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2099             action = UM_MASSACTION;
    2100             li->type = IDM_ARCHIVE;
    2101           }
    2102           break;
    2103         case DND_WILDCOPY:
    2104           li->type = IDM_WILDCOPY;
    2105           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2106             action = UM_MASSACTION;
    2107             li->type = IDM_ARCHIVE;
    2108           }
    2109           break;
    2110         default:
    2111           if (*li->arcname && li->info) {
    2112             action = UM_MASSACTION;
    2113             li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
    2114               IDM_FAKEEXTRACT;
    2115           }
    2116           else if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2117             action = UM_MASSACTION;
    2118             li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
    2119           }
    2120           else
    2121             li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    2122           break;
    2123         }
    2124         if (!li->list || !li->list[0])
    2125           FreeListInfo(li);
    2126         else
    2127           WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
     2054        strcpy(li->targetpath, szDrv);
     2055        strcat(li->targetpath, "\\");
     2056        if (li->list && li->list[0] && IsRoot(li->list[0]))
     2057          li->type = DO_LINK;
     2058        else if (fDragndropDlg && (!*li->arcname || !li->info)) {
     2059
     2060          CHECKLIST cl;
     2061
     2062          memset(&cl, 0, sizeof(cl));
     2063          cl.size = sizeof(cl);
     2064          cl.flags = li->type;
     2065          cl.list = li->list;
     2066          cl.cmd = li->type;
     2067          cl.prompt = li->targetpath;
     2068          li->type = WinDlgBox(HWND_DESKTOP,
     2069                               hwndMain,
     2070                               DropListProc,
     2071                               FM3ModHandle, DND_FRAME, MPFROMP(&cl));
     2072          if (li->type == DID_ERROR)
     2073                  Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
     2074                            "Drag & Drop Dialog");
     2075          if (!li->type) {
     2076            FreeListInfo(li);
     2077            return 0;
     2078          }
     2079          li->list = cl.list;
     2080          if (!li->list || !li->list[0]) {
     2081            FreeListInfo(li);
     2082            return 0;
     2083          }
     2084        }
     2085        else {
     2086          if (!WinDlgBox(HWND_DESKTOP,
     2087                        hwndMain,
     2088                        WalkDlgProc,
     2089                        FM3ModHandle,
     2090                        WALK_FRAME,
     2091                        MPFROMP(li->targetpath)) || !*li->targetpath) {
     2092            FreeListInfo(li);
     2093            return 0;
     2094          }
     2095        }
     2096        switch (li->type) {
     2097        case DND_LAUNCH:
     2098          strcat(li->targetpath, " %a");
     2099          ExecOnList(hwndMain,
     2100                     li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
     2101                     pszSrcFile, __LINE__);
     2102          FreeList(li->list);
     2103          li->list = NULL;
     2104          break;
     2105        case DO_LINK:
     2106          if (fLinkSetsIcon) {
     2107            li->type = IDM_SETICON;
     2108            action = UM_MASSACTION;
     2109          }
     2110          else
     2111            li->type = IDM_COMPARE;
     2112          break;
     2113        case DND_EXTRACT:
     2114          if (*li->targetpath && !IsFile(li->targetpath))
     2115            li->type = IDM_EXTRACT;
     2116          break;
     2117        case DND_MOVE:
     2118          li->type = IDM_MOVE;
     2119          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2120            action = UM_MASSACTION;
     2121            li->type = IDM_ARCHIVEM;
     2122          }
     2123          break;
     2124        case DND_WILDMOVE:
     2125          li->type = IDM_WILDMOVE;
     2126          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2127            action = UM_MASSACTION;
     2128            li->type = IDM_ARCHIVEM;
     2129          }
     2130          break;
     2131        case DND_OBJECT:
     2132          li->type = IDM_OBJECT;
     2133          action = UM_MASSACTION;
     2134          break;
     2135        case DND_SHADOW:
     2136          li->type = IDM_SHADOW;
     2137          action = UM_MASSACTION;
     2138          break;
     2139        case DND_COMPARE:
     2140          li->type = IDM_COMPARE;
     2141          break;
     2142        case DND_SETICON:
     2143          action = UM_MASSACTION;
     2144          li->type = IDM_SETICON;
     2145          break;
     2146        case DND_COPY:
     2147          li->type = IDM_COPY;
     2148          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2149            action = UM_MASSACTION;
     2150            li->type = IDM_ARCHIVE;
     2151          }
     2152          break;
     2153        case DND_WILDCOPY:
     2154          li->type = IDM_WILDCOPY;
     2155          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2156            action = UM_MASSACTION;
     2157            li->type = IDM_ARCHIVE;
     2158          }
     2159          break;
     2160        default:
     2161          if (*li->arcname && li->info) {
     2162            action = UM_MASSACTION;
     2163            li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
     2164              IDM_FAKEEXTRACT;
     2165          }
     2166          else if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2167            action = UM_MASSACTION;
     2168            li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
     2169          }
     2170          else
     2171            li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
     2172          break;
     2173        }
     2174        if (!li->list || !li->list[0])
     2175          FreeListInfo(li);
     2176        else
     2177          WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
    21282178      }
    21292179      return 0;
     
    21592209    for (x = 0; x < 26; x++) {
    21602210      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    2161         if (x > 1) {
    2162           if (driveflags[x] & DRIVE_CDROM)
    2163             iconid = CDROM_ICON;
    2164           else
    2165             iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
    2166               REMOVABLE_ICON :
    2167                      (driveflags[x] & DRIVE_VIRTUAL) ?
    2168                       VIRTUAL_ICON :
    2169               (driveflags[x] & DRIVE_REMOTE) ?
    2170               REMOTE_ICON :
    2171                      (driveflags[x] & DRIVE_RAMDISK) ?
    2172                       RAMDISK_ICON :
    2173                      (driveflags[x] & DRIVE_ZIPSTREAM) ?
    2174                       ZIPSTREAM_ICON :DRIVE_ICON;
    2175         }
    2176         else
    2177           iconid = FLOPPY_ICON;
    2178         sprintf(s, "#%lu", iconid);
    2179         hwndB = WinCreateWindow(hwndT,
    2180                                 WC_DRIVEBUTTONS,
    2181                                 s,
    2182                                 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
    2183                                 0,
    2184                                 0,
    2185                                 28,
    2186                                 18,
    2187                                 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
    2188         if (!hwndB)
    2189           Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2190                      IDS_WINCREATEWINDOW);
    2191         else {
    2192           WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2193           sprintf(s, "%c:", (CHAR) x + 'A');
    2194           hwndB = WinCreateWindow(hwndT,
    2195                                   WC_STATIC,
    2196                                   s,
    2197                                   SS_TEXT | DT_LEFT | DT_VCENTER,
    2198                                   0,
    2199                                   0,
    2200                                   10,
    2201                                   18,
    2202                                   hwndT,
    2203                                   HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
    2204           if (!hwndB)
    2205             Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2206                        IDS_WINCREATEWINDOW);
    2207           else {
    2208             SetPresParams(hwndB,
    2209                           &RGBGREY,
    2210                           &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    2211             WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2212           }
    2213           y++;
    2214         }
     2211        if (x > 1) {
     2212          if (driveflags[x] & DRIVE_CDROM)
     2213            iconid = CDROM_ICON;
     2214          else
     2215            iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
     2216              REMOVABLE_ICON :
     2217                     (driveflags[x] & DRIVE_VIRTUAL) ?
     2218                      VIRTUAL_ICON :
     2219              (driveflags[x] & DRIVE_REMOTE) ?
     2220              REMOTE_ICON :
     2221                     (driveflags[x] & DRIVE_RAMDISK) ?
     2222                      RAMDISK_ICON :
     2223                     (driveflags[x] & DRIVE_ZIPSTREAM) ?
     2224                      ZIPSTREAM_ICON :DRIVE_ICON;
     2225        }
     2226        else
     2227          iconid = FLOPPY_ICON;
     2228        sprintf(s, "#%lu", iconid);
     2229        hwndB = WinCreateWindow(hwndT,
     2230                                WC_DRIVEBUTTONS,
     2231                                s,
     2232                                BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
     2233                                0,
     2234                                0,
     2235                                28,
     2236                                18,
     2237                                hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
     2238        if (!hwndB)
     2239          Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2240                     IDS_WINCREATEWINDOW);
     2241        else {
     2242          WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2243          sprintf(s, "%c:", (CHAR) x + 'A');
     2244          hwndB = WinCreateWindow(hwndT,
     2245                                  WC_STATIC,
     2246                                  s,
     2247                                  SS_TEXT | DT_LEFT | DT_VCENTER,
     2248                                  0,
     2249                                  0,
     2250                                  10,
     2251                                  18,
     2252                                  hwndT,
     2253                                  HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
     2254          if (!hwndB)
     2255            Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2256                       IDS_WINCREATEWINDOW);
     2257          else {
     2258            SetPresParams(hwndB,
     2259                          &RGBGREY,
     2260                          &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     2261            WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2262          }
     2263          y++;
     2264        }
    22152265      }
    22162266    }                                   // for
    22172267  }                                     // if drivebar
    22182268  PostMsg(WinQueryWindow(hwndT, QW_PARENT),
    2219           WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2269          WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22202270}
    22212271
     
    22332283    WinQueryWindowRect(hwndT, &rcl);
    22342284    xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
    2235                                              SV_CYSIZEBORDER) * 2) + 2);
     2285                                             SV_CYSIZEBORDER) * 2) + 2);
    22362286  }
    22372287  henum = WinBeginEnumWindows(hwndT);
     
    22422292      ctrlxsize = 28;
    22432293    WinSetWindowPos(hwndB,
    2244                     HWND_TOP,
    2245                     ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
     2294                    HWND_TOP,
     2295                    ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
    22462296    ctrlxpos += (ctrlxsize + 2);
    22472297    if (ctrlxsize == 10) {
    22482298      if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
    2249                             256 : 0)) > xwidth) {
    2250         ctrlxpos = 2;
    2251         ctrlypos += 18;
    2252         DriveLines++;
     2299                            256 : 0)) > xwidth) {
     2300        ctrlxpos = 2;
     2301        ctrlypos += 18;
     2302        DriveLines++;
    22532303      }
    22542304    }
     
    22692319
    22702320      SetPresParams(hwnd,
    2271                     &RGBGREY,
    2272                     &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
     2321                    &RGBGREY,
     2322                    &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
    22732323      return mr;
    22742324    }
     
    22802330
    22812331      cbRetLen = WinQueryPresParam(hwnd,
    2282                                    (ULONG) mp1,
    2283                                    0,
    2284                                    &AttrFound,
    2285                                    (ULONG) sizeof(AttrValue), &AttrValue, 0);
     2332                                   (ULONG) mp1,
     2333                                   0,
     2334                                   &AttrFound,
     2335                                   (ULONG) sizeof(AttrValue), &AttrValue, 0);
    22862336      if (cbRetLen) {
    2287         PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2288                 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2337        PostMsg(WinQueryWindow(hwnd, QW_PARENT),
     2338                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22892339      }
    22902340    }
     
    23032353      WinQueryWindowPos(hwndTree, &swp);
    23042354      if (!(swp.fl & SWP_MAXIMIZE))
    2305         fl |= SWP_RESTORE;
     2355        fl |= SWP_RESTORE;
    23062356      WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
    23072357    }
     
    23362386
    23372387      if (fOtherHelp) {
    2338         if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    2339             && !WinQueryCapture(HWND_DESKTOP)) {
    2340           switch (id) {
    2341           case IDM_ATTRS:
    2342             if (WinQueryWindowTextLength(hwnd))
    2343               s = GetPString(IDS_ATTRSBUTTONHELP);
    2344             break;
    2345           case IDM_INFO:
    2346             if (WinQueryWindowTextLength(hwnd))
    2347               s = GetPString(IDS_INFOBUTTONHELP);
    2348             break;
    2349           case IDM_RENAME:
    2350             if (WinQueryWindowTextLength(hwnd))
    2351               s = GetPString(IDS_NAMEBUTTONHELP);
    2352             break;
    2353           case MAIN_STATUS2:
    2354             if (!hwndE)
    2355               s = GetPString(IDS_STATUS2HELP);
    2356             break;
    2357           default:
    2358             break;
    2359           }
    2360           if (s)
    2361             MakeBubble(hwnd, FALSE, s);
    2362           else if (hwndBubble)
    2363             WinDestroyWindow(hwndBubble);
    2364         }
     2388        if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
     2389            && !WinQueryCapture(HWND_DESKTOP)) {
     2390          switch (id) {
     2391          case IDM_ATTRS:
     2392            if (WinQueryWindowTextLength(hwnd))
     2393              s = GetPString(IDS_ATTRSBUTTONHELP);
     2394            break;
     2395          case IDM_INFO:
     2396            if (WinQueryWindowTextLength(hwnd))
     2397              s = GetPString(IDS_INFOBUTTONHELP);
     2398            break;
     2399          case IDM_RENAME:
     2400            if (WinQueryWindowTextLength(hwnd))
     2401              s = GetPString(IDS_NAMEBUTTONHELP);
     2402            break;
     2403          case MAIN_STATUS2:
     2404            if (!hwndE)
     2405              s = GetPString(IDS_STATUS2HELP);
     2406            break;
     2407          default:
     2408            break;
     2409          }
     2410          if (s)
     2411            MakeBubble(hwnd, FALSE, s);
     2412          else if (hwndBubble)
     2413            WinDestroyWindow(hwndBubble);
     2414        }
    23652415      }
    23662416      switch (id) {
     
    23692419      case IDM_RENAME:
    23702420      case MAIN_STATUS2:
    2371         return CommonTextProc(hwnd, msg, mp1, mp2);
     2421        return CommonTextProc(hwnd, msg, mp1, mp2);
    23722422      default:
    2373         break;
     2423        break;
    23742424      }
    23752425    }
     
    23942444      case IDM_RENAME:
    23952445      case MAIN_STATUS2:
    2396         return CommonTextButton(hwnd, msg, mp1, mp2);
     2446        return CommonTextButton(hwnd, msg, mp1, mp2);
    23972447      default:
    2398         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    2399         break;
     2448        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     2449        break;
    24002450      }
    24012451    }
     
    24092459      id = WinQueryWindowUShort(hwnd, QWS_ID);
    24102460      if (id == MAIN_STATUS2 && hwndE)
    2411         WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2461        WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    24122462      else
    2413         return CommonTextButton(hwnd, msg, mp1, mp2);
     2463        return CommonTextButton(hwnd, msg, mp1, mp2);
    24142464    }
    24152465    break;
     
    24212471      id = WinQueryWindowUShort(hwnd, QWS_ID);
    24222472      if (id == MAIN_STATUS) {
    2423         if (SHORT2FROMMP(mp2) & KC_CTRL)
    2424           PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2425                                   FID_CLIENT),
    2426                   WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    2427         else if (hwndTree)
    2428           PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
     2473        if (SHORT2FROMMP(mp2) & KC_CTRL)
     2474          PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2475                                  FID_CLIENT),
     2476                  WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     2477        else if (hwndTree)
     2478          PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
    24292479      }
    24302480    }
     
    24392489      if (id == MAIN_STATUS2 && !hwndE) {
    24402490
    2441         SWP swp;
    2442         CHAR directory[CCHMAXPATH];
    2443         PFNWP oldproce;
    2444 
    2445         *directory = 0;
    2446         TopWindowName(hwndMain, (HWND) 0, directory);
    2447         WinQueryWindowPos(hwnd, &swp);
    2448         hwndB = WinCreateWindow(hwnd,
    2449                                 WC_BUTTON,
    2450                                 "+",
    2451                                 WS_VISIBLE | BS_PUSHBUTTON |
    2452                                 BS_NOPOINTERFOCUS,
    2453                                 swp.cx - swp.cy,
    2454                                 0,
    2455                                 swp.cy,
    2456                                 swp.cy,
    2457                                 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
    2458         if (!hwndB)
    2459           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2460         hwndE = WinCreateWindow(hwnd,
    2461                                 WC_ENTRYFIELD,
    2462                                 NULL,
    2463                                 WS_VISIBLE | ES_AUTOSCROLL,
    2464                                 0,
    2465                                 0,
    2466                                 swp.cx - swp.cy,
    2467                                 swp.cy,
    2468                                 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
    2469         if (!hwndE)
    2470           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2471         if (!hwndE || !hwndB) {
    2472           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2473           return 0;
    2474         }
    2475         WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
    2476         WinSetWindowText(hwndStatus, directory);
    2477         if (*lastcmd)
    2478           WinSetWindowText(hwndE, lastcmd);
    2479         else
    2480           WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
    2481         oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
    2482         if (oldproce)
    2483           WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
    2484         PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
    2485         PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
    2486         return 0;
     2491        SWP swp;
     2492        CHAR directory[CCHMAXPATH];
     2493        PFNWP oldproce;
     2494
     2495        *directory = 0;
     2496        TopWindowName(hwndMain, (HWND) 0, directory);
     2497        WinQueryWindowPos(hwnd, &swp);
     2498        hwndB = WinCreateWindow(hwnd,
     2499                                WC_BUTTON,
     2500                                "+",
     2501                                WS_VISIBLE | BS_PUSHBUTTON |
     2502                                BS_NOPOINTERFOCUS,
     2503                                swp.cx - swp.cy,
     2504                                0,
     2505                                swp.cy,
     2506                                swp.cy,
     2507                                hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
     2508        if (!hwndB)
     2509          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2510        hwndE = WinCreateWindow(hwnd,
     2511                                WC_ENTRYFIELD,
     2512                                NULL,
     2513                                WS_VISIBLE | ES_AUTOSCROLL,
     2514                                0,
     2515                                0,
     2516                                swp.cx - swp.cy,
     2517                                swp.cy,
     2518                                hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
     2519        if (!hwndE)
     2520          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2521        if (!hwndE || !hwndB) {
     2522          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2523          return 0;
     2524        }
     2525        WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
     2526        WinSetWindowText(hwndStatus, directory);
     2527        if (*lastcmd)
     2528          WinSetWindowText(hwndE, lastcmd);
     2529        else
     2530          WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
     2531        oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
     2532        if (oldproce)
     2533          WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
     2534        PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
     2535        PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     2536        return 0;
    24872537      }
    24882538      if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
    2489         switch (id) {
    2490         case IDM_ATTRS:
    2491           id = IDM_SORTSIZE;
    2492           break;
    2493         case IDM_INFO:
    2494           id = IDM_SORTLWDATE;
    2495           break;
    2496         case IDM_RENAME:
    2497           id = IDM_SORTFILENAME;
    2498           break;
    2499         }
     2539        switch (id) {
     2540        case IDM_ATTRS:
     2541          id = IDM_SORTSIZE;
     2542          break;
     2543        case IDM_INFO:
     2544          id = IDM_SORTLWDATE;
     2545          break;
     2546        case IDM_RENAME:
     2547          id = IDM_SORTFILENAME;
     2548          break;
     2549        }
    25002550      }
    25012551      PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2502               WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
     2552              WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
    25032553    }
    25042554    return 0;
     
    25142564      case IDM_RENAME:
    25152565      case MAIN_STATUS2:
    2516         PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
    2517         break;
     2566        PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
     2567        break;
    25182568      default:
    2519         PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
    2520         break;
     2569        PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
     2570        break;
    25212571      }
    25222572      if (id == IDM_RENAME) {
    25232573
    2524         HPS hps;
    2525 
    2526         hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    2527         if (hps) {
    2528           PaintSTextWindow(hwnd, hps);
    2529           WinEndPaint(hps);
    2530         }
    2531         return 0;
     2574        HPS hps;
     2575
     2576        hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
     2577        if (hps) {
     2578          PaintSTextWindow(hwnd, hps);
     2579          WinEndPaint(hps);
     2580        }
     2581        return 0;
    25322582      }
    25332583    }
     
    25622612  case UM_COMMAND:
    25632613    return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2564                                       FID_CLIENT), msg, mp1, mp2);
     2614                                      FID_CLIENT), msg, mp1, mp2);
    25652615
    25662616  case WM_PAINT:
     
    25752625      hps = WinBeginPaint(hwnd, (HPS)0, NULL);
    25762626      if (hps) {
    2577         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
    2578         WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
     2627        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
     2628        WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
    25792629                          sizeof(lColor), &lColor, 0);
    25802630        if (!lColor)
    25812631          lColor = CLR_PALEGRAY;
    2582         WinQueryWindowRect(hwnd, &rcl);
    2583         WinFillRect(hps, &rcl, lColor);
    2584         WinEndPaint(hps);
     2632        WinQueryWindowRect(hwnd, &rcl);
     2633        WinFillRect(hps, &rcl, lColor);
     2634        WinEndPaint(hps);
    25852635      }
    25862636
     
    26012651      tool = find_tool(id);
    26022652      if (tool) {
    2603         del_tool(tool);
    2604         WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
    2605         if (fToolTitles)
    2606           WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
     2653        del_tool(tool);
     2654        WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
     2655        if (fToolTitles)
     2656          WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
    26072657        ResizeTools(hwnd);
    26082658        save_tools(NULL);
     
    26202670
    26212671      id = (USHORT) WinDlgBox(HWND_DESKTOP,
    2622                               hwnd,
    2623                               AddToolProc,
    2624                               FM3ModHandle, ADDBTN_FRAME, MPVOID);
     2672                              hwnd,
     2673                              AddToolProc,
     2674                              FM3ModHandle, ADDBTN_FRAME, MPVOID);
    26252675      if (id && id != (USHORT) - 1)
    2626         WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2627                                    FID_CLIENT),
    2628                    WM_COMMAND,
    2629                    MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
     2676        WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2677                                   FID_CLIENT),
     2678                   WM_COMMAND,
     2679                   MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
    26302680    }
    26312681    break;
     
    26332683  case WM_CONTEXTMENU:
    26342684    if (WinDlgBox(HWND_DESKTOP,
    2635                   hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
     2685                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    26362686      PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
    26372687    return MRFROMSHORT(TRUE);
     
    26562706  if (pswp) {
    26572707    if (WinQueryWindowPos(hwndTree, &swp) &&
    2658         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
     2708        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
    26592709      pswp->x = swp.cx;
    26602710      pswp->cx -= swp.cx;
     
    26632713  if (prectl) {
    26642714    if (WinQueryWindowPos(hwndTree, &swp) &&
    2665         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
    2666         WinQueryWindowRect(hwndTree, &rectl)) {
     2715        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
     2716        WinQueryWindowRect(hwndTree, &rectl)) {
    26672717      prectl->xLeft = rectl.xRight;
    26682718      prectl->xRight -= rectl.xRight;
     
    27162766    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    27172767      if (swp.x < swpT.cx) {
    2718         swp.x = swpT.cx;
    2719         if (swp.x + swp.cx > swpC.cx)
    2720           swp.cx = swpC.cx - swp.x;
    2721         if (swp.cx > 24)
    2722           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    2723                           SWP_SIZE | SWP_MOVE | SWP_SHOW);
     2768        swp.x = swpT.cx;
     2769        if (swp.x + swp.cx > swpC.cx)
     2770          swp.cx = swpC.cx - swp.x;
     2771        if (swp.cx > 24)
     2772          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     2773                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
    27242774      }
    27252775    }
     
    27412791      WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    27422792      WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    2743                       SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
     2793                      SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
    27442794    }
    27452795  }
     
    27632813    if (hwndNext) {
    27642814      if (!WinQueryWindowUShort(hwndNext, QWS_ID))
    2765         continue;
     2815        continue;
    27662816      if (next)
    2767         break;
     2817        break;
    27682818      if (hwndNext == hwndActive) {
    2769         if (!previous && hwndPrev) {
    2770           hwndNext = hwndPrev;
    2771           break;
    2772         }
    2773         else if (previous)
    2774           next = TRUE;
     2819        if (!previous && hwndPrev) {
     2820          hwndNext = hwndPrev;
     2821          break;
     2822        }
     2823        else if (previous)
     2824          next = TRUE;
    27752825      }
    27762826      hwndPrev = hwndNext;
     
    27782828    else {
    27792829      if ((!next && previous) || once)
    2780         break;
     2830        break;
    27812831      else if (!previous) {
    2782         hwndNext = hwndPrev;
    2783         break;
     2832        hwndNext = hwndPrev;
     2833        break;
    27842834      }
    27852835      else
    2786         once = next = TRUE;
     2836        once = next = TRUE;
    27872837    }
    27882838  }
     
    27912841  if (hwndNext && hwndNext != hwndActive) {
    27922842    WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
    2793                     SWP_ZORDER | SWP_ACTIVATE);
     2843                    SWP_ZORDER | SWP_ACTIVATE);
    27942844    WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
    2795                     0, 0, SWP_ZORDER);
     2845                    0, 0, SWP_ZORDER);
    27962846  }
    27972847}
     
    28082858    if (hwndChild != hwndTree) {
    28092859      WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2810                 WM_SAVEAPPLICATION, MPVOID, MPVOID);
     2860                WM_SAVEAPPLICATION, MPVOID, MPVOID);
    28112861      if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2812                      WM_CLOSE, MPVOID, MPVOID)) {
    2813         ret = TRUE;
    2814         break;
     2862                     WM_CLOSE, MPVOID, MPVOID)) {
     2863        ret = TRUE;
     2864        break;
    28152865      }
    28162866    }
     
    28352885      hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
    28362886      if (hwndTemp) {
    2837         hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
    2838         if (hwndDir) {
    2839           WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2840                      WM_CLOSE, MPVOID, MPVOID);
    2841           ret = TRUE;
    2842         }
     2887        hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
     2888        if (hwndDir) {
     2889          WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
     2890                     WM_CLOSE, MPVOID, MPVOID);
     2891          ret = TRUE;
     2892        }
    28432893      }
    28442894    }
     
    28982948      hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
    28992949      if (hwndC) {
    2900         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    2901         if (hwndDir) {
    2902           WinQueryWindowPos(hwndChild, &swp);
    2903           *szDir = 0;
    2904           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
    2905           if (*szDir) {
    2906            // If saving shutdown state skip no prescan drives
    2907             if (fIsShutDownState &&
    2908                 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    2909               continue;
    2910             }
    2911             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2912             PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    2913                                 sizeof(SWP));
    2914             dcd =
    2915               WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2916             if (dcd) {
    2917               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2918               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2919                                   sizeof(INT));
    2920               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2921               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2922                                   sizeof(MASK));
    2923               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    2924               flWindowAttr = dcd->flWindowAttr;
    2925               if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
    2926                 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    2927                 if (dcd->lastattr) {
    2928                   if (dcd->lastattr & CV_TEXT)
    2929                     flWindowAttr |= CV_TEXT;
    2930                   else if (dcd->lastattr & CV_DETAIL)
    2931                     flWindowAttr |= CV_DETAIL;
    2932                   else if (dcd->lastattr & CV_ICON)
    2933                     flWindowAttr |= CV_ICON;
    2934                   else
    2935                     flWindowAttr |= CV_NAME;
    2936                 }
    2937                 else
    2938                   flWindowAttr |= CV_NAME;
    2939               }
    2940               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    2941                                   sizeof(ULONG));
    2942               sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
    2943               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
    2944                                   sizeof(BOOL));
    2945               sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
    2946               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
    2947                                   sizeof(BOOL));
    2948               sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
    2949               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
    2950                                   sizeof(BOOL));
    2951               sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
    2952               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
    2953                                   sizeof(BOOL));
    2954               sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
    2955               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
    2956                                   sizeof(BOOL));
    2957               sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
    2958               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
    2959                                   sizeof(BOOL));
    2960               sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
    2961               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
    2962                                   sizeof(BOOL));
    2963               sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
    2964               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
    2965                                   sizeof(BOOL));
    2966               sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
    2967               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
    2968                                   sizeof(BOOL));
    2969               sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
    2970               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
    2971                                   sizeof(BOOL));
    2972               sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
    2973               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
    2974                                   sizeof(BOOL));
    2975               sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
    2976               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
    2977                                   sizeof(BOOL));
    2978               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2979               SavePresParams(hwndDir, szKey);
    2980             }
    2981             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    2982             PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    2983           }
    2984         }
     2950        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     2951        if (hwndDir) {
     2952          WinQueryWindowPos(hwndChild, &swp);
     2953          *szDir = 0;
     2954          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
     2955          if (*szDir) {
     2956           // If saving shutdown state skip no prescan drives
     2957            if (fIsShutDownState &&
     2958                driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     2959              continue;
     2960            }
     2961            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2962            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
     2963                                sizeof(SWP));
     2964            dcd =
     2965              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
     2966            if (dcd) {
     2967              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2968              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
     2969                                  sizeof(INT));
     2970              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2971              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
     2972                                  sizeof(MASK));
     2973              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2974              flWindowAttr = dcd->flWindowAttr;
     2975              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     2976                flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     2977                if (dcd->lastattr) {
     2978                  if (dcd->lastattr & CV_TEXT)
     2979                    flWindowAttr |= CV_TEXT;
     2980                  else if (dcd->lastattr & CV_DETAIL)
     2981                    flWindowAttr |= CV_DETAIL;
     2982                  else if (dcd->lastattr & CV_ICON)
     2983                    flWindowAttr |= CV_ICON;
     2984                  else
     2985                    flWindowAttr |= CV_NAME;
     2986                }
     2987                else
     2988                  flWindowAttr |= CV_NAME;
     2989              }
     2990              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2991                                  sizeof(ULONG));
     2992              sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
     2993              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
     2994                                  sizeof(BOOL));
     2995              sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
     2996              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
     2997                                  sizeof(BOOL));
     2998              sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
     2999              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
     3000                                  sizeof(BOOL));
     3001              sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
     3002              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
     3003                                  sizeof(BOOL));
     3004              sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
     3005              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
     3006                                  sizeof(BOOL));
     3007              sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
     3008              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
     3009                                  sizeof(BOOL));
     3010              sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
     3011              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
     3012                                  sizeof(BOOL));
     3013              sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
     3014              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
     3015                                  sizeof(BOOL));
     3016              sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
     3017              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
     3018                                  sizeof(BOOL));
     3019              sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
     3020              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
     3021                                  sizeof(BOOL));
     3022              sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
     3023              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
     3024                                  sizeof(BOOL));
     3025              sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
     3026              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
     3027                                  sizeof(BOOL));
     3028              sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
     3029              SavePresParams(hwndDir, szKey);
     3030            }
     3031            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     3032            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     3033          }
     3034        }
    29853035      }
    29863036    }
     
    30673117    if (hwnd) {
    30683118      if (WinQueryWindowPos(hwnd, &swp)) {
    3069         if (pswp->x > swp.cx)
    3070           pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
    3071         if (pswp->y > swp.cy)
    3072           pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
    3073         if (pswp->x + pswp->cx > swp.cx)
    3074           pswp->cx = swp.cx - pswp->x;
    3075         if (pswp->y + pswp->cy > swp.cy)
    3076           pswp->cy = swp.cy - pswp->y;
     3119        if (pswp->x > swp.cx)
     3120          pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
     3121        if (pswp->y > swp.cy)
     3122          pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
     3123        if (pswp->x + pswp->cx > swp.cx)
     3124          pswp->cx = swp.cx - pswp->x;
     3125        if (pswp->y + pswp->cy > swp.cy)
     3126          pswp->cy = swp.cy - pswp->y;
    30773127      }
    30783128    }
     
    31413191  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    31423192  if (!PrfQueryProfileData(fmprof,
    3143                            FM3Str,
    3144                            szKey,
    3145                            (PVOID) & swpO,
    3146                            &size) ||
     3193                           FM3Str,
     3194                           szKey,
     3195                           (PVOID) & swpO,
     3196                           &size) ||
    31473197      size != sizeof(SWP) || !swp.cx || !swp.cy)
    31483198  {
     
    31723222      swp.fl &= (~SWP_ACTIVATE);
    31733223      WinSetWindowPos(hwndTree,
    3174                       HWND_TOP,
    3175                       swp.x,
    3176                       swp.y,
    3177                       swp.cx,
    3178                       swp.cy,
    3179                       swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     3224                      HWND_TOP,
     3225                      swp.x,
     3226                      swp.y,
     3227                      swp.cx,
     3228                      swp.cy,
     3229                      swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    31803230    }
    31813231    else {
    31823232      WinSetWindowPos(hwndTree,
    3183                       HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3233                      HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    31843234      WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
    31853235      WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
     
    31913241  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    31923242  if (PrfQueryProfileData(fmprof,
    3193                           FM3Str, szKey, (PVOID) & numsaves, &size)) {
     3243                          FM3Str, szKey, (PVOID) & numsaves, &size)) {
    31943244    if (fDeleteState)
    31953245      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     
    31983248      size = sizeof(SWP);
    31993249      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3200         if (fDeleteState)
    3201           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3202         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    3203         size = sizeof(szDir);
    3204         if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    3205           // If restoring shutdown state and drive marked no prescan
    3206           // bypass window restore
    3207           if (fIsShutDownState &&
    3208               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3209             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3210             continue;
    3211           }
    3212           if (fDeleteState)
    3213             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3214           localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
    3215           size = sizeof(BOOL);
    3216           sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
    3217           if (PrfQueryProfileData(fmprof,
    3218                                   FM3Str,
    3219                                   szKey,
    3220                                   (PVOID)&localdcd.ds.detailslongname,
    3221                                   &size) &&
    3222               size == sizeof(BOOL))
    3223           {
    3224             if (fDeleteState)
    3225               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3226           }
    3227           localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
    3228           size = sizeof(BOOL);
    3229           sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
    3230           if (PrfQueryProfileData(fmprof,
    3231                                   FM3Str,
    3232                                   szKey,
    3233                                   (PVOID)&localdcd.ds.detailssubject,
    3234                                   &size) &&
    3235               size == sizeof(BOOL))
    3236           {
    3237             if (fDeleteState)
    3238               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3239           }
    3240           localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
    3241           size = sizeof(BOOL);
    3242           sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
    3243           if (PrfQueryProfileData(fmprof,
    3244                                   FM3Str,
    3245                                   szKey,
    3246                                   (PVOID) & localdcd.ds.detailsea,
    3247                                   &size) &&
    3248               size == sizeof(BOOL))
    3249           {
    3250             if (fDeleteState)
    3251               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3252           }
    3253           localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
    3254           size = sizeof(BOOL);
    3255           sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
    3256           if (PrfQueryProfileData(fmprof,
    3257                                   FM3Str,
    3258                                   szKey,
    3259                                   (PVOID) & localdcd.ds.detailssize,
    3260                                   &size) &&
    3261               size == sizeof(BOOL))
    3262           {
    3263             if (fDeleteState)
    3264               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3265           }
    3266           localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
    3267           size = sizeof(BOOL);
    3268           sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
    3269           if (PrfQueryProfileData(fmprof,
    3270                                   FM3Str,
    3271                                   szKey,
    3272                                   (PVOID) & localdcd.ds.detailsicon,
    3273                                   &size) &&
    3274               size == sizeof(BOOL))
    3275           {
    3276             if (fDeleteState)
    3277               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3278           }
    3279           localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
    3280           size = sizeof(BOOL);
    3281           sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
    3282           if (PrfQueryProfileData(fmprof,
    3283                                   FM3Str,
    3284                                   szKey,
    3285                                   (PVOID)&localdcd.ds.detailsattr,
    3286                                   &size) &&
    3287               size == sizeof(BOOL))
    3288           {
    3289             if (fDeleteState)
    3290               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3291           }
    3292           localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
    3293           size = sizeof(BOOL);
    3294           sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
    3295           if (PrfQueryProfileData(fmprof,
    3296                                   FM3Str,
    3297                                   szKey,
    3298                                   (PVOID) & localdcd.ds.detailscrdate,
    3299               &size) && size == sizeof(BOOL))
    3300           {
    3301             if (fDeleteState)
    3302               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3303           }
    3304           localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
    3305           size = sizeof(BOOL);
    3306           sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
    3307           if (PrfQueryProfileData(fmprof,
    3308                                   FM3Str,
    3309                                   szKey,
    3310                                   (PVOID)&localdcd.ds.detailscrtime,
    3311                                   &size) &&
    3312               size == sizeof(BOOL))
    3313           {
    3314             if (fDeleteState)
    3315               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3316           }
    3317           localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
    3318           size = sizeof(BOOL);
    3319           sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
    3320           if (PrfQueryProfileData(fmprof,
    3321                                   FM3Str,
    3322                                   szKey,
    3323                                   (PVOID) & localdcd.ds.detailslwdate,
    3324                                   &size) &&
    3325               size == sizeof(BOOL))
    3326           {
    3327             if (fDeleteState)
    3328               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3329           }
    3330           localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
    3331           size = sizeof(BOOL);
    3332           sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
    3333           if (PrfQueryProfileData(fmprof,
    3334                                   FM3Str,
    3335                                   szKey,
    3336                                   (PVOID) & localdcd.ds.detailslwtime,
    3337                                   &size) &&
    3338               size == sizeof(BOOL))
    3339           {
    3340             if (fDeleteState)
    3341               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3342           }
    3343           localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
    3344           size = sizeof(BOOL);
    3345           sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
    3346           if (PrfQueryProfileData(fmprof,
    3347                                   FM3Str,
    3348                                   szKey,
    3349                                   (PVOID) & localdcd.ds.detailsladate,
    3350                                   &size) &&
    3351               size == sizeof(BOOL))
    3352           {
    3353             if (fDeleteState)
    3354               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3355           }
    3356           localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
    3357           size = sizeof(BOOL);
    3358           sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
    3359           if (PrfQueryProfileData(fmprof,
    3360                                   FM3Str,
    3361                                   szKey,
    3362                                   (PVOID) & localdcd.ds.detailslatime,
    3363                                   &size) &&
    3364               size == sizeof(BOOL))
    3365           {
    3366             if (fDeleteState)
    3367               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3368           }
    3369           hwndDir = (HWND) WinSendMsg(hwndClient,
    3370                                       UM_SETDIR,
    3371                                       MPFROMP(szDir), MPFROMLONG(1));
    3372           if (hwndDir) {
    3373             hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
    3374             if (hwndC) {
    3375               HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
    3376               if (!hwndPPSave) {
    3377                 hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
    3378                                              WC_CONTAINER,
    3379                                              NULL,
    3380                                              CCS_AUTOPOSITION | CCS_MINIICONS |
    3381                                              CCS_MINIRECORDCORE | ulCnrType |
    3382                                              WS_VISIBLE,
    3383                                              0,
    3384                                              0,
    3385                                              0,
    3386                                              0,
    3387                                              hwndCnr,
    3388                                              HWND_TOP, (ULONG) -1, NULL, NULL);
    3389                 CopyPresParams(hwndPPSave, hwndC);
    3390                 RestorePresParams(hwndPPSave, "DirCnr");
    3391               }
    3392               sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3393               RestorePresParams(hwndCnr, szKey);
    3394               dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    3395               if (dcd) {
    3396                 dcd->ds.detailslongname = localdcd.ds.detailslongname;
    3397                 dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
    3398                 dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
    3399                 dcd->ds.detailsea       = localdcd.ds.detailsea      ;
    3400                 dcd->ds.detailssize     = localdcd.ds.detailssize    ;
    3401                 dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
    3402                 dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
    3403                 dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
    3404                 dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
    3405                 dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
    3406                 dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
    3407                 dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
    3408                 size = sizeof(INT);
    3409                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    3410                 if (PrfQueryProfileData(fmprof,
    3411                                         FM3Str,
    3412                                         szKey,
    3413                                         (PVOID) & dcd->sortFlags,
    3414                                         &size) && size == sizeof(INT)) {
    3415                   if (!dcd->sortFlags)
    3416                     dcd->sortFlags = SORT_PATHNAME;
    3417                 }
    3418                 if (fDeleteState)
    3419                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3420                 size = sizeof(MASK);
    3421                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    3422                 if (PrfQueryProfileData(fmprof,
    3423                                         FM3Str,
    3424                                         szKey,
    3425                                         (PVOID) & dcd->mask, &size) && size) {
    3426                   if (*dcd->mask.szMask)
    3427                     WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3428                                UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
    3429                 }
    3430                 *(dcd->mask.prompt) = 0;
    3431                 if (fDeleteState)
    3432                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3433                 size = sizeof(ULONG);
    3434                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    3435                 if (!noview) {
    3436                   if (PrfQueryProfileData(fmprof,
    3437                                           FM3Str,
    3438                                           szKey,
    3439                                           (PVOID) & dcd->flWindowAttr,
    3440                                           &size) && size == sizeof(ULONG)) {
    3441 
    3442                     CNRINFO cnri;
    3443 
    3444                     memset(&cnri, 0, sizeof(CNRINFO));
    3445                     cnri.cb = sizeof(CNRINFO);
    3446                     if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3447                                    CM_QUERYCNRINFO,
    3448                                    MPFROMP(&cnri),
    3449                                    MPFROMLONG(sizeof(CNRINFO)))) {
    3450                       cnri.flWindowAttr = dcd->flWindowAttr;
    3451                       WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3452                                 CM_SETCNRINFO,
    3453                                 MPFROMP(&cnri),
    3454                                 MPFROMLONG(CMA_FLWINDOWATTR));
    3455                     }
    3456                   }
    3457                 }
    3458                 if (fDeleteState)
    3459                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3460                   if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    3461                     WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
    3462               }
    3463             }
    3464             fRestored = TRUE;
    3465             swp.hwnd = hwndDir;
    3466             TransformSwp(&swp, xtrans, ytrans);
    3467             if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3468               WinSetWindowPos(hwndDir,
    3469                               HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    3470               WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
    3471               WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
    3472               WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
    3473               WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
    3474             } else
    3475               WinSetWindowPos(hwndDir,
    3476                               HWND_TOP,
    3477                               swp.x,
    3478                               swp.y,
    3479                               swp.cx,
    3480                               swp.cy,
    3481                               swp.fl | SWP_MOVE |
    3482                               SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
    3483                               SWP_ACTIVATE);
    3484           }
    3485         }
     3250        if (fDeleteState)
     3251          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3252        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3253        size = sizeof(szDir);
     3254        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     3255          // If restoring shutdown state and drive marked no prescan
     3256          // bypass window restore
     3257          if (fIsShutDownState &&
     3258              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     3259            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3260            continue;
     3261          }
     3262          if (fDeleteState)
     3263            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3264          localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
     3265          size = sizeof(BOOL);
     3266          sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
     3267          if (PrfQueryProfileData(fmprof,
     3268                                  FM3Str,
     3269                                  szKey,
     3270                                  (PVOID)&localdcd.ds.detailslongname,
     3271                                  &size) &&
     3272              size == sizeof(BOOL))
     3273          {
     3274            if (fDeleteState)
     3275              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3276          }
     3277          localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
     3278          size = sizeof(BOOL);
     3279          sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
     3280          if (PrfQueryProfileData(fmprof,
     3281                                  FM3Str,
     3282                                  szKey,
     3283                                  (PVOID)&localdcd.ds.detailssubject,
     3284                                  &size) &&
     3285              size == sizeof(BOOL))
     3286          {
     3287            if (fDeleteState)
     3288              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3289          }
     3290          localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
     3291          size = sizeof(BOOL);
     3292          sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
     3293          if (PrfQueryProfileData(fmprof,
     3294                                  FM3Str,
     3295                                  szKey,
     3296                                  (PVOID) & localdcd.ds.detailsea,
     3297                                  &size) &&
     3298              size == sizeof(BOOL))
     3299          {
     3300            if (fDeleteState)
     3301              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3302          }
     3303          localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
     3304          size = sizeof(BOOL);
     3305          sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
     3306          if (PrfQueryProfileData(fmprof,
     3307                                  FM3Str,
     3308                                  szKey,
     3309                                  (PVOID) & localdcd.ds.detailssize,
     3310                                  &size) &&
     3311              size == sizeof(BOOL))
     3312          {
     3313            if (fDeleteState)
     3314              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3315          }
     3316          localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
     3317          size = sizeof(BOOL);
     3318          sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
     3319          if (PrfQueryProfileData(fmprof,
     3320                                  FM3Str,
     3321                                  szKey,
     3322                                  (PVOID) & localdcd.ds.detailsicon,
     3323                                  &size) &&
     3324              size == sizeof(BOOL))
     3325          {
     3326            if (fDeleteState)
     3327              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3328          }
     3329          localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
     3330          size = sizeof(BOOL);
     3331          sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
     3332          if (PrfQueryProfileData(fmprof,
     3333                                  FM3Str,
     3334                                  szKey,
     3335                                  (PVOID)&localdcd.ds.detailsattr,
     3336                                  &size) &&
     3337              size == sizeof(BOOL))
     3338          {
     3339            if (fDeleteState)
     3340              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3341          }
     3342          localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
     3343          size = sizeof(BOOL);
     3344          sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
     3345          if (PrfQueryProfileData(fmprof,
     3346                                  FM3Str,
     3347                                  szKey,
     3348                                  (PVOID) & localdcd.ds.detailscrdate,
     3349              &size) && size == sizeof(BOOL))
     3350          {
     3351            if (fDeleteState)
     3352              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3353          }
     3354          localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
     3355          size = sizeof(BOOL);
     3356          sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
     3357          if (PrfQueryProfileData(fmprof,
     3358                                  FM3Str,
     3359                                  szKey,
     3360                                  (PVOID)&localdcd.ds.detailscrtime,
     3361                                  &size) &&
     3362              size == sizeof(BOOL))
     3363          {
     3364            if (fDeleteState)
     3365              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3366          }
     3367          localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
     3368          size = sizeof(BOOL);
     3369          sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
     3370          if (PrfQueryProfileData(fmprof,
     3371                                  FM3Str,
     3372                                  szKey,
     3373                                  (PVOID) & localdcd.ds.detailslwdate,
     3374                                  &size) &&
     3375              size == sizeof(BOOL))
     3376          {
     3377            if (fDeleteState)
     3378              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3379          }
     3380          localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
     3381          size = sizeof(BOOL);
     3382          sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
     3383          if (PrfQueryProfileData(fmprof,
     3384                                  FM3Str,
     3385                                  szKey,
     3386                                  (PVOID) & localdcd.ds.detailslwtime,
     3387                                  &size) &&
     3388              size == sizeof(BOOL))
     3389          {
     3390            if (fDeleteState)
     3391              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3392          }
     3393          localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
     3394          size = sizeof(BOOL);
     3395          sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
     3396          if (PrfQueryProfileData(fmprof,
     3397                                  FM3Str,
     3398                                  szKey,
     3399                                  (PVOID) & localdcd.ds.detailsladate,
     3400                                  &size) &&
     3401              size == sizeof(BOOL))
     3402          {
     3403            if (fDeleteState)
     3404              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3405          }
     3406          localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
     3407          size = sizeof(BOOL);
     3408          sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
     3409          if (PrfQueryProfileData(fmprof,
     3410                                  FM3Str,
     3411                                  szKey,
     3412                                  (PVOID) & localdcd.ds.detailslatime,
     3413                                  &size) &&
     3414              size == sizeof(BOOL))
     3415          {
     3416            if (fDeleteState)
     3417              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3418          }
     3419          hwndDir = (HWND) WinSendMsg(hwndClient,
     3420                                      UM_SETDIR,
     3421                                      MPFROMP(szDir), MPFROMLONG(1));
     3422          if (hwndDir) {
     3423            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     3424            if (hwndC) {
     3425              HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
     3426              if (!hwndPPSave) {
     3427                hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
     3428                                             WC_CONTAINER,
     3429                                             NULL,
     3430                                             CCS_AUTOPOSITION | CCS_MINIICONS |
     3431                                             CCS_MINIRECORDCORE | ulCnrType |
     3432                                             WS_VISIBLE,
     3433                                             0,
     3434                                             0,
     3435                                             0,
     3436                                             0,
     3437                                             hwndCnr,
     3438                                             HWND_TOP, (ULONG) -1, NULL, NULL);
     3439                CopyPresParams(hwndPPSave, hwndC);
     3440                RestorePresParams(hwndPPSave, "DirCnr");
     3441              }
     3442              sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
     3443              RestorePresParams(hwndCnr, szKey);
     3444              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
     3445              if (dcd) {
     3446                dcd->ds.detailslongname = localdcd.ds.detailslongname;
     3447                dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
     3448                dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
     3449                dcd->ds.detailsea       = localdcd.ds.detailsea      ;
     3450                dcd->ds.detailssize     = localdcd.ds.detailssize    ;
     3451                dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
     3452                dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
     3453                dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
     3454                dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
     3455                dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
     3456                dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
     3457                dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
     3458                size = sizeof(INT);
     3459                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3460                if (PrfQueryProfileData(fmprof,
     3461                                        FM3Str,
     3462                                        szKey,
     3463                                        (PVOID) & dcd->sortFlags,
     3464                                        &size) && size == sizeof(INT)) {
     3465                  if (!dcd->sortFlags)
     3466                    dcd->sortFlags = SORT_PATHNAME;
     3467                }
     3468                if (fDeleteState)
     3469                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3470                size = sizeof(MASK);
     3471                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3472                if (PrfQueryProfileData(fmprof,
     3473                                        FM3Str,
     3474                                        szKey,
     3475                                        (PVOID) & dcd->mask, &size) && size) {
     3476                  if (*dcd->mask.szMask)
     3477                    WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3478                               UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
     3479                }
     3480                *(dcd->mask.prompt) = 0;
     3481                if (fDeleteState)
     3482                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3483                size = sizeof(ULONG);
     3484                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3485                if (!noview) {
     3486                  if (PrfQueryProfileData(fmprof,
     3487                                          FM3Str,
     3488                                          szKey,
     3489                                          (PVOID) & dcd->flWindowAttr,
     3490                                          &size) && size == sizeof(ULONG)) {
     3491
     3492                    CNRINFO cnri;
     3493
     3494                    memset(&cnri, 0, sizeof(CNRINFO));
     3495                    cnri.cb = sizeof(CNRINFO);
     3496                    if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3497                                   CM_QUERYCNRINFO,
     3498                                   MPFROMP(&cnri),
     3499                                   MPFROMLONG(sizeof(CNRINFO)))) {
     3500                      cnri.flWindowAttr = dcd->flWindowAttr;
     3501                      WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3502                                CM_SETCNRINFO,
     3503                                MPFROMP(&cnri),
     3504                                MPFROMLONG(CMA_FLWINDOWATTR));
     3505                    }
     3506                  }
     3507                }
     3508                if (fDeleteState)
     3509                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3510                  if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
     3511                    WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     3512              }
     3513            }
     3514            fRestored = TRUE;
     3515            swp.hwnd = hwndDir;
     3516            TransformSwp(&swp, xtrans, ytrans);
     3517            if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3518              WinSetWindowPos(hwndDir,
     3519                              HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3520              WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
     3521              WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
     3522              WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
     3523              WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
     3524            } else
     3525              WinSetWindowPos(hwndDir,
     3526                              HWND_TOP,
     3527                              swp.x,
     3528                              swp.y,
     3529                              swp.cx,
     3530                              swp.cy,
     3531                              swp.fl | SWP_MOVE |
     3532                              SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
     3533                              SWP_ACTIVATE);
     3534          }
     3535        }
    34863536      }
    34873537    } // for
     
    35123562    if (ulNumMinChildren) {
    35133563      if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
    3514         (*ulNumMinChildren)++;
     3564        (*ulNumMinChildren)++;
    35153565    }
    35163566  }
     
    35203570
    35213571VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
    3522                       ULONG * ulNumMinChildrenR)
     3572                      ULONG * ulNumMinChildrenR)
    35233573{
    35243574  register ULONG ulCnt;
     
    35843634    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    35853635      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3586         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3636        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    35873637      if (swp.x != 0)
    3588         swp.x = 0;
     3638        swp.x = 0;
    35893639      if (swp.y < 0)
    3590         swp.y = 0;
     3640        swp.y = 0;
    35913641      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3592         swp.cx = Rectl.xRight - Rectl.xLeft;
     3642        swp.cx = Rectl.xRight - Rectl.xLeft;
    35933643      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3594                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3644                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    35953645    }
    35963646  }
     
    36043654      GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
    36053655      WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3606                       SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
    3607                       SWP_ZORDER | SWP_ACTIVATE);
     3656                      SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
     3657                      SWP_ZORDER | SWP_ACTIVATE);
    36083658      ulCnt++;
    36093659    }
     
    36583708    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    36593709      if (swp.y < 0)
    3660         swp.y = 0;
     3710        swp.y = 0;
    36613711      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3662         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3712        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    36633713      if (swp.x != 0)
    3664         swp.x = 0;
     3714        swp.x = 0;
    36653715      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3666         swp.cx = Rectl.xRight - Rectl.xLeft;
     3716        swp.cx = Rectl.xRight - Rectl.xLeft;
    36673717      WinSetWindowPos(hwndTree,
    3668                       HWND_TOP,
    3669                       swp.x,
    3670                       swp.y,
    3671                       swp.cx,
    3672                       swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3718                      HWND_TOP,
     3719                      swp.x,
     3720                      swp.y,
     3721                      swp.cx,
     3722                      swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    36733723      WinQueryWindowPos(hwndTree, &swp);
    36743724    }
     
    36953745
    36963746      for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
    3697         if ((ulNumRows - ulCurRow) <= ulExtraCols)
    3698           ulNumCols++;
    3699         for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
    3700           ulWidth = Rectl.xRight / ulNumCols;
    3701 
    3702           while (hwndChild) {
    3703             id = WinQueryWindowUShort(hwndChild, QWS_ID);
    3704             if (id && (id != TREE_FRAME || fFreeTree)) {
    3705               WinQueryWindowPos(hwndChild, &swp);
    3706               if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3707                 break;
    3708             }
    3709             hwndChild = WinGetNextWindow(henum);
    3710           }
    3711 
    3712           if (hwndChild) {
    3713             if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
    3714               WinGetMaxPosition(hwndChild, &swp);
    3715               WinSetWindowPos(hwndChild,
    3716                               HWND_TOP,
    3717                               swp.x,
    3718                               swp.y,
    3719                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3720               WinSetWindowUShort(hwndChild,
    3721                                 QWS_XRESTORE,
    3722                                 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
    3723               WinSetWindowUShort(hwndChild,
    3724                                 QWS_YRESTORE,
    3725                                 (USHORT) (Rectl.yTop -
    3726                                            (ulHeight * (ulCurRow + 1))));
    3727               WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    3728               WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
    3729             }
    3730             else
    3731               WinSetWindowPos(hwndChild,
    3732                               HWND_TOP,
    3733                               (ulWidth * ulCurCol) + Rectl.xLeft,
    3734                               Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    3735                               ulWidth,
    3736                               ulHeight,
    3737                               SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    3738             hwndChild = WinGetNextWindow(henum);
    3739           }
    3740         }
    3741         if ((ulNumRows - ulCurRow) <= ulExtraCols) {
    3742           ulNumCols--;
    3743           ulExtraCols--;
    3744         }
     3747        if ((ulNumRows - ulCurRow) <= ulExtraCols)
     3748          ulNumCols++;
     3749        for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
     3750          ulWidth = Rectl.xRight / ulNumCols;
     3751
     3752          while (hwndChild) {
     3753            id = WinQueryWindowUShort(hwndChild, QWS_ID);
     3754            if (id && (id != TREE_FRAME || fFreeTree)) {
     3755              WinQueryWindowPos(hwndChild, &swp);
     3756              if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3757                break;
     3758            }
     3759            hwndChild = WinGetNextWindow(henum);
     3760          }
     3761
     3762          if (hwndChild) {
     3763            if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
     3764              WinGetMaxPosition(hwndChild, &swp);
     3765              WinSetWindowPos(hwndChild,
     3766                              HWND_TOP,
     3767                              swp.x,
     3768                              swp.y,
     3769                              swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3770              WinSetWindowUShort(hwndChild,
     3771                                QWS_XRESTORE,
     3772                                (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
     3773              WinSetWindowUShort(hwndChild,
     3774                                QWS_YRESTORE,
     3775                                (USHORT) (Rectl.yTop -
     3776                                           (ulHeight * (ulCurRow + 1))));
     3777              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
     3778              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     3779            }
     3780            else
     3781              WinSetWindowPos(hwndChild,
     3782                              HWND_TOP,
     3783                              (ulWidth * ulCurCol) + Rectl.xLeft,
     3784                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
     3785                              ulWidth,
     3786                              ulHeight,
     3787                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3788            hwndChild = WinGetNextWindow(henum);
     3789          }
     3790        }
     3791        if ((ulNumRows - ulCurRow) <= ulExtraCols) {
     3792          ulNumCols--;
     3793          ulExtraCols--;
     3794        }
    37453795      }
    37463796    }
     
    37523802
    37533803static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
    3754                            SHORT newcx, SHORT newcy)
     3804                           SHORT newcx, SHORT newcy)
    37553805{
    37563806  /*
     
    37703820    while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
    37713821      if (!WinQueryWindowUShort(hwndChild, QWS_ID))
    3772         continue;
     3822        continue;
    37733823      if (WinQueryWindowPos(hwndChild, &swp)) {
    3774         if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
    3775           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3776           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3777           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3778           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3779         }
    3780         else if (swp.fl & SWP_MAXIMIZE) {
    3781           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3782           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3783           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3784           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3785         }
    3786         cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
    3787         cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
    3788         x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
    3789         y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
    3790         if (x < 0)
    3791           x = 0;
    3792         if (y < 0)
    3793           y = 0;
    3794         ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
    3795         uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
    3796         ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
    3797         ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
    3798         if (ux + ucx > newcx)
    3799           ucx = newcx - ux;
    3800         if (uy + ucy > newcy)
    3801           ucy = newcy - uy;
    3802 
    3803         if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
    3804           WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
    3805                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3806         else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3807           WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
    3808           WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    3809           WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    3810                           SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
    3811           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3812           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3813           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3814           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3815         }
    3816         else {
    3817           WinGetMaxPosition(hwndChild, &swp);
    3818           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3819                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3820           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3821           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3822           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3823           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3824         }
     3824        if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
     3825          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3826          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3827          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3828          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3829        }
     3830        else if (swp.fl & SWP_MAXIMIZE) {
     3831          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3832          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3833          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3834          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3835        }
     3836        cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
     3837        cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
     3838        x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
     3839        y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
     3840        if (x < 0)
     3841          x = 0;
     3842        if (y < 0)
     3843          y = 0;
     3844        ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
     3845        uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
     3846        ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
     3847        ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
     3848        if (ux + ucx > newcx)
     3849          ucx = newcx - ux;
     3850        if (uy + ucy > newcy)
     3851          ucy = newcy - uy;
     3852
     3853        if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
     3854          WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
     3855                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3856        else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3857          WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
     3858          WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
     3859          WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
     3860                          SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
     3861          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3862          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3863          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3864          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3865        }
     3866        else {
     3867          WinGetMaxPosition(hwndChild, &swp);
     3868          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     3869                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3870          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3871          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3872          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3873          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3874        }
    38253875      }
    38263876    }
     
    38383888
    38393889      if (!fNoTreeGap) {
    3840         INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    3841         if (swp.y < height)
    3842           swp.y = height;        // Force bottom to position
     3890        INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     3891        if (swp.y < height)
     3892          swp.y = height;        // Force bottom to position
    38433893      }
    38443894      else
    3845         swp.y = 0;                // Force bottom to position
     3895        swp.y = 0;                // Force bottom to position
    38463896
    38473897      swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    38483898      if (swp.cy < 0)
    3849         swp.cy = 0;
     3899        swp.cy = 0;
    38503900
    38513901      if (swp.x != 0)
    3852         swp.x = 0;                // Left align
     3902        swp.x = 0;                // Left align
    38533903
    38543904      // AdjustSizeOfClient can return bogus xRight values - fixme someday
    38553905      if (Rectl.xRight >= Rectl.xLeft) {
    3856         if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3857           swp.cx = Rectl.xRight - Rectl.xLeft;
     3906        if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
     3907          swp.cx = Rectl.xRight - Rectl.xLeft;
    38583908      }
    38593909      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3860                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3910                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    38613911    }
    38623912  }
     
    38863936
    38873937static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
    3888                                              ULONG msg,
    3889                                              MPARAM mp1, MPARAM mp2)
     3938                                             ULONG msg,
     3939                                             MPARAM mp1, MPARAM mp2)
    38903940{
    38913941  USHORT id;
     
    39013951    if (fOtherHelp) {
    39023952      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    3903           && !WinQueryCapture(HWND_DESKTOP)) {
    3904         id = WinQueryWindowUShort(hwnd, QWS_ID);
    3905         switch (id) {
    3906         case IDM_OPENWALK:
    3907           MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
    3908           break;
    3909         case IDM_USERLIST:
    3910           MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
    3911           break;
    3912         }
     3953          && !WinQueryCapture(HWND_DESKTOP)) {
     3954        id = WinQueryWindowUShort(hwnd, QWS_ID);
     3955        switch (id) {
     3956        case IDM_OPENWALK:
     3957          MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
     3958          break;
     3959        case IDM_USERLIST:
     3960          MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
     3961          break;
     3962        }
    39133963      }
    39143964    }
     
    39243974      switch (id) {
    39253975      case IDM_OPENWALK:
    3926         switch (msg) {
    3927         case WM_BUTTON2CLICK:
    3928           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3929               (KC_ALT | KC_SHIFT | KC_CTRL))
    3930             cmd = IDM_GREP;
    3931           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3932             CascadeChildren(hwndMain);
     3976        switch (msg) {
     3977        case WM_BUTTON2CLICK:
     3978          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3979              (KC_ALT | KC_SHIFT | KC_CTRL))
     3980            cmd = IDM_GREP;
     3981          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3982            CascadeChildren(hwndMain);
    39333983
    39343984#ifdef NEVER
    3935           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3936             cmd = IDM_SYSINFO;
     3985          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3986            cmd = IDM_SYSINFO;
    39373987#endif
    39383988
    3939           else if (shiftstate & KC_SHIFT)
    3940             cmd = IDM_WINDOWDLG;
    3941           else if (shiftstate & KC_CTRL)
    3942             cmd = IDM_SEEALL;
    3943           else if (shiftstate & KC_ALT)
    3944             TileChildren(hwndMain, TRUE);
    3945           else
    3946             cmd = IDM_WALKDIR;
    3947           break;
    3948         case WM_BUTTON3CLICK:
    3949           TileChildren(hwndMain, TRUE);
    3950           break;
    3951         }
    3952         break;
     3989          else if (shiftstate & KC_SHIFT)
     3990            cmd = IDM_WINDOWDLG;
     3991          else if (shiftstate & KC_CTRL)
     3992            cmd = IDM_SEEALL;
     3993          else if (shiftstate & KC_ALT)
     3994            TileChildren(hwndMain, TRUE);
     3995          else
     3996            cmd = IDM_WALKDIR;
     3997          break;
     3998        case WM_BUTTON3CLICK:
     3999          TileChildren(hwndMain, TRUE);
     4000          break;
     4001        }
     4002        break;
    39534003      case IDM_USERLIST:
    3954         switch (msg) {
    3955         case WM_BUTTON2CLICK:
    3956           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3957               (KC_ALT | KC_SHIFT | KC_CTRL))
    3958             cmd = IDM_COLORPALETTE;
    3959           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3960             cmd = IDM_HIDEMENU;
    3961           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3962             cmd = IDM_NOTEBOOK;
    3963           else if (shiftstate & KC_SHIFT)
    3964             cmd = IDM_TOOLTITLES;
    3965           else if (shiftstate & KC_CTRL)
    3966             cmd = IDM_TEXTTOOLS;
    3967           else if (shiftstate & KC_ALT)
    3968             cmd = IDM_FONTPALETTE;
    3969           else
    3970             cmd = IDM_TOOLBAR;
    3971           break;
    3972         case WM_BUTTON3CLICK:
    3973           cmd = IDM_DRIVEBAR;
    3974           break;
    3975         }
    3976         break;
     4004        switch (msg) {
     4005        case WM_BUTTON2CLICK:
     4006          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     4007              (KC_ALT | KC_SHIFT | KC_CTRL))
     4008            cmd = IDM_COLORPALETTE;
     4009          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     4010            cmd = IDM_HIDEMENU;
     4011          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     4012            cmd = IDM_NOTEBOOK;
     4013          else if (shiftstate & KC_SHIFT)
     4014            cmd = IDM_TOOLTITLES;
     4015          else if (shiftstate & KC_CTRL)
     4016            cmd = IDM_TEXTTOOLS;
     4017          else if (shiftstate & KC_ALT)
     4018            cmd = IDM_FONTPALETTE;
     4019          else
     4020            cmd = IDM_TOOLBAR;
     4021          break;
     4022        case WM_BUTTON3CLICK:
     4023          cmd = IDM_DRIVEBAR;
     4024          break;
     4025        }
     4026        break;
    39774027      }                                 // switch id
    39784028
    39794029      if (cmd) {
    3980         PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
    3981                 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
     4030        PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
     4031                WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
    39824032      }
    39834033    }
     
    39884038    if (id == IDM_OPENWALK) {
    39894039      if (!emphasized) {
    3990         emphasized = TRUE;
    3991         DrawTargetEmphasis(hwnd, emphasized);
     4040        emphasized = TRUE;
     4041        DrawTargetEmphasis(hwnd, emphasized);
    39924042      }
    39934043      if (AcceptOneDrop(hwnd, mp1, mp2))
    3994         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     4044        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    39954045    }
    39964046    return MRFROM2SHORT(DOR_NEVERDROP, 0);
     
    40124062
    40134063      if (emphasized) {
    4014         emphasized = FALSE;
    4015         DrawTargetEmphasis(hwnd, emphasized);
     4064        emphasized = FALSE;
     4065        DrawTargetEmphasis(hwnd, emphasized);
    40164066      }
    40174067      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    4018         if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
    4019           OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
    4020         }
     4068        if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
     4069          OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
     4070        }
    40214071      }
    40224072    }
     
    40314081
    40324082static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    4033                                         MPARAM mp2)
     4083                                        MPARAM mp2)
    40344084{
    40354085  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    40434093      pswp = (SWP *) mp1;
    40444094      if (fDataMin && !fAmClosing) {
    4045         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    4046 
    4047           SWP swp;
    4048 
    4049           WinQueryWindowPos(hwnd, &swp);
    4050           PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
    4051           HideNote();
    4052         }
    4053         else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    4054           if (DataHwnd)
    4055             PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
    4056         }
     4095        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
     4096
     4097          SWP swp;
     4098
     4099          WinQueryWindowPos(hwnd, &swp);
     4100          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     4101          HideNote();
     4102        }
     4103        else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
     4104          if (DataHwnd)
     4105            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     4106        }
    40574107      }
    40584108      if (!fAmClosing) {
    4059         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    4060           HideNote();
     4109        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
     4110          HideNote();
    40614111      }
    40624112    }
     
    40814131  case WM_CONTROL:
    40824132    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
    4083                       mp2);
     4133                      mp2);
    40844134
    40854135  case WM_COMMAND:
     
    41014151
    41024152      if (mr && mp2) {
    4103         prectl = (PRECTL) mp1;
    4104         if (prectl->yBottom != prectl->yTop) {
    4105           {
    4106             HPS hps;
    4107             POINTL aptl[TXTBOX_COUNT];
    4108 
    4109             hps = WinGetPS(hwndStatus);
    4110             if (hps) {
    4111               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4112               bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4113               WinReleasePS(hps);
    4114             }
    4115           }
    4116           prectl->yBottom += (sheight + 4);
    4117           prectl->yTop -= (sheight + 4);
    4118           if (fMoreButtons) {
    4119 
    4120             HPS hps;
    4121             POINTL aptl[TXTBOX_COUNT];
    4122 
    4123             hps = WinGetPS(hwndName);
    4124             if (hps) {
    4125               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4126               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4127               WinReleasePS(hps);
    4128             }
    4129             prectl->yBottom += (bheight + 4);
    4130             prectl->yTop -= (bheight + 4);
    4131           }
    4132           if (fToolbar) {
    4133             if (!fTextTools)
    4134               prectl->yTop -= ((fToolTitles) ? 50 : 40);
    4135             else
    4136               prectl->yTop -= 32;
    4137           }
    4138           if (fDrivebar) {
    4139             ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
    4140                         ((prectl->xRight -
    4141                            (WinQuerySysValue(HWND_DESKTOP,
    4142                                              SV_CYSIZEBORDER) * 2)) - 4));
    4143             prectl->yTop -= (16 * (DriveLines * 18));
    4144           }
    4145           if (fUserComboBox) {
    4146             if (!aheight) {
    4147 
    4148               SWP swpTemp;
    4149 
    4150               WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4151                                 &swpTemp);
    4152               aheight = swpTemp.cy;
    4153             }
    4154             prectl->yTop -= (aheight + 6L);
    4155           }
    4156           if (fAutoView) {
    4157             AutoviewHeight = min(AutoviewHeight,
    4158                                 (prectl->yTop - prectl->yBottom) - 116);
    4159             AutoviewHeight = max(AutoviewHeight, 36);
    4160             prectl->yBottom += (AutoviewHeight + 6);
    4161           }
    4162         }
     4153        prectl = (PRECTL) mp1;
     4154        if (prectl->yBottom != prectl->yTop) {
     4155          {
     4156            HPS hps;
     4157            POINTL aptl[TXTBOX_COUNT];
     4158
     4159            hps = WinGetPS(hwndStatus);
     4160            if (hps) {
     4161              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4162              bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4163              WinReleasePS(hps);
     4164            }
     4165          }
     4166          prectl->yBottom += (sheight + 4);
     4167          prectl->yTop -= (sheight + 4);
     4168          if (fMoreButtons) {
     4169
     4170            HPS hps;
     4171            POINTL aptl[TXTBOX_COUNT];
     4172
     4173            hps = WinGetPS(hwndName);
     4174            if (hps) {
     4175              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4176              bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4177              WinReleasePS(hps);
     4178            }
     4179            prectl->yBottom += (bheight + 4);
     4180            prectl->yTop -= (bheight + 4);
     4181          }
     4182          if (fToolbar) {
     4183            if (!fTextTools)
     4184              prectl->yTop -= ((fToolTitles) ? 50 : 40);
     4185            else
     4186              prectl->yTop -= 32;
     4187          }
     4188          if (fDrivebar) {
     4189            ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     4190                        ((prectl->xRight -
     4191                           (WinQuerySysValue(HWND_DESKTOP,
     4192                                             SV_CYSIZEBORDER) * 2)) - 4));
     4193            prectl->yTop -= (16 * (DriveLines * 18));
     4194          }
     4195          if (fUserComboBox) {
     4196            if (!aheight) {
     4197
     4198              SWP swpTemp;
     4199
     4200              WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4201                                &swpTemp);
     4202              aheight = swpTemp.cy;
     4203            }
     4204            prectl->yTop -= (aheight + 6L);
     4205          }
     4206          if (fAutoView) {
     4207            AutoviewHeight = min(AutoviewHeight,
     4208                                (prectl->yTop - prectl->yBottom) - 116);
     4209            AutoviewHeight = max(AutoviewHeight, 36);
     4210            prectl->yBottom += (AutoviewHeight + 6);
     4211          }
     4212        }
    41634213      }
    41644214      return mr;
     
    41844234      pswp = (PSWP) mp1;
    41854235      {
    4186         SHORT x;
    4187 
    4188         for (x = 0; x < soldCount; x++) {
    4189           if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
    4190             pswpClient = pswp;
    4191             break;
    4192           }
    4193           pswp++;
    4194         }
     4236        SHORT x;
     4237
     4238        for (x = 0; x < soldCount; x++) {
     4239          if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
     4240            pswpClient = pswp;
     4241            break;
     4242          }
     4243          pswp++;
     4244        }
    41954245      }
    41964246
    41974247      {
    4198         HPS hps;
    4199         POINTL aptl[TXTBOX_COUNT];
    4200 
    4201         hps = WinGetPS(hwndStatus);
    4202         if (hps) {
    4203           GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4204           bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4205           WinReleasePS(hps);
    4206         }
    4207         if (fMoreButtons) {
    4208           hps = WinGetPS(hwndName);
    4209           if (hps) {
    4210             GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4211             bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4212             WinReleasePS(hps);
    4213           }
    4214         }
     4248        HPS hps;
     4249        POINTL aptl[TXTBOX_COUNT];
     4250
     4251        hps = WinGetPS(hwndStatus);
     4252        if (hps) {
     4253          GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4254          bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4255          WinReleasePS(hps);
     4256        }
     4257        if (fMoreButtons) {
     4258          hps = WinGetPS(hwndName);
     4259          if (hps) {
     4260            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4261            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4262            WinReleasePS(hps);
     4263          }
     4264        }
    42154265      }
    42164266      pswpNew = (PSWP) mp1 + soldCount;
     
    42224272      pswpNew->y = swpClient.y + 2;
    42234273      if (!fSplitStatus)
    4224         width = swpClient.cx - (16 + (sheight * 2) + 4);
     4274        width = swpClient.cx - (16 + (sheight * 2) + 4);
    42254275      else
    4226         width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
     4276        width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
    42274277      width = max(width, 10);
    42284278      if (fSplitStatus)
    4229         pswpNew->cx = width - 6;
     4279        pswpNew->cx = width - 6;
    42304280      else
    4231         pswpNew->cx = width - 8;
     4281        pswpNew->cx = width - 8;
    42324282      pswpNew->cy = sheight;
    42334283      pswpClient->y = pswpNew->y + pswpNew->cy + 3;
     
    42364286
    42374287      if (fSplitStatus) {
    4238         pswpNew = (PSWP) mp1 + (soldCount + 1);
    4239         *pswpNew = *pswpClient;
    4240         pswpNew->hwnd = hwndStatus2;
    4241         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4242         pswpNew->x = width + 8;
    4243         pswpNew->y = swpClient.y + 2;
    4244         pswpNew->cx = width - 6;
    4245         pswpNew->cy = sheight;
    4246         sCount++;
     4288        pswpNew = (PSWP) mp1 + (soldCount + 1);
     4289        *pswpNew = *pswpClient;
     4290        pswpNew->hwnd = hwndStatus2;
     4291        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4292        pswpNew->x = width + 8;
     4293        pswpNew->y = swpClient.y + 2;
     4294        pswpNew->cx = width - 6;
     4295        pswpNew->cy = sheight;
     4296        sCount++;
    42474297      }
    42484298      else {
    4249         WinShowWindow(hwndStatus2, FALSE);
    4250         WinSetWindowText(hwndStatus2, NullStr);
     4299        WinShowWindow(hwndStatus2, FALSE);
     4300        WinSetWindowText(hwndStatus2, NullStr);
    42514301      }
    42524302
    42534303      if (fToolbar) {
    4254         if (fTextTools)
    4255           theight = 32L;
    4256         else if (!fToolTitles)
    4257           theight = 40L;
    4258         pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
    4259         *pswpNew = *pswpClient;
    4260         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
    4261         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4262         pswpNew->x = swpClient.x + 2;
    4263         pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    4264         pswpNew->cx = swpClient.cx - 4;
    4265         pswpNew->cy = theight - 4;
    4266         pswpClient->cy -= theight;
    4267         sCount++;
     4304        if (fTextTools)
     4305          theight = 32L;
     4306        else if (!fToolTitles)
     4307          theight = 40L;
     4308        pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
     4309        *pswpNew = *pswpClient;
     4310        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     4311        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4312        pswpNew->x = swpClient.x + 2;
     4313        pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
     4314        pswpNew->cx = swpClient.cx - 4;
     4315        pswpNew->cy = theight - 4;
     4316        pswpClient->cy -= theight;
     4317        sCount++;
    42684318      }
    42694319      else
    4270         WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     4320        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
    42714321
    42724322      if (fDrivebar) {
    4273         ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
    4274         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4275                                 (fSplitStatus != FALSE) +
    4276                                 (fToolbar != FALSE));
    4277         *pswpNew = *pswpClient;
    4278         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
    4279         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4280         pswpNew->x = swpClient.x + 2;
    4281         dheight += ((dheight - 2) * DriveLines);
    4282         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    4283         if (fToolbar)
    4284           pswpNew->y -= theight;
    4285         pswpNew->cx = swpClient.cx - 4;
    4286         pswpNew->cy = dheight - 4;
    4287         pswpClient->cy -= dheight;
    4288         sCount++;
     4323        ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
     4324        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4325                                (fSplitStatus != FALSE) +
     4326                                (fToolbar != FALSE));
     4327        *pswpNew = *pswpClient;
     4328        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     4329        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4330        pswpNew->x = swpClient.x + 2;
     4331        dheight += ((dheight - 2) * DriveLines);
     4332        pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
     4333        if (fToolbar)
     4334          pswpNew->y -= theight;
     4335        pswpNew->cx = swpClient.cx - 4;
     4336        pswpNew->cy = dheight - 4;
     4337        pswpClient->cy -= dheight;
     4338        sCount++;
    42894339      }
    42904340      else
    4291         WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
     4341        WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
    42924342
    42934343      if (fAutoView) {
    4294         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4295                                 (fToolbar != FALSE) +
    4296                                 (fDrivebar != FALSE) +
    4297                                 (fSplitStatus != FALSE));
    4298         *pswpNew = *pswpClient;
    4299         pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    4300         pswpNew->x = pswpClient->x + 3;
    4301         pswpNew->y = pswpClient->y + 3;
    4302         if (fMoreButtons)
    4303           pswpNew->y += (bheight + 4);
    4304         pswpNew->cx = pswpClient->cx - 6;
    4305         AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
    4306         AutoviewHeight = max(AutoviewHeight, 36);
    4307         pswpNew->cy = AutoviewHeight;
    4308         pswpClient->y += (AutoviewHeight + 6);
    4309         pswpClient->cy -= (AutoviewHeight + 6);
    4310         sCount++;
    4311         WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     4344        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4345                                (fToolbar != FALSE) +
     4346                                (fDrivebar != FALSE) +
     4347                                (fSplitStatus != FALSE));
     4348        *pswpNew = *pswpClient;
     4349        pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     4350        pswpNew->x = pswpClient->x + 3;
     4351        pswpNew->y = pswpClient->y + 3;
     4352        if (fMoreButtons)
     4353          pswpNew->y += (bheight + 4);
     4354        pswpNew->cx = pswpClient->cx - 6;
     4355        AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
     4356        AutoviewHeight = max(AutoviewHeight, 36);
     4357        pswpNew->cy = AutoviewHeight;
     4358        pswpClient->y += (AutoviewHeight + 6);
     4359        pswpClient->cy -= (AutoviewHeight + 6);
     4360        sCount++;
     4361        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
    43124362      }
    43134363      else {
    4314         WinShowWindow(hwndAutoview, FALSE);
    4315         WinShowWindow(hwndAutoMLE, FALSE);
     4364        WinShowWindow(hwndAutoview, FALSE);
     4365        WinShowWindow(hwndAutoMLE, FALSE);
    43164366      }
    43174367
    43184368      pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4319                               (fToolbar != FALSE) +
    4320                               (fDrivebar != FALSE) +
    4321                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4369                              (fToolbar != FALSE) +
     4370                              (fDrivebar != FALSE) +
     4371                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43224372      *pswpNew = *pswpClient;
    43234373      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
     
    43284378      sCount++;
    43294379      pswpNew = (PSWP) mp1 + (soldCount + 2 +
    4330                               (fToolbar != FALSE) +
    4331                               (fDrivebar != FALSE) +
    4332                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4380                              (fToolbar != FALSE) +
     4381                              (fDrivebar != FALSE) +
     4382                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43334383      *pswpNew = *pswpClient;
    43344384      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
     
    43394389      sCount++;
    43404390      pswpNew = (PSWP) mp1 + (soldCount + 3 +
    4341                               (fToolbar != FALSE) +
    4342                               (fDrivebar != FALSE) +
    4343                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4391                              (fToolbar != FALSE) +
     4392                              (fDrivebar != FALSE) +
     4393                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43444394      *pswpNew = *pswpClient;
    43454395      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
     
    43504400      sCount++;
    43514401      pswpNew = (PSWP) mp1 + (soldCount + 4 +
    4352                               (fToolbar != FALSE) +
    4353                               (fDrivebar != FALSE) +
    4354                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4402                              (fToolbar != FALSE) +
     4403                              (fDrivebar != FALSE) +
     4404                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    43554405      *pswpNew = *pswpClient;
    43564406      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     
    43614411      sCount++;
    43624412      if (fUserComboBox) {
    4363         if (!aheight) {
    4364 
    4365           SWP swpTemp;
    4366 
    4367           WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4368                             &swpTemp);
    4369           aheight = swpTemp.cy;
    4370         }
    4371         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4372                                 (fToolbar != FALSE) +
    4373                                 (fSplitStatus != FALSE) +
    4374                                 (fDrivebar != FALSE) + (fAutoView != FALSE));
    4375         *pswpNew = *pswpClient;
    4376         pswpNew->hwnd = hwndDrivelist;
    4377         pswpNew->x = swpClient.x;
    4378         pswpNew->cx = 48;
    4379         pswpClient->cy -= (aheight + 6L);
    4380         pswpNew->y = pswpClient->y;
    4381         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4382         sCount++;
    4383         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4384                                 (fToolbar != FALSE) +
    4385                                 (fDrivebar != FALSE) +
    4386                                 (fSplitStatus != FALSE) +
    4387                                 (fAutoView != FALSE));
    4388         *pswpNew = *pswpClient;
    4389         pswpNew->hwnd = hwndStatelist;
    4390         pswpNew->x = swpClient.x + 48;
    4391         pswpNew->cx = (swpClient.cx - 48) / 7;
    4392         pswpNew->y = pswpClient->y;
    4393         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4394         sCount++;
    4395         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4396                                 (fToolbar != FALSE) +
    4397                                 (fDrivebar != FALSE) +
    4398                                 (fSplitStatus != FALSE) +
    4399                                 (fAutoView != FALSE));
    4400         *pswpNew = *pswpClient;
    4401         pswpNew->hwnd = hwndCmdlist;
    4402         pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
    4403         pswpNew->cx = (swpClient.cx - 48) / 5 +
    4404           ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
    4405         pswpNew->y = pswpClient->y;
    4406         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4407         sCount++;
    4408         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4409                                 (fToolbar != FALSE) +
    4410                                 (fDrivebar != FALSE) +
    4411                                 (fSplitStatus != FALSE) +
    4412                                 (fAutoView != FALSE));
    4413         *pswpNew = *pswpClient;
    4414         pswpNew->hwnd = hwndUserlist;
    4415         pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
    4416         pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
    4417           ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
    4418         pswpNew->y = pswpClient->y;
    4419         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4420         sCount++;
    4421         if (fToolbar) {
    4422           pswpNew = (PSWP) mp1 + (soldCount + 9 +
    4423                                   (fToolbar != FALSE) +
    4424                                   (fDrivebar != FALSE) +
    4425                                   (fSplitStatus != FALSE) +
    4426                                   (fAutoView != FALSE));
    4427           *pswpNew = *pswpClient;
    4428           pswpNew->hwnd = hwndButtonlist;
    4429           pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
    4430           pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
    4431           pswpNew->y = pswpClient->y;
    4432           pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4433           sCount++;
    4434         }
    4435         else
    4436           WinShowWindow(hwndButtonlist, FALSE);
     4413        if (!aheight) {
     4414
     4415          SWP swpTemp;
     4416
     4417          WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4418                            &swpTemp);
     4419          aheight = swpTemp.cy;
     4420        }
     4421        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4422                                (fToolbar != FALSE) +
     4423                                (fSplitStatus != FALSE) +
     4424                                (fDrivebar != FALSE) + (fAutoView != FALSE));
     4425        *pswpNew = *pswpClient;
     4426        pswpNew->hwnd = hwndDrivelist;
     4427        pswpNew->x = swpClient.x;
     4428        pswpNew->cx = 48;
     4429        pswpClient->cy -= (aheight + 6L);
     4430        pswpNew->y = pswpClient->y;
     4431        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4432        sCount++;
     4433        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4434                                (fToolbar != FALSE) +
     4435                                (fDrivebar != FALSE) +
     4436                                (fSplitStatus != FALSE) +
     4437                                (fAutoView != FALSE));
     4438        *pswpNew = *pswpClient;
     4439        pswpNew->hwnd = hwndStatelist;
     4440        pswpNew->x = swpClient.x + 48;
     4441        pswpNew->cx = (swpClient.cx - 48) / 7;
     4442        pswpNew->y = pswpClient->y;
     4443        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4444        sCount++;
     4445        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4446                                (fToolbar != FALSE) +
     4447                                (fDrivebar != FALSE) +
     4448                                (fSplitStatus != FALSE) +
     4449                                (fAutoView != FALSE));
     4450        *pswpNew = *pswpClient;
     4451        pswpNew->hwnd = hwndCmdlist;
     4452        pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
     4453        pswpNew->cx = (swpClient.cx - 48) / 5 +
     4454          ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
     4455        pswpNew->y = pswpClient->y;
     4456        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4457        sCount++;
     4458        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4459                                (fToolbar != FALSE) +
     4460                                (fDrivebar != FALSE) +
     4461                                (fSplitStatus != FALSE) +
     4462                                (fAutoView != FALSE));
     4463        *pswpNew = *pswpClient;
     4464        pswpNew->hwnd = hwndUserlist;
     4465        pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
     4466        pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
     4467          ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
     4468        pswpNew->y = pswpClient->y;
     4469        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4470        sCount++;
     4471        if (fToolbar) {
     4472          pswpNew = (PSWP) mp1 + (soldCount + 9 +
     4473                                  (fToolbar != FALSE) +
     4474                                  (fDrivebar != FALSE) +
     4475                                  (fSplitStatus != FALSE) +
     4476                                  (fAutoView != FALSE));
     4477          *pswpNew = *pswpClient;
     4478          pswpNew->hwnd = hwndButtonlist;
     4479          pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
     4480          pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
     4481          pswpNew->y = pswpClient->y;
     4482          pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4483          sCount++;
     4484        }
     4485        else
     4486          WinShowWindow(hwndButtonlist, FALSE);
    44374487      }
    44384488      else {
    4439         WinShowWindow(hwndUserlist, FALSE);
    4440         WinShowWindow(hwndDrivelist, FALSE);
    4441         WinShowWindow(hwndStatelist, FALSE);
    4442         WinShowWindow(hwndButtonlist, FALSE);
    4443         WinShowWindow(hwndCmdlist, FALSE);
     4489        WinShowWindow(hwndUserlist, FALSE);
     4490        WinShowWindow(hwndDrivelist, FALSE);
     4491        WinShowWindow(hwndStatelist, FALSE);
     4492        WinShowWindow(hwndButtonlist, FALSE);
     4493        WinShowWindow(hwndCmdlist, FALSE);
    44444494      }
    44454495      {
    4446         PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
    4447         SHORT x;
    4448 
    4449         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4450                                 (fToolbar != FALSE) +
    4451                                 (fDrivebar != FALSE) +
    4452                                 (fSplitStatus != FALSE) +
    4453                                 (fAutoView != FALSE) +
    4454                                 ((fUserComboBox != FALSE) * 4) +
    4455                                 (fUserComboBox != FALSE &&
    4456                                 fToolbar != FALSE));
    4457         pswp = (PSWP) mp1;
    4458         for (x = 0; x < soldCount; x++) {
    4459           if (!pswpTitlebar &&
    4460               WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
    4461             pswpTitlebar = pswp;
    4462           else if (!pswpMinbutton &&
    4463                    WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
    4464             pswpMinbutton = pswp;
    4465           if (pswpTitlebar && pswpMinbutton)
    4466             break;
    4467           pswp++;
    4468         }
    4469         if (pswpMinbutton && pswpTitlebar) {
    4470           *pswpNew = *pswpMinbutton;
    4471           pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
    4472           pswpNew->cy = pswpMinbutton->cy + 3;
    4473           pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
    4474           pswpTitlebar->cx -= (pswpNew->cx - 1);
    4475           pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
    4476           pswpNew->y = pswpMinbutton->y - 1;
    4477           sCount++;
    4478         }
    4479         else
    4480           WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
     4496        PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
     4497        SHORT x;
     4498
     4499        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4500                                (fToolbar != FALSE) +
     4501                                (fDrivebar != FALSE) +
     4502                                (fSplitStatus != FALSE) +
     4503                                (fAutoView != FALSE) +
     4504                                ((fUserComboBox != FALSE) * 4) +
     4505                                (fUserComboBox != FALSE &&
     4506                                fToolbar != FALSE));
     4507        pswp = (PSWP) mp1;
     4508        for (x = 0; x < soldCount; x++) {
     4509          if (!pswpTitlebar &&
     4510              WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
     4511            pswpTitlebar = pswp;
     4512          else if (!pswpMinbutton &&
     4513                   WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
     4514            pswpMinbutton = pswp;
     4515          if (pswpTitlebar && pswpMinbutton)
     4516            break;
     4517          pswp++;
     4518        }
     4519        if (pswpMinbutton && pswpTitlebar) {
     4520          *pswpNew = *pswpMinbutton;
     4521          pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
     4522          pswpNew->cy = pswpMinbutton->cy + 3;
     4523          pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
     4524          pswpTitlebar->cx -= (pswpNew->cx - 1);
     4525          pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
     4526          pswpNew->y = pswpMinbutton->y - 1;
     4527          sCount++;
     4528        }
     4529        else
     4530          WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
    44814531      }
    44824532
    44834533      if (fMoreButtons) {
    44844534
    4485         LONG lastx;
    4486 
    4487         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4488                                 (fToolbar != FALSE) +
    4489                                 (fDrivebar != FALSE) +
    4490                                 (fSplitStatus != FALSE) +
    4491                                 (fAutoView != FALSE) +
    4492                                 ((fUserComboBox != FALSE) * 4) +
    4493                                 (fUserComboBox != FALSE &&
    4494                                 fToolbar != FALSE));
    4495         *pswpNew = *pswpClient;
    4496         pswpNew->hwnd = hwndName;
    4497         pswpNew->x = swpClient.x + 3;
    4498         pswpNew->y = swpClient.y + (sheight + 6);
    4499         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    4500         lastx = pswpNew->x + pswpNew->cx;
    4501         pswpNew->cy = bheight;
    4502         pswpClient->y += (bheight + 4);
    4503         pswpClient->cy -= (bheight + 4);
    4504         sCount++;
    4505         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4506                                 (fToolbar != FALSE) +
    4507                                 (fDrivebar != FALSE) +
    4508                                 (fSplitStatus != FALSE) +
    4509                                 (fAutoView != FALSE) +
    4510                                 ((fUserComboBox != FALSE) * 4) +
    4511                                 (fUserComboBox != FALSE &&
    4512                                 fToolbar != FALSE));
    4513         *pswpNew = *pswpClient;
    4514         pswpNew->hwnd = hwndDate;
    4515         pswpNew->x = lastx + 3;
    4516         pswpNew->y = swpClient.y + (sheight + 6);
    4517         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    4518         lastx = pswpNew->x + pswpNew->cx;
    4519         pswpNew->cy = bheight;
    4520         sCount++;
    4521         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4522                                 (fToolbar != FALSE) +
    4523                                 (fDrivebar != FALSE) +
    4524                                 (fSplitStatus != FALSE) +
    4525                                 (fAutoView != FALSE) +
    4526                                 ((fUserComboBox != FALSE) * 4) +
    4527                                 (fUserComboBox != FALSE &&
    4528                                 fToolbar != FALSE));
    4529         *pswpNew = *pswpClient;
    4530         pswpNew->hwnd = hwndAttr;
    4531         pswpNew->x = lastx + 3;
    4532         pswpNew->y = swpClient.y + (sheight + 6);
    4533         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    4534         pswpNew->cy = bheight;
    4535         sCount++;
     4535        LONG lastx;
     4536
     4537        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4538                                (fToolbar != FALSE) +
     4539                                (fDrivebar != FALSE) +
     4540                                (fSplitStatus != FALSE) +
     4541                                (fAutoView != FALSE) +
     4542                                ((fUserComboBox != FALSE) * 4) +
     4543                                (fUserComboBox != FALSE &&
     4544                                fToolbar != FALSE));
     4545        *pswpNew = *pswpClient;
     4546        pswpNew->hwnd = hwndName;
     4547        pswpNew->x = swpClient.x + 3;
     4548        pswpNew->y = swpClient.y + (sheight + 6);
     4549        pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     4550        lastx = pswpNew->x + pswpNew->cx;
     4551        pswpNew->cy = bheight;
     4552        pswpClient->y += (bheight + 4);
     4553        pswpClient->cy -= (bheight + 4);
     4554        sCount++;
     4555        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4556                                (fToolbar != FALSE) +
     4557                                (fDrivebar != FALSE) +
     4558                                (fSplitStatus != FALSE) +
     4559                                (fAutoView != FALSE) +
     4560                                ((fUserComboBox != FALSE) * 4) +
     4561                                (fUserComboBox != FALSE &&
     4562                                fToolbar != FALSE));
     4563        *pswpNew = *pswpClient;
     4564        pswpNew->hwnd = hwndDate;
     4565        pswpNew->x = lastx + 3;
     4566        pswpNew->y = swpClient.y + (sheight + 6);
     4567        pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     4568        lastx = pswpNew->x + pswpNew->cx;
     4569        pswpNew->cy = bheight;
     4570        sCount++;
     4571        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4572                                (fToolbar != FALSE) +
     4573                                (fDrivebar != FALSE) +
     4574                                (fSplitStatus != FALSE) +
     4575                                (fAutoView != FALSE) +
     4576                                ((fUserComboBox != FALSE) * 4) +
     4577                                (fUserComboBox != FALSE &&
     4578                                fToolbar != FALSE));
     4579        *pswpNew = *pswpClient;
     4580        pswpNew->hwnd = hwndAttr;
     4581        pswpNew->x = lastx + 3;
     4582        pswpNew->y = swpClient.y + (sheight + 6);
     4583        pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
     4584        pswpNew->cy = bheight;
     4585        sCount++;
    45364586      }
    45374587      else {
    4538         WinShowWindow(hwndAttr, FALSE);
    4539         WinShowWindow(hwndName, FALSE);
    4540         WinShowWindow(hwndDate, FALSE);
     4588        WinShowWindow(hwndAttr, FALSE);
     4589        WinShowWindow(hwndName, FALSE);
     4590        WinShowWindow(hwndDate, FALSE);
    45414591      }
    45424592      return MRFROMSHORT(sCount);
     
    45514601      sCount += 6;
    45524602      if (fSplitStatus)
    4553         sCount++;
     4603        sCount++;
    45544604      if (fToolbar)
    4555         sCount++;
     4605        sCount++;
    45564606      if (fUserComboBox) {
    4557         sCount += 4;
    4558         if (fToolbar)
    4559           sCount++;
     4607        sCount += 4;
     4608        if (fToolbar)
     4609          sCount++;
    45604610      }
    45614611      if (fDrivebar)
    4562         sCount++;
     4612        sCount++;
    45634613      if (fAutoView)
    4564         sCount++;
     4614        sCount++;
    45654615      if (fMoreButtons)
    4566         sCount += 3;
     4616        sCount += 3;
    45674617      return MRFROMSHORT(sCount);
    45684618    }
     
    45854635      // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
    45864636      if (hwnd != NULLHANDLE) {
    4587         HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
    4588         USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
    4589         switch (id) {
    4590         case MAIN_SETUPLIST:
    4591         case MAIN_USERLIST:
    4592         case MAIN_CMDLIST:
    4593           // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
    4594           WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
    4595         }
     4637        HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
     4638        USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
     4639        switch (id) {
     4640        case MAIN_SETUPLIST:
     4641        case MAIN_USERLIST:
     4642        case MAIN_CMDLIST:
     4643          // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
     4644          WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
     4645        }
    45964646      }
    45974647    }
     
    46224672      wa.size = sizeof(wa);
    46234673      pci =
    4624         (PCNRITEM)
    4625         WinSendMsg(WinWindowFromID
    4626                    (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
    4627                    CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
    4628                    MPFROMSHORT(CRA_CURSORED));
     4674        (PCNRITEM)
     4675        WinSendMsg(WinWindowFromID
     4676                   (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
     4677                   CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
     4678                   MPFROMSHORT(CRA_CURSORED));
    46294679      if (pci && (INT) pci != -1) {
    4630         strcpy(wa.szCurrentPath1, pci->pszFileName);
    4631         MakeValidDir(wa.szCurrentPath1);
     4680        strcpy(wa.szCurrentPath1, pci->pszFileName);
     4681        MakeValidDir(wa.szCurrentPath1);
    46324682      }
    46334683      else
    4634         strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
     4684        strcpy(wa.szCurrentPath1, pFM2SaveDirectory);
    46354685      TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
    46364686      if (!*wa.szCurrentPath2)
    4637         strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
     4687        strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
    46384688      MakeValidDir(wa.szCurrentPath2);
    46394689      if (WinDlgBox(HWND_DESKTOP,
    4640                     hwnd,
    4641                     WalkTwoCmpDlgProc,
    4642                     FM3ModHandle,
    4643                     WALK2_FRAME,
    4644                     MPFROMP(&wa)) &&
    4645           !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
    4646         if (!*dircompare) {
    4647 
    4648           COMPARE *cmp;
    4649 
    4650           cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    4651           if (cmp) {
    4652             cmp->size = sizeof(COMPARE);
    4653             strcpy(cmp->leftdir, wa.szCurrentPath1);
    4654             strcpy(cmp->rightdir, wa.szCurrentPath2);
    4655             cmp->hwndParent = hwnd;
    4656             cmp->dcd.hwndParent = hwnd;
    4657             WinDlgBox(HWND_DESKTOP,
    4658                       HWND_DESKTOP,
    4659                       CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    4660           }
    4661         }
    4662         else {
    4663 
    4664           CHAR szPath1[CCHMAXPATH];
    4665           CHAR szPath2[CCHMAXPATH];
    4666           runemf2(SEPARATE,
    4667                   HWND_DESKTOP, pszSrcFile, __LINE__,
    4668                   NULL, NULL,
    4669                   "%s %s %s",
    4670                   dircompare,
    4671                   BldQuotedFileName(szPath1, wa.szCurrentPath1),
    4672                   BldQuotedFileName(szPath2, wa.szCurrentPath2));
    4673         }
     4690                    hwnd,
     4691                    WalkTwoCmpDlgProc,
     4692                    FM3ModHandle,
     4693                    WALK2_FRAME,
     4694                    MPFROMP(&wa)) &&
     4695          !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
     4696        if (!*dircompare) {
     4697
     4698          COMPARE *cmp;
     4699
     4700          cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
     4701          if (cmp) {
     4702            cmp->size = sizeof(COMPARE);
     4703            strcpy(cmp->leftdir, wa.szCurrentPath1);
     4704            strcpy(cmp->rightdir, wa.szCurrentPath2);
     4705            cmp->hwndParent = hwnd;
     4706            cmp->dcd.hwndParent = hwnd;
     4707            WinDlgBox(HWND_DESKTOP,
     4708                      HWND_DESKTOP,
     4709                      CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
     4710          }
     4711        }
     4712        else {
     4713
     4714          CHAR szPath1[CCHMAXPATH];
     4715          CHAR szPath2[CCHMAXPATH];
     4716          runemf2(SEPARATE,
     4717                  HWND_DESKTOP, pszSrcFile, __LINE__,
     4718                  NULL, NULL,
     4719                  "%s %s %s",
     4720                  dircompare,
     4721                  BldQuotedFileName(szPath1, wa.szCurrentPath1),
     4722                  BldQuotedFileName(szPath2, wa.szCurrentPath2));
     4723        }
    46744724      }
    46754725    }
     
    46834733  case IDM_CLI:
    46844734    if (fSplitStatus &&
    4685         hwndStatus2 &&
    4686         !WinIsWindow(WinQueryAnchorBlock(hwnd),
    4687                      WinWindowFromID(hwndStatus2, COMMAND_LINE)))
     4735        hwndStatus2 &&
     4736        !WinIsWindow(WinQueryAnchorBlock(hwnd),
     4737                     WinWindowFromID(hwndStatus2, COMMAND_LINE)))
    46884738      PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
    46894739    break;
     
    46984748      bstrip(temp);
    46994749      if (*temp &&
    4700           !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
    4701         if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
    4702           add_udir(TRUE, path);
    4703           if (fUdirsChanged)
    4704             save_udirs();
    4705           WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4706         }
    4707         else {
    4708           if (!remove_udir(path))
    4709             Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
    4710           else {
    4711             if (fUdirsChanged)
    4712               save_udirs();
    4713             WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4714           }
    4715         }
     4750          !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
     4751        if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
     4752          add_udir(TRUE, path);
     4753          if (fUdirsChanged)
     4754            save_udirs();
     4755          WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4756        }
     4757        else {
     4758          if (!remove_udir(path))
     4759            Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
     4760          else {
     4761            if (fUdirsChanged)
     4762              save_udirs();
     4763            WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4764          }
     4765        }
    47164766      }
    47174767    }
     
    47284778      // Complain if attempting to use reserved name
    47294779      if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
    4730           stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
     4780          stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
    47314781      {
    4732         saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4733                GetPString(IDS_WARNINGTEXT),
    4734                "\"%s\" is a reserved state name", szStateName);
     4782        saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4783               GetPString(IDS_WARNINGTEXT),
     4784               "\"%s\" is a reserved state name", szStateName);
    47354785      }
    47364786      // Ignore request if blank
    47374787      else if (*szStateName) {
    4738         BOOL fAbortOperation = FALSE;
    4739         if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
    4740         {
    4741           if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
    4742               GetPString(IDS_WARNINGTEXT),
    4743               GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
    4744               fAbortOperation = TRUE;
    4745         }
    4746         if (!fAbortOperation) {
    4747           if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
    4748             // Save
    4749             INT nSaved = SaveDirCnrState(hwnd, szStateName);
    4750             if (nSaved >= 0) {
    4751               INT ret = add_setup(szStateName);
    4752               if (ret == 0) {
    4753                 WinSendMsg(hwndStatelist, LM_INSERTITEM,
    4754                            MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    4755                 save_setups();
    4756               }
    4757               else if (ret != 1) {
    4758                 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4759                        GetPString(IDS_WARNINGTEXT),
    4760                        "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    4761                 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4762               }
    4763             }
    4764             else {
    4765               saymsg(MB_ENTER | MB_ICONASTERISK,
    4766                      hwnd,
    4767                      GetPString(IDS_WARNINGTEXT),
    4768                      "State data save failed");
    4769               WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4770             }
    4771           }
    4772           else {
    4773             // Delete
    4774             ULONG numsaves = 0, size, x;
    4775             CHAR s[STATE_NAME_MAX_BYTES + 80];
    4776 
    4777             INT ret = remove_setup(szStateName);
    4778             if (ret == 1)
    4779               save_setups();
    4780             sprintf(s, "%s.NumDirsLastTime", szStateName);
    4781             size = sizeof(ULONG);
    4782             if (!PrfQueryProfileData(fmprof,
    4783                                      FM3Str,
    4784                                      s,
    4785                                      (PVOID)&numsaves,
    4786                                      &size)) {
    4787               saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4788                      GetPString(IDS_WARNINGTEXT),
    4789                      GetPString(IDS_DOESNTEXISTTEXT), szStateName);
    4790             }
    4791             else if (!size)
    4792               Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    4793             else {
    4794               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4795               for (x = 0; x < numsaves; x++) {
    4796                 sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4797                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4798                 sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4799                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4800                 sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4801                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4802                 sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4803                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4804                 sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4805                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4806                 sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
    4807                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4808                 sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
    4809                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4810                 sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
    4811                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4812                 sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
    4813                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4814                 sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
    4815                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4816                 sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
    4817                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4818                 sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
    4819                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4820                 sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
    4821                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4822                 sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
    4823                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4824                 sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
    4825                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4826                 sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
    4827                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4828                 sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
    4829                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4830                 sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
    4831                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4832                 sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
    4833                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4834               }
    4835               sprintf(s, "%s.LastTreePos", szStateName);
    4836               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4837               sprintf(s, "%s.MySizeLastTime", szStateName);
    4838               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4839             }
    4840             PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
    4841           }
    4842         }
     4788        BOOL fAbortOperation = FALSE;
     4789        if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
     4790        {
     4791          if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
     4792              GetPString(IDS_WARNINGTEXT),
     4793              GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
     4794              fAbortOperation = TRUE;
     4795        }
     4796        if (!fAbortOperation) {
     4797          if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
     4798            // Save
     4799            INT nSaved = SaveDirCnrState(hwnd, szStateName);
     4800            if (nSaved >= 0) {
     4801              INT ret = add_setup(szStateName);
     4802              if (ret == 0) {
     4803                WinSendMsg(hwndStatelist, LM_INSERTITEM,
     4804                           MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
     4805                save_setups();
     4806              }
     4807              else if (ret != 1) {
     4808                saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4809                       GetPString(IDS_WARNINGTEXT),
     4810                       "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
     4811                WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4812              }
     4813            }
     4814            else {
     4815              saymsg(MB_ENTER | MB_ICONASTERISK,
     4816                     hwnd,
     4817                     GetPString(IDS_WARNINGTEXT),
     4818                     "State data save failed");
     4819              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4820            }
     4821          }
     4822          else {
     4823            // Delete
     4824            ULONG numsaves = 0, size, x;
     4825            CHAR s[STATE_NAME_MAX_BYTES + 80];
     4826
     4827            INT ret = remove_setup(szStateName);
     4828            if (ret == 1)
     4829              save_setups();
     4830            sprintf(s, "%s.NumDirsLastTime", szStateName);
     4831            size = sizeof(ULONG);
     4832            if (!PrfQueryProfileData(fmprof,
     4833                                     FM3Str,
     4834                                     s,
     4835                                     (PVOID)&numsaves,
     4836                                     &size)) {
     4837              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4838                     GetPString(IDS_WARNINGTEXT),
     4839                     GetPString(IDS_DOESNTEXISTTEXT), szStateName);
     4840            }
     4841            else if (!size)
     4842              Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     4843            else {
     4844              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     4845              for (x = 0; x < numsaves; x++) {
     4846                sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
     4847                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4848                sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
     4849                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4850                sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
     4851                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4852                sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
     4853                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4854                sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
     4855                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4856                sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
     4857                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4858                sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
     4859                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4860                sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
     4861                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4862                sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
     4863                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4864                sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
     4865                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4866                sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
     4867                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4868                sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
     4869                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4870                sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
     4871                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4872                sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
     4873                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4874                sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
     4875                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4876                sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
     4877                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4878                sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
     4879                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4880                sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
     4881                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4882                sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
     4883                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4884              }
     4885              sprintf(s, "%s.LastTreePos", szStateName);
     4886              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4887              sprintf(s, "%s.MySizeLastTime", szStateName);
     4888              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4889            }
     4890            PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     4891          }
     4892        }
    48434893      }
    48444894    }
     
    48534903      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    48544904      if (swp.fl & SWP_MAXIMIZE) {
    4855         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
    4856                    MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    4857         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     4905        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
     4906                   MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     4907        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    48584908      }
    48594909      WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
     
    48634913      swpD.cy -= (icz + bsz);
    48644914      if (swp.x == swpD.x && swp.y == swpD.y &&
    4865           swp.cx == swpD.cx && swp.cy == swpD.cy &&
    4866           // fixme to be #defined someday
    4867           WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
    4868           WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
    4869         swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
    4870         swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
    4871         swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
    4872         swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
     4915          swp.cx == swpD.cx && swp.cy == swpD.cy &&
     4916          // fixme to be #defined someday
     4917          WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
     4918          WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
     4919        swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
     4920        swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
     4921        swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
     4922        swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
    48734923      }
    48744924      else {
    4875         WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
    4876         WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
    4877         WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
    4878         WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
     4925        WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
     4926        WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
     4927        WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
     4928        WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
    48794929      }
    48804930      WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
    4881                       swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
     4931                      swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
    48824932    }
    48834933    break;
     
    48854935  case IDM_BLINK:
    48864936    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4887                     SWP_MINIMIZE);
     4937                    SWP_MINIMIZE);
    48884938    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4889                     SWP_RESTORE | SWP_ZORDER);
     4939                    SWP_RESTORE | SWP_ZORDER);
    48904940    break;
    48914941
     
    48954945
    48964946      if (hwndTop)
    4897         WinSetFocus(HWND_DESKTOP, hwndTop);
     4947        WinSetFocus(HWND_DESKTOP, hwndTop);
    48984948    }
    48994949    break;
     
    49174967  case IDM_QUICKSETTINGS:
    49184968    WinDlgBox(HWND_DESKTOP,
    4919               hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
     4969              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
    49204970    break;
    49214971
     
    49234973  case IDM_VIEWINFS:
    49244974    WinDlgBox(HWND_DESKTOP,
    4925               HWND_DESKTOP,
    4926               ViewInfProc,
    4927               FM3ModHandle,
    4928               VINF_FRAME,
    4929               ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
    4930                MPFROMP(NullStr) : MPVOID));
     4975              HWND_DESKTOP,
     4976              ViewInfProc,
     4977              FM3ModHandle,
     4978              VINF_FRAME,
     4979              ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
     4980               MPFROMP(NullStr) : MPVOID));
    49314981    break;
    49324982
     
    49384988      TopWindowName(hwnd, (HWND) 0, newpath);
    49394989      if (WinDlgBox(HWND_DESKTOP,
    4940                     hwnd,
    4941                     WalkAllDlgProc,
    4942                     FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
    4943         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
     4990                    hwnd,
     4991                    WalkAllDlgProc,
     4992                    FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
     4993        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
    49444994    }
    49454995    break;
     
    49625012      if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    49635013
    4964         RECTL rcl;
    4965         ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
    4966 
    4967         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4968         rcl.yBottom += icz;
    4969         rcl.yTop -= icz;
    4970         rcl.xLeft += icz;
    4971         rcl.xRight -= icz;
    4972         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     5014        RECTL rcl;
     5015        ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
     5016
     5017        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     5018        rcl.yBottom += icz;
     5019        rcl.yTop -= icz;
     5020        rcl.xLeft += icz;
     5021        rcl.xRight -= icz;
     5022        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    49735023      }
    49745024      else {
    49755025
    4976         RECTL rcl;
    4977 
    4978         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4979         rcl.yBottom += 8;
    4980         rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
    4981         rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
    4982         rcl.xRight -= 8;
    4983         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     5026        RECTL rcl;
     5027
     5028        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     5029        rcl.yBottom += 8;
     5030        rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
     5031        rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
     5032        rcl.xRight -= 8;
     5033        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    49845034      }
    49855035      switch (SHORT1FROMMP(mp1)) {
    49865036      case IDM_HELPCONTEXT:
    4987         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4988                    MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
    4989         break;
     5037        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5038                   MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
     5039        break;
    49905040
    49915041      case IDM_HELPMOUSE:
    4992         if (hwndHelp)
    4993           WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4994                      MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
    4995         break;
     5042        if (hwndHelp)
     5043          WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5044                     MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
     5045        break;
    49965046
    49975047      case IDM_HELPPIX:
    4998         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4999                    MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
    5000         break;
     5048        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5049                   MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
     5050        break;
    50015051
    50025052      case IDM_HELPTUTOR:
    5003         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5004                    MPFROM2SHORT(HELP_TUTORIAL, 0),
    5005                    MPFROMSHORT(HM_RESOURCEID));
    5006         break;
     5053        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5054                   MPFROM2SHORT(HELP_TUTORIAL, 0),
     5055                   MPFROMSHORT(HM_RESOURCEID));
     5056        break;
    50075057
    50085058      case IDM_HELPHINTS:
    5009         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5010                    MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
    5011         break;
     5059        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5060                   MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
     5061        break;
    50125062
    50135063      case IDM_HELPGENERAL:
    5014         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5015                    MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
    5016         break;
     5064        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5065                   MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
     5066        break;
    50175067      case IDM_HELPKEYS:
    5018         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5019                    MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
    5020         break;
     5068        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5069                   MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
     5070        break;
    50215071
    50225072      case IDM_HELP:
    50235073      case IDM_HELPCONTENTS:
    5024         WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
    5025         break;
     5074        WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
     5075        break;
    50265076
    50275077      case IDM_HELPUSERLIST:
    5028         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    5029                    MPFROM2SHORT(HELP_USERLISTS, 0),
    5030                    MPFROMSHORT(HM_RESOURCEID));
    5031         break;
     5078        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     5079                   MPFROM2SHORT(HELP_USERLISTS, 0),
     5080                   MPFROMSHORT(HM_RESOURCEID));
     5081        break;
    50325082      }
    50335083    }
     
    50405090  case IDM_ABOUT:
    50415091    WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
    5042               ABT_FRAME, MPVOID);
     5092              ABT_FRAME, MPVOID);
    50435093    break;
    50445094
     
    50545104
    50555105      if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
    5056                            (PVOID) & version, (ULONG) sizeof(version))) {
    5057         if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
    5058           if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
    5059             palette = "<WP_HIRESCLRPAL>";
    5060           else
    5061             palette = "<WP_LORESCLRPAL>";
    5062         }
     5106                           (PVOID) & version, (ULONG) sizeof(version))) {
     5107        if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
     5108          if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
     5109            palette = "<WP_HIRESCLRPAL>";
     5110          else
     5111            palette = "<WP_LORESCLRPAL>";
     5112        }
    50635113      }
    50645114      OpenObject(palette, Default, hwnd);
     
    50765126      hWPSObject = WinQueryObject("<WP_SCHPAL>");
    50775127      if (hWPSObject != NULLHANDLE)
    5078         WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
    5079                         "Spring:PM_Spring,Summer:PM_Summer,"
    5080                         "System:PM_System,Windows:PM_Windows;"
    5081                         "OPEN=DEFAULT");
     5128        WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
     5129                        "Spring:PM_Spring,Summer:PM_Summer,"
     5130                        "System:PM_System,Windows:PM_Windows;"
     5131                        "OPEN=DEFAULT");
    50825132    }
    50835133    break;
     
    50905140  case IDM_SYSINFO:
    50915141    WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
    5092               SYS_FRAME, NULL);
     5142              SYS_FRAME, NULL);
    50935143    break;
    50945144#endif
     
    51005150
    51015151      if (hwndTree)
    5102         pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
    5103                                     MPFROMLONG(CMA_FIRST),
    5104                                     MPFROMSHORT(CRA_CURSORED));
     5152        pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
     5153                                    MPFROMLONG(CMA_FIRST),
     5154                                    MPFROMSHORT(CRA_CURSORED));
    51055155      if (pci && (INT) pci != -1) {
    5106         strcpy(path, pci->pszFileName);
    5107         MakeValidDir(path);
     5156        strcpy(path, pci->pszFileName);
     5157        MakeValidDir(path);
    51085158      }
    51095159      else
    5110         strcpy(path, pFM2SaveDirectory);
     5160        strcpy(path, pFM2SaveDirectory);
    51115161      WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
    5112                 BAT_FRAME, MPFROMP(path));
     5162                BAT_FRAME, MPFROMP(path));
    51135163    }
    51145164    break;
     
    51245174      TopWindowName(hwnd, (HWND) 0, path);
    51255175      if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
    5126         env = GetCmdSpec(TRUE);
     5176        env = GetCmdSpec(TRUE);
    51275177      else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
    5128         env = "WINOS2.COM";
    5129         type = SEPARATE | FULLSCREEN;
     5178        env = "WINOS2.COM";
     5179        type = SEPARATE | FULLSCREEN;
    51305180      }
    51315181      runemf2(type, hwnd, pszSrcFile, __LINE__,
    5132               path, NULL, "%s", env);
     5182              path, NULL, "%s", env);
    51335183    }
    51345184    break;
     
    51365186  case IDM_KILLPROC:
    51375187    WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
    5138               KILL_FRAME, NULL);
     5188              KILL_FRAME, NULL);
    51395189    break;
    51405190
     
    51515201  case IDM_AUTOVIEW:
    51525202    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5153                 &fAutoView, TRUE, "AutoView");
     5203                &fAutoView, TRUE, "AutoView");
    51545204  AutoChange:
    51555205    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5156             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5206            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51575207    if (fAutoView) {
    51585208
     
    51635213      hwndDir = TopWindowName(hwnd, (HWND) 0, s);
    51645214      if (hwndDir) {
    5165         hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
    5166         if (hwndDir) {
    5167           hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
    5168           if (hwndDir) {
    5169             pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
    5170                                         MPFROMLONG(CMA_FIRST),
    5171                                         MPFROMSHORT(CRA_CURSORED));
    5172             if (pci && (INT) pci != -1 &&
    5173                 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
    5174               WinSendMsg(hwnd,
    5175                         UM_LOADFILE,
    5176                         MPFROMP(pci->pszFileName),
    5177                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    5178                         MPVOID : MPFROMLONG(1));
    5179           }
    5180         }
     5215        hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
     5216        if (hwndDir) {
     5217          hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
     5218          if (hwndDir) {
     5219            pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
     5220                                        MPFROMLONG(CMA_FIRST),
     5221                                        MPFROMSHORT(CRA_CURSORED));
     5222            if (pci && (INT) pci != -1 &&
     5223                (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
     5224              WinSendMsg(hwnd,
     5225                        UM_LOADFILE,
     5226                        MPFROMP(pci->pszFileName),
     5227                        (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
     5228                        MPVOID : MPFROMLONG(1));
     5229          }
     5230        }
    51815231      }
    51825232    }
     
    51855235  case IDM_TEXTTOOLS:
    51865236    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5187                 &fTextTools, TRUE, "TextTools");
     5237                &fTextTools, TRUE, "TextTools");
    51885238    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    51895239    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5190             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5240            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51915241    break;
    51925242
    51935243  case IDM_TOOLTITLES:
    51945244    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5195                 &fToolTitles, TRUE, "ToolTitles");
     5245                &fToolTitles, TRUE, "ToolTitles");
    51965246    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    51975247    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5198             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5248            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51995249    break;
    52005250
     
    52045254      MenuInvisible = MenuInvisible ? FALSE : TRUE;
    52055255      if (MenuInvisible) {
    5206         WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
    5207         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5208                                            FID_SYSMENU), IDM_HIDEMENU,
    5209                            GetPString(IDS_UNHIDEMENUTEXT));
     5256        WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
     5257        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5258                                           FID_SYSMENU), IDM_HIDEMENU,
     5259                           GetPString(IDS_UNHIDEMENUTEXT));
    52105260      }
    52115261      else {
    5212         WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
    5213         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5214                                            FID_SYSMENU), IDM_HIDEMENU,
    5215                            GetPString(IDS_HIDEMENUTEXT));
     5262        WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
     5263        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5264                                           FID_SYSMENU), IDM_HIDEMENU,
     5265                           GetPString(IDS_HIDEMENUTEXT));
    52165266      }
    52175267      PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5218               MPFROMLONG(FCF_MENU), MPVOID);
     5268              MPFROMLONG(FCF_MENU), MPVOID);
    52195269      PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
    5220                           &MenuInvisible, sizeof(BOOL));
     5270                          &MenuInvisible, sizeof(BOOL));
    52215271    }
    52225272    break;
     
    52315281
    52325282      if (Collector)
    5233         already = TRUE;
     5283        already = TRUE;
    52345284      if (!already && !fAutoTile && !fExternalCollector)
    5235         GetNextWindowPos(hwnd, &swp, NULL, NULL);
     5285        GetNextWindowPos(hwnd, &swp, NULL, NULL);
    52365286      hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
    52375287      if (hwndC) {
    5238         if (!already && !fAutoTile && !fExternalCollector)
    5239           WinSetWindowPos(hwndC, HWND_TOP,
    5240                           swp.x, swp.y, swp.cx, swp.cy,
    5241                           SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    5242         else if (fAutoTile && !already)
    5243           TileChildren(hwnd, TRUE);
    5244         WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
    5245                         SWP_ACTIVATE);
    5246         if (SHORT1FROMMP(mp1) == IDM_GREP)
    5247           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5248                   MPFROM2SHORT(IDM_GREP, 0), MPVOID);
    5249         if (SHORT1FROMMP(mp1) == IDM_SEEALL)
    5250           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5251                   MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
     5288        if (!already && !fAutoTile && !fExternalCollector)
     5289          WinSetWindowPos(hwndC, HWND_TOP,
     5290                          swp.x, swp.y, swp.cx, swp.cy,
     5291                          SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     5292        else if (fAutoTile && !already)
     5293          TileChildren(hwnd, TRUE);
     5294        WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
     5295                        SWP_ACTIVATE);
     5296        if (SHORT1FROMMP(mp1) == IDM_GREP)
     5297          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5298                  MPFROM2SHORT(IDM_GREP, 0), MPVOID);
     5299        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     5300          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5301                  MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
    52525302      }
    52535303    }
     
    52605310
    52615311      if (!toolhead || !toolhead->next) {
    5262         firsttool = (toolhead) ? toolhead->id : 0;
    5263         break;
     5312        firsttool = (toolhead) ? toolhead->id : 0;
     5313        break;
    52645314      }
    52655315      tool = find_tool(firsttool);
    52665316      if (!tool)
    5267         tool = toolhead;
     5317        tool = toolhead;
    52685318      if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
    5269         tool = prev_tool(tool, TRUE);
    5270         firsttool = tool->id;
     5319        tool = prev_tool(tool, TRUE);
     5320        firsttool = tool->id;
    52715321      }
    52725322      else {
    5273         tool = next_tool(tool, TRUE);
    5274         firsttool = tool->id;
     5323        tool = next_tool(tool, TRUE);
     5324        firsttool = tool->id;
    52755325      }
    52765326      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5277                                   MAIN_TOOLS));
     5327                                  MAIN_TOOLS));
    52785328    }
    52795329    break;
     
    52855335  case IDM_TOOLBAR:
    52865336    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5287                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
     5337                IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    52885338    PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    52895339    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5290                                   MAIN_TOOLS), fToolbar);
     5340                                  MAIN_TOOLS), fToolbar);
    52915341    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    5292                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5342               WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52935343    if (fDrivebar)
    52945344      WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5295                                         MAIN_DRIVES), NULL, TRUE);
     5345                                        MAIN_DRIVES), NULL, TRUE);
    52965346    break;
    52975347
    52985348  case IDM_DRIVEBAR:
    52995349    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5300                 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
     5350                IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
    53015351    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5302                                   MAIN_DRIVES), fDrivebar);
     5352                                  MAIN_DRIVES), fDrivebar);
    53035353    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5304             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5354            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53055355    PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    53065356    break;
     
    53085358  case IDM_USERLIST:
    53095359    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5310                 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
     5360                SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
    53115361    WinShowWindow(hwndUserlist, fUserComboBox);
    53125362    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5313             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5363            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53145364    PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    53155365    PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    53235373    WinSetWindowText(hwndAttr, NullStr);
    53245374    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5325                 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
     5375                SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
    53265376    if (fMoreButtons) {
    53275377
     
    53315381
    53325382      if (hwndTemp) {
    5333         WinSetFocus(HWND_DESKTOP, hwnd);
    5334         WinSetFocus(HWND_DESKTOP, hwndTemp);
     5383        WinSetFocus(HWND_DESKTOP, hwnd);
     5384        WinSetFocus(HWND_DESKTOP, hwndTemp);
    53355385      }
    53365386    }
    53375387    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5338             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5388            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    53395389    break;
    53405390
    53415391  case IDM_TOGGLEDRAGDIALOG:
    53425392    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5343                 IDM_TOGGLEDRAGDIALOG,
    5344                 &fDragndropDlg,
    5345                 TRUE,
    5346                 "Drag&DropDlg");
     5393                IDM_TOGGLEDRAGDIALOG,
     5394                &fDragndropDlg,
     5395                TRUE,
     5396                "Drag&DropDlg");
    53475397    break;
    53485398
    53495399  case IDM_SYNCUPDATES:
    53505400    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5351                 IDM_SYNCUPDATES,
    5352                 &fSyncUpdates,
    5353                 TRUE,
    5354                 "SyncUpdates");
     5401                IDM_SYNCUPDATES,
     5402                &fSyncUpdates,
     5403                TRUE,
     5404                "SyncUpdates");
    53555405    break;
    53565406
     
    53625412      WinQueryWindowPos(hwnd, &swp);
    53635413      WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
    5364                       SWP_MOVE);
     5414                      SWP_MOVE);
    53655415    }
    53665416    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5367                 &fFreeTree, TRUE, "FreeTree");
     5417                &fFreeTree, TRUE, "FreeTree");
    53685418    if (fAutoTile)
    53695419      TileChildren(hwnd, TRUE);
     
    53725422  case IDM_AUTOTILE:
    53735423    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5374                 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
     5424                SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
    53755425    if (fAutoTile)
    53765426      TileChildren(hwnd, TRUE);
     
    53795429  case IDM_TILEBACKWARDS:
    53805430    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5381                 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
     5431                SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
    53825432    if (fAutoTile)
    53835433      TileChildren(hwnd, TRUE);
     
    54245474  default:
    54255475    if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
    5426                        SHORT1FROMMP(mp1))) {
     5476                       SHORT1FROMMP(mp1))) {
    54275477      if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    5428           SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    5429 
    5430         INT x;
    5431         HWND hwndCnr;
    5432 
    5433         if (!cmdloaded)
    5434           load_commands();
    5435         hwndCnr = TopWindow(hwnd, (HWND) 0);
    5436         hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
    5437                                     UM_CONTAINERHWND, MPVOID, MPVOID);
    5438         if (!hwndCnr) {
    5439           Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
    5440           break;
    5441         }
    5442         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    5443         if (x >= 0) {
    5444           x++;
    5445           RunCommand(hwndCnr, x);
    5446           if (fUnHilite) {
    5447 
    5448             PCNRITEM pci;
    5449             DIRCNRDATA *dcd = NULL;
    5450 
    5451             // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
    5452             if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
    5453               dcd = INSTDATA(hwndCnr);
    5454             pci = (PCNRITEM) WinSendMsg(hwndCnr,
    5455                                         CM_QUERYRECORDEMPHASIS,
    5456                                         MPFROMLONG(CMA_FIRST),
    5457                                         MPFROMSHORT(CRA_CURSORED));
    5458             if (pci && (INT) pci != -1 &&
    5459                 (pci->rc.flRecordAttr & CRA_SELECTED))
    5460             {
    5461               UnHilite(hwnd,
    5462                        TRUE,
    5463                        dcd ? &dcd->lastselection : NULL,
    5464                        dcd ? dcd ->ulItemsToUnHilite : 0);
    5465             }
    5466           }
    5467         }
     5478          SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
     5479
     5480        INT x;
     5481        HWND hwndCnr;
     5482
     5483        if (!cmdloaded)
     5484          load_commands();
     5485        hwndCnr = TopWindow(hwnd, (HWND) 0);
     5486        hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     5487                                    UM_CONTAINERHWND, MPVOID, MPVOID);
     5488        if (!hwndCnr) {
     5489          Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
     5490          break;
     5491        }
     5492        x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     5493        if (x >= 0) {
     5494          x++;
     5495          RunCommand(hwndCnr, x);
     5496          if (fUnHilite) {
     5497
     5498            PCNRITEM pci;
     5499            DIRCNRDATA *dcd = NULL;
     5500
     5501            // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
     5502            if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     5503              dcd = INSTDATA(hwndCnr);
     5504            pci = (PCNRITEM) WinSendMsg(hwndCnr,
     5505                                        CM_QUERYRECORDEMPHASIS,
     5506                                        MPFROMLONG(CMA_FIRST),
     5507                                        MPFROMSHORT(CRA_CURSORED));
     5508            if (pci && (INT) pci != -1 &&
     5509                (pci->rc.flRecordAttr & CRA_SELECTED))
     5510            {
     5511              UnHilite(hwnd,
     5512                       TRUE,
     5513                       dcd ? &dcd->lastselection : NULL,
     5514                       dcd ? dcd ->ulItemsToUnHilite : 0);
     5515            }
     5516          }
     5517        }
    54685518      }
    54695519      else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    5470                SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
    5471         if (!qtloaded)
    5472           load_quicktools();
    5473         if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
    5474           if (fToolsChanged)
    5475             save_tools(NULL);
    5476           if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
    5477             load_tools(NULL);
    5478           else {
    5479             strcpy(lasttoolbar,
    5480                    quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
    5481             PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
    5482           }
    5483           PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    5484         }
     5520               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
     5521        if (!qtloaded)
     5522          load_quicktools();
     5523        if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
     5524          if (fToolsChanged)
     5525            save_tools(NULL);
     5526          if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
     5527            load_tools(NULL);
     5528          else {
     5529            strcpy(lasttoolbar,
     5530                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
     5531            PrfWriteProfileString(fmprof, FM3Str, "LastToolbar", lasttoolbar);
     5532          }
     5533          PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
     5534        }
    54855535      }
    54865536      else {
    54875537
    5488         HWND hwndActive;
    5489 
    5490         hwndActive = TopWindow(hwnd, (HWND) 0);
    5491         if (hwndActive)
    5492           PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    5493                   WM_COMMAND, mp1, mp2);
     5538        HWND hwndActive;
     5539
     5540        hwndActive = TopWindow(hwnd, (HWND) 0);
     5541        if (hwndActive)
     5542          PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     5543                  WM_COMMAND, mp1, mp2);
    54945544      }
    54955545    }
     
    55005550
    55015551static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
    5502                                    MPARAM mp2)
     5552                                   MPARAM mp2)
    55035553{
    55045554  TID tid;
     
    55235573    if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
    55245574      Runtime_Error(pszSrcFile, __LINE__,
    5525                     GetPString(IDS_COULDNTSTARTTHREADTEXT));
     5575                    GetPString(IDS_COULDNTSTARTTHREADTEXT));
    55265576      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    55275577      return 0;
     
    55425592
    55435593    if (!WinCreateWindow(hwndFrame,
    5544                         WC_BUTTON,
    5545                         "I",
    5546                         WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
    5547                         ((swp.cx -
    5548                            WinQuerySysValue(HWND_DESKTOP,
    5549                                             SV_CXMINMAXBUTTON)) -
    5550                           WinQuerySysValue(HWND_DESKTOP,
    5551                                            SV_CXMINMAXBUTTON) / 2) -
    5552                         WinQuerySysValue(HWND_DESKTOP,
    5553                                           SV_CXSIZEBORDER),
    5554                         (swp.cy - WinQuerySysValue(HWND_DESKTOP,
    5555                                                     SV_CYMINMAXBUTTON)) -
    5556                         WinQuerySysValue(HWND_DESKTOP,
    5557                                           SV_CYSIZEBORDER),
    5558                         WinQuerySysValue(HWND_DESKTOP,
    5559                                           SV_CXMINMAXBUTTON) / 2,
    5560                         WinQuerySysValue(HWND_DESKTOP,
    5561                                           SV_CYMINMAXBUTTON),
    5562                         hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
     5594                        WC_BUTTON,
     5595                        "I",
     5596                        WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
     5597                        ((swp.cx -
     5598                           WinQuerySysValue(HWND_DESKTOP,
     5599                                            SV_CXMINMAXBUTTON)) -
     5600                          WinQuerySysValue(HWND_DESKTOP,
     5601                                           SV_CXMINMAXBUTTON) / 2) -
     5602                        WinQuerySysValue(HWND_DESKTOP,
     5603                                          SV_CXSIZEBORDER),
     5604                        (swp.cy - WinQuerySysValue(HWND_DESKTOP,
     5605                                                    SV_CYMINMAXBUTTON)) -
     5606                        WinQuerySysValue(HWND_DESKTOP,
     5607                                          SV_CYSIZEBORDER),
     5608                        WinQuerySysValue(HWND_DESKTOP,
     5609                                          SV_CXMINMAXBUTTON) / 2,
     5610                        WinQuerySysValue(HWND_DESKTOP,
     5611                                          SV_CYMINMAXBUTTON),
     5612                        hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
    55635613      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55645614    }
    55655615    else {
    55665616      WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
    5567                         IdealButtonProc);
     5617                        IdealButtonProc);
    55685618      SetPresParams(WinWindowFromID(hwndFrame,
    5569                                     IDM_IDEALSIZE),
    5570                     NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
     5619                                    IDM_IDEALSIZE),
     5620                    NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
    55715621    }
    55725622
    55735623    hwndTmp = WinCreateWindow(hwndFrame,
    5574                               WC_BUTTON,
    5575                               "#1019",
    5576                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5577                               BS_BITMAP,
    5578                               swp.cx - 46,
    5579                               swp.y + 2,
    5580                               24,
    5581                               22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
     5624                              WC_BUTTON,
     5625                              "#1019",
     5626                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5627                              BS_BITMAP,
     5628                              swp.cx - 46,
     5629                              swp.y + 2,
     5630                              24,
     5631                              22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
    55825632    if (!hwndTmp)
    55835633      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55845634
    55855635    hwndTmp = WinCreateWindow(hwndFrame,
    5586                               WC_BUTTON,
    5587                               "#3062",
    5588                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5589                               BS_BITMAP,
    5590                               swp.cx - 22,
    5591                               swp.y + 2,
    5592                               24,
    5593                               22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
     5636                              WC_BUTTON,
     5637                              "#3062",
     5638                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5639                              BS_BITMAP,
     5640                              swp.cx - 22,
     5641                              swp.y + 2,
     5642                              24,
     5643                              22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
    55945644    if (!hwndTmp)
    55955645      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55965646
    55975647    hwndUserlist = WinCreateWindow(hwndFrame,
    5598                                    WC_COMBOBOX,
    5599                                    (PSZ) NULL,
    5600                                    WS_VISIBLE | CBS_DROPDOWN |
    5601                                    LS_HORZSCROLL,
    5602                                    (swp.x +
    5603                                     WinQuerySysValue(HWND_DESKTOP,
    5604                                                      SV_CXSIZEBORDER) + 48L),
    5605                                    (swp.cy -
    5606                                     WinQuerySysValue(HWND_DESKTOP,
    5607                                                      SV_CYSIZEBORDER)) - 60,
    5608                                    ((swp.cx -
    5609                                      (WinQuerySysValue(HWND_DESKTOP,
    5610                                                        SV_CXSIZEBORDER) *
    5611                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5612                                    MAIN_USERLIST, NULL, NULL);
     5648                                   WC_COMBOBOX,
     5649                                   (PSZ) NULL,
     5650                                   WS_VISIBLE | CBS_DROPDOWN |
     5651                                   LS_HORZSCROLL,
     5652                                   (swp.x +
     5653                                    WinQuerySysValue(HWND_DESKTOP,
     5654                                                     SV_CXSIZEBORDER) + 48L),
     5655                                   (swp.cy -
     5656                                    WinQuerySysValue(HWND_DESKTOP,
     5657                                                     SV_CYSIZEBORDER)) - 60,
     5658                                   ((swp.cx -
     5659                                     (WinQuerySysValue(HWND_DESKTOP,
     5660                                                       SV_CXSIZEBORDER) *
     5661                                      2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5662                                   MAIN_USERLIST, NULL, NULL);
    56135663    if (!hwndUserlist)
    56145664      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56155665    hwndCmdlist = WinCreateWindow(hwndFrame,
    5616                                   WC_COMBOBOX,
    5617                                   (PSZ) NULL,
    5618                                   WS_VISIBLE | CBS_DROPDOWN |
    5619                                   LS_HORZSCROLL,
    5620                                   (swp.x +
    5621                                    WinQuerySysValue(HWND_DESKTOP,
    5622                                                     SV_CXSIZEBORDER) + 48L),
    5623                                   (swp.cy -
    5624                                    WinQuerySysValue(HWND_DESKTOP,
    5625                                                     SV_CYSIZEBORDER)) - 60,
    5626                                   ((swp.cx -
    5627                                     (WinQuerySysValue(HWND_DESKTOP,
    5628                                                       SV_CXSIZEBORDER) * 2)) -
    5629                                    64L), 60L, hwndFrame, HWND_TOP,
    5630                                   MAIN_CMDLIST, NULL, NULL);
     5666                                  WC_COMBOBOX,
     5667                                  (PSZ) NULL,
     5668                                  WS_VISIBLE | CBS_DROPDOWN |
     5669                                  LS_HORZSCROLL,
     5670                                  (swp.x +
     5671                                   WinQuerySysValue(HWND_DESKTOP,
     5672                                                    SV_CXSIZEBORDER) + 48L),
     5673                                  (swp.cy -
     5674                                   WinQuerySysValue(HWND_DESKTOP,
     5675                                                    SV_CYSIZEBORDER)) - 60,
     5676                                  ((swp.cx -
     5677                                    (WinQuerySysValue(HWND_DESKTOP,
     5678                                                      SV_CXSIZEBORDER) * 2)) -
     5679                                   64L), 60L, hwndFrame, HWND_TOP,
     5680                                  MAIN_CMDLIST, NULL, NULL);
    56315681    if (!hwndCmdlist)
    56325682      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56335683    WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    56345684    hwndStatelist = WinCreateWindow(hwndFrame,
    5635                                     WC_COMBOBOX,
    5636                                     (PSZ) NULL,
    5637                                     WS_VISIBLE | CBS_DROPDOWN |
    5638                                     LS_HORZSCROLL,
    5639                                     (swp.x +
    5640                                      WinQuerySysValue(HWND_DESKTOP,
    5641                                                       SV_CXSIZEBORDER) + 48L),
    5642                                     (swp.cy -
    5643                                      WinQuerySysValue(HWND_DESKTOP,
    5644                                                       SV_CYSIZEBORDER)) - 60,
    5645                                     ((swp.cx -
    5646                                       (WinQuerySysValue(HWND_DESKTOP,
    5647                                                         SV_CXSIZEBORDER) *
    5648                                        2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5649                                     MAIN_SETUPLIST, NULL, NULL);
     5685                                    WC_COMBOBOX,
     5686                                    (PSZ) NULL,
     5687                                    WS_VISIBLE | CBS_DROPDOWN |
     5688                                    LS_HORZSCROLL,
     5689                                    (swp.x +
     5690                                     WinQuerySysValue(HWND_DESKTOP,
     5691                                                      SV_CXSIZEBORDER) + 48L),
     5692                                    (swp.cy -
     5693                                     WinQuerySysValue(HWND_DESKTOP,
     5694                                                      SV_CYSIZEBORDER)) - 60,
     5695                                    ((swp.cx -
     5696                                      (WinQuerySysValue(HWND_DESKTOP,
     5697                                                        SV_CXSIZEBORDER) *
     5698                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5699                                    MAIN_SETUPLIST, NULL, NULL);
    56505700    if (!hwndStatelist)
    56515701      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56525702
    56535703    hwndDrivelist = WinCreateWindow(hwndFrame,
    5654                                     WC_COMBOBOX,
    5655                                     (PSZ) NULL,
    5656                                     WS_VISIBLE | CBS_DROPDOWN,
    5657                                     (swp.x +
    5658                                      WinQuerySysValue(HWND_DESKTOP,
    5659                                                       SV_CXSIZEBORDER)),
    5660                                     (swp.cy -
    5661                                      WinQuerySysValue(HWND_DESKTOP,
    5662                                                       SV_CYSIZEBORDER)) - 60,
    5663                                     48L,
    5664                                     60L,
    5665                                     hwndFrame,
    5666                                     HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
     5704                                    WC_COMBOBOX,
     5705                                    (PSZ) NULL,
     5706                                    WS_VISIBLE | CBS_DROPDOWN,
     5707                                    (swp.x +
     5708                                     WinQuerySysValue(HWND_DESKTOP,
     5709                                                      SV_CXSIZEBORDER)),
     5710                                    (swp.cy -
     5711                                     WinQuerySysValue(HWND_DESKTOP,
     5712                                                      SV_CYSIZEBORDER)) - 60,
     5713                                    48L,
     5714                                    60L,
     5715                                    hwndFrame,
     5716                                    HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
    56675717    if (!hwndDrivelist)
    56685718      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56695719    SetPresParams(hwndDrivelist,
    5670                   NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
     5720                  NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
    56715721    hwndButtonlist = WinCreateWindow(hwndFrame,
    5672                                      WC_COMBOBOX,
    5673                                      (PSZ) NULL,
    5674                                      WS_VISIBLE | CBS_DROPDOWN |
    5675                                      LS_HORZSCROLL,
    5676                                      (swp.cx -
    5677                                       WinQuerySysValue(HWND_DESKTOP,
    5678                                                        SV_CXSIZEBORDER)) -
    5679                                      164L,
    5680                                      (swp.cy -
    5681                                       WinQuerySysValue(HWND_DESKTOP,
    5682                                                        SV_CYSIZEBORDER)) - 60,
    5683                                      164L, 60L, hwndFrame, HWND_TOP,
    5684                                      MAIN_BUTTONLIST, NULL, NULL);
     5722                                     WC_COMBOBOX,
     5723                                     (PSZ) NULL,
     5724                                     WS_VISIBLE | CBS_DROPDOWN |
     5725                                     LS_HORZSCROLL,
     5726                                     (swp.cx -
     5727                                      WinQuerySysValue(HWND_DESKTOP,
     5728                                                       SV_CXSIZEBORDER)) -
     5729                                     164L,
     5730                                     (swp.cy -
     5731                                      WinQuerySysValue(HWND_DESKTOP,
     5732                                                       SV_CYSIZEBORDER)) - 60,
     5733                                     164L, 60L, hwndFrame, HWND_TOP,
     5734                                     MAIN_BUTTONLIST, NULL, NULL);
    56855735    if (!hwndButtonlist)
    56865736      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    56875737    WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5688                EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     5738               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    56895739    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5690                EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
     5740               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    56915741    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5692                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5742               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56935743    WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5694                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5744               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56955745    WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5696                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5746               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56975747
    56985748    oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5699                                 DropDownListProc);
     5749                                DropDownListProc);
    57005750    WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5701                     QWL_USER, (PVOID) oldproc);
     5751                    QWL_USER, (PVOID) oldproc);
    57025752    oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5703                                 DropDownListProc);
     5753                                DropDownListProc);
    57045754    WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5705                     QWL_USER, (PVOID) oldproc);
     5755                    QWL_USER, (PVOID) oldproc);
    57065756    oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5707                                 DropDownListProc);
     5757                                DropDownListProc);
    57085758    WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5709                     QWL_USER, (PVOID) oldproc);
     5759                    QWL_USER, (PVOID) oldproc);
    57105760    oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5711                                 DropDownListProc);
     5761                                DropDownListProc);
    57125762    WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5713                     QWL_USER, (PVOID) oldproc);
     5763                    QWL_USER, (PVOID) oldproc);
    57145764    oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5715                                 DropDownListProc);
     5765                                DropDownListProc);
    57165766    WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5717                     QWL_USER, (PVOID) oldproc);
     5767                    QWL_USER, (PVOID) oldproc);
    57185768    oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
    57195769    WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
     
    57275777    WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
    57285778    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5729                                 ChildFrameButtonProc);
     5779                                ChildFrameButtonProc);
    57305780    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5731                     QWL_USER, (PVOID) oldproc);
     5781                    QWL_USER, (PVOID) oldproc);
    57325782    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5733                                 ChildFrameButtonProc);
     5783                                ChildFrameButtonProc);
    57345784    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5735                     QWL_USER, (PVOID) oldproc);
     5785                    QWL_USER, (PVOID) oldproc);
    57365786    hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
    57375787    WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
     
    57475797    hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
    57485798    idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
    5749                                         MM_ITEMIDFROMPOSITION,
    5750                                         MPVOID, MPVOID));
     5799                                        MM_ITEMIDFROMPOSITION,
     5800                                        MPVOID, MPVOID));
    57515801    WinSendMsg(hwndSysMenu,
    5752                MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
     5802               MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
    57535803    hwndSysSubMenu = mit.hwndSubMenu;
    57545804    mi.iPosition = MIT_END;
     
    57595809    mi.id = IDM_IDEALSIZE;
    57605810    WinSendMsg(hwndSysSubMenu,
    5761                MM_INSERTITEM,
    5762                MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
     5811               MM_INSERTITEM,
     5812               MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
    57635813    mi.afStyle = MIS_TEXT;
    57645814    mi.id = IDM_HIDEMENU;
    57655815    WinSendMsg(hwndSysSubMenu,
    5766                MM_INSERTITEM,
    5767                MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
     5816               MM_INSERTITEM,
     5817               MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
    57685818    SetSysMenu(hwndSysMenu);
    57695819
    57705820    size = sizeof(BOOL);
    57715821    if (PrfQueryProfileData(fmprof,
    5772                             FM3Str,
    5773                             "MenuInvisible", &temp, &size) && size && temp)
     5822                            FM3Str,
     5823                            "MenuInvisible", &temp, &size) && size && temp)
    57745824      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
    57755825    size = sizeof(BOOL);
    57765826    if (PrfQueryProfileData(fmprof,
    5777                             FM3Str, "FreeTree", &temp, &size) && size && temp)
     5827                            FM3Str, "FreeTree", &temp, &size) && size && temp)
    57785828      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
    57795829    size = sizeof(BOOL);
    57805830    if (PrfQueryProfileData(fmprof,
    5781                             FM3Str,
    5782                             "AutoTile", &temp, &size) && size && !temp)
     5831                            FM3Str,
     5832                            "AutoTile", &temp, &size) && size && !temp)
    57835833      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
    57845834    size = sizeof(BOOL);
    57855835    if (PrfQueryProfileData(fmprof,
    5786                             FM3Str, "Toolbar", &temp, &size) && size && !temp)
     5836                            FM3Str, "Toolbar", &temp, &size) && size && !temp)
    57875837      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
    57885838
     
    58075857      hwndTree = StartTreeCnr(hwnd, 4);
    58085858      if (!hwndTree)
    5809         WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     5859        WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    58105860      else {
    5811         if (!fSaveState ||
    5812             !PrfQueryProfileData(fmprof,
    5813                                 FM3Str,
    5814                                 "LastTreePos",
    5815                                 &swp, &size) || size != sizeof(SWP)) {
    5816 
    5817           INT ratio, height = 0;
    5818 
    5819           if (!fNoTreeGap)
    5820             height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    5821           size = sizeof(ratio);
    5822           if (!PrfQueryProfileData(fmprof,
    5823                                    FM3Str,
    5824                                    "TreeWindowRatio",
    5825                                    (PVOID) & ratio,
    5826                                    &size) || size < sizeof(ratio))
    5827             ratio = 400;
    5828           WinSetWindowPos(hwndTree,
    5829                           HWND_TOP,
    5830                           0,
    5831                           height,
    5832                           (swp.cx * 100) / ratio,
    5833                           swp.cy - height,
    5834                           SWP_SHOW | SWP_SIZE | SWP_MOVE |
    5835                           SWP_ACTIVATE | SWP_ZORDER);
    5836         }
    5837         else
    5838           WinSetWindowPos(hwndTree,
    5839                           HWND_TOP,
    5840                           swp.x,
    5841                           swp.y,
    5842                           swp.cx,
    5843                           swp.cy,
    5844                           swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
    5845                           SWP_ZORDER | SWP_ACTIVATE);
     5861        if (!fSaveState ||
     5862            !PrfQueryProfileData(fmprof,
     5863                                FM3Str,
     5864                                "LastTreePos",
     5865                                &swp, &size) || size != sizeof(SWP)) {
     5866
     5867          INT ratio, height = 0;
     5868
     5869          if (!fNoTreeGap)
     5870            height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     5871          size = sizeof(ratio);
     5872          if (!PrfQueryProfileData(fmprof,
     5873                                   FM3Str,
     5874                                   "TreeWindowRatio",
     5875                                   (PVOID) & ratio,
     5876                                   &size) || size < sizeof(ratio))
     5877            ratio = 400;
     5878          WinSetWindowPos(hwndTree,
     5879                          HWND_TOP,
     5880                          0,
     5881                          height,
     5882                          (swp.cx * 100) / ratio,
     5883                          swp.cy - height,
     5884                          SWP_SHOW | SWP_SIZE | SWP_MOVE |
     5885                          SWP_ACTIVATE | SWP_ZORDER);
     5886        }
     5887        else
     5888          WinSetWindowPos(hwndTree,
     5889                          HWND_TOP,
     5890                          swp.x,
     5891                          swp.y,
     5892                          swp.cx,
     5893                          swp.cy,
     5894                          swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
     5895                          SWP_ZORDER | SWP_ACTIVATE);
    58465896      }
    58475897//       ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5848 //                                MAIN_TOOLS));
     5898//                                MAIN_TOOLS));
    58495899    }
    58505900    PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
     
    58715921
    58725922      for (x = 1; x < argc; x++) {
    5873         if (*argv[x] == '/' || *argv[x] == ';')
    5874           continue;
    5875         if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
    5876           OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
     5923        if (*argv[x] == '/' || *argv[x] == ';')
     5924          continue;
     5925        if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
     5926          OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
    58775927      }
    58785928    }
     
    58925942      hwndActive = TopWindow(hwnd, hwndTree);
    58935943      if (hwndActive)
    5894         WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
     5944        WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
    58955945    }
    58965946    if (fStartMinimized || fReminimize)
     
    59255975  case WM_CONTROLPOINTER:
    59265976    if (!fNoFinger &&
    5927         (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
    5928         SHORT1FROMMP(mp1) == IDM_USERLIST))
     5977        (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
     5978        SHORT1FROMMP(mp1) == IDM_USERLIST))
    59295979      return MRFROMLONG(hptrFinger);
    59305980    break;
     
    59666016    if (mp1) {
    59676017      if (fUserComboBox)
    5968         WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5969                         (CHAR *)mp1);
     6018        WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
     6019                        (CHAR *)mp1);
    59706020      if (add_udir(FALSE, (CHAR *)mp1)) {
    5971         if (fUserComboBox && fAutoAddDirs) {
    5972           WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5973                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5974                      MPFROMP((CHAR *)mp1));
    5975         }
     6021        if (fUserComboBox && fAutoAddDirs) {
     6022          WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6023                     MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6024                     MPFROMP((CHAR *)mp1));
     6025        }
    59766026      }
    59776027    }
     
    60056055      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    60066056      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    6007         WinStoreWindowPos(FM2Str,
    6008                           "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
    6009         if (!fNoSaveState && fSaveState)
    6010           SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
     6057        WinStoreWindowPos(FM2Str,
     6058                          "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
     6059        if (!fNoSaveState && fSaveState)
     6060          SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
    60116061      }
    60126062    }
     
    60186068    case 1:
    60196069      {
    6020         HWND hwndCurrent;
    6021         ULONG wmsg;
    6022 
    6023         wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
    6024         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    6025         PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
    6026                                                        FID_CLIENT), wmsg,
    6027                                        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);
    60286078      }
    60296079      break;
     
    60436093       */
    60446094      {
    6045         HWND hwndMenu, hwndSubMenu;
    6046         MENUITEM mi;
    6047 
    6048         hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
    6049         memset(&mi, 0, sizeof(mi));
    6050         mi.iPosition = MIT_END;
    6051         mi.afStyle = MIS_TEXT;
    6052         if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
    6053                         MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
    6054           break;
    6055         hwndSubMenu = mi.hwndSubMenu;
    6056         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));
    60576107      }
    60586108      break;
     
    60606110    default:
    60616111      {
    6062         HWND hwndCurrent;
    6063 
    6064         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    6065         if (hwndCurrent)
    6066           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);
    60676117      }
    60686118      break;
     
    60726122  case UM_ADDTOMENU:
    60736123    AddToMenu((CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6074                                             FID_MENU));
     6124                                            FID_MENU));
    60756125    return 0;
    60766126
     
    60856135      info = cmdhead;
    60866136      while (info) {
    6087         WinSendMsg(hwndCmdlist, LM_INSERTITEM,
    6088                    MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
    6089         info = info->next;
     6137        WinSendMsg(hwndCmdlist, LM_INSERTITEM,
     6138                   MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
     6139        info = info->next;
    60906140      }
    60916141    }
     
    61116161      ulSearchCount = 1;
    61126162      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    6113                         &findbuf, sizeof(FILEFINDBUF3),
    6114                         &ulSearchCount, FIL_STANDARD)) {
    6115         do {
    6116           priority_bumped();
    6117           if (!foundit) {
    6118             thisone = FALSE;
    6119             p = strrchr(lasttoolbar, '\\');
    6120             if (!p)
    6121               p = lasttoolbar;
    6122             else
    6123               p++;
    6124             if (!stricmp(findbuf.achName, p))
    6125               thisone = TRUE;
    6126           }
    6127           p = strrchr(findbuf.achName, '.');
    6128           if (p)
    6129             *p = 0;
    6130           sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
    6131                                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6132                                        MPFROMP(findbuf.achName));
    6133           if (!foundit && thisone && sSelect >= 0) {
    6134             WinSendMsg(hwndButtonlist, LM_SELECTITEM,
    6135                        MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
    6136             foundit = TRUE;
    6137           }
    6138         }
    6139         while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
    6140                             &ulSearchCount));
    6141         DosFindClose(hDir);
    6142         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();
    61436193      }
    61446194      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
     
    61596209
    61606210      if (!loadedudirs)
    6161         load_udirs();
     6211        load_udirs();
    61626212      DosError(FERR_DISABLEHARDERR);
    61636213      DosQCurDisk(&ulDriveNum, &ulDriveMap);
    61646214      info = udirhead;
    61656215      while (info) {
    6166         if (IsFullName(info->path) &&
    6167             !(driveflags[toupper(*info->path) - 'A'] &
    6168               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6169           DosError(FERR_DISABLEHARDERR);
    6170           hDir = HDIR_CREATE;
    6171           ulSearchCount = 1;
    6172           if (!IsRoot(info->path))
    6173             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6174                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6175                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6176                               &findbuf, sizeof(FILEFINDBUF3),
    6177                               &ulSearchCount, FIL_STANDARD);
    6178           else {
    6179             rc = 0;
    6180             findbuf.attrFile = FILE_DIRECTORY;
    6181           }
    6182           priority_bumped();
    6183           if (!rc) {
    6184             if (!IsRoot(info->path))
    6185               DosFindClose(hDir);
    6186             if (findbuf.attrFile & FILE_DIRECTORY)
    6187               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6188                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6189                         MPFROMP(info->path));
    6190             else {
    6191               temp = info->next;
    6192               remove_udir(info->path);
    6193               info = temp;
    6194               continue;
    6195             }
    6196           }
    6197           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6198             temp = info->next;
    6199             remove_udir(info->path);
    6200             info = temp;
    6201             continue;
    6202           }
    6203         }
    6204         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;
    62056255      }
    62066256      info = ldirhead;
    62076257      while (info) {
    6208         if (IsFullName(info->path) &&
    6209             !(driveflags[toupper(*info->path) - 'A'] &
    6210               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6211           DosError(FERR_DISABLEHARDERR);
    6212           hDir = HDIR_CREATE;
    6213           ulSearchCount = 1;
    6214           if (!IsRoot(info->path))
    6215             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6216                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6217                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6218                               &findbuf, sizeof(FILEFINDBUF3),
    6219                               &ulSearchCount, FIL_STANDARD);
    6220           else {
    6221             rc = 0;
    6222             findbuf.attrFile = FILE_DIRECTORY;
    6223           }
    6224           priority_bumped();
    6225           if (!rc) {
    6226             if (!IsRoot(info->path))
    6227               DosFindClose(hDir);
    6228             if (findbuf.attrFile & FILE_DIRECTORY)
    6229               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6230                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6231                         MPFROMP(info->path));
    6232             else {
    6233               temp = info->next;
    6234               remove_udir(info->path);
    6235               info = temp;
    6236               continue;
    6237             }
    6238           }
    6239           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6240             temp = info->next;
    6241             remove_udir(info->path);
    6242             info = temp;
    6243             continue;
    6244           }
    6245         }
    6246         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;
    62476297      }
    62486298      WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6249                 MPFROM2SHORT(0, 0),
    6250                 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
     6299                MPFROM2SHORT(0, 0),
     6300                MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
    62516301      WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
    62526302    }
     
    62626312  case WM_SIZE:
    62636313    ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
    6264                    SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
     6314                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
    62656315    break;
    62666316
     
    62766326      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    62776327      if (hps) {
    6278         WinQueryWindowRect(hwnd, &rcl);
    6279         WinFillRect(hps, &rcl, CLR_PALEGRAY);
    6280         WinEndPaint(hps);
     6328        WinQueryWindowRect(hwnd, &rcl);
     6329        WinFillRect(hps, &rcl, CLR_PALEGRAY);
     6330        WinEndPaint(hps);
    62816331      }
    62826332    }
     
    62926342      switch (SHORT2FROMMP(mp1)) {
    62936343      case CBN_ENTER:
    6294         {
    6295           HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6296                                         SHORT1FROMMP(mp1));
    6297           CHAR path[CCHMAXPATH];
    6298           ULONG ul;
    6299 
    6300           switch (SHORT1FROMMP(mp1)) {
    6301           case MAIN_USERLIST:
    6302             ul = CCHMAXPATH;
    6303             break;
    6304           case MAIN_SETUPLIST:
    6305             ul = STATE_NAME_MAX_BYTES;
    6306             break;
    6307           default:
    6308             ul = 13;                    // fixme to not be hardcoded
    6309           }
    6310 
    6311           SetShiftState();
    6312           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    6313           bstrip(path);
    6314           if (*path) {
    6315             if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
    6316               if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
    6317                 if (!LastDir ||
    6318                     !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
    6319                                 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
    6320                   strcpy(path, pFM2SaveDirectory);
    6321                 if (!PMMkDir(hwnd, path, TRUE)) {
    6322                   WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
    6323                   break;
    6324                 }
    6325               }
    6326               if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
    6327 
    6328                 HWND hwndDir;
    6329 
    6330                 if ((fUserListSwitches &&
    6331                      !(shiftstate & KC_SHIFT)) ||
    6332                     (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
    6333                   hwndDir = FindDirCnr(hwnd);
    6334                   if (hwndDir) {
    6335                     WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
    6336                     break;
    6337                   }
    6338                 }
    6339                 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
    6340               }
    6341             }
    6342             else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
    6343               ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    6344                                                           FID_CLIENT),
    6345                                           TREE_CNR), path, FALSE, TRUE);
    6346               WinSetFocus(HWND_DESKTOP, hwndTree);
    6347             }
    6348             else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
    6349               strcat(path, ".TLS");
    6350               load_tools(path);
    6351               PrfWriteProfileString(fmprof,
    6352                                     FM3Str, "LastToolbar", lasttoolbar);
    6353               PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
    6354               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBARTEXT));
    6355             }
    6356             else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    6357               CHAR szKey[80];
    6358               ULONG size, numsaves = 0;
    6359 
    6360               SetShiftState();
    6361               size = sizeof(ULONG);
    6362               sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
    6363               if (!PrfQueryProfileData(fmprof,
    6364                                        FM3Str,
    6365                                        szKey,
    6366                                        (PVOID)&numsaves,
    6367                                        &size))
    6368               {
    6369                 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
    6370                   saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    6371                         GetPString(IDS_WARNINGTEXT),
    6372                         GetPString(IDS_DOESNTEXISTTEXT), path);
    6373                 }
    6374                 else {
    6375                   Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
    6376                              IDS_PRFQUERYPROFILEDATA);
    6377                 }
    6378               }
    6379               else {
    6380                 char *pszStateName;
    6381                 if ((shiftstate & KC_SHIFT) == 0)
    6382                   PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
    6383                 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
    6384                 if (!pszStateName) {
    6385                   // Fall back if out of memory - already complained
    6386                   if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
    6387                     // Autotile requested or forced
    6388                     PostMsg(MainObjectHwnd,
    6389                             UM_RESTORE,
    6390                             MPVOID,
    6391                             MPFROMLONG(1));                // Autotile
    6392                   }
    6393                 }
    6394                 else if (!PostMsg(MainObjectHwnd,
    6395                                   UM_RESTORE,
    6396                                   MPFROMP(pszStateName),
    6397                                   MPVOID)) {
    6398                   free(pszStateName);
    6399                 }
    6400               }
    6401             }
    6402             else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
    6403 
    6404               SHORT sSelect;
    6405 
    6406               sSelect = (SHORT) WinSendMsg(hwndCmdlist,
    6407                                            LM_QUERYSELECTION,
    6408                                            MPFROMSHORT(LIT_FIRST), MPVOID);
    6409               if (sSelect >= 0)
    6410                 WinPostMsg(hwnd,
    6411                            WM_COMMAND,
    6412                            MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
    6413                            MPVOID);
    6414               WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    6415             }
    6416           }
    6417         }
    6418         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;
    64196469
    64206470      default:
    6421         break;
     6471        break;
    64226472      }
    64236473      break;
     
    64396489  case WM_CLOSE:
    64406490    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6441                WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     6491               WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    64426492    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    64436493    fAmClosing = TRUE;
    64446494    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6445                WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
     6495               WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
    64466496    if (CloseChildren(hwnd)) {
    64476497      fAmClosing = FALSE;
    64486498      if (fAutoTile)
    6449         PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
     6499        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
    64506500      return 0;
    64516501    }
    64526502    if (hwndTree) {
    64536503      if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
    6454         WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
     6504        WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    64556505    }
    64566506    DosSleep(1);
     
    64666516      // Try to restore saved shutdown state
    64676517      char *pszDefaultStateName = xstrdup(GetPString(IDS_SHUTDOWNSTATE),
    6468                                           pszSrcFile, __LINE__);
     6518                                          pszSrcFile, __LINE__);
    64696519      if (pszDefaultStateName) {
    6470         if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
    6471           // 05 Feb 08 SHL fixme to complain?
    6472           free(pszDefaultStateName);
     6520        if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
     6521          // 05 Feb 08 SHL fixme to complain?
     6522          free(pszDefaultStateName);
    64736523      }
    64746524    }
     
    64796529    if (mp1)
    64806530      return MRFROMLONG(OpenDirCnr((HWND) 0,
    6481                                    hwndMain,
    6482                                    hwndTree, (BOOL) mp2, (char *)mp1));
     6531                                   hwndMain,
     6532                                   hwndTree, (BOOL) mp2, (char *)mp1));
    64836533    return 0;
    64846534
Note: See TracChangeset for help on using the changeset viewer.