Changeset 1077 for trunk/dll


Ignore:
Timestamp:
Jul 18, 2008, 8:11:54 PM (17 years ago)
Author:
Steven Levine
Message:

Enhance Fortify infrastructure
Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT support
Add more fm/2 Fortify tooling and rework existing tooling for correct nesting
Still lots to do for cross-thread allocations
Add misc.h
Add walkem.h

Location:
trunk/dll
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r1076 r1077  
    339339  if (pai->pszFileName && pai->pszFileName != NullStr) {
    340340    psz = pai->pszFileName;
    341     pai->pszFileName = NULL;
     341    pai->pszFileName = NULL;            // 08 Jul 08 SHL was NulStr
    342342    free(psz);
    343343  }
     
    12301230
    12311231  switch (msg) {
     1232  case WM_CREATE:
     1233    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
     1234    break;
     1235
    12321236  case DM_PRINTOBJECT:
    12331237  case DM_DISCARDOBJECT:
     
    13471351
    13481352  case UM_SETUP:
     1353#   ifdef FORTIFY
     1354    Fortify_EnterScope();
     1355#   endif
    13491356    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    13501357    if (!dcd) {
     
    13531360    }
    13541361    else {
     1362#     ifdef FORTIFY
     1363      Fortify_ChangeOwner(dcd);
     1364#     endif
    13551365      /* set unique id */
    13561366      WinSetWindowUShort(hwnd, QWS_ID, ARCOBJ_FRAME + (ARC_FRAME - dcd->id));
     
    15001510
    15011511      if (li && li->list && li->list[0]) {
    1502         printf("%x/r", li->type); fflush(stdout);
     1512        printf("%x/r", li->type); fflush(stdout);
    15031513        switch (li->type) {
    15041514        case IDM_ARCHIVE:
     
    15651575        case IDM_DELETE:
    15661576          {
    1567             CHAR *endofit;
    1568             PSZ pszCmdLine;
     1577            CHAR *endofit;
     1578            PSZ pszCmdLine;
    15691579            INT z;
    15701580            CHECKLIST ck;
     
    15921602            li->list = ck.list;
    15931603            if (!li->list || !li->list[0])
    1594               break;
    1595             pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    1596             if (!pszCmdLine)
    1597               break;
     1604              break;
     1605            pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     1606            if (!pszCmdLine)
     1607              break;
    15981608            strcpy(pszCmdLine, li->type == IDM_DELETE ?
    15991609                         dcd->info->delete :
     
    16131623                      (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
    16141624                      hwnd, pszSrcFile, __LINE__, NullStr, NULL, "%s", pszCmdLine);
    1615               *endofit = 0;
    1616               free(pszCmdLine);
     1625              *endofit = 0;
     1626              free(pszCmdLine);
    16171627            } while (li->list[x]);
    16181628            PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
     
    16391649        case IDM_OPENSETTINGS:
    16401650          {
    1641             CHAR *endofit, *ptr;
    1642             PSZ pszCmdLine;
     1651            CHAR *endofit, *ptr;
     1652            PSZ pszCmdLine;
    16431653            INT z;
    16441654            if ((li->type == IDM_EXTRACT && !li->info->extract) ||
     
    16991709            }
    17001710            if (!li->list || !li->list[0])
    1701               break;
    1702             pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    1703             if (!pszCmdLine)
    1704               break;
     1711              break;
     1712            pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     1713            if (!pszCmdLine)
     1714              break;
    17051715            strcpy(pszCmdLine,
    17061716                   (li->type == IDM_EXTRACT ||
     
    17391749                      (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED) |
    17401750                      WAIT, hwnd, pszSrcFile, __LINE__,
    1741                       li->targetpath, NULL, "%s", pszCmdLine);
     1751                      li->targetpath, NULL, "%s", pszCmdLine);
    17421752              *endofit = 0;
    17431753            } while (li->list[x]);
     
    17571767                p = xmalloc(strlen(temp) + strlen(li->targetpath) + 2,
    17581768                            pszSrcFile, __LINE__);
    1759                 if (p) {
    1760                   BldFullPathName(p, li->targetpath, temp);
     1769                if (p) {
     1770                  BldFullPathName(p, li->targetpath, temp);
    17611771                  /*strcpy(p, li->targetpath);
    17621772                  if (p[strlen(p) - 1] != '\\')
     
    18271837                    }
    18281838                  }
    1829                 }
     1839                }
    18301840                BldFullPathName(pszCmdLine, li->targetpath, li->list[x]);
    18311841                temp = li->list[x];
    1832                 li->list[x] = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
     1842                li->list[x] = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
    18331843                if (!li->list[x])
    18341844                  li->list[x] = temp;
    18351845                else
    18361846                  xfree(temp, pszSrcFile, __LINE__);
    1837               }
    1838               free(pszCmdLine);
     1847              }
     1848              free(pszCmdLine);
    18391849              if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
    18401850
     
    18561866              if (li->type == IDM_MCIPLAY) {
    18571867
    1858                 FILE *fp;
    1859                 CHAR szTempFile[CCHMAXPATH];
    1860 
    1861                 BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
     1868                FILE *fp;
     1869                CHAR szTempFile[CCHMAXPATH];
     1870
     1871                BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
    18621872                fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
    18631873                if (fp) {
     
    18661876                    fprintf(fp, "%s\n", li->list[x]);
    18671877                  fprintf(fp, ";end\n");
    1868                   fclose(fp);
    1869                   strrev(szTempFile);
    1870                   strcat(szTempFile, "@/");
    1871                   strrev(szTempFile);
     1878                  fclose(fp);
     1879                  strrev(szTempFile);
     1880                  strcat(szTempFile, "@/");
     1881                  strrev(szTempFile);
    18721882                  RunFM2Util("FM2PLAY.EXE", szTempFile);
    18731883                }
     
    19131923                       li->type == IDM_OPENSETTINGS) {
    19141924                WORKER *wk;
    1915 #               ifdef FORTIFY
    1916                 Fortify_EnterScope();
    1917 #               endif
     1925#               ifdef FORTIFY
     1926                Fortify_EnterScope();
     1927#               endif
    19181928                wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    19191929                if (!wk)
    1920                   FreeListInfo(li);
     1930                  FreeListInfo(li);
    19211931                else {
    1922                   wk->size = sizeof(WORKER);
    1923                   wk->hwndCnr = dcd->hwndCnr;
    1924                   wk->hwndParent = dcd->hwndParent;
    1925                   wk->hwndFrame = dcd->hwndFrame;
    1926                   wk->hwndClient = dcd->hwndClient;
    1927                   wk->li = li;
    1928                   strcpy(wk->directory, dcd->directory);
    1929                   if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
    1930                     Runtime_Error(pszSrcFile, __LINE__,
    1931                                   GetPString(IDS_COULDNTSTARTTHREADTEXT));
    1932                     free(wk);
    1933                     FreeListInfo((LISTINFO *) mp1);
    1934 #                   ifdef FORTIFY
    1935                     Fortify_LeaveScope();
    1936 #                   endif
    1937                   }
    1938         }
    1939 
     1932                  wk->size = sizeof(WORKER);
     1933                  wk->hwndCnr = dcd->hwndCnr;
     1934                  wk->hwndParent = dcd->hwndParent;
     1935                  wk->hwndFrame = dcd->hwndFrame;
     1936                  wk->hwndClient = dcd->hwndClient;
     1937                  wk->li = li;
     1938                  strcpy(wk->directory, dcd->directory);
     1939                  if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
     1940                    Runtime_Error(pszSrcFile, __LINE__,
     1941                                  GetPString(IDS_COULDNTSTARTTHREADTEXT));
     1942                    free(wk);
     1943                    FreeListInfo((LISTINFO *) mp1);
     1944                  }
     1945                }
     1946#               ifdef FORTIFY
     1947                Fortify_LeaveScope();
     1948#               endif
    19401949              }
    19411950              else {
     
    19541963                    else
    19551964                      viewtype = 0;
     1965#                   ifdef FORTIFY
     1966                    Fortify_EnterScope();
     1967#                   endif
    19561968                    temp = xstrdup(li->list[x], pszSrcFile, __LINE__);
    19571969                    if (temp) {
     
    19641976                        free(temp);
    19651977                    }
     1978#                   ifdef FORTIFY
     1979                    DosSleep(1);        // Allow MassAction to take ownership
     1980                    Fortify_LeaveScope();
     1981#                   endif
    19661982                  }
    19671983                }
     
    20202036      if (li->type != IDM_OPENDEFAULT && li->type != IDM_OPENSETTINGS)
    20212037      {
    2022         FreeListInfo(li);
     2038        FreeListInfo(li);
    20232039      }
    20242040    }
     
    20452061      free(dcd);
    20462062#     ifdef FORTIFY
    2047       //Fortify_LeaveScope();
    2048 #      endif
     2063      Fortify_LeaveScope();
     2064#     endif
    20492065      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
    20502066    }
     
    25922608
    25932609      if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
    2594         hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
    2595                            (CHAR *)mp2, dcd->hwndFrame);
     2610        hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
     2611                           (CHAR *)mp2, dcd->hwndFrame);
    25962612      else
    2597         hwnd = StartMLEEditor(dcd->hwndParent,
    2598                               (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     2613        hwnd = StartMLEEditor(dcd->hwndParent,
     2614                              (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    25992615      free((CHAR *)mp2);
    26002616      return MRFROMLONG(hwnd);
     
    29532969        {
    29542970          LISTINFO *li;
    2955 #         ifdef FORTIFY
    2956           Fortify_EnterScope();
    2957 #          endif
     2971#         ifdef FORTIFY
     2972          Fortify_EnterScope();
     2973#         endif
    29582974          li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    29592975          if (li) {
     
    30153031            case IDM_VIRUSSCAN:
    30163032            case IDM_OPENDEFAULT:
    3017             case IDM_OPENSETTINGS:
    3018             case IDM_MCIPLAY:
     3033            case IDM_OPENSETTINGS:
     3034            case IDM_MCIPLAY:
    30193035              strcpy(li->targetpath, dcd->workdir);
    30203036              break;
     
    30313047                UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
    30323048            }
    3033             else {
     3049            else {
    30343050              free(li);
    3035 #             ifdef FORTIFY
    3036               Fortify_LeaveScope();
    3037 #              endif
    3038             }
    3039           }
     3051            }
     3052          }
     3053#         ifdef FORTIFY
     3054          Fortify_LeaveScope();
     3055#         endif
    30403056        }
    30413057        break;
     
    35093525#     ifdef FORTIFY
    35103526      Fortify_EnterScope();
    3511 #      endif
     3527#     endif
    35123528      dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    35133529      if (!dcd) {
     
    35193535        dcd->id = id;
    35203536        dcd->type = ARC_FRAME;
    3521         if (!pTmpDir) {
    3522           save_dir2(dcd->workdir);
    3523           if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
    3524             strcat(dcd->workdir, "\\");
    3525           sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
    3526                   ArcTempRoot, (clock() & 4095));
    3527         }
    3528         else
    3529           sprintf(dcd->workdir, "%s.%03x",
    3530                   ArcTempRoot, (clock() & 4095));
     3537        if (!pTmpDir) {
     3538          save_dir2(dcd->workdir);
     3539          if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
     3540            strcat(dcd->workdir, "\\");
     3541          sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
     3542                  ArcTempRoot, (clock() & 4095));
     3543        }
     3544        else
     3545          sprintf(dcd->workdir, "%s.%03x",
     3546                  ArcTempRoot, (clock() & 4095));
    35313547        strcpy(dcd->arcname, fullname);
    35323548        if (*extractpath) {
     
    35983614                     IDS_WINCREATEWINDOW);
    35993615          PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3600           free(dcd);
    3601 #         ifdef FORTIFY
    3602           Fortify_LeaveScope();
    3603 #          endif
     3616          free(dcd);
    36043617          hwndFrame = (HWND) 0;
    36053618        }
     
    36923705        }
    36933706      }
     3707#     ifdef FORTIFY
     3708      Fortify_LeaveScope();
     3709#     endif
    36943710    }
    36953711  }
  • trunk/dll/collect.c

    r1065 r1077  
    5050  06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
    5151  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    52                 all the details view settings (both the global variables and those in the
    53                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     52                all the details view settings (both the global variables and those in the
     53                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    5454
    5555***********************************************************************/
     
    7878#include "tmrsvcs.h"                    // ITIMER_DESC
    7979#include "notebook.h"                   // CfgDlgProc
    80 #include "command.h"                    // RunCommand
     80#include "command.h"                    // RunCommand
    8181#include "fm3dll.h"
    8282
     
    466466  switch (msg) {
    467467  case WM_CREATE:
     468    // 18 Jul 08 SHL fixme to doc why messsage gets lost
     469    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
    468470    break;
    469471
     
    505507
    506508  case UM_SETUP:
     509#   ifdef FORTIFY
     510    Fortify_EnterScope();
     511#   endif
    507512    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    508513    if (dcd) {
     514#     ifdef FORTIFY
     515      Fortify_ChangeOwner(dcd);
     516#     endif
    509517      /* set unique id */
    510518      WinSetWindowUShort(hwnd,
     
    601609            nm = 1;
    602610            hdir = HDIR_CREATE;
    603             DosError(FERR_DISABLEHARDERR);
    604             if (FindCnrRecord(dcd->hwndCnr,
     611            DosError(FERR_DISABLEHARDERR);
     612            if (FindCnrRecord(dcd->hwndCnr,
    605613                              li->list[x],
    606614                              NULL,
    607615                              FALSE,
    608616                              FALSE,
    609                               TRUE)) {
    610               pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
    611               if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
    612                 pci->rc.flRecordAttr &= ~CRA_FILTERED;
    613                 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
    614                            MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
    615               }
    616               pci = (PCNRITEM) pci->rc.preccNextRecord;
     617                              TRUE)) {
     618              pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
     619              if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
     620                pci->rc.flRecordAttr &= ~CRA_FILTERED;
     621                WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
     622                           MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
     623              }
     624              pci = (PCNRITEM) pci->rc.preccNextRecord;
    617625              if (pciP)
    618626                pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
    619627              else
    620                 pciFirst = pci;
    621             }
     628                pciFirst = pci;
     629            }
    622630            else if (*li->list[x] &&
    623631                !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
     
    631639                               &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
    632640              DosFindClose(hdir);
    633               priority_normal();
    634                 *fb4.achName = 0;
    635                 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
    636                                                     pci,
     641              priority_normal();
     642                *fb4.achName = 0;
     643                ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
     644                                                    pci,
    637645                                                    fullname, &fb4, FALSE, dcd);
    638                 dcd->ullTotalBytes += ullTotalBytes;
    639                 pciP = pci;
    640                 pci = (PCNRITEM) pci->rc.preccNextRecord;
     646                dcd->ullTotalBytes += ullTotalBytes;
     647                pciP = pci;
     648                pci = (PCNRITEM) pci->rc.preccNextRecord;
    641649            }
    642650            else {
     
    647655                pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
    648656              else
    649                 pciFirst = pci;
    650               if (pciT)
    651                 FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
     657                pciFirst = pci;
     658              if (pciT)
     659                FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
    652660              ulMaxFiles--;             // Remember gone
    653661            }
     
    680688  case UM_COLLECTFROMFILE:
    681689    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
     690#   ifdef FORTIFY
     691    Fortify_EnterScope();
     692#   endif
     693
    682694    if (dcd && mp1) {
    683695      FILESTATUS4L fs4;
     
    690702      size_t c;
    691703
     704#     ifdef FORTIFY
     705      Fortify_ChangeOwner(mp1);
     706#     endif
     707
    692708      fp = _fsopen((CHAR *)mp1, "r", SH_DENYNO);
    693709      if (fp) {
     
    722738            }
    723739            /* fullname now contains name of file to collect */
    724             DosError(FERR_DISABLEHARDERR);
    725             if (FindCnrRecord(dcd->hwndCnr,
     740            DosError(FERR_DISABLEHARDERR);
     741            if (FindCnrRecord(dcd->hwndCnr,
    726742                              fullname,
    727743                              NULL,
    728744                              FALSE,
    729745                              FALSE,
    730                               TRUE)) {
    731               pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
    732               if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
    733                 pci->rc.flRecordAttr &= ~CRA_FILTERED;
    734                 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
    735                            MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
    736               }
    737               /*pci = (PCNRITEM) pci->rc.preccNextRecord;
     746                              TRUE)) {
     747              pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
     748              if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
     749                pci->rc.flRecordAttr &= ~CRA_FILTERED;
     750                WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
     751                           MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
     752              }
     753              /*pci = (PCNRITEM) pci->rc.preccNextRecord;
    738754              if (pciP)
    739755                pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
    740756              else
    741                 pciFirst = pci;*/
    742             }
     757                pciFirst = pci;*/
     758            }
    743759            else if (IsFullName(fullname) &&
    744760                !IsRoot(fullname) &&
     
    746762                                  FIL_QUERYEASIZEL,
    747763                                  &fs4,
    748                                   sizeof(fs4)))  {
     764                                  sizeof(fs4))) {
    749765              /* collect it */
    750766              pci = WinSendMsg(dcd->hwndCnr,
     
    791807#   ifdef FORTIFY
    792808    Fortify_LeaveScope();
    793 #    endif
     809#   endif
    794810    return 0;
    795811
     
    890906
    891907  case UM_MASSACTION:
     908#   ifdef FORTIFY
     909    Fortify_EnterScope();
     910#   endif
    892911    if (mp1) {
     912#     ifdef FORTIFY
     913      Fortify_ChangeOwner(mp1);
     914#     endif
    893915      dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    894916      if (dcd) {
    895917        WORKER *wk;
    896 #       ifdef FORTIFY
    897         Fortify_EnterScope();
    898 #        endif
    899918        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    900919        if (!wk)
     
    911930            Runtime_Error(pszSrcFile, __LINE__,
    912931                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    913             free(wk);
     932            free(wk);
    914933            FreeListInfo((LISTINFO *) mp1);
    915 #           ifdef FORTIFY
    916             Fortify_LeaveScope();
    917 #            endif
    918           }
    919         }
    920       }
    921     }
     934          }
     935        }
     936      }
     937    }
     938#   ifdef FORTIFY
     939    DosSleep(1);                        // Let receiver take ownership
     940    Fortify_LeaveScope();
     941#   endif
    922942    return 0;
    923943
    924944  case UM_ACTION:
     945#   ifdef FORTIFY
     946    Fortify_EnterScope();
     947#   endif
    925948    if (mp1) {
     949#     ifdef FORTIFY
     950      Fortify_ChangeOwner(mp1);
     951#     endif
    926952      dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    927953      if (dcd) {
    928954        WORKER *wk;
    929 #       ifdef FORTIFY
    930         Fortify_EnterScope();
    931 #        endif
    932955        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    933956        if (!wk)
     
    944967            Runtime_Error(pszSrcFile, __LINE__,
    945968                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    946             free(wk);
     969            free(wk);
    947970            FreeListInfo((LISTINFO *) mp1);
    948 #           ifdef FORTIFY
    949             Fortify_LeaveScope();
    950 #            endif
    951           }
    952         }
    953       }
    954     }
     971          }
     972        }
     973      }
     974    }
     975#   ifdef FORTIFY
     976    DosSleep(1);                        // Let receiver take ownership
     977    Fortify_LeaveScope();
     978#   endif
    955979    return 0;
    956980
     
    975999#     ifdef FORTIFY
    9761000      Fortify_LeaveScope();
    977 #      endif
     1001#     endif
    9781002      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
    9791003    }
     
    14701494  case UM_COLLECTFROMFILE:
    14711495    if (mp1) {
    1472       if (!dcd) {
    1473         free(mp1);
    1474 #       ifdef FORTIFY
    1475         Fortify_LeaveScope();
    1476 #        endif
     1496#     ifdef FORTIFY
     1497      Fortify_EnterScope();
     1498      Fortify_ChangeOwner(mp1);
     1499#     endif
     1500      if (!dcd)
    14771501        Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    1478       }
    14791502      else {
    14801503        if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
    14811504          Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
    1482           free(mp1);
    1483 #         ifdef FORTIFY
    1484           Fortify_LeaveScope();
    1485 #          endif
    1486         }
    1487       }
     1505        }
     1506      }
     1507      free(mp1);
     1508#     ifdef FORTIFY
     1509      DosSleep(1);                      // Let receiver take ownership
     1510      Fortify_LeaveScope();
     1511#     endif
    14881512    }
    14891513    return 0;
     
    16061630          }
    16071631          if (insert_filename(hwnd, filename, FALSE, FALSE)) {
     1632#           ifdef FORTIFY
     1633            Fortify_EnterScope();
     1634#           endif
    16081635            p = xstrdup(filename, pszSrcFile, __LINE__);
    16091636            if (p) {
    16101637              if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
    1611                 free(p);
    1612 #               ifdef FORTIFY
    1613                 Fortify_LeaveScope();
    1614 #                endif
    1615             }
     1638                free(p);
     1639            }
     1640#           ifdef FORTIFY
     1641            DosSleep(1);                // Let receiver take ownership
     1642            Fortify_LeaveScope();
     1643#           endif
    16161644          }
    16171645        }
     
    17271755        {
    17281756          LISTINFO *li;
    1729 #         ifdef FORTIFY
    1730           Fortify_EnterScope();
    1731 #          endif
     1757#         ifdef FORTIFY
     1758          Fortify_EnterScope();
     1759#         endif
    17321760          li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    17331761          if (li) {
     
    17411769            }
    17421770          }
     1771#         ifdef FORTIFY
     1772          DosSleep(1);          // Let receiver take ownership
     1773          Fortify_LeaveScope();
     1774#         endif
    17431775        }
    17441776        break;
     
    17781810        if (mp2) {
    17791811          LISTINFO *li;
    1780 #         ifdef FORTIFY
    1781           Fortify_EnterScope();
    1782 #          endif
     1812#         ifdef FORTIFY
     1813          Fortify_EnterScope();
     1814#         endif
    17831815          li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    17841816          if (li) {
     
    17941826          else
    17951827            FreeList(mp2);
     1828#         ifdef FORTIFY
     1829          DosSleep(1);                  // Let receiver take ownership
     1830          Fortify_LeaveScope();
     1831#         endif
    17961832        }
    17971833        break;
    17981834
    17991835      case IDM_UNDELETE:
    1800         {
     1836        {
    18011837          PCNRITEM pci;
    1802           CHAR path[CCHMAXPATH];
    1803           HOBJECT hObject;
    1804           HWND hwndDesktop;
    1805 
    1806           hObject = WinQueryObject("<XWP_TRASHCAN>");
    1807           if (hObject != NULLHANDLE && fTrashCan) {
    1808             hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
     1838          CHAR path[CCHMAXPATH];
     1839          HOBJECT hObject;
     1840          HWND hwndDesktop;
     1841
     1842          hObject = WinQueryObject("<XWP_TRASHCAN>");
     1843          if (hObject != NULLHANDLE && fTrashCan) {
     1844            hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
    18091845            WinSetFocus(HWND_DESKTOP, hwndDesktop);
    1810             WinOpenObject(hObject, 0, TRUE);
    1811           }
    1812           else {
    1813             pci = (PCNRITEM) CurrentRecord(hwnd);
    1814             if (pci && (INT) pci != -1) {
    1815               strcpy(path, pci->pszFileName);
    1816               MakeValidDir(path);
    1817               WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
    1818                         UNDEL_FRAME, MPFROMP(path));
    1819             }
     1846            WinOpenObject(hObject, 0, TRUE);
     1847          }
     1848          else {
     1849            pci = (PCNRITEM) CurrentRecord(hwnd);
     1850            if (pci && (INT) pci != -1) {
     1851              strcpy(path, pci->pszFileName);
     1852              MakeValidDir(path);
     1853              WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
     1854                        UNDEL_FRAME, MPFROMP(path));
     1855            }
    18201856          }
    18211857        }
     
    18911927                                    DIR_FILTER), &dcd->mask, FALSE);
    18921928        }
    1893         break;
     1929        break;
    18941930
    18951931      case IDM_UNHIDEALL:
    1896         WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
    1897         break;
     1932        WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
     1933        break;
    18981934
    18991935      case IDM_HIDEALL:
     
    20922128          LISTINFO *li;
    20932129          ULONG action = UM_ACTION;
    2094 #         ifdef FORTIFY
    2095           Fortify_EnterScope();
    2096 #          endif
     2130#         ifdef FORTIFY
     2131          Fortify_EnterScope();
     2132#         endif
    20972133          li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    20982134          if (li) {
     
    21372173                UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
    21382174            }
    2139             else
    2140               free(li);
    2141 #             ifdef FORTIFY
    2142               Fortify_LeaveScope();
    2143 #              endif
    2144           }
     2175            else
     2176              free(li);
     2177          }
     2178#         ifdef FORTIFY
     2179          Fortify_LeaveScope();
     2180#         endif
    21452181        }
    21462182        break;
     
    27002736
    27012737      if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
    2702         hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
    2703                            (CHAR *)mp2, dcd->hwndFrame);
     2738        hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
     2739                           (CHAR *)mp2, dcd->hwndFrame);
    27042740      else
    2705         hwnd = StartMLEEditor(dcd->hwndParent,
    2706                               (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     2741        hwnd = StartMLEEditor(dcd->hwndParent,
     2742                              (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    27072743      free((CHAR *)mp2);
    27082744      return MRFROMLONG(hwnd);
     
    27642800{
    27652801  PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
    2766   static short  sLastMenuitem;
     2802  static short sLastMenuitem;
    27672803
    27682804  switch (msg) {
     
    27912827            MOUSEMSG(&msg)->y < rectl.yTop)
    27922828           break;
    2793         }                      // for
     2829        } // for
    27942830
    27952831
     
    28592895#   ifdef FORTIFY
    28602896    Fortify_EnterScope();
    2861 #    endif
     2897#   endif
    28622898    dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    28632899    if (!dcd) {
     
    28982934                   IDS_WINCREATEWINDOW);
    28992935        PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    2900         free(dcd);
    2901 #       ifdef FORTIFY
    2902         Fortify_LeaveScope();
    2903 #        endif
     2936        free(dcd);
    29042937        hwndFrame = (HWND) 0;
    29052938      }
     
    29522985      }
    29532986    }
     2987#   ifdef FORTIFY
     2988    DosSleep(1);                // Let receiver take ownership
     2989    Fortify_LeaveScope();
     2990#   endif
    29542991  }
    29552992  return hwndFrame;
  • trunk/dll/dircnrs.c

    r1065 r1077  
    4242  06 Jul 08 GKY Update delete/undelete to include move to and open XWP trashcan
    4343  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    44                 all the details view settings (both the global variables and those in the
    45                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     44                all the details view settings (both the global variables and those in the
     45                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    4646
    4747***********************************************************************/
     
    7070#include "command.h"                    // RunCommand
    7171#include "fm3dll.h"
    72 #include "avl.h"                        // free_archivers
     72#include "avl.h"                        // free_archivers
    7373#include "fortify.h"
    7474
     
    598598  switch (msg) {
    599599  case WM_CREATE:
     600    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
    600601    break;
    601602
     
    606607    dcd = INSTDATA(hwnd);
    607608    if (fFM2Deletes && dcd) {
    608 
    609609      LISTINFO *li;
    610610      CNRDRAGINFO cni;
    611 
    612611      cni.pRecord = NULL;
    613612      cni.pDragInfo = (PDRAGINFO) mp1;
     
    641640
    642641  case UM_SETUP:
     642#   ifdef FORTIFY
     643    Fortify_EnterScope();
     644#   endif
    643645    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    644646    if (dcd) {
     647#     ifdef FORTIFY
     648      Fortify_ChangeOwner(dcd);
     649#     endif
    645650      /* set unique id */
    646651      WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
     
    988993  case UM_MASSACTION:
    989994    if (mp1) {
    990 
    991995      dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    992996      if (dcd) {
    993 
    994997        WORKER *wk;
    995 #       ifdef FORTIFY
    996         Fortify_EnterScope();
    997 #        endif
     998#       ifdef FORTIFY
     999        Fortify_EnterScope();
     1000#       endif
    9981001        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    9991002        if (!wk)
     
    10101013            Runtime_Error(pszSrcFile, __LINE__,
    10111014                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    1012             free(wk);
     1015            free(wk);
    10131016            FreeListInfo((LISTINFO *) mp1);
    1014 #           ifdef FORTIFY
    1015             Fortify_LeaveScope();
    1016 #            endif
    1017           }
    1018         }
     1017          }
     1018        }
     1019#       ifdef FORTIFY
     1020        DosSleep(1);             // Allow MassAction to take ownership
     1021        Fortify_LeaveScope();
     1022#       endif
    10191023      }
    10201024    }
     
    10281032
    10291033        WORKER *wk;
    1030 #       ifdef FORTIFY
    1031         Fortify_EnterScope();
    1032 #        endif
     1034#       ifdef FORTIFY
     1035        Fortify_EnterScope();
     1036#       endif
    10331037        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    10341038        if (!wk)
     
    10451049            Runtime_Error(pszSrcFile, __LINE__,
    10461050                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    1047             free(wk);
     1051            free(wk);
    10481052            FreeListInfo((LISTINFO *) mp1);
    1049 #           ifdef FORTIFY
    1050             Fortify_LeaveScope();
    1051 #            endif
    1052           }
    1053         }
     1053          }
     1054        }
     1055#       ifdef FORTIFY
     1056        Fortify_LeaveScope();
     1057#       endif
    10541058      }
    10551059    }
     
    10911095
    10921096  switch (msg) {
     1097  case WM_CREATE:
     1098#   ifdef FORTIFY
     1099    Fortify_EnterScope();
     1100#   endif
     1101    break;
     1102
    10931103  case DM_PRINTOBJECT:
    10941104    return MRFROMLONG(DRR_TARGET);
     
    12421252
    12431253      if (!IsFile(leftdir) && !IsFile(rightdir)) {
     1254#       ifdef FORTIFY
     1255        Fortify_EnterScope();
     1256#       endif
    12441257        cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    12451258        if (cmp) {
     
    12531266                    CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    12541267        }
     1268#       ifdef FORTIFY
     1269        Fortify_LeaveScope();
     1270#       endif
    12551271      }
    12561272    }
     
    20402056        {
    20412057          PCNRITEM pci;
    2042           CHAR path[CCHMAXPATH];
    2043           HOBJECT hObject;
    2044           HWND hwndDesktop;
    2045 
    2046           hObject = WinQueryObject("<XWP_TRASHCAN>");
    2047           if (hObject != NULLHANDLE && fTrashCan) {
    2048             hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
     2058          CHAR path[CCHMAXPATH];
     2059          HOBJECT hObject;
     2060          HWND hwndDesktop;
     2061
     2062          hObject = WinQueryObject("<XWP_TRASHCAN>");
     2063          if (hObject != NULLHANDLE && fTrashCan) {
     2064            hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
    20492065            WinSetFocus(HWND_DESKTOP, hwndDesktop);
    2050             WinOpenObject(hObject, 0, TRUE);
    2051           }
    2052           else {
    2053             pci = (PCNRITEM) CurrentRecord(hwnd);
    2054             if (pci && (INT) pci != -1) {
    2055               strcpy(path, pci->pszFileName);
    2056               MakeValidDir(path);
    2057               WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
    2058                         UNDEL_FRAME, MPFROMP(path));
    2059             }
     2066            WinOpenObject(hObject, 0, TRUE);
     2067          }
     2068          else {
     2069            pci = (PCNRITEM) CurrentRecord(hwnd);
     2070            if (pci && (INT) pci != -1) {
     2071              strcpy(path, pci->pszFileName);
     2072              MakeValidDir(path);
     2073              WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
     2074                        UNDEL_FRAME, MPFROMP(path));
     2075            }
    20602076          }
    20612077        }
     
    20632079
    20642080      case IDM_UNDELETESPEC:
    2065         {
    2066           HOBJECT hObject;
    2067           HWND hwndDesktop;
    2068 
    2069           hObject = WinQueryObject("<XWP_TRASHCAN>");
    2070           if (hObject != NULLHANDLE && fTrashCan) {
    2071             hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
     2081        {
     2082          HOBJECT hObject;
     2083          HWND hwndDesktop;
     2084
     2085          hObject = WinQueryObject("<XWP_TRASHCAN>");
     2086          if (hObject != NULLHANDLE && fTrashCan) {
     2087            hwndDesktop = WinQueryDesktopWindow((HAB) 0, NULLHANDLE);
    20722088            WinSetFocus(HWND_DESKTOP, hwndDesktop);
    2073             WinOpenObject(hObject, 0, TRUE);
    2074           }
    2075         else
     2089            WinOpenObject(hObject, 0, TRUE);
     2090          }
     2091        else
    20762092          WinDlgBox(HWND_DESKTOP,
    20772093                    hwnd,
    20782094                    UndeleteDlgProc,
    2079                     FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
    2080         }
    2081         break;
     2095                    FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
     2096        }
     2097        break;
    20822098
    20832099      case IDM_RESORT:
     
    33383354
    33393355      if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
    3340         hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
    3341                            (CHAR *)mp2, dcd->hwndFrame);
     3356        hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
     3357                           (CHAR *)mp2, dcd->hwndFrame);
    33423358      else
    3343         hwnd = StartMLEEditor(dcd->hwndParent,
    3344                               (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     3359        hwnd = StartMLEEditor(dcd->hwndParent,
     3360                              (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    33453361      xfree((CHAR *)mp2, pszSrcFile, __LINE__);
    33463362      return MRFROMLONG(hwnd);
     
    34003416    DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
    34013417    EmptyCnr(hwnd);
     3418#   ifdef FORTIFY
     3419    Fortify_LeaveScope();
     3420#   endif
    34023421    break;
    34033422  } // switch
     
    34403459  if (!hwndMain && !first) {
    34413460    if (DirCnrMenu) {
    3442 
    34433461      MENUITEM mi;
    3444 
    34453462      memset(&mi, 0, sizeof(mi));
    34463463      WinSendMsg(DirCnrMenu,
     
    34703487#     ifdef FORTIFY
    34713488      Fortify_EnterScope();
    3472 #      endif
     3489#     endif
    34733490      dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    34743491      if (!dcd) {
     
    35213538                     IDS_WINCREATEWINDOW);
    35223539          PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3523           free(dcd);
    3524 #         ifdef FORTIFY
    3525           Fortify_LeaveScope();
    3526 #          endif
     3540          free(dcd);
    35273541          hwndFrame = (HWND) 0;
    35283542        }
     
    35733587        }
    35743588      }
     3589#     ifdef FORTIFY
     3590      Fortify_LeaveScope();
     3591#     endif
    35753592    }
    35763593  }
  • trunk/dll/filldir.c

    r1076 r1077  
    15951595      pci->pszLongName != pci->pszDisplayName + 1) {
    15961596    psz = pci->pszLongName;
    1597     //pci->pszLongName = NullStr;
    1598     pci->pszLongName = NULL;
     1597    // pci->pszLongName = NullStr;
     1598    pci->pszLongName = NULL;            // for debug
    15991599    free(psz);
    16001600  }
     
    16021602  if (pci->pszFileName && pci->pszFileName != NullStr) {
    16031603    psz = pci->pszFileName;
    1604     //pci->pszFileName = NullStr;
    1605     pci->pszFileName = NULL;
     1604    // pci->pszFileName = NullStr;
     1605    pci->pszFileName = NULL;            // for debug
    16061606    free(psz);
    16071607  }
     
    16091609  if (pci->pszFmtFileSize && pci->pszFmtFileSize != NullStr) {
    16101610    psz = pci->pszFmtFileSize;
    1611     //pci->pszFmtFileSize = NullStr;
    1612     pci->pszFmtFileSize = NULL;
     1611    // pci->pszFmtFileSize = NullStr;
     1612    pci->pszFmtFileSize = NULL;         // for debug
    16131613    free(psz);
    16141614  }
  • trunk/dll/fortify.c

    r1072 r1077  
    4343 /* 06 May 08 SHL Rework scope logic to be MT capable
    4444    26 May 08 SHL Show TID for leaking scope
    45     17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner
     45    17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
     46    18 Jul 08 SHL Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT
    4647 */
    4748
     
    177178#ifdef MT_SCOPES
    178179static unsigned volatile st_cOrdinals;          // Number of known threads
    179 static unsigned volatile char*  st_pScopes;     // Scope level of blocks allocated by thread
    180 static unsigned volatile long*  st_pOwners;     // Owner of blocks allocated by thread
     180static volatile unsigned char*  st_pScopes;     // Scope level of blocks allocated by thread
     181static volatile unsigned long*  st_pOwners;     // Owner of blocks allocated by thread
    181182#else
    182183static unsigned char  st_Scope            = 0;
     
    997998        FORTIFY_UNLOCK();
    998999    }
    999     return(++st_pScopes[ordinal]);
     1000    i = ++st_pScopes[ordinal];
     1001#   ifdef FORTIFY_VERBOSE_SCOPE_ENTER_EXIT
     1002    sprintf(st_Buffer,
     1003            "Fortify: Entering scope %u in TID %u at %s.%lu\n",
     1004            i, ordinal,
     1005            file, line);        // 26 May 08 SHL
     1006    st_Output(st_Buffer);
     1007#   endif
     1008    return(i);
    10001009#else
    10011010    return(++st_Scope);
     
    10251034    // Complain on leave without enter 06 May 08 SHL
    10261035    ordinal = Get_TID_Ordinal();
    1027     if (ordinal < st_cOrdinals && st_pScopes[ordinal] > 0)
     1036    if (ordinal < st_cOrdinals && st_pScopes[ordinal] > 0) {
    10281037        st_pScopes[ordinal]--;
     1038    }
    10291039    else {
    10301040        sprintf(st_Buffer,
    1031                 "\nFortify: attempting to leave scope before enter at %s.%lu in TID %u\n",
    1032                 file, line, ordinal);   // 26 May 08 SHL
     1041                "\nFortify: Attempting to leave scope before enter in TID %u at %s.%lu\n",
     1042                ordinal, file, line);   // 26 May 08 SHL
    10331043        st_Output(st_Buffer);
    10341044    }
     
    10371047        st_Scope--;
    10381048    else {
    1039         sprintf(st_Buffer, "\nFortify: attempting to leave scope before enter at %s.%lu\n", file, line);
     1049        sprintf(st_Buffer, "\nFortify: Attempting to leave scope before enter at %s.%lu\n", file, line);
    10401050        st_Output(st_Buffer);
    10411051    }
     
    10541064#ifdef MT_SCOPES
    10551065                sprintf(st_Buffer,
    1056                         "\nFortify: Memory leak detected leaving scope at %s.%lu in TID %u\n",
    1057                         file, line, ordinal);
     1066                        "\nFortify: Memory leak detected leaving scope %d in TID %u at %s.%lu\n",
     1067                        ordinal < st_cOrdinals ? st_pScopes[ordinal] + 1 : 0,
     1068                        ordinal,
     1069                        file, line);
    10581070#else
    10591071                sprintf(st_Buffer, "\nFortify: Memory leak detected leaving scope at %s.%lu\n", file, line);
     
    10781090        st_Output(st_Buffer);
    10791091    }
     1092#   ifdef FORTIFY_VERBOSE_SCOPE_ENTER_EXIT
     1093    else {
     1094        sprintf(st_Buffer,
     1095                "Fortify: Leaving scope %u in TID %u at %s.%lu\n",
     1096                ordinal < st_cOrdinals ? st_pScopes[ordinal] + 1 : 0,
     1097                ordinal,
     1098                file, line);    // 26 May 08 SHL
     1099        st_Output(st_Buffer);
     1100    }
     1101#   endif
    10801102
    10811103#ifdef FORTIFY_TRACK_DEALLOCATED_MEMORY
     
    24302452    if (ordinal >= st_cOrdinals) {
    24312453        // Expand arrays
    2432         unsigned i;
    2433         unsigned c;
     2454        unsigned i;
     2455        unsigned c;
    24342456        FORTIFY_LOCK();
    24352457        i = st_cOrdinals;
     
    24502472/**
    24512473 * Take ownership of block allocated by some other thread
    2452  * Allows scope enter/exit logic to correctly report leaks in 
     2474 * Allows scope enter/exit logic to correctly report leaks in
    24532475 * cross thread allocations
    2454  * @param pVoid is point to block allocated by Fortify
     2476 * @param pBlock points to block allocated by Fortify
    24552477 */
    24562478
     
    24662488    h->Scope = ordinal < st_cOrdinals ? st_pScopes[ordinal] : 0;
    24672489    h->Owner = ordinal;         // Take ownership
     2490    st_MakeHeaderValid(h);
     2491}
     2492
     2493/**
     2494 * Adjust scope level of allocated block
     2495 * Allows scope enter/exit logic to correctly report leaks in
     2496 * window procedure related allocations
     2497 * @param pBlock points to block allocated by Fortify
     2498 */
     2499
     2500void Fortify_ChangeScope(void *pBlock, int delta)
     2501{
     2502    unsigned char *ptr = (unsigned char *)pBlock -
     2503                             FORTIFY_HEADER_SIZE -
     2504                             FORTIFY_ALIGNED_BEFORE_SIZE;
     2505    struct Header *h = (struct Header *)ptr;
     2506    h->Scope += delta;
     2507    st_MakeHeaderValid(h);
    24682508}
    24692509
  • trunk/dll/fortify.h

    r1072 r1077  
    4242
    4343 /* 06 May 08 SHL Rework scope logic to be MT capable
    44     17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner
     44    17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope
    4545 */
    4646
     
    190190
    191191#ifdef MT_SCOPES
    192 void  Fortify_SetOwner(long lOwnerTID);
    193 void  Fortify_ChangeOwner(void *pBlock);
     192void Fortify_SetOwner(long lOwnerTID);
     193void Fortify_ChangeOwner(void *pBlock);
     194void Fortify_ChangeScope(void *pBlock, int delta);
    194195#endif
    195196
     
    228229     */
    229230    #ifdef FORTIFY_PROVIDE_ARRAY_NEW
    230         void *operator new[](size_t size);
    231         void *operator new[](size_t size, const char *file, unsigned long line);        // 16 Jan 08 SHL
     231        void *operator new[](size_t size);
     232        void *operator new[](size_t size, const char *file, unsigned long line);        // 16 Jan 08 SHL
    232233    #endif
    233234
     
    236237     */
    237238    #ifdef FORTIFY_PROVIDE_ARRAY_DELETE
    238         void  operator delete[](void *pointer);
     239        void  operator delete[](void *pointer);
    239240    #endif
    240241
     
    266267    /* Fortify versions of some non-ANSI C memory allocation functions */
    267268    #ifdef FORTIFY_STRDUP
    268         #define strdup(ptr)                Fortify_strdup(ptr, __FILE__, __LINE__)
     269        #define strdup(ptr)                Fortify_strdup(ptr, __FILE__, __LINE__)
    269270    #endif
    270271
    271272    /* Fortify versions of new and delete */
    272273    #ifdef __cplusplus
    273         #define Fortify_New                new(__FILE__, __LINE__)
    274         #define Fortify_Delete             for(gbl_FortifyMagic = 1, \
    275                                                Fortify_PreDelete(__FILE__, __LINE__); \
    276                                                gbl_FortifyMagic; Fortify_PostDelete()) \
    277                                                        gbl_FortifyMagic = 0, delete
    278         #define new                        Fortify_New
    279         #define delete                     Fortify_Delete
     274        #define Fortify_New                new(__FILE__, __LINE__)
     275        #define Fortify_Delete             for(gbl_FortifyMagic = 1, \
     276                                               Fortify_PreDelete(__FILE__, __LINE__); \
     277                                               gbl_FortifyMagic; Fortify_PostDelete()) \
     278                                                       gbl_FortifyMagic = 0, delete
     279        #define new                        Fortify_New
     280        #define delete                     Fortify_Delete
    280281    #endif /* __cplusplus */
    281282
  • trunk/dll/init.c

    r1076 r1077  
    4444  29 Feb 08 GKY Refactor global command line variables to notebook.h
    4545  08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
    46                 keys using a "DirCnr." prefix
     46                keys using a "DirCnr." prefix
    4747  20 Apr 08 GKY Change default cmd line length to 1024 Ask once if user wants to reset it.
    4848  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    49                 all the details view settings (both the global variables and those in the
    50                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     49                all the details view settings (both the global variables and those in the
     50                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    5151  16 JUL 08 GKY Use TMP directory for temp files
    5252  17 Jul 08 SHL Reduce code bulk in fUseTmp setup
     
    8181#include "strutil.h"                    // GetPString
    8282#include "fm3dll.h"
    83 #include "notebook.h"                   // command line variables (editor etc)
     83#include "notebook.h"                   // command line variables (editor etc)
    8484#include "fortify.h"
    8585
     
    660660      if (fs3.attrFile & FILE_DIRECTORY) {
    661661        // 17 Jul 08 SHL fixme to check writable someday
    662         pTmpDir = xstrdup(env, pszSrcFile, __LINE__);
     662        pTmpDir = xstrdup(env, pszSrcFile, __LINE__);
    663663      }
    664664    }
    665665  }
    666   BldFullPathName(ArcTempRoot, env, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
     666  BldFullPathName(ArcTempRoot, pTmpDir, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
    667667
    668668  /* initialize random number generator */
     
    731731    else {
    732732      if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
    733         saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,
    734                "Check INI header failed will attempt to replace with backup \\
    735                if backup fails or not found will open with new ini");
    736         DosCopy("FM3.INI", "FM3INI.BAD", DCPY_EXISTING);
    737         DosCopy("FM3INI.BAK", "FM3.INI", DCPY_EXISTING);
    738         if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
    739           DosCopy("FM3.INI", "FM3INI2.BAD", DCPY_EXISTING);
    740           fWantFirstTimeInit = TRUE;
    741         }
     733        saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,
     734               "Check INI header failed will attempt to replace with backup \\
     735               if backup fails or not found will open with new ini");
     736        DosCopy("FM3.INI", "FM3INI.BAD", DCPY_EXISTING);
     737        DosCopy("FM3INI.BAK", "FM3.INI", DCPY_EXISTING);
     738        if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
     739          DosCopy("FM3.INI", "FM3INI2.BAD", DCPY_EXISTING);
     740          fWantFirstTimeInit = TRUE;
     741        }
    742742      }
    743743      if (!fWantFirstTimeInit) {
    744         fIniExisted = TRUE;
    745         if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
    746           fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
    747           rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
    748           if (rc) {
    749             Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    750                         GetPString(IDS_INIREADONLYTEXT), inipath);
    751           }
    752         }
     744        fIniExisted = TRUE;
     745        if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
     746          fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
     747          rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
     748          if (rc) {
     749            Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     750                        GetPString(IDS_INIREADONLYTEXT), inipath);
     751          }
     752        }
    753753      }
    754754    }
     
    763763    if (!fmprof) {
    764764      Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
    765                 "PrfOpenProfile");
     765                "PrfOpenProfile");
    766766      return FALSE;
    767767    }
     
    10191019    if (!MaxComLineChecked) {
    10201020      ret = saymsg(MB_YESNO,
    1021                    HWND_DESKTOP,
    1022                    NullStr,
    1023                    GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
     1021                   HWND_DESKTOP,
     1022                   NullStr,
     1023                   GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
    10241024      if (ret == MBID_YES)
    1025         MaxComLineStrg = 1024;
     1025        MaxComLineStrg = 1024;
    10261026      MaxComLineChecked = TRUE;
    10271027      PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
     
    15251525      if (!DosRead(handle, buffer, l, &len) && len == l) {
    15261526        if (!memcmp(signature, buffer, l))
    1527           ret = TRUE;                   // Matched
     1527          ret = TRUE;                   // Matched
    15281528      }
    15291529    }
  • trunk/dll/killproc.c

    r1075 r1077  
    3838#include "errutil.h"                    // Dos_Error...
    3939#include "strutil.h"                    // GetPString
    40 #include "pathutil.h"                   // BldFullPathName
     40#include "pathutil.h"                   // BldFullPathName
    4141#include "fm3dll.h"
    4242#include "fortify.h"
     
    113113            if (!stricmp(pmi->szModName, "SYSINIT"))
    114114              GetDosPgmName(ppi->pid, s + strlen(s));
    115             else {
     115            else {
    116116              if (*pmi->szModName)
    117                 strcat(s, pmi->szModName);
     117                strcat(s, pmi->szModName);
    118118              else
    119119                strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
     
    182182            if (!stricmp((CHAR *) pmi->pName, "SYSINIT"))
    183183              GetDosPgmName(ppi->pid, s + strlen(s));
    184             else {
     184            else {
    185185              if (*pmi->pName)
    186                 strcat(s, (CHAR *) pmi->pName);
     186                strcat(s, (CHAR *) pmi->pName);
    187187              else
    188188                strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
     
    197197          }
    198198        }
    199         ppi = (QSPREC *) (ppi->pThrdRec + ppi->cTCB);
     199        ppi = (QSPREC *) (ppi->pThrdRec + ppi->cTCB);   // 22 Jun 08 SHL fixme to know why this looks odd
    200200      }                                 // while
    201201    }
     
    254254    DosDupHandle(fileno(fp), &oldstdout);
    255255    rc = runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
    256                 hwnd, pszSrcFile, __LINE__, NULL, NULL,
    257                 "%s", "PSTAT.EXE /C");
     256                hwnd, pszSrcFile, __LINE__, NULL, NULL,
     257                "%s", "PSTAT.EXE /C");
    258258    oldstdout = fileno(stdout);
    259259    DosDupHandle(newstdout, &oldstdout);
     
    363363      PrfWriteProfileData(fmprof,
    364364                          FM3Str,
    365                           "UseQProcStat", &fUseQProcStat, sizeof(BOOL));
     365                          "UseQProcStat", &fUseQProcStat, sizeof(BOOL));
    366366      PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
    367367      if (WinQueryButtonCheckstate(hwnd, KILL_CHECKBOX)) {
     
    437437          DosSleep(100);                // 05 Aug 07 GKY 250
    438438        else
    439             WinDismissDlg(hwnd, 0);
     439            WinDismissDlg(hwnd, 0);
    440440      }
    441441      else if (fUseQSysState)
    442         if (_beginthread(FillKillListThread3,
     442        if (_beginthread(FillKillListThread3,
    443443                         NULL, 65536, (PVOID) & hwnd) != -1)
    444444          DosSleep(100);//05 Aug 07 GKY 250
    445445        else
    446             WinDismissDlg(hwnd, 0);
     446            WinDismissDlg(hwnd, 0);
    447447      else {
    448448        if (_beginthread(FillKillListThread,
    449449                         NULL, 65536, (PVOID) & hwnd) != -1)
    450           DosSleep(100);                // 05 Aug 07 GKY 250
     450          DosSleep(100);                // 05 Aug 07 GKY 250
    451451        else
    452452          WinDismissDlg(hwnd, 0);
  • trunk/dll/mainwnd.c

    r1066 r1077  
    6060  07 Jul 08 JBS Ticket 242: Delete obsolete INI keys when re-saving a state
    6161  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    62                 all the details view settings (both the global variables and those in the
    63                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     62                all the details view settings (both the global variables and those in the
     63                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
    6464  12 Jul 08 JBS Ticket 246: Allow saved directory container states to have no directory containers
    65                 (i.e. just a directory tree container).
     65                (i.e. just a directory tree container).
     66  18 Jul 08 SHL Use new Fortify feature to avoid spurious reports
    6667
    6768***********************************************************************/
     
    7071#include <string.h>
    7172#include <ctype.h>
    72 #include <process.h>                    // _beginthread
     73#include <process.h>                    // _beginthread
    7374
    7475#define INCL_DOS
    7576#define INCL_WIN
    76 #define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
     77#define INCL_SHLERRORS                  // PMERR_NOT_IN_IDX
    7778#define INCL_WINHELP
    7879#define INCL_GPI
     
    8485#include "comp.h"
    8586#include "datamin.h"
    86 #include "pathutil.h"                   // BldQuotedFileName
    87 #include "errutil.h"                    // Dos_Error...
    88 #include "strutil.h"                    // GetPString
    89 #include "notebook.h"                   // CfgDlgProc CfgMenuInit
    90 #include "command.h"                    // LINKCMDS
     87#include "pathutil.h"                   // BldQuotedFileName
     88#include "errutil.h"                    // Dos_Error...
     89#include "strutil.h"                    // GetPString
     90#include "notebook.h"                   // CfgDlgProc CfgMenuInit
     91#include "command.h"                    // LINKCMDS
     92#include "avl.h"                        // free_archivers
     93#include "walkem.h"                     // free_setups...
    9194#include "fm3dll.h"
    92 #include "avl.h"                        // free_archivers
    9395
    9496#include "fortify.h"
     
    105107
    106108static MRESULT EXPENTRY MainObjectWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    107                                           MPARAM mp2)
     109                                          MPARAM mp2)
    108110{
    109111  switch (msg) {
     112  case WM_CREATE:
     113    break;
     114
    110115  case UM_SETUP:
    111116  case UM_SETUP2:
     
    131136      *dv = 0;
    132137      WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwndB, QW_PARENT),
    133                                         id + 50), sizeof(dv), dv);
     138                                        id + 50), sizeof(dv), dv);
    134139      d = toupper(*dv);
    135140      if (isalpha(d) && d > 'B' &&
    136           !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
    137                                    DRIVE_SLOW)) &&
    138           (!hwndBubble ||
    139            WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    140           !WinQueryCapture(HWND_DESKTOP)) {
    141 
    142         FSALLOCATE fsa;
    143         CHAR s[90], szQty[38];
    144         ULONG ulPctFree;
    145         ULONGLONG ullFreeQty;
    146 
    147         if (!DosQueryFSInfo((d - 'A') + 1,
    148                             FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
    149           ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
    150             (fsa.cSectorUnit * fsa.cbSector);
    151           ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
    152             (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
    153           CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
    154           sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
    155         }
    156         if ((!hwndBubble ||
    157              WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
    158             !WinQueryCapture(HWND_DESKTOP))
    159           WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
     141          !(driveflags[d - 'A'] & (DRIVE_CDROM | DRIVE_INVALID |
     142                                   DRIVE_SLOW)) &&
     143          (!hwndBubble ||
     144           WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     145          !WinQueryCapture(HWND_DESKTOP)) {
     146
     147        FSALLOCATE fsa;
     148        CHAR s[90], szQty[38];
     149        ULONG ulPctFree;
     150        ULONGLONG ullFreeQty;
     151
     152        if (!DosQueryFSInfo((d - 'A') + 1,
     153                            FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
     154          ullFreeQty = (ULONGLONG) fsa.cUnitAvail *
     155            (fsa.cSectorUnit * fsa.cbSector);
     156          ulPctFree = (fsa.cUnit && fsa.cUnitAvail) ?
     157            (fsa.cUnitAvail * 100) / fsa.cUnit : 0;
     158          CommaFmtULL(szQty, sizeof(szQty), ullFreeQty, ' ');
     159          sprintf(s, "%s (%lu%%) free", szQty, ulPctFree);
     160        }
     161        if ((!hwndBubble ||
     162             WinQueryWindowULong(hwndBubble, QWL_USER) != hwndB) &&
     163            !WinQueryCapture(HWND_DESKTOP))
     164          WinSendMsg(hwndB, UM_SETUP6, MPFROMP(s), MPVOID);
    160165      }
    161166    }
     
    168173
    169174      if (DosQuerySysInfo(QSV_BOOT_DRIVE,
    170                           QSV_BOOT_DRIVE,
    171                           (PVOID) & bd, (ULONG) sizeof(ULONG)))
    172         bd = 3L;
     175                          QSV_BOOT_DRIVE,
     176                          (PVOID) & bd, (ULONG) sizeof(ULONG)))
     177        bd = 3L;
    173178      *s = (CHAR) bd + '@';
    174179      WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPFROMLONG(1));
    175180      if (!mp1) {
    176         s[3] = 0;
    177         WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
     181        s[3] = 0;
     182        WinSendMsg(hwndMain, UM_SETDIR, MPFROMP(s), MPVOID);
    178183      }
    179184      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMLONG(1), MPFROMLONG(1));
     
    215220    if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
    216221      WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
    217 #     ifdef FORTIFY
    218       Fortify_LeaveScope();
    219 #      endif
    220222    break;
    221223  }
     
    236238      DosError(FERR_DISABLEHARDERR);
    237239      WinRegisterClass(hab2,
    238                        (PSZ) WC_OBJECTWINDOW,
    239                        MainObjectWndProc, 0, sizeof(PVOID));
     240                       (PSZ) WC_OBJECTWINDOW,
     241                       MainObjectWndProc, 0, sizeof(PVOID));
    240242      MainObjectHwnd = WinCreateWindow(HWND_OBJECT,
    241                                        WC_OBJECTWINDOW,
    242                                        (PSZ) NULL,
    243                                        0,
    244                                        0L,
    245                                        0L,
    246                                        0L,
    247                                        0L,
    248                                        0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
     243                                       WC_OBJECTWINDOW,
     244                                       (PSZ) NULL,
     245                                       0,
     246                                       0L,
     247                                       0L,
     248                                       0L,
     249                                       0L,
     250                                       0L, HWND_TOP, OBJ_FRAME, NULL, NULL);
    249251      if (!MainObjectHwnd)
    250         Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
    251                    IDS_WINCREATEWINDOW);
     252        Win_Error2(HWND_OBJECT, HWND_DESKTOP, pszSrcFile, __LINE__,
     253                   IDS_WINCREATEWINDOW);
    252254      else {
    253         WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
    254         while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
    255           WinDispatchMsg(hab2, &qmsg2);
    256         WinDestroyWindow(MainObjectHwnd);
     255        WinSetWindowPtr(MainObjectHwnd, QWL_USER, args);
     256#       ifdef FORTIFY
     257        Fortify_EnterScope();
     258#       endif
     259        while (WinGetMsg(hab2, &qmsg2, (HWND) 0, 0, 0))
     260          WinDispatchMsg(hab2, &qmsg2);
     261        WinDestroyWindow(MainObjectHwnd);
     262#       ifdef FORTIFY
     263        Fortify_LeaveScope();
     264#       endif
    257265      }
    258266      WinDestroyMsgQueue(hmq2);
     
    263271
    264272static MRESULT EXPENTRY IdealButtonProc(HWND hwnd, ULONG msg, MPARAM mp1,
    265                                         MPARAM mp2)
     273                                        MPARAM mp2)
    266274{
    267275  switch (msg) {
     
    283291    while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    284292      if (hwndC != exclude) {
    285         id = WinQueryWindowUShort(hwndC, QWS_ID);
    286         if (id)
    287           break;
     293        id = WinQueryWindowUShort(hwndC, QWS_ID);
     294        if (id)
     295          break;
    288296      }
    289297    }
     
    305313      henum = WinBeginEnumWindows(hwndMain);
    306314      while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
    307         // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
    308         if (hwndC != exclude && hwndC != hwndTree) {
    309           id = WinQueryWindowUShort(hwndC, QWS_ID);
    310           if (id) {
    311             hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
    312             if (hwndClient) {
    313               hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
    314               if (hwndDir) {
    315                 if (fLookInDir) {
    316                   pci = (PCNRITEM) WinSendMsg(hwndDir,
    317                                               CM_QUERYRECORDEMPHASIS,
    318                                               MPFROMLONG(CMA_FIRST),
    319                                               MPFROMSHORT(CRA_CURSORED));
    320                   if (pci && (INT) pci != -1)
    321                     break;
    322                 }
    323                 if (WinSendMsg(hwndClient,
    324                                UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
    325                   MakeValidDir(ret);
    326                   // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
    327                   WinEndEnumWindows(henum);
    328                   return hwndC;
    329                 }
    330               }
    331             }
    332           }
    333         }
     315        // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu",hwndTree,exclude,hwndC);
     316        if (hwndC != exclude && hwndC != hwndTree) {
     317          id = WinQueryWindowUShort(hwndC, QWS_ID);
     318          if (id) {
     319            hwndClient = WinWindowFromID(hwndC, FID_CLIENT);
     320            if (hwndClient) {
     321              hwndDir = WinWindowFromID(hwndClient, DIR_CNR);
     322              if (hwndDir) {
     323                if (fLookInDir) {
     324                  pci = (PCNRITEM) WinSendMsg(hwndDir,
     325                                              CM_QUERYRECORDEMPHASIS,
     326                                              MPFROMLONG(CMA_FIRST),
     327                                              MPFROMSHORT(CRA_CURSORED));
     328                  if (pci && (INT) pci != -1)
     329                    break;
     330                }
     331                if (WinSendMsg(hwndClient,
     332                               UM_CONTAINERDIR, MPFROMP(ret), MPVOID)) {
     333                  MakeValidDir(ret);
     334                  // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Tree = %lu\rExclude = %lu\rFound = %lu\r\"%s\"",hwndTree,exclude,hwndC,ret);
     335                  WinEndEnumWindows(henum);
     336                  return hwndC;
     337                }
     338              }
     339            }
     340          }
     341        }
    334342      }
    335343      WinEndEnumWindows(henum);
    336344      if (!pci || (INT) pci == -1) {
    337         hwndC = hwndTree;
    338         pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
    339                                                                     FID_CLIENT),
    340                                                     TREE_CNR),
    341                                     CM_QUERYRECORDEMPHASIS,
    342                                     MPFROMLONG(CMA_FIRST),
    343                                     MPFROMSHORT(CRA_CURSORED));
     345        hwndC = hwndTree;
     346        pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(hwndTree,
     347                                                                    FID_CLIENT),
     348                                                    TREE_CNR),
     349                                    CM_QUERYRECORDEMPHASIS,
     350                                    MPFROMLONG(CMA_FIRST),
     351                                    MPFROMSHORT(CRA_CURSORED));
    344352      }
    345353      if (pci && (INT) pci != -1) {
    346         strcpy(ret, pci->pszFileName);
    347         MakeValidDir(ret);
     354        strcpy(ret, pci->pszFileName);
     355        MakeValidDir(ret);
    348356      }
    349357      else
    350         save_dir2(ret);
     358        save_dir2(ret);
    351359    }
    352360  }
     
    366374      hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    367375      if (hwndDir)
    368         ret++;
     376        ret++;
    369377    }
    370378  }
     
    384392      hwndC = WinWindowFromID(hwndF, FID_CLIENT);
    385393      if (hwndC) {
    386         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    387         if (hwndDir) {
    388           *retstr = 0;
    389           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
    390           if (*retstr && !stricmp(retstr, directory)) {
    391             if (restore)
    392               WinSetWindowPos(hwndF,
    393                               HWND_TOP,
    394                               0,
    395                               0,
    396                               0,
    397                               0,
    398                               SWP_RESTORE | SWP_SHOW |
    399                               SWP_ACTIVATE | SWP_ZORDER);
    400             break;
    401           }
    402         }
     394        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     395        if (hwndDir) {
     396          *retstr = 0;
     397          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
     398          if (*retstr && !stricmp(retstr, directory)) {
     399            if (restore)
     400              WinSetWindowPos(hwndF,
     401                              HWND_TOP,
     402                              0,
     403                              0,
     404                              0,
     405                              0,
     406                              SWP_RESTORE | SWP_SHOW |
     407                              SWP_ACTIVATE | SWP_ZORDER);
     408            break;
     409          }
     410        }
    403411      }
    404412    }
     
    467475    while (tool) {
    468476      if (!(tool->flags & T_INVISIBLE)) {
    469         swp[x].x = butx;
    470         if (fTextTools || (tool->flags & T_TEXT)) {
    471           butx += 55L;
    472           swp[x].cx = 54L;
    473           swp[x].cy = 24L;
    474           swp[x].y = 3L;
    475         }
    476         else
    477           butx += 33L;
    478         if (tool->flags & T_SEPARATOR)
    479           butx += 12;
     477        swp[x].x = butx;
     478        if (fTextTools || (tool->flags & T_TEXT)) {
     479          butx += 55L;
     480          swp[x].cx = 54L;
     481          swp[x].cy = 24L;
     482          swp[x].y = 3L;
     483        }
     484        else
     485          butx += 33L;
     486        if (tool->flags & T_SEPARATOR)
     487          butx += 12;
    480488      }
    481489      else
    482         swp[x].fl = noattrib;
     490        swp[x].fl = noattrib;
    483491      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    484492      x++;
     
    489497      swp[x].x = butx;
    490498      if (!(tool->flags & T_INVISIBLE)) {
    491         if (fTextTools || (tool->flags & T_TEXT)) {
    492           butx += 55L;
    493           swp[x].cx = 54L;
    494           swp[x].cy = 24L;
    495           swp[x].y = 3L;
    496         }
    497         else
    498           butx += 33L;
    499         if (tool->flags & T_SEPARATOR)
    500           butx += 12;
     499        if (fTextTools || (tool->flags & T_TEXT)) {
     500          butx += 55L;
     501          swp[x].cx = 54L;
     502          swp[x].cy = 24L;
     503          swp[x].y = 3L;
     504        }
     505        else
     506          butx += 33L;
     507        if (tool->flags & T_SEPARATOR)
     508          butx += 12;
    501509      }
    502510      else
    503         swp[x].fl = noattrib;
     511        swp[x].fl = noattrib;
    504512      swp[x].hwnd = WinWindowFromID(hwnd, tool->id);
    505513      x++;
     
    509517    if (!fTextTools && fToolTitles) {
    510518      for (x = 2L; x < numtools + 2L; x++) {
    511         if (fTextTools || !fToolTitles)
    512           swp[x].fl = noattrib;
    513         else {
    514           tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
    515           if (tool && (tool->flags & T_TEXT))
    516             swp[x].fl = noattrib;
    517           else {
    518             swp[x].hwndInsertBehind = HWND_TOP;
    519             swp[x].y = 1L;
    520             swp[x].cy = 10L;
    521           }
    522         }
    523         swp[x].hwnd = WinWindowFromID(hwnd,
    524                                       WinQueryWindowUShort(swp[x].hwnd,
    525                                                            QWS_ID) + 25000);
     519        if (fTextTools || !fToolTitles)
     520          swp[x].fl = noattrib;
     521        else {
     522          tool = find_tool(WinQueryWindowUShort(swp[x].hwnd, QWS_ID));
     523          if (tool && (tool->flags & T_TEXT))
     524            swp[x].fl = noattrib;
     525          else {
     526            swp[x].hwndInsertBehind = HWND_TOP;
     527            swp[x].y = 1L;
     528            swp[x].cy = 10L;
     529          }
     530        }
     531        swp[x].hwnd = WinWindowFromID(hwnd,
     532                                      WinQueryWindowUShort(swp[x].hwnd,
     533                                                           QWS_ID) + 25000);
    526534      }
    527535      WinSetMultWindowPos(WinQueryAnchorBlock(hwnd), &swp[2], numtools);
     
    533541
    534542static MRESULT EXPENTRY DropDownListProc(HWND hwnd, ULONG msg, MPARAM mp1,
    535                                         MPARAM mp2)
     543                                        MPARAM mp2)
    536544{
    537545  PFNWP oldproc = (PFNWP) INSTDATA(hwnd);
     
    571579      id = WinQueryWindowUShort(hwndParent, QWS_ID);
    572580      if (SHORT1FROMMP(mp2)) {
    573         // If getting focus 1st time - save original accelerator
    574         if (haccelSaved == NULLHANDLE) {
    575           haccelSaved = WinQueryAccelTable(hab, hwndFrame);
    576           if (haccelSaved == NULLHANDLE)
    577             Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
    578           // else
    579             // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
    580         }
    581         if (haccelSaved != NULLHANDLE) {
    582           switch (id) {
    583           case MAIN_DRIVELIST:
    584             if (haccelDriveList == NULLHANDLE) {
    585                 haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
    586                 if (haccelDriveList == NULLHANDLE)
    587                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    588             }
    589             if (haccelDriveList != NULLHANDLE) {
    590               if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
    591                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    592               // else
    593                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
    594             }
    595             break;
    596           case MAIN_SETUPLIST:
    597             if (haccelSetupList == NULLHANDLE) {
    598                 haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
    599                 if (haccelSetupList == NULLHANDLE)
    600                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    601             }
    602             if (haccelSetupList != NULLHANDLE) {
    603               if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
    604                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    605               // else
    606                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
    607             }
    608             break;
    609           case MAIN_CMDLIST:
    610             if (haccelCmdList == NULLHANDLE) {
    611                 haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
    612                 if (haccelCmdList == NULLHANDLE)
    613                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    614             }
    615             if (haccelCmdList != NULLHANDLE) {
    616               if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
    617                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    618               // else
    619                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
    620             }
    621             break;
    622           case MAIN_USERLIST:
    623             if (haccelUserList == NULLHANDLE) {
    624                 haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
    625                 if (haccelUserList == NULLHANDLE)
    626                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    627             }
    628             if (haccelUserList != NULLHANDLE) {
    629               if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
    630                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    631               // else
    632                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
    633             }
    634             break;
    635           case MAIN_BUTTONLIST:
    636             if (haccelButtonList == NULLHANDLE) {
    637                 haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
    638                 if (haccelButtonList == NULLHANDLE)
    639                   Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
    640             }
    641             if (haccelButtonList != NULLHANDLE) {
    642               if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
    643                 Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    644               // else
    645                 // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
    646             }
    647             break;
    648           } // switch
    649         }
     581        // If getting focus 1st time - save original accelerator
     582        if (haccelSaved == NULLHANDLE) {
     583          haccelSaved = WinQueryAccelTable(hab, hwndFrame);
     584          if (haccelSaved == NULLHANDLE)
     585            Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryAccelTable");
     586          // else
     587            // DbgMsg(pszSrcFile, __LINE__, "WinQueryAccelTable SAVED %x", haccelSaved);
     588        }
     589        if (haccelSaved != NULLHANDLE) {
     590          switch (id) {
     591          case MAIN_DRIVELIST:
     592            if (haccelDriveList == NULLHANDLE) {
     593                haccelDriveList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_DRIVELIST);
     594                if (haccelDriveList == NULLHANDLE)
     595                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     596            }
     597            if (haccelDriveList != NULLHANDLE) {
     598              if (!WinSetAccelTable(hab, haccelDriveList, hwndFrame))
     599                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     600              // else
     601                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_DRIVELIST %x %x", hwndFrame, haccelDriveList);
     602            }
     603            break;
     604          case MAIN_SETUPLIST:
     605            if (haccelSetupList == NULLHANDLE) {
     606                haccelSetupList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_SETUPLIST);
     607                if (haccelSetupList == NULLHANDLE)
     608                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     609            }
     610            if (haccelSetupList != NULLHANDLE) {
     611              if (!WinSetAccelTable(hab, haccelSetupList, hwndFrame))
     612                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     613              // else
     614                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_SETUPLIST %x %x", hwndFrame, haccelSetupList);
     615            }
     616            break;
     617          case MAIN_CMDLIST:
     618            if (haccelCmdList == NULLHANDLE) {
     619                haccelCmdList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_CMDLIST);
     620                if (haccelCmdList == NULLHANDLE)
     621                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     622            }
     623            if (haccelCmdList != NULLHANDLE) {
     624              if (!WinSetAccelTable(hab, haccelCmdList, hwndFrame))
     625                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     626              // else
     627                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_CMDLIST %x %x", hwndFrame, haccelCmdList);
     628            }
     629            break;
     630          case MAIN_USERLIST:
     631            if (haccelUserList == NULLHANDLE) {
     632                haccelUserList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_USERLIST);
     633                if (haccelUserList == NULLHANDLE)
     634                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     635            }
     636            if (haccelUserList != NULLHANDLE) {
     637              if (!WinSetAccelTable(hab, haccelUserList, hwndFrame))
     638                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     639              // else
     640                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_USERLIST %x %x", hwndFrame, haccelUserList);
     641            }
     642            break;
     643          case MAIN_BUTTONLIST:
     644            if (haccelButtonList == NULLHANDLE) {
     645                haccelButtonList = WinLoadAccelTable(hab, FM3ModHandle, MAIN_BUTTONLIST);
     646                if (haccelButtonList == NULLHANDLE)
     647                  Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinLoadAccelTable");
     648            }
     649            if (haccelButtonList != NULLHANDLE) {
     650              if (!WinSetAccelTable(hab, haccelButtonList, hwndFrame))
     651                Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     652              // else
     653                // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable MAIN_BUTTONLIST %x %x", hwndFrame, haccelButtonList);
     654            }
     655            break;
     656          } // switch
     657        }
    650658      }
    651659      else {
    652         // Losing focus
    653         switch (id) {
    654         case MAIN_DRIVELIST:
    655         case MAIN_SETUPLIST:
    656         case MAIN_CMDLIST:
    657         case MAIN_USERLIST:
    658         case MAIN_BUTTONLIST:
    659           if (haccelSaved != NULLHANDLE) {
    660             if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
    661               Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
    662             // else
    663               // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
    664           }
    665           break;
    666         } // switch
     660        // Losing focus
     661        switch (id) {
     662        case MAIN_DRIVELIST:
     663        case MAIN_SETUPLIST:
     664        case MAIN_CMDLIST:
     665        case MAIN_USERLIST:
     666        case MAIN_BUTTONLIST:
     667          if (haccelSaved != NULLHANDLE) {
     668            if (!WinSetAccelTable(hab, haccelSaved, hwndFrame))
     669              Win_Error(hwndFrame, HWND_DESKTOP, pszSrcFile, __LINE__, "WinSetAccelTable");
     670            // else
     671              // DbgMsg(pszSrcFile, __LINE__, "WinSetAccelTable SAVED %x %x", hwndFrame, haccelSaved);
     672          }
     673          break;
     674        } // switch
    667675      }
    668676    }
     
    674682
    675683      if (hwndMenu)
    676         WinDestroyWindow(hwndMenu);
     684        WinDestroyWindow(hwndMenu);
    677685      hwndMenu = (HWND) 0;
    678686      id = WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID);
    679687      switch (id) {
    680688      case MAIN_CMDLIST:
    681         WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    682                                                                 QW_PARENT),
    683                                                   QW_PARENT),
    684                                    FID_CLIENT),
    685                    WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
    686         break;
     689        WinPostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     690                                                                QW_PARENT),
     691                                                  QW_PARENT),
     692                                   FID_CLIENT),
     693                   WM_COMMAND, MPFROM2SHORT(IDM_EDITCOMMANDS, 0), MPVOID);
     694        break;
    687695      case MAIN_USERLIST:
    688696      case MAIN_SETUPLIST:
    689         hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
    690         if (hwndMenu)
    691           PopupMenu(hwnd,
    692                     WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    693                                                                   QW_PARENT),
    694                                                    QW_PARENT),
    695                                     FID_CLIENT), hwndMenu);
    696         break;
     697        hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
     698        if (hwndMenu)
     699          PopupMenu(hwnd,
     700                    WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     701                                                                  QW_PARENT),
     702                                                   QW_PARENT),
     703                                    FID_CLIENT), hwndMenu);
     704        break;
    697705      default:
    698         ret = FALSE;
    699         break;
     706        ret = FALSE;
     707        break;
    700708      } // switch
    701709      return ret;
     
    706714      switch (SHORT1FROMMP(mp1)) {
    707715      case CBID_EDIT:
    708         id = WinQueryWindowUShort(hwnd, QWS_ID);
    709         switch (SHORT2FROMMP(mp1)) {
    710         case EN_SETFOCUS:
    711           switch (id) {
    712           case MAIN_CMDLIST:
    713             WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
    714             break;
    715           case MAIN_SETUPLIST:
    716             WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
    717             break;
    718           case MAIN_USERLIST:
    719             WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
    720             break;
    721           case MAIN_DRIVELIST:
    722             WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
    723             break;
    724           case MAIN_BUTTONLIST:
    725             WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
    726             break;
    727           default:
    728             break;
    729           }
    730           break;
    731 
    732         default:
    733           break;
    734         }
     716        id = WinQueryWindowUShort(hwnd, QWS_ID);
     717        switch (SHORT2FROMMP(mp1)) {
     718        case EN_SETFOCUS:
     719          switch (id) {
     720          case MAIN_CMDLIST:
     721            WinSetWindowText(hwndStatus2, GetPString(IDS_CMDLISTHELP));
     722            break;
     723          case MAIN_SETUPLIST:
     724            WinSetWindowText(hwndStatus2, GetPString(IDS_SETUPLISTHELP));
     725            break;
     726          case MAIN_USERLIST:
     727            WinSetWindowText(hwndStatus2, GetPString(IDS_USERLISTHELP));
     728            break;
     729          case MAIN_DRIVELIST:
     730            WinSetWindowText(hwndStatus2, GetPString(IDS_DRIVELISTHELP));
     731            break;
     732          case MAIN_BUTTONLIST:
     733            WinSetWindowText(hwndStatus2, GetPString(IDS_BUTTONLISTHELP));
     734            break;
     735          default:
     736            break;
     737          }
     738          break;
     739
     740        default:
     741          break;
     742        }
    735743      }
    736744      break;
     
    745753    // 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);
    746754    if (id == CBID_EDIT &&
    747         WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
    748         MAIN_USERLIST) {
     755        WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_ID) ==
     756        MAIN_USERLIST) {
    749757
    750758      CHAR path[CCHMAXPATH];
     
    755763      // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Dragging: %s",path);
    756764      if (*path && !IsRoot(path))
    757         DragOne(hwnd, (HWND) 0, path, FALSE);
     765        DragOne(hwnd, (HWND) 0, path, FALSE);
    758766      return 0;
    759767    }
     
    764772    if (id == MAIN_USERLIST) {
    765773      if (!emphasized) {
    766         emphasized = TRUE;
    767         DrawTargetEmphasis(hwnd, emphasized);
     774        emphasized = TRUE;
     775        DrawTargetEmphasis(hwnd, emphasized);
    768776      }
    769777      if (AcceptOneDrop(hwnd, mp1, mp2))
    770         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     778        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    771779      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    772780    }
     
    777785    if (id == MAIN_USERLIST) {
    778786      if (emphasized) {
    779         emphasized = FALSE;
    780         DrawTargetEmphasis(hwnd, emphasized);
     787        emphasized = FALSE;
     788        DrawTargetEmphasis(hwnd, emphasized);
    781789      }
    782790    }
     
    798806
    799807      if (emphasized) {
    800         emphasized = FALSE;
    801         DrawTargetEmphasis(hwnd, emphasized);
     808        emphasized = FALSE;
     809        DrawTargetEmphasis(hwnd, emphasized);
    802810      }
    803811      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    804         MakeValidDir(szFrom);
    805         WinSetWindowText(hwnd, szFrom);
    806         PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    807                                                               QW_PARENT),
    808                                                QW_PARENT),
    809                                 FID_CLIENT),
    810                 UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
    811         return 0;
     812        MakeValidDir(szFrom);
     813        WinSetWindowText(hwnd, szFrom);
     814        PostMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     815                                                              QW_PARENT),
     816                                               QW_PARENT),
     817                                FID_CLIENT),
     818                UM_COMMAND, MPFROM2SHORT(IDM_ADDTOUSERLIST, 0), MPVOID);
     819        return 0;
    812820      }
    813821    }
     
    830838       (other && fOtherHelp) || (!other && !drive && fToolbarHelp))) {
    831839    if ((!hwndBubble ||
    832         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    833         !WinQueryCapture(HWND_DESKTOP))
     840        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     841        !WinQueryCapture(HWND_DESKTOP))
    834842      MakeBubble(hwnd, above, help);
    835843  }
     
    852860      /* don't bring up help if window isn't active */
    853861      if (!WinIsChild(hwnd, hwndActive))
    854         return;
     862        return;
    855863    }
    856864    hwndActive = WinQueryFocus(HWND_DESKTOP);
     
    858866      /* don't bring up help if a menu is active */
    859867      if (!strcmp(ucClassname, "#4"))
    860         return;
     868        return;
    861869    }
    862870  }
    863871
    864872  hwndBubble = WinCreateWindow(HWND_DESKTOP,
    865                                WC_BUBBLE,
    866                                help,
    867                                WS_CLIPSIBLINGS | SS_TEXT |
    868                                DT_CENTER | DT_VCENTER,
    869                                0,
    870                                0,
    871                                0,
    872                                0,
    873                                HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
     873                               WC_BUBBLE,
     874                               help,
     875                               WS_CLIPSIBLINGS | SS_TEXT |
     876                               DT_CENTER | DT_VCENTER,
     877                               0,
     878                               0,
     879                               0,
     880                               0,
     881                               HWND_DESKTOP, HWND_TOP, MAIN_HELP, NULL, NULL);
    874882  if (!hwndBubble)
    875883    Win_Error2(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
    876                IDS_WINCREATEWINDOW);
     884               IDS_WINCREATEWINDOW);
    877885  else {
    878886    HPS hps;
     
    894902      pp = strchr(p, '\r');
    895903      if (pp) {
    896         wp = pp;
    897         *pp = 0;
    898         pp++;
     904        wp = pp;
     905        *pp = 0;
     906        pp++;
    899907      }
    900908      GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    901909      tptl.x = max(aptl[TXTBOX_TOPRIGHT].x, tptl.x);
    902910      if (tptl.y)
    903         tptl.y += extra;
     911        tptl.y += extra;
    904912      else
    905         extra = aptl[TXTBOX_TOPLEFT].y / 4;
     913        extra = aptl[TXTBOX_TOPLEFT].y / 4;
    906914      tptl.y += aptl[TXTBOX_TOPLEFT].y;
    907915      if (wp)
    908         *wp = '\r';
     916        *wp = '\r';
    909917      p = pp;
    910918    }
     
    916924      sy = ptl.y + swp.cy + 4;
    917925      if (sy + tptl.y + 12 > lyScreen) {
    918         above = FALSE;
    919         sy = ptl.y - (tptl.y + 14);
     926        above = FALSE;
     927        sy = ptl.y - (tptl.y + 14);
    920928      }
    921929    }
     
    933941      sy = ptl.y + swp.cy + 4;
    934942      if (sy + tptl.y + 12 > lyScreen)
    935         sy = 0;
     943        sy = 0;
    936944    }
    937945    WinSetWindowPos(hwndBubble, HWND_TOP, sx, sy,
    938                     tptl.x + 14,
    939                     tptl.y + 12,
    940                     SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
    941                     SWP_MOVE | SWP_SIZE);
     946                    tptl.x + 14,
     947                    tptl.y + 12,
     948                    SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER |
     949                    SWP_MOVE | SWP_SIZE);
    942950  }
    943951}
     
    965973      WinQueryPointerPos(HWND_DESKTOP, &ptl);
    966974      if (WinWindowFromPoint(HWND_DESKTOP, &ptl, TRUE) !=
    967           WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
    968         WinDestroyWindow(hwnd);
     975          WinQueryWindowULong(hwnd, QWL_USER) || !WinIsWindowVisible(hwnd))
     976        WinDestroyWindow(hwnd);
    969977    }
    970978    return 0;
     
    980988      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    981989      if (hps) {
    982         WinQueryWindowPos(hwnd, &swp);
    983         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
    984         GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
    985         GpiSetBackMix(hps, BM_LEAVEALONE);
    986         GpiSetMix(hps, FM_OVERPAINT);
    987         ptl.x = ptl.y = 0;
    988         GpiMove(hps, &ptl);
    989         ptl.x = swp.cx - 1;
    990         ptl.y = swp.cy - 1;
    991         GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
    992         tlen = WinQueryWindowTextLength(hwnd);
    993         if (tlen) {
    994           s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
    995           if (s) {
    996             WinQueryWindowText(hwnd, tlen + 1, s);
    997             if (*s) {
    998               p = s;
    999               y = swp.cy - 3;
    1000               extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
    1001               GpiSetColor(hps, 0);
    1002               GpiSetMix(hps, FM_OVERPAINT);
    1003               while (p && *p) {
    1004                 wp = NULL;
    1005                 pp = strchr(p, '\r');
    1006                 if (pp) {
    1007                   wp = pp;
    1008                   *pp = 0;
    1009                   pp++;
    1010                 }
    1011                 GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
    1012                 ptl.x = 7;
    1013                 y -= aptl[TXTBOX_TOPLEFT].y;
    1014                 if (p != s)
    1015                   y -= extra;
    1016                 ptl.y = y;
    1017                 GpiCharStringAt(hps, &ptl, strlen(p), p);
    1018                 if (wp)
    1019                   *wp = '\r';
    1020                 p = pp;
    1021               }
    1022             }
    1023             free(s);
    1024           }
    1025         }
    1026         if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
    1027           GpiSetColor(hps, CLR_WHITE);
    1028           ptl.x = 1;
    1029           ptl.y = 1;
    1030           GpiMove(hps, &ptl);
    1031           ptl.y = swp.cy - 2;
    1032           GpiLine(hps, &ptl);
    1033           ptl.x = swp.cx - 2;
    1034           GpiLine(hps, &ptl);
    1035           ptl.x = 2;
    1036           ptl.y = 2;
    1037           GpiMove(hps, &ptl);
    1038           ptl.y = swp.cy - 3;
    1039           GpiLine(hps, &ptl);
    1040           ptl.x = swp.cx - 3;
    1041           GpiLine(hps, &ptl);
    1042           GpiSetColor(hps, CLR_BROWN);
    1043           ptl.x = 1;
    1044           ptl.y = 1;
    1045           GpiMove(hps, &ptl);
    1046           ptl.x = swp.cx - 2;
    1047           GpiLine(hps, &ptl);
    1048           ptl.y = swp.cy - 2;
    1049           GpiLine(hps, &ptl);
    1050           ptl.x = 2;
    1051           ptl.y = 2;
    1052           GpiMove(hps, &ptl);
    1053           ptl.x = swp.cx - 3;
    1054           GpiLine(hps, &ptl);
    1055           ptl.y = swp.cy - 3;
    1056           GpiLine(hps, &ptl);
    1057         }
    1058         WinEndPaint(hps);
     990        WinQueryWindowPos(hwnd, &swp);
     991        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
     992        GpiSetColor(hps, ((255 << 16) | (255 << 8) | 198));
     993        GpiSetBackMix(hps, BM_LEAVEALONE);
     994        GpiSetMix(hps, FM_OVERPAINT);
     995        ptl.x = ptl.y = 0;
     996        GpiMove(hps, &ptl);
     997        ptl.x = swp.cx - 1;
     998        ptl.y = swp.cy - 1;
     999        GpiBox(hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     1000        tlen = WinQueryWindowTextLength(hwnd);
     1001        if (tlen) {
     1002          s = xmalloc(tlen + 2, pszSrcFile, __LINE__);
     1003          if (s) {
     1004            WinQueryWindowText(hwnd, tlen + 1, s);
     1005            if (*s) {
     1006              p = s;
     1007              y = swp.cy - 3;
     1008              extra = WinQueryWindowULong(hwnd, QWL_USER + 4);
     1009              GpiSetColor(hps, 0);
     1010              GpiSetMix(hps, FM_OVERPAINT);
     1011              while (p && *p) {
     1012                wp = NULL;
     1013                pp = strchr(p, '\r');
     1014                if (pp) {
     1015                  wp = pp;
     1016                  *pp = 0;
     1017                  pp++;
     1018                }
     1019                GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
     1020                ptl.x = 7;
     1021                y -= aptl[TXTBOX_TOPLEFT].y;
     1022                if (p != s)
     1023                  y -= extra;
     1024                ptl.y = y;
     1025                GpiCharStringAt(hps, &ptl, strlen(p), p);
     1026                if (wp)
     1027                  *wp = '\r';
     1028                p = pp;
     1029              }
     1030            }
     1031            free(s);
     1032          }
     1033        }
     1034        if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)) && swp.cx > 6 && swp.cy > 6) {
     1035          GpiSetColor(hps, CLR_WHITE);
     1036          ptl.x = 1;
     1037          ptl.y = 1;
     1038          GpiMove(hps, &ptl);
     1039          ptl.y = swp.cy - 2;
     1040          GpiLine(hps, &ptl);
     1041          ptl.x = swp.cx - 2;
     1042          GpiLine(hps, &ptl);
     1043          ptl.x = 2;
     1044          ptl.y = 2;
     1045          GpiMove(hps, &ptl);
     1046          ptl.y = swp.cy - 3;
     1047          GpiLine(hps, &ptl);
     1048          ptl.x = swp.cx - 3;
     1049          GpiLine(hps, &ptl);
     1050          GpiSetColor(hps, CLR_BROWN);
     1051          ptl.x = 1;
     1052          ptl.y = 1;
     1053          GpiMove(hps, &ptl);
     1054          ptl.x = swp.cx - 2;
     1055          GpiLine(hps, &ptl);
     1056          ptl.y = swp.cy - 2;
     1057          GpiLine(hps, &ptl);
     1058          ptl.x = 2;
     1059          ptl.y = 2;
     1060          GpiMove(hps, &ptl);
     1061          ptl.x = swp.cx - 3;
     1062          GpiLine(hps, &ptl);
     1063          ptl.y = swp.cy - 3;
     1064          GpiLine(hps, &ptl);
     1065        }
     1066        WinEndPaint(hps);
    10591067      }
    10601068    }
     
    10831091      switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
    10841092      case MAIN_LED:
    1085         hps = WinGetPS(hwnd);
    1086         hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
    1087         if (!fBlueLED) {
    1088           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
    1089           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
    1090         }
    1091         else {
    1092           hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
    1093           hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
    1094         }
    1095         if (hbmLEDoff && hbmLEDon)
    1096           WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
    1097         else {
    1098           if (hbmLEDoff)
    1099             GpiDeleteBitmap(hbmLEDoff);
    1100           if (hbmLEDon)
    1101             GpiDeleteBitmap(hbmLEDon);
    1102         }
    1103         if (hbmold &&
    1104             hbmLEDon &&
    1105             hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
    1106           GpiDeleteBitmap(hbmold);
    1107         if (hps)
    1108           WinReleasePS(hps);
    1109         break;
     1093        hps = WinGetPS(hwnd);
     1094        hbmold = (HBITMAP) WinSendMsg(hwnd, SM_QUERYHANDLE, MPVOID, MPVOID);
     1095        if (!fBlueLED) {
     1096          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON_BMP, 12, 12);
     1097          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF_BMP, 12, 12);
     1098        }
     1099        else {
     1100          hbmLEDon = GpiLoadBitmap(hps, 0, LEDON2_BMP, 12, 12);
     1101          hbmLEDoff = GpiLoadBitmap(hps, 0, LEDOFF2_BMP, 12, 12);
     1102        }
     1103        if (hbmLEDoff && hbmLEDon)
     1104          WinSendMsg(hwnd, SM_SETHANDLE, MPFROMLONG(hbmLEDoff), MPVOID);
     1105        else {
     1106          if (hbmLEDoff)
     1107            GpiDeleteBitmap(hbmLEDoff);
     1108          if (hbmLEDon)
     1109            GpiDeleteBitmap(hbmLEDon);
     1110        }
     1111        if (hbmold &&
     1112            hbmLEDon &&
     1113            hbmLEDoff && hbmold != hbmLEDon && hbmold != hbmLEDoff)
     1114          GpiDeleteBitmap(hbmold);
     1115        if (hps)
     1116          WinReleasePS(hps);
     1117        break;
    11101118      default:
    1111         SetPresParams(hwnd,
    1112                       &RGBGREY,
    1113                       &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    1114         break;
     1119        SetPresParams(hwnd,
     1120                      &RGBGREY,
     1121                      &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     1122        break;
    11151123      }
    11161124      return mr;
     
    11361144  case WM_BUTTON1CLICK:
    11371145    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1138             WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
     1146            WM_COMMAND, MPFROM2SHORT(IDM_SHOWNOTEWND, 0), MPVOID);
    11391147    break;
    11401148
    11411149  case WM_BUTTON2CLICK:
    11421150    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1143             WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
     1151            WM_COMMAND, MPFROM2SHORT(IDM_HIDENOTEWND, 0), MPVOID);
    11441152    break;
    11451153
     
    11471155  case WM_BUTTON3CLICK:
    11481156    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    1149             WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     1157            WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    11501158    break;
    11511159  }
     
    11701178    if (fToolbarHelp) {
    11711179      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    1172           && !WinQueryCapture(HWND_DESKTOP)) {
    1173         id = WinQueryWindowUShort(hwnd, QWS_ID);
    1174         tool = find_tool(id);
    1175         if (tool && tool->help && *tool->help) {
    1176 
    1177           char s[128];
    1178 
    1179           strcpy(s, tool->help);
    1180           if (tool->flags & T_DROPABLE)
    1181             strcat(s, GetPString(IDS_DROPONMETEXT));
    1182           MakeBubble(hwnd, FALSE, s);
    1183         }
     1180          && !WinQueryCapture(HWND_DESKTOP)) {
     1181        id = WinQueryWindowUShort(hwnd, QWS_ID);
     1182        tool = find_tool(id);
     1183        if (tool && tool->help && *tool->help) {
     1184
     1185          char s[128];
     1186
     1187          strcpy(s, tool->help);
     1188          if (tool->flags & T_DROPABLE)
     1189            strcat(s, GetPString(IDS_DROPONMETEXT));
     1190          MakeBubble(hwnd, FALSE, s);
     1191        }
    11841192      }
    11851193    }
     
    11901198    case IDM_HELP:
    11911199      if (hwndHelp)
    1192         WinSendMsg(hwndHelp,
    1193                    HM_DISPLAY_HELP,
    1194                    MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
     1200        WinSendMsg(hwndHelp,
     1201                   HM_DISPLAY_HELP,
     1202                   MPFROM2SHORT(HELP_TOOLBAR, 0), MPFROMSHORT(HM_RESOURCEID));
    11951203      break;
    11961204
     
    11981206    case IDM_HIDETOOL:                  /* hide tool */
    11991207      if (SHORT1FROMMP(mp1) == IDM_HIDETOOL)
    1200         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1208        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12011209      else
    1202         id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
    1203                                 PickToolProc, FM3ModHandle,
    1204                                 PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
     1210        id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd,
     1211                                PickToolProc, FM3ModHandle,
     1212                                PICKBTN_FRAME, GetPString(IDS_HIDETEXT));
    12051213      if (id) {
    1206         tool = find_tool(id);
    1207         if (tool) {
    1208           tool->flags |= T_INVISIBLE;
    1209           fToolsChanged = TRUE;
    1210         }
     1214        tool = find_tool(id);
     1215        if (tool) {
     1216          tool->flags |= T_INVISIBLE;
     1217          fToolsChanged = TRUE;
     1218        }
    12111219      }
    12121220      break;
     
    12151223      tool = toolhead;
    12161224      while (tool) {
    1217         tool->flags &= (~T_INVISIBLE);
    1218         tool = tool->next;
    1219         fToolsChanged = TRUE;
     1225        tool->flags &= (~T_INVISIBLE);
     1226        tool = tool->next;
     1227        fToolsChanged = TRUE;
    12201228      }
    12211229      break;
     
    12241232    case IDM_DELETETOOL:                /* delete button */
    12251233      if (SHORT1FROMMP(mp1) == IDM_DELETETOOL)
    1226         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1234        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12271235      else
    1228         id =
    1229           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1230                              PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
     1236        id =
     1237          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1238                             PICKBTN_FRAME, GetPString(IDS_DELETETEXT));
    12311239      if (id)
    1232         PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
    1233                 MPFROM2SHORT(id, 0), MPVOID);
     1240        PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_SETUP,
     1241                MPFROM2SHORT(id, 0), MPVOID);
    12341242      return 0;
    12351243
     
    12371245    case IDM_EDITTOOL:                  /* edit button */
    12381246      if (SHORT1FROMMP(mp1) == IDM_EDITTOOL)
    1239         id = WinQueryWindowUShort(hwnd, QWS_ID);
     1247        id = WinQueryWindowUShort(hwnd, QWS_ID);
    12401248      else
    1241         id =
    1242           (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
    1243                              PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
     1249        id =
     1250          (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, PickToolProc, FM3ModHandle,
     1251                             PICKBTN_FRAME, GetPString(IDS_EDITTEXT));
    12441252      if (id) {
    1245         tool = find_tool(id);
    1246         if (tool) {
    1247           if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1248                         ADDBTN_FRAME, (PVOID) tool))
    1249             WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1250                                                                      QW_PARENT),
    1251                                                       QW_PARENT), FID_CLIENT),
    1252                        WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1253                        MPFROM2SHORT(id, 0));
    1254         }
     1253        tool = find_tool(id);
     1254        if (tool) {
     1255          if (WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
     1256                        ADDBTN_FRAME, (PVOID) tool))
     1257            WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1258                                                                     QW_PARENT),
     1259                                                      QW_PARENT), FID_CLIENT),
     1260                       WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1261                       MPFROM2SHORT(id, 0));
     1262        }
    12551263      }
    12561264      break;
     
    12581266    case IDM_ADDTOOL:                   /* add tool */
    12591267      id = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, AddToolProc, FM3ModHandle,
    1260                               ADDBTN_FRAME, MPVOID);
     1268                              ADDBTN_FRAME, MPVOID);
    12611269      if (id && id != (USHORT) - 1)
    1262         WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
    1263                                                                 QW_PARENT),
    1264                                                   QW_PARENT), FID_CLIENT),
    1265                    WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
    1266                    MPFROM2SHORT(id, 0));
     1270        WinSendMsg(WinWindowFromID(WinQueryWindow(WinQueryWindow(hwnd,
     1271                                                                QW_PARENT),
     1272                                                  QW_PARENT), FID_CLIENT),
     1273                   WM_COMMAND, MPFROM2SHORT(IDM_CREATETOOL, 0),
     1274                   MPFROM2SHORT(id, 0));
    12671275      break;
    12681276
    12691277    case IDM_REORDERTOOLS:              /* reorder tools */
    12701278      WinDlgBox(HWND_DESKTOP,
    1271                 hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
     1279                hwnd, ReOrderToolsProc, FM3ModHandle, RE_FRAME, MPVOID);
    12721280      break;
    12731281
     
    12751283    case IDM_LOADTOOLS:
    12761284      if (WinDlgBox(HWND_DESKTOP,
    1277                     hwnd,
    1278                     ToolIODlgProc,
    1279                     FM3ModHandle,
    1280                     SVBTN_FRAME,
    1281                     (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
    1282                     "TRUE" : NULL))
    1283         BuildTools(hwndToolback, TRUE);
     1285                    hwnd,
     1286                    ToolIODlgProc,
     1287                    FM3ModHandle,
     1288                    SVBTN_FRAME,
     1289                    (PVOID) (SHORT1FROMMP(mp1) == IDM_SAVETOOLS) ?
     1290                    "TRUE" : NULL))
     1291        BuildTools(hwndToolback, TRUE);
    12841292      break;
    12851293    }
     
    13131321      tool = find_tool(id);
    13141322      if (!tool) {
    1315         DrgFreeDraginfo(pDInfo);
    1316         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1323        DrgFreeDraginfo(pDInfo);
     1324        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13171325      }
    13181326      if (!(tool->flags & T_DROPABLE)) {
    1319         DrgFreeDraginfo(pDInfo);
    1320         return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
     1327        DrgFreeDraginfo(pDInfo);
     1328        return (MRFROM2SHORT(DOR_NEVERDROP, 0));        /* Drop not valid */
    13211329      }
    13221330      {
    1323         PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
    1324 
    1325         pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
    1326                                      0);        /* Index to DRAGITEM */
    1327         if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
    1328                         DRM_OS2FILE,   /* mechanisms and data */
    1329                         NULL)) {       /* formats */
    1330           if (!(tool->flags & T_EMPHASIZED)) {
    1331             tool->flags |= T_EMPHASIZED;
    1332             DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1333             DrgFreeDraginfo(pDInfo);
    1334           }
    1335           return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
    1336                                DO_MOVE));       /* Move operation valid */
    1337         }
    1338         DrgFreeDraginfo(pDInfo);
     1331        PDRAGITEM pDItem;               /* Pointer to DRAGITEM */
     1332
     1333        pDItem = DrgQueryDragitemPtr(pDInfo,    /* Access DRAGITEM */
     1334                                     0);        /* Index to DRAGITEM */
     1335        if (DrgVerifyRMF(pDItem,        /* Check valid rendering */
     1336                        DRM_OS2FILE,   /* mechanisms and data */
     1337                        NULL)) {       /* formats */
     1338          if (!(tool->flags & T_EMPHASIZED)) {
     1339            tool->flags |= T_EMPHASIZED;
     1340            DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1341            DrgFreeDraginfo(pDInfo);
     1342          }
     1343          return (MRFROM2SHORT(DOR_DROP,        /* Return okay to drop */
     1344                               DO_MOVE));       /* Move operation valid */
     1345        }
     1346        DrgFreeDraginfo(pDInfo);
    13391347      }
    13401348    }
     
    13531361    if (tool && (tool->flags & T_DROPABLE)) {
    13541362      if (tool->flags & T_EMPHASIZED) {
    1355         tool->flags &= (~T_EMPHASIZED);
    1356         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1363        tool->flags &= (~T_EMPHASIZED);
     1364        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    13571365      }
    13581366    }
     
    13671375
    13681376      if (tool->flags & T_EMPHASIZED) {
    1369         DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
    1370         tool->flags &= (~T_EMPHASIZED);
     1377        DrawTargetEmphasis(hwnd, ((tool->flags & T_EMPHASIZED) != 0));
     1378        tool->flags &= (~T_EMPHASIZED);
    13711379      }
    13721380      memset(&cdi, 0, sizeof(cdi));
     
    13751383      CheckPmDrgLimit(cdi.pDragInfo);
    13761384      if (li) {
    1377         li->type = id;
    1378         if (!li->list || !li->list[0])
    1379           FreeListInfo(li);
    1380         else {
    1381           HWND hwndActive;
    1382 
    1383           hwndActive = TopWindow(hwndMain, (HWND) 0);
    1384           if (hwndActive) {
    1385             if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
    1386               FreeListInfo(li);
    1387           }
    1388           else
    1389             FreeListInfo(li);
    1390         }
     1385        li->type = id;
     1386        if (!li->list || !li->list[0])
     1387          FreeListInfo(li);
     1388        else {
     1389          HWND hwndActive;
     1390
     1391          hwndActive = TopWindow(hwndMain, (HWND) 0);
     1392          if (hwndActive) {
     1393            if (!WinSendMsg(hwndActive, UM_COMMAND, MPFROMP(li), MPVOID))
     1394              FreeListInfo(li);
     1395          }
     1396          else
     1397            FreeListInfo(li);
     1398        }
    13911399      }
    13921400    }
     
    14251433    if (!fTextTools) {
    14261434      if (!(tool->flags & T_MYICON)) {
    1427         hwndTool = WinCreateWindow(hwndT,
    1428                                    WC_TOOLBUTTONS,
    1429                                    s,
    1430                                    BS_NOPOINTERFOCUS |
    1431                                    BS_BITMAP | BS_PUSHBUTTON,
    1432                                    ctrlxpos,
    1433                                    14,
    1434                                    32,
    1435                                    32, hwndT, HWND_TOP, tool->id, NULL, NULL);
     1435        hwndTool = WinCreateWindow(hwndT,
     1436                                   WC_TOOLBUTTONS,
     1437                                   s,
     1438                                   BS_NOPOINTERFOCUS |
     1439                                   BS_BITMAP | BS_PUSHBUTTON,
     1440                                   ctrlxpos,
     1441                                   14,
     1442                                   32,
     1443                                   32, hwndT, HWND_TOP, tool->id, NULL, NULL);
    14361444      }
    14371445      if (!hwndTool) {
    1438         HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
    1439 
    1440         if (hbm) {
    1441           BTNCDATA btc;
    1442 
    1443           memset(&btc, 0, sizeof(btc));
    1444           btc.cb = sizeof(btc);
    1445           btc.hImage = hbm;
    1446           hwndTool = WinCreateWindow(hwndT,
    1447                                      WC_TOOLBUTTONS,
    1448                                      NullStr,
    1449                                      BS_NOPOINTERFOCUS |
    1450                                      BS_BITMAP | BS_PUSHBUTTON,
    1451                                      ctrlxpos,
    1452                                      14,
    1453                                      32,
    1454                                      32,
    1455                                      hwndT, HWND_TOP, tool->id, &btc, NULL);
    1456           if (!hwndTool)
    1457             GpiDeleteBitmap(hbm);
    1458         }
     1446        HBITMAP hbm = LoadBitmapFromFileNum(tool->id);
     1447
     1448        if (hbm) {
     1449          BTNCDATA btc;
     1450
     1451          memset(&btc, 0, sizeof(btc));
     1452          btc.cb = sizeof(btc);
     1453          btc.hImage = hbm;
     1454          hwndTool = WinCreateWindow(hwndT,
     1455                                     WC_TOOLBUTTONS,
     1456                                     NullStr,
     1457                                     BS_NOPOINTERFOCUS |
     1458                                     BS_BITMAP | BS_PUSHBUTTON,
     1459                                     ctrlxpos,
     1460                                     14,
     1461                                     32,
     1462                                     32,
     1463                                     hwndT, HWND_TOP, tool->id, &btc, NULL);
     1464          if (!hwndTool)
     1465            GpiDeleteBitmap(hbm);
     1466        }
    14591467      }
    14601468      if (hwndTool)
    1461         tool->flags &= (~T_TEXT);
     1469        tool->flags &= (~T_TEXT);
    14621470    }
    14631471    if (!hwndTool) {
    14641472      hwndTool = WinCreateWindow(hwndT,
    1465                                 WC_TOOLBUTTONS,
    1466                                 (!tool->text && tool->id >= IDM_COMMANDSTART
    1467                                   && tool->id <
    1468                                   IDM_QUICKTOOLSTART) ? command_title(tool->
    1469                                                                       id -
    1470                                                                       IDM_COMMANDSTART)
    1471                                 : tool->text,
    1472                                 BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
    1473                                 2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
    1474                                 NULL);
     1473                                WC_TOOLBUTTONS,
     1474                                (!tool->text && tool->id >= IDM_COMMANDSTART
     1475                                  && tool->id <
     1476                                  IDM_QUICKTOOLSTART) ? command_title(tool->
     1477                                                                      id -
     1478                                                                      IDM_COMMANDSTART)
     1479                                : tool->text,
     1480                                BS_NOPOINTERFOCUS | BS_PUSHBUTTON, ctrlxpos,
     1481                                2, 54, 24, hwndT, HWND_TOP, tool->id, NULL,
     1482                                NULL);
    14751483      if (!hwndTool)
    1476         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1477                    IDS_WINCREATEWINDOW);
     1484        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1485                   IDS_WINCREATEWINDOW);
    14781486      tool->flags |= T_TEXT;
    14791487    }
    14801488    if (fToolTitles && !fTextTools) {
    14811489      hwndTool = WinCreateWindow(hwndT,
    1482                                 WC_STATIC,
    1483                                 tool->text,
    1484                                 SS_TEXT | DT_LEFT | DT_VCENTER,
    1485                                 ctrlxpos,
    1486                                 1,
    1487                                 32,
    1488                                 10,
    1489                                 hwndT,
    1490                                 HWND_TOP, tool->id + 25000, NULL, NULL);
     1490                                WC_STATIC,
     1491                                tool->text,
     1492                                SS_TEXT | DT_LEFT | DT_VCENTER,
     1493                                ctrlxpos,
     1494                                1,
     1495                                32,
     1496                                10,
     1497                                hwndT,
     1498                                HWND_TOP, tool->id + 25000, NULL, NULL);
    14911499      if (!hwndTool)
    1492         Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1493                    IDS_WINCREATEWINDOW);
     1500        Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     1501                   IDS_WINCREATEWINDOW);
    14941502      else {
    1495         SetPresParams(hwndTool,
    1496                       &RGBGREY,
    1497                       &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
     1503        SetPresParams(hwndTool,
     1504                      &RGBGREY,
     1505                      &RGBBLACK, &RGBGREY, GetPString(IDS_2SYSTEMVIOTEXT));
    14981506      }
    14991507    }
    15001508    ctrlxpos += ((tool->flags & T_TEXT) ? 55L : 33L);
    15011509    SetPresParams(WinWindowFromID(hwndT, tool->id),
    1502                   NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
     1510                  NULL, NULL, NULL, GetPString(IDS_8HELVTEXT));
    15031511    tool = tool->next;
    15041512  }                                     // while tool
    15051513
    15061514  hwndTool = WinCreateWindow(hwndT,
    1507                              WC_BUTTON,
    1508                              "#6010",
    1509                              BS_NOPOINTERFOCUS |
    1510                              BS_BITMAP | BS_PUSHBUTTON,
    1511                              1,
    1512                              19,
    1513                              14,
    1514                              13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
     1515                             WC_BUTTON,
     1516                             "#6010",
     1517                             BS_NOPOINTERFOCUS |
     1518                             BS_BITMAP | BS_PUSHBUTTON,
     1519                             1,
     1520                             19,
     1521                             14,
     1522                             13, hwndT, HWND_TOP, IDM_TOOLLEFT, NULL, NULL);
    15151523  if (!hwndTool)
    15161524    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1517                IDS_WINCREATEWINDOW);
     1525               IDS_WINCREATEWINDOW);
    15181526  hwndTool =
    15191527    WinCreateWindow(hwndT, WC_BUTTON, "#6011",
    1520                     BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
    1521                     13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
     1528                    BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON, 1, 4, 14,
     1529                    13, hwndT, HWND_TOP, IDM_TOOLRIGHT, NULL, NULL);
    15221530  if (!hwndTool)
    15231531    Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    1524                IDS_WINCREATEWINDOW);
     1532               IDS_WINCREATEWINDOW);
    15251533  if (resize)
    15261534    ResizeTools(hwndT);
     
    15281536
    15291537static MRESULT EXPENTRY CommandLineProc(HWND hwnd, ULONG msg, MPARAM mp1,
    1530                                         MPARAM mp2)
     1538                                        MPARAM mp2)
    15311539{
    15321540  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    15451553
    15461554      if (WinQueryWindowUShort((HWND) mp1, QWS_ID) == COMMAND_BUTTON)
    1547         break;
     1555        break;
    15481556      if (!WinQueryWindowProcess((HWND) mp1, &pid, &tid) || pid == mypid)
    1549         WinDestroyWindow(hwnd);
     1557        WinDestroyWindow(hwnd);
    15501558    }
    15511559    break;
     
    15571565      pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    15581566      if (pszCmdLine) {
    1559         lbup = TRUE;
    1560         if (WinDlgBox(HWND_DESKTOP,
    1561                         hwnd,
    1562                       CmdLine2DlgProc,
    1563                       FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
    1564           lstrip(pszCmdLine);
    1565         WinSetWindowText(hwnd, pszCmdLine);
    1566         }
    1567         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    1568         PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
    1569         free(pszCmdLine);
     1567        lbup = TRUE;
     1568        if (WinDlgBox(HWND_DESKTOP,
     1569                        hwnd,
     1570                      CmdLine2DlgProc,
     1571                      FM3ModHandle, EXEC2_FRAME, MPFROMP(pszCmdLine))) {
     1572          lstrip(pszCmdLine);
     1573        WinSetWindowText(hwnd, pszCmdLine);
     1574        }
     1575        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     1576        PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
     1577        free(pszCmdLine);
    15701578      }
    15711579    }
     
    15841592    case COMMAND_BUTTON:
    15851593      if (!lbup)
    1586         PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1594        PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    15871595      break;
    15881596    }
     
    16031611      bstrip(cl + len);
    16041612      if (strlen(cl) > len) {
    1605         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    1606                    UM_SETUP, MPFROMP(cl + len), MPVOID);
    1607         WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
    1608         bstrip(directory);
    1609         if (*directory && (IsRoot(directory) || !IsFile(directory))) {
    1610           if (!FM2Command(directory, cl + len)) {
    1611             hwndCnr = TopWindow(hwndMain, (HWND) 0);
    1612             if (hwndCnr) {
    1613               hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
    1614               if (hwndCnr) {
    1615                 hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
    1616                 if (hwndCnr)
    1617                   list = BuildList(hwndCnr);
    1618               }
    1619             }
    1620             WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
    1621             if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
    1622               save_cmdlines(FALSE);
    1623             ExecOnList(hwndCnr,
    1624                        cl,
    1625                        WINDOWED | ((fKeepCmdLine) ?
    1626                                    SEPARATEKEEP : SEPARATE),
    1627                        directory, list, NULL, pszSrcFile, __LINE__);
    1628             xfree(list, pszSrcFile, __LINE__);
    1629             WinDestroyWindow(hwnd);
    1630             break;
    1631           }
    1632         }
     1613        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
     1614                   UM_SETUP, MPFROMP(cl + len), MPVOID);
     1615        WinQueryWindowText(hwndStatus, CCHMAXPATH, directory);
     1616        bstrip(directory);
     1617        if (*directory && (IsRoot(directory) || !IsFile(directory))) {
     1618          if (!FM2Command(directory, cl + len)) {
     1619            hwndCnr = TopWindow(hwndMain, (HWND) 0);
     1620            if (hwndCnr) {
     1621              hwndCnr = WinWindowFromID(hwndCnr, FID_CLIENT);
     1622              if (hwndCnr) {
     1623                hwndCnr = WinWindowFromID(hwndCnr, DIR_CNR);
     1624                if (hwndCnr)
     1625                  list = BuildList(hwndCnr);
     1626              }
     1627            }
     1628            WinSetActiveWindow(HWND_DESKTOP, hwndCnr);
     1629            if (add_cmdline(cl + len, FALSE) && fSaveMiniCmds)
     1630              save_cmdlines(FALSE);
     1631            ExecOnList(hwndCnr,
     1632                       cl,
     1633                       WINDOWED | ((fKeepCmdLine) ?
     1634                                   SEPARATEKEEP : SEPARATE),
     1635                       directory, list, NULL, pszSrcFile, __LINE__);
     1636            xfree(list, pszSrcFile, __LINE__);
     1637            WinDestroyWindow(hwnd);
     1638            break;
     1639          }
     1640        }
    16331641      }
    16341642      WinSendMsg(hwnd, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     
    16391647    if (!lbup && !(SHORT1FROMMP(mp1) & KC_KEYUP)) {
    16401648      if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
    1641         if ((SHORT1FROMMP(mp2) & 255) == '\r')
    1642           PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
    1643         else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
    1644           WinDestroyWindow(hwnd);
    1645         else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
    1646           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     1649        if ((SHORT1FROMMP(mp2) & 255) == '\r')
     1650          PostMsg(hwnd, UM_OPENWINDOWFORME, MPVOID, MPVOID);
     1651        else if ((SHORT1FROMMP(mp2) & 0xff) == 0x1b)
     1652          WinDestroyWindow(hwnd);
     1653        else if (SHORT2FROMMP(mp2) == VK_UP || SHORT2FROMMP(mp2) == VK_DOWN)
     1654          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    16471655      }
    16481656    }
    16491657    else if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
    1650              ((SHORT2FROMMP(mp2) == VK_UP ||
    1651                SHORT2FROMMP(mp2) == VK_DOWN) ||
    1652               (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
     1658             ((SHORT2FROMMP(mp2) == VK_UP ||
     1659               SHORT2FROMMP(mp2) == VK_DOWN) ||
     1660              (SHORT1FROMMP(mp2) == '\x1b') || (SHORT1FROMMP(mp2) == '\r')))
    16531661      return 0;
    16541662    break;
     
    16761684      rgb.bRed = (BYTE)128;
    16771685      SetPresParams(hwnd,
    1678                     &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
     1686                    &RGBGREY, &rgb, &RGBGREY, GetPString(IDS_8HELVTEXT));
    16791687      SetTargetDir(hwnd, TRUE);
    16801688    }
     
    17061714  case WM_CONTROLPOINTER:
    17071715    if (!fNoFinger &&
    1708         (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
    1709         SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
     1716        (SHORT1FROMMP(mp1) >= IDM_DRIVEA &&
     1717        SHORT1FROMMP(mp1) < IDM_DRIVEA + 26))
    17101718      return MRFROMLONG(hptrFinger);
    17111719    break;
     
    17171725      *dv = 0;
    17181726      WinQueryWindowText(WinWindowFromID(hwnd, SHORT1FROMMP(mp1) + 50),
    1719                         2, dv);
     1727                        2, dv);
    17201728      if (isalpha(*dv)) {
    17211729
    1722         HWND hwndActive;
    1723 
    1724         dv[1] = ':';
    1725         dv[2] = '\\';
    1726         dv[3] = 0;
    1727         hwndActive = TopWindow(hwnd, (HWND) 0);
    1728         if (hwndActive)
    1729           WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    1730                      UM_DRIVECMD, MPFROMP(dv), MPVOID);
     1730        HWND hwndActive;
     1731
     1732        dv[1] = ':';
     1733        dv[2] = '\\';
     1734        dv[3] = 0;
     1735        hwndActive = TopWindow(hwnd, (HWND) 0);
     1736        if (hwndActive)
     1737          WinSendMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     1738                     UM_DRIVECMD, MPFROMP(dv), MPVOID);
    17311739      }
    17321740    }
     
    17561764  case WM_MOUSEMOVE:
    17571765    if (fDrivebarHelp &&
    1758         (!hwndBubble ||
    1759         WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1760         !WinQueryCapture(HWND_DESKTOP)) {
     1766        (!hwndBubble ||
     1767        WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1768        !WinQueryCapture(HWND_DESKTOP)) {
    17611769      id = WinQueryWindowUShort(hwnd, QWS_ID);
    17621770      if (helpid != id) {
    1763         helpid = id;
    1764         PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
     1771        helpid = id;
     1772        PostMsg(MainObjectHwnd, UM_SETUP6, MPFROMLONG((ULONG) hwnd), MPVOID);
    17651773      }
    17661774      else
    1767         helpid = 0;
     1775        helpid = 0;
    17681776    }
    17691777    break;
     
    17721780    if (helpid == WinQueryWindowUShort(hwnd, QWS_ID)) {
    17731781      if ((char *)mp1 &&
    1774           (!hwndBubble ||
    1775            WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
    1776           !WinQueryCapture(HWND_DESKTOP)) {
    1777 
    1778         RECTL rcl;
    1779         POINTL ptl;
    1780 
    1781         WinQueryPointerPos(HWND_DESKTOP, &ptl);
    1782         WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
    1783         WinQueryWindowRect(hwnd, &rcl);
    1784         if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
    1785           BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
     1782          (!hwndBubble ||
     1783           WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
     1784          !WinQueryCapture(HWND_DESKTOP)) {
     1785
     1786        RECTL rcl;
     1787        POINTL ptl;
     1788
     1789        WinQueryPointerPos(HWND_DESKTOP, &ptl);
     1790        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
     1791        WinQueryWindowRect(hwnd, &rcl);
     1792        if (WinPtInRect(WinQueryAnchorBlock(hwnd), &rcl, &ptl))
     1793          BubbleHelp(hwnd, FALSE, TRUE, FALSE, (char *)mp1);
    17861794      }
    17871795    }
     
    18021810    *szDrv = 0;
    18031811    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1804                                        id + 50), sizeof(szDrv), szDrv);
     1812                                       id + 50), sizeof(szDrv), szDrv);
    18051813    if (isalpha(*szDrv)) {
    18061814      hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, MAIN_DRIVES);
    18071815      if (hwndMenu) {
    1808         BOOL rdy;
    1809         CHAR chDrv = *szDrv;
    1810         UINT iDrv;
    1811 
    1812         strcpy(szDrv + 2, "\\");
    1813         MakeValidDir(szDrv);
    1814         // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
    1815         rdy = toupper(*szDrv) == toupper(chDrv);
    1816         iDrv = toupper(*szDrv) - 'A';
    1817         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
    1818           WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
    1819 
    1820         if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
    1821           WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
    1822           WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
    1823           WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
    1824           WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
    1825         }
    1826         if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
    1827           WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
    1828           WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
    1829           WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
    1830         }
    1831         if (!rdy) {
    1832           WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
    1833           WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
    1834           WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
    1835           WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
    1836           WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
    1837         }
    1838         /* fixme to be gone?
    1839           if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
    1840             WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
    1841           }
    1842         */
    1843         PopupMenu(hwnd, hwnd, hwndMenu);
     1816        BOOL rdy;
     1817        CHAR chDrv = *szDrv;
     1818        UINT iDrv;
     1819
     1820        strcpy(szDrv + 2, "\\");
     1821        MakeValidDir(szDrv);
     1822        // Disable menus if MakeValidDir changes drive letter fixme this section doesn't do anything see treecnt.c
     1823        rdy = toupper(*szDrv) == toupper(chDrv);
     1824        iDrv = toupper(*szDrv) - 'A';
     1825        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOTE)
     1826          WinEnableMenuItem(hwndMenu, IDM_DETACH, FALSE);
     1827
     1828        if (!rdy || driveflags[iDrv] & DRIVE_NOTWRITEABLE) {
     1829          WinEnableMenuItem(hwndMenu, IDM_MKDIR, FALSE);
     1830          WinEnableMenuItem(hwndMenu, IDM_FORMAT, FALSE);
     1831          WinEnableMenuItem(hwndMenu, IDM_OPTIMIZE, FALSE);
     1832          WinEnableMenuItem(hwndMenu, IDM_UNDELETE, FALSE);
     1833        }
     1834        if (!rdy || ~driveflags[iDrv] & DRIVE_REMOVABLE) {
     1835          WinEnableMenuItem(hwndMenu, IDM_EJECT, FALSE);
     1836          WinEnableMenuItem(hwndMenu, IDM_LOCK, FALSE);
     1837          WinEnableMenuItem(hwndMenu, IDM_UNLOCK, FALSE);
     1838        }
     1839        if (!rdy) {
     1840          WinEnableMenuItem(hwndMenu, IDM_INFO, FALSE);
     1841          WinEnableMenuItem(hwndMenu, IDM_ARCHIVE, FALSE);
     1842          WinEnableMenuItem(hwndMenu, IDM_SIZES, FALSE);
     1843          WinEnableMenuItem(hwndMenu, IDM_SHOWALLFILES, FALSE);
     1844          WinEnableMenuItem(hwndMenu, IDM_CHKDSK, FALSE);
     1845        }
     1846        /* fixme to be gone?
     1847          if (!rdy || ~driveflags[iDrv] & DRIVE_CDROM) {
     1848            WinEnableMenuItem(hwndMenu, IDM_CLOSETRAY, FALSE);
     1849          }
     1850        */
     1851        PopupMenu(hwnd, hwnd, hwndMenu);
    18441852      }
    18451853    }
     
    18561864    *szDrv = 0;
    18571865    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1858                                        id + 50), sizeof(szDrv), szDrv);
     1866                                       id + 50), sizeof(szDrv), szDrv);
    18591867    if (isalpha(*szDrv)) {
    18601868      strcat(szDrv, "\\");
    18611869      if (!FindDirCnrByName(szDrv, TRUE))
    1862         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
     1870        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szDrv);
    18631871    }
    18641872    break;
     
    18721880    *szDrv = 0;
    18731881    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1874                                        id + 50), sizeof(szDrv), szDrv);
     1882                                       id + 50), sizeof(szDrv), szDrv);
    18751883    if (isalpha(*szDrv)) {
    18761884      strcat(szDrv, "\\");
     
    18831891    *szDrv = 0;
    18841892    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1885                                        id + 50), sizeof(szDrv), szDrv);
     1893                                       id + 50), sizeof(szDrv), szDrv);
    18861894    if (isalpha(*szDrv) &&
    1887         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1895        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    18881896      if (!emphasized) {
    1889         emphasized = TRUE;
    1890         DrawTargetEmphasis(hwnd, emphasized);
     1897        emphasized = TRUE;
     1898        DrawTargetEmphasis(hwnd, emphasized);
    18911899      }
    18921900      if (AcceptOneDrop(hwnd, mp1, mp2))
    1893         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     1901        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    18941902      return MRFROM2SHORT(DOR_NEVERDROP, 0);
    18951903    }
     
    19001908    *szDrv = 0;
    19011909    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1902                                        id + 50), sizeof(szDrv), szDrv);
     1910                                       id + 50), sizeof(szDrv), szDrv);
    19031911    if (isalpha(*szDrv) &&
    1904         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1912        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19051913      if (emphasized) {
    1906         emphasized = FALSE;
    1907         DrawTargetEmphasis(hwnd, emphasized);
     1914        emphasized = FALSE;
     1915        DrawTargetEmphasis(hwnd, emphasized);
    19081916      }
    19091917    }
     
    19141922    *szDrv = 0;
    19151923    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1916                                        id + 50), sizeof(szDrv), szDrv);
     1924                                       id + 50), sizeof(szDrv), szDrv);
    19171925    if (isalpha(*szDrv) &&
    1918         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1926        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19191927      DropHelp(mp1, mp2, hwnd, GetPString(IDS_DRIVEDROPHELP));
    19201928      return 0;
     
    19261934    *szDrv = 0;
    19271935    WinQueryWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    1928                                        id + 50), sizeof(szDrv), szDrv);
     1936                                       id + 50), sizeof(szDrv), szDrv);
    19291937    if (isalpha(*szDrv) &&
    1930         !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
     1938        !(driveflags[toupper(*szDrv) - 'A'] & DRIVE_NOTWRITEABLE)) {
    19311939
    19321940      CNRDRAGINFO cnd;
     
    19351943
    19361944      if (emphasized) {
    1937         emphasized = FALSE;
    1938         DrawTargetEmphasis(hwnd, emphasized);
     1945        emphasized = FALSE;
     1946        DrawTargetEmphasis(hwnd, emphasized);
    19391947      }
    19401948      memset(&cnd, 0, sizeof(cnd));
     
    19421950      cnd.pRecord = NULL;
    19431951      li = DoFileDrop(hwnd,
    1944                       NULL,
    1945                       TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
     1952                      NULL,
     1953                      TRUE, MPFROM2SHORT(TREE_CNR, CN_DROP), MPFROMP(&cnd));
    19461954      CheckPmDrgLimit(cnd.pDragInfo);
    19471955      if (li) {
    1948         strcpy(li->targetpath, szDrv);
    1949         strcat(li->targetpath, "\\");
    1950         if (li->list && li->list[0] && IsRoot(li->list[0]))
    1951           li->type = DO_LINK;
    1952         else if (fDragndropDlg && (!*li->arcname || !li->info)) {
    1953 
    1954           CHECKLIST cl;
    1955 
    1956           memset(&cl, 0, sizeof(cl));
    1957           cl.size = sizeof(cl);
    1958           cl.flags = li->type;
    1959           cl.list = li->list;
    1960           cl.cmd = li->type;
    1961           cl.prompt = li->targetpath;
    1962           li->type = WinDlgBox(HWND_DESKTOP,
    1963                                hwndMain,
    1964                                DropListProc,
    1965                                FM3ModHandle, DND_FRAME, MPFROMP(&cl));
    1966           if (li->type == DID_ERROR)
    1967                   Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
    1968                             "Drag & Drop Dialog");
    1969           if (!li->type) {
    1970             FreeListInfo(li);
    1971             return 0;
    1972           }
    1973           li->list = cl.list;
    1974           if (!li->list || !li->list[0]) {
    1975             FreeListInfo(li);
    1976             return 0;
    1977           }
    1978         }
    1979         else {
    1980           if (!WinDlgBox(HWND_DESKTOP,
    1981                         hwndMain,
    1982                         WalkDlgProc,
    1983                         FM3ModHandle,
    1984                         WALK_FRAME,
    1985                         MPFROMP(li->targetpath)) || !*li->targetpath) {
    1986             FreeListInfo(li);
    1987             return 0;
    1988           }
    1989         }
    1990         switch (li->type) {
    1991         case DND_LAUNCH:
    1992           strcat(li->targetpath, " %a");
    1993           ExecOnList(hwndMain,
    1994                      li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
    1995                      pszSrcFile, __LINE__);
    1996           FreeList(li->list);
    1997           li->list = NULL;
    1998           break;
    1999         case DO_LINK:
    2000           if (fLinkSetsIcon) {
    2001             li->type = IDM_SETICON;
    2002             action = UM_MASSACTION;
    2003           }
    2004           else
    2005             li->type = IDM_COMPARE;
    2006           break;
    2007         case DND_EXTRACT:
    2008           if (*li->targetpath && !IsFile(li->targetpath))
    2009             li->type = IDM_EXTRACT;
    2010           break;
    2011         case DND_MOVE:
    2012           li->type = IDM_MOVE;
    2013           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2014             action = UM_MASSACTION;
    2015             li->type = IDM_ARCHIVEM;
    2016           }
    2017           break;
    2018         case DND_WILDMOVE:
    2019           li->type = IDM_WILDMOVE;
    2020           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2021             action = UM_MASSACTION;
    2022             li->type = IDM_ARCHIVEM;
    2023           }
    2024           break;
    2025         case DND_OBJECT:
    2026           li->type = IDM_OBJECT;
    2027           action = UM_MASSACTION;
    2028           break;
    2029         case DND_SHADOW:
    2030           li->type = IDM_SHADOW;
    2031           action = UM_MASSACTION;
    2032           break;
    2033         case DND_COMPARE:
    2034           li->type = IDM_COMPARE;
    2035           break;
    2036         case DND_SETICON:
    2037           action = UM_MASSACTION;
    2038           li->type = IDM_SETICON;
    2039           break;
    2040         case DND_COPY:
    2041           li->type = IDM_COPY;
    2042           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2043             action = UM_MASSACTION;
    2044             li->type = IDM_ARCHIVE;
    2045           }
    2046           break;
    2047         case DND_WILDCOPY:
    2048           li->type = IDM_WILDCOPY;
    2049           if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2050             action = UM_MASSACTION;
    2051             li->type = IDM_ARCHIVE;
    2052           }
    2053           break;
    2054         default:
    2055           if (*li->arcname && li->info) {
    2056             action = UM_MASSACTION;
    2057             li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
    2058               IDM_FAKEEXTRACT;
    2059           }
    2060           else if (*li->targetpath && IsFile(li->targetpath) == 1) {
    2061             action = UM_MASSACTION;
    2062             li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
    2063           }
    2064           else
    2065             li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
    2066           break;
    2067         }
    2068         if (!li->list || !li->list[0])
    2069           FreeListInfo(li);
    2070         else
    2071           WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
     1956        strcpy(li->targetpath, szDrv);
     1957        strcat(li->targetpath, "\\");
     1958        if (li->list && li->list[0] && IsRoot(li->list[0]))
     1959          li->type = DO_LINK;
     1960        else if (fDragndropDlg && (!*li->arcname || !li->info)) {
     1961
     1962          CHECKLIST cl;
     1963
     1964          memset(&cl, 0, sizeof(cl));
     1965          cl.size = sizeof(cl);
     1966          cl.flags = li->type;
     1967          cl.list = li->list;
     1968          cl.cmd = li->type;
     1969          cl.prompt = li->targetpath;
     1970          li->type = WinDlgBox(HWND_DESKTOP,
     1971                               hwndMain,
     1972                               DropListProc,
     1973                               FM3ModHandle, DND_FRAME, MPFROMP(&cl));
     1974          if (li->type == DID_ERROR)
     1975                  Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
     1976                            "Drag & Drop Dialog");
     1977          if (!li->type) {
     1978            FreeListInfo(li);
     1979            return 0;
     1980          }
     1981          li->list = cl.list;
     1982          if (!li->list || !li->list[0]) {
     1983            FreeListInfo(li);
     1984            return 0;
     1985          }
     1986        }
     1987        else {
     1988          if (!WinDlgBox(HWND_DESKTOP,
     1989                        hwndMain,
     1990                        WalkDlgProc,
     1991                        FM3ModHandle,
     1992                        WALK_FRAME,
     1993                        MPFROMP(li->targetpath)) || !*li->targetpath) {
     1994            FreeListInfo(li);
     1995            return 0;
     1996          }
     1997        }
     1998        switch (li->type) {
     1999        case DND_LAUNCH:
     2000          strcat(li->targetpath, " %a");
     2001          ExecOnList(hwndMain,
     2002                     li->targetpath, PROMPT | WINDOWED, NULL, li->list, NULL,
     2003                     pszSrcFile, __LINE__);
     2004          FreeList(li->list);
     2005          li->list = NULL;
     2006          break;
     2007        case DO_LINK:
     2008          if (fLinkSetsIcon) {
     2009            li->type = IDM_SETICON;
     2010            action = UM_MASSACTION;
     2011          }
     2012          else
     2013            li->type = IDM_COMPARE;
     2014          break;
     2015        case DND_EXTRACT:
     2016          if (*li->targetpath && !IsFile(li->targetpath))
     2017            li->type = IDM_EXTRACT;
     2018          break;
     2019        case DND_MOVE:
     2020          li->type = IDM_MOVE;
     2021          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2022            action = UM_MASSACTION;
     2023            li->type = IDM_ARCHIVEM;
     2024          }
     2025          break;
     2026        case DND_WILDMOVE:
     2027          li->type = IDM_WILDMOVE;
     2028          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2029            action = UM_MASSACTION;
     2030            li->type = IDM_ARCHIVEM;
     2031          }
     2032          break;
     2033        case DND_OBJECT:
     2034          li->type = IDM_OBJECT;
     2035          action = UM_MASSACTION;
     2036          break;
     2037        case DND_SHADOW:
     2038          li->type = IDM_SHADOW;
     2039          action = UM_MASSACTION;
     2040          break;
     2041        case DND_COMPARE:
     2042          li->type = IDM_COMPARE;
     2043          break;
     2044        case DND_SETICON:
     2045          action = UM_MASSACTION;
     2046          li->type = IDM_SETICON;
     2047          break;
     2048        case DND_COPY:
     2049          li->type = IDM_COPY;
     2050          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2051            action = UM_MASSACTION;
     2052            li->type = IDM_ARCHIVE;
     2053          }
     2054          break;
     2055        case DND_WILDCOPY:
     2056          li->type = IDM_WILDCOPY;
     2057          if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2058            action = UM_MASSACTION;
     2059            li->type = IDM_ARCHIVE;
     2060          }
     2061          break;
     2062        default:
     2063          if (*li->arcname && li->info) {
     2064            action = UM_MASSACTION;
     2065            li->type = (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM :
     2066              IDM_FAKEEXTRACT;
     2067          }
     2068          else if (*li->targetpath && IsFile(li->targetpath) == 1) {
     2069            action = UM_MASSACTION;
     2070            li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
     2071          }
     2072          else
     2073            li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
     2074          break;
     2075        }
     2076        if (!li->list || !li->list[0])
     2077          FreeListInfo(li);
     2078        else
     2079          WinSendMsg(hwndTree, UM_ACTION, MPFROMP(li), MPFROMLONG(action));
    20722080      }
    20732081      return 0;
     
    21032111    for (x = 0; x < 26; x++) {
    21042112      if ((ulDriveMap & (1L << x)) && !(driveflags[x] & DRIVE_IGNORE)) {
    2105         if (x > 1) {
    2106           if (driveflags[x] & DRIVE_CDROM)
    2107             iconid = CDROM_ICON;
    2108           else
    2109             iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
    2110               REMOVABLE_ICON :
    2111                      (driveflags[x] & DRIVE_VIRTUAL) ?
    2112                       VIRTUAL_ICON :
    2113               (driveflags[x] & DRIVE_REMOTE) ?
    2114               REMOTE_ICON :
    2115                      (driveflags[x] & DRIVE_RAMDISK) ?
    2116                       RAMDISK_ICON :
    2117                      (driveflags[x] & DRIVE_ZIPSTREAM) ?
    2118                       ZIPSTREAM_ICON :DRIVE_ICON;
    2119         }
    2120         else
    2121           iconid = FLOPPY_ICON;
    2122         sprintf(s, "#%lu", iconid);
    2123         hwndB = WinCreateWindow(hwndT,
    2124                                 WC_DRIVEBUTTONS,
    2125                                 s,
    2126                                 BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
    2127                                 0,
    2128                                 0,
    2129                                 28,
    2130                                 18,
    2131                                 hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
    2132         if (!hwndB)
    2133           Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2134                      IDS_WINCREATEWINDOW);
    2135         else {
    2136           WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2137           sprintf(s, "%c:", (CHAR) x + 'A');
    2138           hwndB = WinCreateWindow(hwndT,
    2139                                   WC_STATIC,
    2140                                   s,
    2141                                   SS_TEXT | DT_LEFT | DT_VCENTER,
    2142                                   0,
    2143                                   0,
    2144                                   10,
    2145                                   18,
    2146                                   hwndT,
    2147                                   HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
    2148           if (!hwndB)
    2149             Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
    2150                        IDS_WINCREATEWINDOW);
    2151           else {
    2152             SetPresParams(hwndB,
    2153                           &RGBGREY,
    2154                           &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
    2155             WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
    2156           }
    2157           y++;
    2158         }
     2113        if (x > 1) {
     2114          if (driveflags[x] & DRIVE_CDROM)
     2115            iconid = CDROM_ICON;
     2116          else
     2117            iconid = (driveflags[x] & DRIVE_REMOVABLE) ?
     2118              REMOVABLE_ICON :
     2119                     (driveflags[x] & DRIVE_VIRTUAL) ?
     2120                      VIRTUAL_ICON :
     2121              (driveflags[x] & DRIVE_REMOTE) ?
     2122              REMOTE_ICON :
     2123                     (driveflags[x] & DRIVE_RAMDISK) ?
     2124                      RAMDISK_ICON :
     2125                     (driveflags[x] & DRIVE_ZIPSTREAM) ?
     2126                      ZIPSTREAM_ICON :DRIVE_ICON;
     2127        }
     2128        else
     2129          iconid = FLOPPY_ICON;
     2130        sprintf(s, "#%lu", iconid);
     2131        hwndB = WinCreateWindow(hwndT,
     2132                                WC_DRIVEBUTTONS,
     2133                                s,
     2134                                BS_NOPOINTERFOCUS | BS_BITMAP | BS_PUSHBUTTON,
     2135                                0,
     2136                                0,
     2137                                28,
     2138                                18,
     2139                                hwndT, HWND_TOP, y + IDM_DRIVEA, NULL, NULL);
     2140        if (!hwndB)
     2141          Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2142                     IDS_WINCREATEWINDOW);
     2143        else {
     2144          WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2145          sprintf(s, "%c:", (CHAR) x + 'A');
     2146          hwndB = WinCreateWindow(hwndT,
     2147                                  WC_STATIC,
     2148                                  s,
     2149                                  SS_TEXT | DT_LEFT | DT_VCENTER,
     2150                                  0,
     2151                                  0,
     2152                                  10,
     2153                                  18,
     2154                                  hwndT,
     2155                                  HWND_TOP, y + IDM_DRIVEATEXT, NULL, NULL);
     2156          if (!hwndB)
     2157            Win_Error2(hwndT, HWND_DESKTOP, pszSrcFile, __LINE__,
     2158                       IDS_WINCREATEWINDOW);
     2159          else {
     2160            SetPresParams(hwndB,
     2161                          &RGBGREY,
     2162                          &RGBBLACK, &RGBGREY, GetPString(IDS_6HELVTEXT));
     2163            WinSetWindowPos(hwndB, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER);
     2164          }
     2165          y++;
     2166        }
    21592167      }
    21602168    }                                   // for
    21612169  }                                     // if drivebar
    21622170  PostMsg(WinQueryWindow(hwndT, QW_PARENT),
    2163           WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2171          WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    21642172}
    21652173
     
    21772185    WinQueryWindowRect(hwndT, &rcl);
    21782186    xwidth = rcl.xRight - ((WinQuerySysValue(HWND_DESKTOP,
    2179                                              SV_CYSIZEBORDER) * 2) + 2);
     2187                                             SV_CYSIZEBORDER) * 2) + 2);
    21802188  }
    21812189  henum = WinBeginEnumWindows(hwndT);
     
    21862194      ctrlxsize = 28;
    21872195    WinSetWindowPos(hwndB,
    2188                     HWND_TOP,
    2189                     ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
     2196                    HWND_TOP,
     2197                    ctrlxpos, ctrlypos, ctrlxsize, 18, SWP_MOVE | SWP_SHOW);
    21902198    ctrlxpos += (ctrlxsize + 2);
    21912199    if (ctrlxsize == 10) {
    21922200      if (ctrlxpos + (42 + ((fShowTarget && DriveLines == 0) ?
    2193                             256 : 0)) > xwidth) {
    2194         ctrlxpos = 2;
    2195         ctrlypos += 18;
    2196         DriveLines++;
     2201                            256 : 0)) > xwidth) {
     2202        ctrlxpos = 2;
     2203        ctrlypos += 18;
     2204        DriveLines++;
    21972205      }
    21982206    }
     
    22132221
    22142222      SetPresParams(hwnd,
    2215                     &RGBGREY,
    2216                     &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
     2223                    &RGBGREY,
     2224                    &RGBBLACK, &RGBGREY, GetPString(IDS_8HELVBOLDTEXT));
    22172225      return mr;
    22182226    }
     
    22242232
    22252233      cbRetLen = WinQueryPresParam(hwnd,
    2226                                    (ULONG) mp1,
    2227                                    0,
    2228                                    &AttrFound,
    2229                                    (ULONG) sizeof(AttrValue), &AttrValue, 0);
     2234                                   (ULONG) mp1,
     2235                                   0,
     2236                                   &AttrFound,
     2237                                   (ULONG) sizeof(AttrValue), &AttrValue, 0);
    22302238      if (cbRetLen) {
    2231         PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2232                 WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     2239        PostMsg(WinQueryWindow(hwnd, QW_PARENT),
     2240                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    22332241      }
    22342242    }
     
    22472255      WinQueryWindowPos(hwndTree, &swp);
    22482256      if (!(swp.fl & SWP_MAXIMIZE))
    2249         fl |= SWP_RESTORE;
     2257        fl |= SWP_RESTORE;
    22502258      WinSetWindowPos(hwndTree, HWND_TOP, 0, 0, 0, 0, fl);
    22512259    }
     
    22802288
    22812289      if (fOtherHelp) {
    2282         if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    2283             && !WinQueryCapture(HWND_DESKTOP)) {
    2284           switch (id) {
    2285           case IDM_ATTRS:
    2286             if (WinQueryWindowTextLength(hwnd))
    2287               s = GetPString(IDS_ATTRSBUTTONHELP);
    2288             break;
    2289           case IDM_INFO:
    2290             if (WinQueryWindowTextLength(hwnd))
    2291               s = GetPString(IDS_INFOBUTTONHELP);
    2292             break;
    2293           case IDM_RENAME:
    2294             if (WinQueryWindowTextLength(hwnd))
    2295               s = GetPString(IDS_NAMEBUTTONHELP);
    2296             break;
    2297           case MAIN_STATUS2:
    2298             if (!hwndE)
    2299               s = GetPString(IDS_STATUS2HELP);
    2300             break;
    2301           default:
    2302             break;
    2303           }
    2304           if (s)
    2305             MakeBubble(hwnd, FALSE, s);
    2306           else if (hwndBubble)
    2307             WinDestroyWindow(hwndBubble);
    2308         }
     2290        if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
     2291            && !WinQueryCapture(HWND_DESKTOP)) {
     2292          switch (id) {
     2293          case IDM_ATTRS:
     2294            if (WinQueryWindowTextLength(hwnd))
     2295              s = GetPString(IDS_ATTRSBUTTONHELP);
     2296            break;
     2297          case IDM_INFO:
     2298            if (WinQueryWindowTextLength(hwnd))
     2299              s = GetPString(IDS_INFOBUTTONHELP);
     2300            break;
     2301          case IDM_RENAME:
     2302            if (WinQueryWindowTextLength(hwnd))
     2303              s = GetPString(IDS_NAMEBUTTONHELP);
     2304            break;
     2305          case MAIN_STATUS2:
     2306            if (!hwndE)
     2307              s = GetPString(IDS_STATUS2HELP);
     2308            break;
     2309          default:
     2310            break;
     2311          }
     2312          if (s)
     2313            MakeBubble(hwnd, FALSE, s);
     2314          else if (hwndBubble)
     2315            WinDestroyWindow(hwndBubble);
     2316        }
    23092317      }
    23102318      switch (id) {
     
    23132321      case IDM_RENAME:
    23142322      case MAIN_STATUS2:
    2315         return CommonTextProc(hwnd, msg, mp1, mp2);
     2323        return CommonTextProc(hwnd, msg, mp1, mp2);
    23162324      default:
    2317         break;
     2325        break;
    23182326      }
    23192327    }
     
    23382346      case IDM_RENAME:
    23392347      case MAIN_STATUS2:
    2340         return CommonTextButton(hwnd, msg, mp1, mp2);
     2348        return CommonTextButton(hwnd, msg, mp1, mp2);
    23412349      default:
    2342         PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
    2343         break;
     2350        PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
     2351        break;
    23442352      }
    23452353    }
     
    23532361      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23542362      if (id == MAIN_STATUS2 && hwndE)
    2355         WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2363        WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    23562364      else
    2357         return CommonTextButton(hwnd, msg, mp1, mp2);
     2365        return CommonTextButton(hwnd, msg, mp1, mp2);
    23582366    }
    23592367    break;
     
    23652373      id = WinQueryWindowUShort(hwnd, QWS_ID);
    23662374      if (id == MAIN_STATUS) {
    2367         if (SHORT2FROMMP(mp2) & KC_CTRL)
    2368           PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2369                                   FID_CLIENT),
    2370                   WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
    2371         else if (hwndTree)
    2372           PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
     2375        if (SHORT2FROMMP(mp2) & KC_CTRL)
     2376          PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2377                                  FID_CLIENT),
     2378                  WM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
     2379        else if (hwndTree)
     2380          PostMsg(hwndTree, UM_TIMER, MPVOID, MPVOID);
    23732381      }
    23742382    }
     
    23832391      if (id == MAIN_STATUS2 && !hwndE) {
    23842392
    2385         SWP swp;
    2386         CHAR directory[CCHMAXPATH];
    2387         PFNWP oldproce;
    2388 
    2389         *directory = 0;
    2390         TopWindowName(hwndMain, (HWND) 0, directory);
    2391         WinQueryWindowPos(hwnd, &swp);
    2392         hwndB = WinCreateWindow(hwnd,
    2393                                 WC_BUTTON,
    2394                                 "+",
    2395                                 WS_VISIBLE | BS_PUSHBUTTON |
    2396                                 BS_NOPOINTERFOCUS,
    2397                                 swp.cx - swp.cy,
    2398                                 0,
    2399                                 swp.cy,
    2400                                 swp.cy,
    2401                                 hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
    2402         if (!hwndB)
    2403           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2404         hwndE = WinCreateWindow(hwnd,
    2405                                 WC_ENTRYFIELD,
    2406                                 NULL,
    2407                                 WS_VISIBLE | ES_AUTOSCROLL,
    2408                                 0,
    2409                                 0,
    2410                                 swp.cx - swp.cy,
    2411                                 swp.cy,
    2412                                 hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
    2413         if (!hwndE)
    2414           Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    2415         if (!hwndE || !hwndB) {
    2416           PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
    2417           return 0;
    2418         }
    2419         WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
    2420         WinSetWindowText(hwndStatus, directory);
    2421         if (*lastcmd)
    2422           WinSetWindowText(hwndE, lastcmd);
    2423         else
    2424           WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
    2425         oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
    2426         if (oldproce)
    2427           WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
    2428         PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
    2429         PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
    2430         return 0;
     2393        SWP swp;
     2394        CHAR directory[CCHMAXPATH];
     2395        PFNWP oldproce;
     2396
     2397        *directory = 0;
     2398        TopWindowName(hwndMain, (HWND) 0, directory);
     2399        WinQueryWindowPos(hwnd, &swp);
     2400        hwndB = WinCreateWindow(hwnd,
     2401                                WC_BUTTON,
     2402                                "+",
     2403                                WS_VISIBLE | BS_PUSHBUTTON |
     2404                                BS_NOPOINTERFOCUS,
     2405                                swp.cx - swp.cy,
     2406                                0,
     2407                                swp.cy,
     2408                                swp.cy,
     2409                                hwnd, HWND_TOP, COMMAND_BUTTON, NULL, NULL);
     2410        if (!hwndB)
     2411          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2412        hwndE = WinCreateWindow(hwnd,
     2413                                WC_ENTRYFIELD,
     2414                                NULL,
     2415                                WS_VISIBLE | ES_AUTOSCROLL,
     2416                                0,
     2417                                0,
     2418                                swp.cx - swp.cy,
     2419                                swp.cy,
     2420                                hwnd, HWND_TOP, COMMAND_LINE, NULL, NULL);
     2421        if (!hwndE)
     2422          Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
     2423        if (!hwndE || !hwndB) {
     2424          PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
     2425          return 0;
     2426        }
     2427        WinSendMsg(hwndE, EM_SETTEXTLIMIT, MPFROM2SHORT(1024, 0), MPVOID);
     2428        WinSetWindowText(hwndStatus, directory);
     2429        if (*lastcmd)
     2430          WinSetWindowText(hwndE, lastcmd);
     2431        else
     2432          WinSetWindowText(hwndE, GetPString(IDS_HELPCMDTEXT));
     2433        oldproce = WinSubclassWindow(hwndE, (PFNWP) CommandLineProc);
     2434        if (oldproce)
     2435          WinSetWindowPtr(hwndE, QWL_USER, (PVOID) oldproce);
     2436        PostMsg(hwndE, UM_FOCUSME, MPVOID, MPVOID);
     2437        PostMsg(hwndE, EM_SETSEL, MPFROM2SHORT(0, 1024), MPVOID);
     2438        return 0;
    24312439      }
    24322440      if (msg == UM_CLICKED3 || (SHORT2FROMMP(mp2) & KC_CTRL)) {
    2433         switch (id) {
    2434         case IDM_ATTRS:
    2435           id = IDM_SORTSIZE;
    2436           break;
    2437         case IDM_INFO:
    2438           id = IDM_SORTLWDATE;
    2439           break;
    2440         case IDM_RENAME:
    2441           id = IDM_SORTFILENAME;
    2442           break;
    2443         }
     2441        switch (id) {
     2442        case IDM_ATTRS:
     2443          id = IDM_SORTSIZE;
     2444          break;
     2445        case IDM_INFO:
     2446          id = IDM_SORTLWDATE;
     2447          break;
     2448        case IDM_RENAME:
     2449          id = IDM_SORTFILENAME;
     2450          break;
     2451        }
    24442452      }
    24452453      PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    2446               WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
     2454              WM_COMMAND, MPFROM2SHORT(id, 0), MPVOID);
    24472455    }
    24482456    return 0;
     
    24582466      case IDM_RENAME:
    24592467      case MAIN_STATUS2:
    2460         PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
    2461         break;
     2468        PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
     2469        break;
    24622470      default:
    2463         PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
    2464         break;
     2471        PaintRecessedWindow(hwnd, (HPS) 0, FALSE, TRUE);
     2472        break;
    24652473      }
    24662474      if (id == IDM_RENAME) {
    24672475
    2468         HPS hps;
    2469 
    2470         hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    2471         if (hps) {
    2472           PaintSTextWindow(hwnd, hps);
    2473           WinEndPaint(hps);
    2474         }
    2475         return 0;
     2476        HPS hps;
     2477
     2478        hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
     2479        if (hps) {
     2480          PaintSTextWindow(hwnd, hps);
     2481          WinEndPaint(hps);
     2482        }
     2483        return 0;
    24762484      }
    24772485    }
     
    25062514  case UM_COMMAND:
    25072515    return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2508                                       FID_CLIENT), msg, mp1, mp2);
     2516                                      FID_CLIENT), msg, mp1, mp2);
    25092517
    25102518  case WM_PAINT:
     
    25192527      hps = WinBeginPaint(hwnd, (HPS)0, NULL);
    25202528      if (hps) {
    2521         GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
    2522         WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
    2523                           sizeof(lColor), &lColor, 0);
    2524         WinQueryWindowRect(hwnd, &rcl);
    2525         WinFillRect(hps, &rcl, lColor);
    2526         WinEndPaint(hps);
     2529        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
     2530        WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, NULL,
     2531                          sizeof(lColor), &lColor, 0);
     2532        WinQueryWindowRect(hwnd, &rcl);
     2533        WinFillRect(hps, &rcl, lColor);
     2534        WinEndPaint(hps);
    25272535      }
    25282536
     
    25432551      tool = find_tool(id);
    25442552      if (tool) {
    2545         del_tool(tool);
    2546         WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
    2547         if (fToolTitles)
    2548           WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
    2549         ResizeTools(hwnd);
     2553        del_tool(tool);
     2554        WinShowWindow(WinWindowFromID(hwnd, id), FALSE);
     2555        if (fToolTitles)
     2556          WinShowWindow(WinWindowFromID(hwnd, id + 25000), FALSE);
     2557        ResizeTools(hwnd);
    25502558      }
    25512559    }
     
    25572565
    25582566      id = (USHORT) WinDlgBox(HWND_DESKTOP,
    2559                               hwnd,
    2560                               AddToolProc,
    2561                               FM3ModHandle, ADDBTN_FRAME, MPVOID);
     2567                              hwnd,
     2568                              AddToolProc,
     2569                              FM3ModHandle, ADDBTN_FRAME, MPVOID);
    25622570      if (id && id != (USHORT) - 1)
    2563         WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    2564                                    FID_CLIENT),
    2565                    WM_COMMAND,
    2566                    MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
     2571        WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     2572                                   FID_CLIENT),
     2573                   WM_COMMAND,
     2574                   MPFROM2SHORT(IDM_CREATETOOL, 0), MPFROM2SHORT(id, 0));
    25672575    }
    25682576    break;
     
    25702578  case WM_CONTEXTMENU:
    25712579    if (WinDlgBox(HWND_DESKTOP,
    2572                   hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
     2580                  hwnd, ToolIODlgProc, FM3ModHandle, SVBTN_FRAME, MPVOID))
    25732581      BuildTools(hwnd, TRUE);
    25742582    return MRFROMSHORT(TRUE);
     
    25932601  if (pswp) {
    25942602    if (WinQueryWindowPos(hwndTree, &swp) &&
    2595         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
     2603        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE))) {
    25962604      pswp->x = swp.cx;
    25972605      pswp->cx -= swp.cx;
     
    26002608  if (prectl) {
    26012609    if (WinQueryWindowPos(hwndTree, &swp) &&
    2602         !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
    2603         WinQueryWindowRect(hwndTree, &rectl)) {
     2610        !(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)) &&
     2611        WinQueryWindowRect(hwndTree, &rectl)) {
    26042612      prectl->xLeft = rectl.xRight;
    26052613      prectl->xRight -= rectl.xRight;
     
    26532661    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    26542662      if (swp.x < swpT.cx) {
    2655         swp.x = swpT.cx;
    2656         if (swp.x + swp.cx > swpC.cx)
    2657           swp.cx = swpC.cx - swp.x;
    2658         if (swp.cx > 24)
    2659           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    2660                           SWP_SIZE | SWP_MOVE | SWP_SHOW);
     2663        swp.x = swpT.cx;
     2664        if (swp.x + swp.cx > swpC.cx)
     2665          swp.cx = swpC.cx - swp.x;
     2666        if (swp.cx > 24)
     2667          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     2668                          SWP_SIZE | SWP_MOVE | SWP_SHOW);
    26612669      }
    26622670    }
     
    26782686      WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    26792687      WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    2680                       SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
     2688                      SWP_MOVE | SWP_SHOW | SWP_FOCUSDEACTIVATE);
    26812689    }
    26822690  }
     
    27002708    if (hwndNext) {
    27012709      if (!WinQueryWindowUShort(hwndNext, QWS_ID))
    2702         continue;
     2710        continue;
    27032711      if (next)
    2704         break;
     2712        break;
    27052713      if (hwndNext == hwndActive) {
    2706         if (!previous && hwndPrev) {
    2707           hwndNext = hwndPrev;
    2708           break;
    2709         }
    2710         else if (previous)
    2711           next = TRUE;
     2714        if (!previous && hwndPrev) {
     2715          hwndNext = hwndPrev;
     2716          break;
     2717        }
     2718        else if (previous)
     2719          next = TRUE;
    27122720      }
    27132721      hwndPrev = hwndNext;
     
    27152723    else {
    27162724      if ((!next && previous) || once)
    2717         break;
     2725        break;
    27182726      else if (!previous) {
    2719         hwndNext = hwndPrev;
    2720         break;
     2727        hwndNext = hwndPrev;
     2728        break;
    27212729      }
    27222730      else
    2723         once = next = TRUE;
     2731        once = next = TRUE;
    27242732    }
    27252733  }
     
    27282736  if (hwndNext && hwndNext != hwndActive) {
    27292737    WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0,
    2730                     SWP_ZORDER | SWP_ACTIVATE);
     2738                    SWP_ZORDER | SWP_ACTIVATE);
    27312739    WinSetWindowPos(hwndActive, ((previous) ? HWND_BOTTOM : hwndNext), 0, 0,
    2732                     0, 0, SWP_ZORDER);
     2740                    0, 0, SWP_ZORDER);
    27332741  }
    27342742}
     
    27452753    if (hwndChild != hwndTree) {
    27462754      WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2747                 WM_SAVEAPPLICATION, MPVOID, MPVOID);
     2755                WM_SAVEAPPLICATION, MPVOID, MPVOID);
    27482756      if (WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2749                      WM_CLOSE, MPVOID, MPVOID)) {
    2750         ret = TRUE;
    2751         break;
     2757                     WM_CLOSE, MPVOID, MPVOID)) {
     2758        ret = TRUE;
     2759        break;
    27522760      }
    27532761    }
     
    27722780      hwndTemp = WinWindowFromID(hwndChild, FID_CLIENT);
    27732781      if (hwndTemp) {
    2774         hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
    2775         if (hwndDir) {
    2776           WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
    2777                      WM_CLOSE, MPVOID, MPVOID);
    2778           ret = TRUE;
    2779         }
     2782        hwndDir = WinWindowFromID(hwndTemp, DIR_CNR);
     2783        if (hwndDir) {
     2784          WinSendMsg(WinWindowFromID(hwndChild, FID_CLIENT),
     2785                     WM_CLOSE, MPVOID, MPVOID);
     2786          ret = TRUE;
     2787        }
    27802788      }
    27812789    }
     
    28252833      hwndC = WinWindowFromID(hwndChild, FID_CLIENT);
    28262834      if (hwndC) {
    2827         hwndDir = WinWindowFromID(hwndC, DIR_CNR);
    2828         if (hwndDir) {
    2829           WinQueryWindowPos(hwndChild, &swp);
    2830           *szDir = 0;
    2831           WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
    2832           if (*szDir) {
    2833            // If saving shutdown state skip no prescan drives
    2834             if (fIsShutDownState &&
    2835                 driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    2836               continue;
    2837             }
    2838             sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
    2839             PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
    2840                                 sizeof(SWP));
    2841             dcd =
    2842               WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
    2843             if (dcd) {
    2844               sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
    2845               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
    2846                                   sizeof(INT));
    2847               sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
    2848               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
    2849                                   sizeof(MASK));
    2850               sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
    2851               flWindowAttr = dcd->flWindowAttr;
    2852               if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
    2853                 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    2854                 if (dcd->lastattr) {
    2855                   if (dcd->lastattr & CV_TEXT)
    2856                     flWindowAttr |= CV_TEXT;
    2857                   else if (dcd->lastattr & CV_DETAIL)
    2858                     flWindowAttr |= CV_DETAIL;
    2859                   else if (dcd->lastattr & CV_ICON)
    2860                     flWindowAttr |= CV_ICON;
    2861                   else
    2862                     flWindowAttr |= CV_NAME;
    2863                 }
    2864                 else
    2865                   flWindowAttr |= CV_NAME;
    2866               }
    2867               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
    2868                                   sizeof(ULONG));
    2869               sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
    2870               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
    2871                                   sizeof(BOOL));
    2872               sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
    2873               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
    2874                                   sizeof(BOOL));
    2875               sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
    2876               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
    2877                                   sizeof(BOOL));
    2878               sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
    2879               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
    2880                                   sizeof(BOOL));
    2881               sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
    2882               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
    2883                                   sizeof(BOOL));
    2884               sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
    2885               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
    2886                                   sizeof(BOOL));
    2887               sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
    2888               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
    2889                                   sizeof(BOOL));
    2890               sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
    2891               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
    2892                                   sizeof(BOOL));
    2893               sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
    2894               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
    2895                                   sizeof(BOOL));
    2896               sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
    2897               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
    2898                                   sizeof(BOOL));
    2899               sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
    2900               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
    2901                                   sizeof(BOOL));
    2902               sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
    2903               PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
    2904                                   sizeof(BOOL));
    2905               sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
    2906               SavePresParams(hwndDir, szKey);
    2907             }
    2908             sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
    2909             PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
    2910           }
    2911         }
     2835        hwndDir = WinWindowFromID(hwndC, DIR_CNR);
     2836        if (hwndDir) {
     2837          WinQueryWindowPos(hwndChild, &swp);
     2838          *szDir = 0;
     2839          WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(szDir), MPVOID);
     2840          if (*szDir) {
     2841           // If saving shutdown state skip no prescan drives
     2842            if (fIsShutDownState &&
     2843                driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     2844              continue;
     2845            }
     2846            sprintf(szKey, "%sDirCnrPos.%lu", szPrefix, numsaves);
     2847            PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & swp,
     2848                                sizeof(SWP));
     2849            dcd =
     2850              WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
     2851            if (dcd) {
     2852              sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, numsaves);
     2853              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->sortFlags,
     2854                                  sizeof(INT));
     2855              sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, numsaves);
     2856              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->mask,
     2857                                  sizeof(MASK));
     2858              sprintf(szKey, "%sDirCnrView.%lu", szPrefix, numsaves);
     2859              flWindowAttr = dcd->flWindowAttr;
     2860              if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
     2861                flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     2862                if (dcd->lastattr) {
     2863                  if (dcd->lastattr & CV_TEXT)
     2864                    flWindowAttr |= CV_TEXT;
     2865                  else if (dcd->lastattr & CV_DETAIL)
     2866                    flWindowAttr |= CV_DETAIL;
     2867                  else if (dcd->lastattr & CV_ICON)
     2868                    flWindowAttr |= CV_ICON;
     2869                  else
     2870                    flWindowAttr |= CV_NAME;
     2871                }
     2872                else
     2873                  flWindowAttr |= CV_NAME;
     2874              }
     2875              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & flWindowAttr,
     2876                                  sizeof(ULONG));
     2877              sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, numsaves);
     2878              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslongname,
     2879                                  sizeof(BOOL));
     2880              sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, numsaves);
     2881              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssubject,
     2882                                  sizeof(BOOL));
     2883              sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, numsaves);
     2884              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailssize,
     2885                                  sizeof(BOOL));
     2886              sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, numsaves);
     2887              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsea,
     2888                                  sizeof(BOOL));
     2889              sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, numsaves);
     2890              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsattr,
     2891                                  sizeof(BOOL));
     2892              sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, numsaves);
     2893              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsicon,
     2894                                  sizeof(BOOL));
     2895              sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, numsaves);
     2896              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwdate,
     2897                                  sizeof(BOOL));
     2898              sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, numsaves);
     2899              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslwtime,
     2900                                  sizeof(BOOL));
     2901              sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, numsaves);
     2902              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailsladate,
     2903                                  sizeof(BOOL));
     2904              sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, numsaves);
     2905              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailslatime,
     2906                                  sizeof(BOOL));
     2907              sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, numsaves);
     2908              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrdate,
     2909                                  sizeof(BOOL));
     2910              sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, numsaves);
     2911              PrfWriteProfileData(fmprof, FM3Str, szKey, (PVOID) & dcd->ds.detailscrtime,
     2912                                  sizeof(BOOL));
     2913              sprintf(szKey, "%sDirCnr.%lu", szPrefix, numsaves);
     2914              SavePresParams(hwndDir, szKey);
     2915            }
     2916            sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, numsaves++);
     2917            PrfWriteProfileString(fmprof, FM3Str, szKey, szDir);
     2918          }
     2919        }
    29122920      }
    29132921    }
     
    29943002    if (hwnd) {
    29953003      if (WinQueryWindowPos(hwnd, &swp)) {
    2996         if (pswp->x > swp.cx)
    2997           pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
    2998         if (pswp->y > swp.cy)
    2999           pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
    3000         if (pswp->x + pswp->cx > swp.cx)
    3001           pswp->cx = swp.cx - pswp->x;
    3002         if (pswp->y + pswp->cy > swp.cy)
    3003           pswp->cy = swp.cy - pswp->y;
     3004        if (pswp->x > swp.cx)
     3005          pswp->x = (swp.cx > 24) ? swp.cx - 24 : swp.cx;
     3006        if (pswp->y > swp.cy)
     3007          pswp->y = (swp.cy > 24) ? swp.cy - 24 : swp.cy;
     3008        if (pswp->x + pswp->cx > swp.cx)
     3009          pswp->cx = swp.cx - pswp->x;
     3010        if (pswp->y + pswp->cy > swp.cy)
     3011          pswp->cy = swp.cy - pswp->y;
    30043012      }
    30053013    }
     
    30493057  sprintf(szKey, "%sMySizeLastTime", szPrefix);
    30503058  if (!PrfQueryProfileData(fmprof,
    3051                            FM3Str,
    3052                            szKey,
    3053                            (PVOID) & swpO,
    3054                            &size) ||
     3059                           FM3Str,
     3060                           szKey,
     3061                           (PVOID) & swpO,
     3062                           &size) ||
    30553063      size != sizeof(SWP) || !swp.cx || !swp.cy)
    30563064  {
     
    30803088      swp.fl &= (~SWP_ACTIVATE);
    30813089      WinSetWindowPos(hwndTree,
    3082                       HWND_TOP,
    3083                       swp.x,
    3084                       swp.y,
    3085                       swp.cx,
    3086                       swp.cy,
    3087                       swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     3090                      HWND_TOP,
     3091                      swp.x,
     3092                      swp.y,
     3093                      swp.cx,
     3094                      swp.cy,
     3095                      swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    30883096    }
    30893097    else {
    30903098      WinSetWindowPos(hwndTree,
    3091                       HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3099                      HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    30923100      WinSetWindowUShort(hwndTree, QWS_XRESTORE, (USHORT) swp.x);
    30933101      WinSetWindowUShort(hwndTree, QWS_CXRESTORE, (USHORT) swp.cx);
     
    30993107  sprintf(szKey, "%sNumDirsLastTime", szPrefix);
    31003108  if (PrfQueryProfileData(fmprof,
    3101                           FM3Str, szKey, (PVOID) & numsaves, &size)) {
     3109                          FM3Str, szKey, (PVOID) & numsaves, &size)) {
    31023110    if (fDeleteState)
    31033111      PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     
    31063114      size = sizeof(SWP);
    31073115      if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) &swp, &size)) {
    3108         if (fDeleteState)
    3109           PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3110         sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
    3111         size = sizeof(szDir);
    3112         if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
    3113           // If restoring shutdown state and drive marked no prescan
    3114           // bypass window restore
    3115           if (fIsShutDownState &&
    3116               driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
    3117             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3118             continue;
    3119           }
    3120           if (fDeleteState)
    3121             PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3122           localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
    3123           size = sizeof(BOOL);
    3124           sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
    3125           if (PrfQueryProfileData(fmprof,
    3126                                   FM3Str,
    3127                                   szKey,
    3128                                   (PVOID)&localdcd.ds.detailslongname,
    3129                                   &size) &&
    3130               size == sizeof(BOOL))
    3131           {
    3132             if (fDeleteState)
    3133               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3134           }
    3135           localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
    3136           size = sizeof(BOOL);
    3137           sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
    3138           if (PrfQueryProfileData(fmprof,
    3139                                   FM3Str,
    3140                                   szKey,
    3141                                   (PVOID)&localdcd.ds.detailssubject,
    3142                                   &size) &&
    3143               size == sizeof(BOOL))
    3144           {
    3145             if (fDeleteState)
    3146               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3147           }
    3148           localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
    3149           size = sizeof(BOOL);
    3150           sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
    3151           if (PrfQueryProfileData(fmprof,
    3152                                   FM3Str,
    3153                                   szKey,
    3154                                   (PVOID) & localdcd.ds.detailsea,
    3155                                   &size) &&
    3156               size == sizeof(BOOL))
    3157           {
    3158             if (fDeleteState)
    3159               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3160           }
    3161           localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
    3162           size = sizeof(BOOL);
    3163           sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
    3164           if (PrfQueryProfileData(fmprof,
    3165                                   FM3Str,
    3166                                   szKey,
    3167                                   (PVOID) & localdcd.ds.detailssize,
    3168                                   &size) &&
    3169               size == sizeof(BOOL))
    3170           {
    3171             if (fDeleteState)
    3172               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3173           }
    3174           localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
    3175           size = sizeof(BOOL);
    3176           sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
    3177           if (PrfQueryProfileData(fmprof,
    3178                                   FM3Str,
    3179                                   szKey,
    3180                                   (PVOID) & localdcd.ds.detailsicon,
    3181                                   &size) &&
    3182               size == sizeof(BOOL))
    3183           {
    3184             if (fDeleteState)
    3185               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3186           }
    3187           localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
    3188           size = sizeof(BOOL);
    3189           sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
    3190           if (PrfQueryProfileData(fmprof,
    3191                                   FM3Str,
    3192                                   szKey,
    3193                                   (PVOID)&localdcd.ds.detailsattr,
    3194                                   &size) &&
    3195               size == sizeof(BOOL))
    3196           {
    3197             if (fDeleteState)
    3198               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3199           }
    3200           localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
    3201           size = sizeof(BOOL);
    3202           sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
    3203           if (PrfQueryProfileData(fmprof,
    3204                                   FM3Str,
    3205                                   szKey,
    3206                                   (PVOID) & localdcd.ds.detailscrdate,
    3207               &size) && size == sizeof(BOOL))
    3208           {
    3209             if (fDeleteState)
    3210               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3211           }
    3212           localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
    3213           size = sizeof(BOOL);
    3214           sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
    3215           if (PrfQueryProfileData(fmprof,
    3216                                   FM3Str,
    3217                                   szKey,
    3218                                   (PVOID)&localdcd.ds.detailscrtime,
    3219                                   &size) &&
    3220               size == sizeof(BOOL))
    3221           {
    3222             if (fDeleteState)
    3223               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3224           }
    3225           localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
    3226           size = sizeof(BOOL);
    3227           sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
    3228           if (PrfQueryProfileData(fmprof,
    3229                                   FM3Str,
    3230                                   szKey,
    3231                                   (PVOID) & localdcd.ds.detailslwdate,
    3232                                   &size) &&
    3233               size == sizeof(BOOL))
    3234           {
    3235             if (fDeleteState)
    3236               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3237           }
    3238           localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
    3239           size = sizeof(BOOL);
    3240           sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
    3241           if (PrfQueryProfileData(fmprof,
    3242                                   FM3Str,
    3243                                   szKey,
    3244                                   (PVOID) & localdcd.ds.detailslwtime,
    3245                                   &size) &&
    3246               size == sizeof(BOOL))
    3247           {
    3248             if (fDeleteState)
    3249               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3250           }
    3251           localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
    3252           size = sizeof(BOOL);
    3253           sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
    3254           if (PrfQueryProfileData(fmprof,
    3255                                   FM3Str,
    3256                                   szKey,
    3257                                   (PVOID) & localdcd.ds.detailsladate,
    3258                                   &size) &&
    3259               size == sizeof(BOOL))
    3260           {
    3261             if (fDeleteState)
    3262               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3263           }
    3264           localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
    3265           size = sizeof(BOOL);
    3266           sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
    3267           if (PrfQueryProfileData(fmprof,
    3268                                   FM3Str,
    3269                                   szKey,
    3270                                   (PVOID) & localdcd.ds.detailslatime,
    3271                                   &size) &&
    3272               size == sizeof(BOOL))
    3273           {
    3274             if (fDeleteState)
    3275               PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3276           }
    3277           hwndDir = (HWND) WinSendMsg(hwndClient,
    3278                                       UM_SETDIR,
    3279                                       MPFROMP(szDir), MPFROMLONG(1));
    3280           if (hwndDir) {
    3281             hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
    3282             if (hwndC) {
    3283               HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
    3284               if (!hwndPPSave) {
    3285                 hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
    3286                                              WC_CONTAINER,
    3287                                              NULL,
    3288                                              CCS_AUTOPOSITION | CCS_MINIICONS |
    3289                                              CCS_MINIRECORDCORE | ulCnrType |
    3290                                              WS_VISIBLE,
    3291                                              0,
    3292                                              0,
    3293                                              0,
    3294                                              0,
    3295                                              hwndCnr,
    3296                                              HWND_TOP, (ULONG) -1, NULL, NULL);
    3297                 CopyPresParams(hwndPPSave, hwndC);
    3298                 RestorePresParams(hwndPPSave, "DirCnr");
    3299               }
    3300               sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
    3301               RestorePresParams(hwndCnr, szKey);
    3302               dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
    3303               if (dcd) {
    3304                 dcd->ds.detailslongname = localdcd.ds.detailslongname;
    3305                 dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
    3306                 dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
    3307                 dcd->ds.detailsea       = localdcd.ds.detailsea      ;
    3308                 dcd->ds.detailssize     = localdcd.ds.detailssize    ;
    3309                 dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
    3310                 dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
    3311                 dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
    3312                 dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
    3313                 dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
    3314                 dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
    3315                 dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
    3316                 size = sizeof(INT);
    3317                 sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
    3318                 if (PrfQueryProfileData(fmprof,
    3319                                         FM3Str,
    3320                                         szKey,
    3321                                         (PVOID) & dcd->sortFlags,
    3322                                         &size) && size == sizeof(INT)) {
    3323                   if (!dcd->sortFlags)
    3324                     dcd->sortFlags = SORT_PATHNAME;
    3325                 }
    3326                 if (fDeleteState)
    3327                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3328                 size = sizeof(MASK);
    3329                 sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
    3330                 if (PrfQueryProfileData(fmprof,
    3331                                         FM3Str,
    3332                                         szKey,
    3333                                         (PVOID) & dcd->mask, &size) && size) {
    3334                   if (*dcd->mask.szMask)
    3335                     WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3336                                UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
    3337                 }
    3338                 *(dcd->mask.prompt) = 0;
    3339                 if (fDeleteState)
    3340                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3341                 size = sizeof(ULONG);
    3342                 sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
    3343                 if (!noview) {
    3344                   if (PrfQueryProfileData(fmprof,
    3345                                           FM3Str,
    3346                                           szKey,
    3347                                           (PVOID) & dcd->flWindowAttr,
    3348                                           &size) && size == sizeof(ULONG)) {
    3349 
    3350                     CNRINFO cnri;
    3351 
    3352                     memset(&cnri, 0, sizeof(CNRINFO));
    3353                     cnri.cb = sizeof(CNRINFO);
    3354                     if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3355                                    CM_QUERYCNRINFO,
    3356                                    MPFROMP(&cnri),
    3357                                    MPFROMLONG(sizeof(CNRINFO)))) {
    3358                       cnri.flWindowAttr = dcd->flWindowAttr;
    3359                       WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
    3360                                 CM_SETCNRINFO,
    3361                                 MPFROMP(&cnri),
    3362                                 MPFROMLONG(CMA_FLWINDOWATTR));
    3363                     }
    3364                   }
    3365                 }
    3366                 if (fDeleteState)
    3367                   PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
    3368                   if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
    3369                     WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
    3370               }
    3371             }
    3372             fRestored = TRUE;
    3373             swp.hwnd = hwndDir;
    3374             TransformSwp(&swp, xtrans, ytrans);
    3375             if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3376               WinSetWindowPos(hwndDir,
    3377                               HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
    3378               WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
    3379               WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
    3380               WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
    3381               WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
    3382             } else
    3383               WinSetWindowPos(hwndDir,
    3384                               HWND_TOP,
    3385                               swp.x,
    3386                               swp.y,
    3387                               swp.cx,
    3388                               swp.cy,
    3389                               swp.fl | SWP_MOVE |
    3390                               SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
    3391                               SWP_ACTIVATE);
    3392           }
    3393         }
     3116        if (fDeleteState)
     3117          PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3118        sprintf(szKey, "%sDirCnrDir.%lu", szPrefix, x);
     3119        size = sizeof(szDir);
     3120        if (PrfQueryProfileData(fmprof, FM3Str, szKey, (PVOID) szDir, &size)) {
     3121          // If restoring shutdown state and drive marked no prescan
     3122          // bypass window restore
     3123          if (fIsShutDownState &&
     3124              driveflags[toupper(*szDir) - 'A'] & DRIVE_NOPRESCAN) {
     3125            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3126            continue;
     3127          }
     3128          if (fDeleteState)
     3129            PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3130          localdcd.ds.detailslongname = dsDirCnrDefault.detailslongname;  // Set default
     3131          size = sizeof(BOOL);
     3132          sprintf(szKey, "%sDirCnr.%lu.DetailsLongname", szPrefix, x);
     3133          if (PrfQueryProfileData(fmprof,
     3134                                  FM3Str,
     3135                                  szKey,
     3136                                  (PVOID)&localdcd.ds.detailslongname,
     3137                                  &size) &&
     3138              size == sizeof(BOOL))
     3139          {
     3140            if (fDeleteState)
     3141              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3142          }
     3143          localdcd.ds.detailssubject = dsDirCnrDefault.detailssubject;  // Set default
     3144          size = sizeof(BOOL);
     3145          sprintf(szKey, "%sDirCnr.%lu.DetailsSubject", szPrefix, x);
     3146          if (PrfQueryProfileData(fmprof,
     3147                                  FM3Str,
     3148                                  szKey,
     3149                                  (PVOID)&localdcd.ds.detailssubject,
     3150                                  &size) &&
     3151              size == sizeof(BOOL))
     3152          {
     3153            if (fDeleteState)
     3154              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3155          }
     3156          localdcd.ds.detailsea = dsDirCnrDefault.detailsea;  // Set default
     3157          size = sizeof(BOOL);
     3158          sprintf(szKey, "%sDirCnr.%lu.DetailsEA", szPrefix, x);
     3159          if (PrfQueryProfileData(fmprof,
     3160                                  FM3Str,
     3161                                  szKey,
     3162                                  (PVOID) & localdcd.ds.detailsea,
     3163                                  &size) &&
     3164              size == sizeof(BOOL))
     3165          {
     3166            if (fDeleteState)
     3167              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3168          }
     3169          localdcd.ds.detailssize = dsDirCnrDefault.detailssize;  // Set default
     3170          size = sizeof(BOOL);
     3171          sprintf(szKey, "%sDirCnr.%lu.DetailsSize", szPrefix, x);
     3172          if (PrfQueryProfileData(fmprof,
     3173                                  FM3Str,
     3174                                  szKey,
     3175                                  (PVOID) & localdcd.ds.detailssize,
     3176                                  &size) &&
     3177              size == sizeof(BOOL))
     3178          {
     3179            if (fDeleteState)
     3180              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3181          }
     3182          localdcd.ds.detailsicon = dsDirCnrDefault.detailsicon;  // Set default
     3183          size = sizeof(BOOL);
     3184          sprintf(szKey, "%sDirCnr.%lu.DetailsIcon", szPrefix, x);
     3185          if (PrfQueryProfileData(fmprof,
     3186                                  FM3Str,
     3187                                  szKey,
     3188                                  (PVOID) & localdcd.ds.detailsicon,
     3189                                  &size) &&
     3190              size == sizeof(BOOL))
     3191          {
     3192            if (fDeleteState)
     3193              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3194          }
     3195          localdcd.ds.detailsattr = dsDirCnrDefault.detailsattr;  // Set default
     3196          size = sizeof(BOOL);
     3197          sprintf(szKey, "%sDirCnr.%lu.DetailsAttr", szPrefix, x);
     3198          if (PrfQueryProfileData(fmprof,
     3199                                  FM3Str,
     3200                                  szKey,
     3201                                  (PVOID)&localdcd.ds.detailsattr,
     3202                                  &size) &&
     3203              size == sizeof(BOOL))
     3204          {
     3205            if (fDeleteState)
     3206              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3207          }
     3208          localdcd.ds.detailscrdate = dsDirCnrDefault.detailscrdate;  // Set default
     3209          size = sizeof(BOOL);
     3210          sprintf(szKey, "%sDirCnr.%lu.DetailsCRDate", szPrefix, x);
     3211          if (PrfQueryProfileData(fmprof,
     3212                                  FM3Str,
     3213                                  szKey,
     3214                                  (PVOID) & localdcd.ds.detailscrdate,
     3215              &size) && size == sizeof(BOOL))
     3216          {
     3217            if (fDeleteState)
     3218              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3219          }
     3220          localdcd.ds.detailscrtime = dsDirCnrDefault.detailscrtime;  // Set default
     3221          size = sizeof(BOOL);
     3222          sprintf(szKey, "%sDirCnr.%lu.DetailsCRTime", szPrefix, x);
     3223          if (PrfQueryProfileData(fmprof,
     3224                                  FM3Str,
     3225                                  szKey,
     3226                                  (PVOID)&localdcd.ds.detailscrtime,
     3227                                  &size) &&
     3228              size == sizeof(BOOL))
     3229          {
     3230            if (fDeleteState)
     3231              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3232          }
     3233          localdcd.ds.detailslwdate = dsDirCnrDefault.detailslwdate;  // Set default
     3234          size = sizeof(BOOL);
     3235          sprintf(szKey, "%sDirCnr.%lu.DetailsLWDate", szPrefix, x);
     3236          if (PrfQueryProfileData(fmprof,
     3237                                  FM3Str,
     3238                                  szKey,
     3239                                  (PVOID) & localdcd.ds.detailslwdate,
     3240                                  &size) &&
     3241              size == sizeof(BOOL))
     3242          {
     3243            if (fDeleteState)
     3244              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3245          }
     3246          localdcd.ds.detailslwtime = dsDirCnrDefault.detailslwtime;  // Set default
     3247          size = sizeof(BOOL);
     3248          sprintf(szKey, "%sDirCnr.%lu.DetailsLWTime", szPrefix, x);
     3249          if (PrfQueryProfileData(fmprof,
     3250                                  FM3Str,
     3251                                  szKey,
     3252                                  (PVOID) & localdcd.ds.detailslwtime,
     3253                                  &size) &&
     3254              size == sizeof(BOOL))
     3255          {
     3256            if (fDeleteState)
     3257              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3258          }
     3259          localdcd.ds.detailsladate = dsDirCnrDefault.detailsladate;  // Set default
     3260          size = sizeof(BOOL);
     3261          sprintf(szKey, "%sDirCnr.%lu.DetailsLADate", szPrefix, x);
     3262          if (PrfQueryProfileData(fmprof,
     3263                                  FM3Str,
     3264                                  szKey,
     3265                                  (PVOID) & localdcd.ds.detailsladate,
     3266                                  &size) &&
     3267              size == sizeof(BOOL))
     3268          {
     3269            if (fDeleteState)
     3270              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3271          }
     3272          localdcd.ds.detailslatime = dsDirCnrDefault.detailslatime;  // Set default
     3273          size = sizeof(BOOL);
     3274          sprintf(szKey, "%sDirCnr.%lu.DetailsLATime", szPrefix, x);
     3275          if (PrfQueryProfileData(fmprof,
     3276                                  FM3Str,
     3277                                  szKey,
     3278                                  (PVOID) & localdcd.ds.detailslatime,
     3279                                  &size) &&
     3280              size == sizeof(BOOL))
     3281          {
     3282            if (fDeleteState)
     3283              PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3284          }
     3285          hwndDir = (HWND) WinSendMsg(hwndClient,
     3286                                      UM_SETDIR,
     3287                                      MPFROMP(szDir), MPFROMLONG(1));
     3288          if (hwndDir) {
     3289            hwndC = WinWindowFromID(hwndDir, FID_CLIENT);
     3290            if (hwndC) {
     3291              HWND hwndCnr = WinWindowFromID(hwndC, DIR_CNR);
     3292              if (!hwndPPSave) {
     3293                hwndPPSave = WinCreateWindow(hwndCnr,         // Create a window (used to save default presparams)
     3294                                             WC_CONTAINER,
     3295                                             NULL,
     3296                                             CCS_AUTOPOSITION | CCS_MINIICONS |
     3297                                             CCS_MINIRECORDCORE | ulCnrType |
     3298                                             WS_VISIBLE,
     3299                                             0,
     3300                                             0,
     3301                                             0,
     3302                                             0,
     3303                                             hwndCnr,
     3304                                             HWND_TOP, (ULONG) -1, NULL, NULL);
     3305                CopyPresParams(hwndPPSave, hwndC);
     3306                RestorePresParams(hwndPPSave, "DirCnr");
     3307              }
     3308              sprintf(szKey, "%sDirCnr.%lu", szPrefix, x);
     3309              RestorePresParams(hwndCnr, szKey);
     3310              dcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
     3311              if (dcd) {
     3312                dcd->ds.detailslongname = localdcd.ds.detailslongname;
     3313                dcd->ds.detailssubject  = localdcd.ds.detailssubject ;
     3314                dcd->ds.detailsattr     = localdcd.ds.detailsattr    ;
     3315                dcd->ds.detailsea       = localdcd.ds.detailsea      ;
     3316                dcd->ds.detailssize     = localdcd.ds.detailssize    ;
     3317                dcd->ds.detailsicon     = localdcd.ds.detailsicon    ;
     3318                dcd->ds.detailscrdate   = localdcd.ds.detailscrdate  ;
     3319                dcd->ds.detailscrtime   = localdcd.ds.detailscrtime  ;
     3320                dcd->ds.detailsladate   = localdcd.ds.detailsladate  ;
     3321                dcd->ds.detailslatime   = localdcd.ds.detailslatime  ;
     3322                dcd->ds.detailslwdate   = localdcd.ds.detailslwdate  ;
     3323                dcd->ds.detailslwtime   = localdcd.ds.detailslwtime  ;
     3324                size = sizeof(INT);
     3325                sprintf(szKey, "%sDirCnrSort.%lu", szPrefix, x);
     3326                if (PrfQueryProfileData(fmprof,
     3327                                        FM3Str,
     3328                                        szKey,
     3329                                        (PVOID) & dcd->sortFlags,
     3330                                        &size) && size == sizeof(INT)) {
     3331                  if (!dcd->sortFlags)
     3332                    dcd->sortFlags = SORT_PATHNAME;
     3333                }
     3334                if (fDeleteState)
     3335                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3336                size = sizeof(MASK);
     3337                sprintf(szKey, "%sDirCnrFilter.%lu", szPrefix, x);
     3338                if (PrfQueryProfileData(fmprof,
     3339                                        FM3Str,
     3340                                        szKey,
     3341                                        (PVOID) & dcd->mask, &size) && size) {
     3342                  if (*dcd->mask.szMask)
     3343                    WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3344                               UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
     3345                }
     3346                *(dcd->mask.prompt) = 0;
     3347                if (fDeleteState)
     3348                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3349                size = sizeof(ULONG);
     3350                sprintf(szKey, "%sDirCnrView.%lu", szPrefix, x);
     3351                if (!noview) {
     3352                  if (PrfQueryProfileData(fmprof,
     3353                                          FM3Str,
     3354                                          szKey,
     3355                                          (PVOID) & dcd->flWindowAttr,
     3356                                          &size) && size == sizeof(ULONG)) {
     3357
     3358                    CNRINFO cnri;
     3359
     3360                    memset(&cnri, 0, sizeof(CNRINFO));
     3361                    cnri.cb = sizeof(CNRINFO);
     3362                    if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3363                                   CM_QUERYCNRINFO,
     3364                                   MPFROMP(&cnri),
     3365                                   MPFROMLONG(sizeof(CNRINFO)))) {
     3366                      cnri.flWindowAttr = dcd->flWindowAttr;
     3367                      WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     3368                                CM_SETCNRINFO,
     3369                                MPFROMP(&cnri),
     3370                                MPFROMLONG(CMA_FLWINDOWATTR));
     3371                    }
     3372                  }
     3373                }
     3374                if (fDeleteState)
     3375                  PrfWriteProfileData(fmprof, FM3Str, szKey, NULL, 0L);
     3376                  if (!PostMsg(hwndCnr, UM_SETUP2, NULL, NULL))
     3377                    WinSendMsg(hwndCnr, UM_SETUP2, NULL, NULL);
     3378              }
     3379            }
     3380            fRestored = TRUE;
     3381            swp.hwnd = hwndDir;
     3382            TransformSwp(&swp, xtrans, ytrans);
     3383            if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3384              WinSetWindowPos(hwndDir,
     3385                              HWND_TOP, 0, 0, 0, 0, SWP_MINIMIZE | SWP_SHOW);
     3386              WinSetWindowUShort(hwndDir, QWS_XRESTORE, (USHORT) swp.x);
     3387              WinSetWindowUShort(hwndDir, QWS_CXRESTORE, (USHORT) swp.cx);
     3388              WinSetWindowUShort(hwndDir, QWS_YRESTORE, (USHORT) swp.y);
     3389              WinSetWindowUShort(hwndDir, QWS_CYRESTORE, (USHORT) swp.cy);
     3390            } else
     3391              WinSetWindowPos(hwndDir,
     3392                              HWND_TOP,
     3393                              swp.x,
     3394                              swp.y,
     3395                              swp.cx,
     3396                              swp.cy,
     3397                              swp.fl | SWP_MOVE |
     3398                              SWP_SIZE | SWP_SHOW |  SWP_ZORDER |
     3399                              SWP_ACTIVATE);
     3400          }
     3401        }
    33943402      }
    33953403    } // for
     
    34203428    if (ulNumMinChildren) {
    34213429      if (WinQueryWindowPos(hwndChild, &swp) && (swp.fl & SWP_MINIMIZE))
    3422         (*ulNumMinChildren)++;
     3430        (*ulNumMinChildren)++;
    34233431    }
    34243432  }
     
    34283436
    34293437VOID GetNextWindowPos(HWND hwndClient, PSWP pswp, ULONG * ulCntR,
    3430                       ULONG * ulNumMinChildrenR)
     3438                      ULONG * ulNumMinChildrenR)
    34313439{
    34323440  register ULONG ulCnt;
     
    34923500    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    34933501      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3494         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3502        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    34953503      if (swp.x != 0)
    3496         swp.x = 0;
     3504        swp.x = 0;
    34973505      if (swp.y < 0)
    3498         swp.y = 0;
     3506        swp.y = 0;
    34993507      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3500         swp.cx = Rectl.xRight - Rectl.xLeft;
     3508        swp.cx = Rectl.xRight - Rectl.xLeft;
    35013509      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3502                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3510                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    35033511    }
    35043512  }
     
    35123520      GetNextWindowPos(hwndClient, &swp, &ulCnt, &ulNumMinChildren);
    35133521      WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3514                       SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
    3515                       SWP_ZORDER | SWP_ACTIVATE);
     3522                      SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
     3523                      SWP_ZORDER | SWP_ACTIVATE);
    35163524      ulCnt++;
    35173525    }
     
    35663574    if (!(swp.fl & (SWP_MAXIMIZE | SWP_HIDE | SWP_MINIMIZE))) {
    35673575      if (swp.y < 0)
    3568         swp.y = 0;
     3576        swp.y = 0;
    35693577      if (swp.y + swp.cy < Rectl.yTop - Rectl.yBottom)
    3570         swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
     3578        swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    35713579      if (swp.x != 0)
    3572         swp.x = 0;
     3580        swp.x = 0;
    35733581      if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3574         swp.cx = Rectl.xRight - Rectl.xLeft;
     3582        swp.cx = Rectl.xRight - Rectl.xLeft;
    35753583      WinSetWindowPos(hwndTree,
    3576                       HWND_TOP,
    3577                       swp.x,
    3578                       swp.y,
    3579                       swp.cx,
    3580                       swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3584                      HWND_TOP,
     3585                      swp.x,
     3586                      swp.y,
     3587                      swp.cx,
     3588                      swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    35813589      WinQueryWindowPos(hwndTree, &swp);
    35823590    }
     
    36033611
    36043612      for (ulCurRow = 0; ulCurRow < ulNumRows; ulCurRow++) {
    3605         if ((ulNumRows - ulCurRow) <= ulExtraCols)
    3606           ulNumCols++;
    3607         for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
    3608           ulWidth = Rectl.xRight / ulNumCols;
    3609 
    3610           while (hwndChild) {
    3611             id = WinQueryWindowUShort(hwndChild, QWS_ID);
    3612             if (id && (id != TREE_FRAME || fFreeTree)) {
    3613               WinQueryWindowPos(hwndChild, &swp);
    3614               if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
    3615                 break;
    3616             }
    3617             hwndChild = WinGetNextWindow(henum);
    3618           }
    3619 
    3620           if (hwndChild) {
    3621             if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
    3622               WinGetMaxPosition(hwndChild, &swp);
    3623               WinSetWindowPos(hwndChild,
    3624                               HWND_TOP,
    3625                               swp.x,
    3626                               swp.y,
    3627                               swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3628               WinSetWindowUShort(hwndChild,
    3629                                 QWS_XRESTORE,
    3630                                 (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
    3631               WinSetWindowUShort(hwndChild,
    3632                                 QWS_YRESTORE,
    3633                                 (USHORT) (Rectl.yTop -
    3634                                            (ulHeight * (ulCurRow + 1))));
    3635               WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
    3636               WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
    3637             }
    3638             else
    3639               WinSetWindowPos(hwndChild,
    3640                               HWND_TOP,
    3641                               (ulWidth * ulCurCol) + Rectl.xLeft,
    3642                               Rectl.yTop - (ulHeight * (ulCurRow + 1)),
    3643                               ulWidth,
    3644                               ulHeight,
    3645                               SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    3646             hwndChild = WinGetNextWindow(henum);
    3647           }
    3648         }
    3649         if ((ulNumRows - ulCurRow) <= ulExtraCols) {
    3650           ulNumCols--;
    3651           ulExtraCols--;
    3652         }
     3613        if ((ulNumRows - ulCurRow) <= ulExtraCols)
     3614          ulNumCols++;
     3615        for (ulCurCol = 0; ulCurCol < ulNumCols; ulCurCol++) {
     3616          ulWidth = Rectl.xRight / ulNumCols;
     3617
     3618          while (hwndChild) {
     3619            id = WinQueryWindowUShort(hwndChild, QWS_ID);
     3620            if (id && (id != TREE_FRAME || fFreeTree)) {
     3621              WinQueryWindowPos(hwndChild, &swp);
     3622              if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
     3623                break;
     3624            }
     3625            hwndChild = WinGetNextWindow(henum);
     3626          }
     3627
     3628          if (hwndChild) {
     3629            if (!absolute && (swp.fl & SWP_MAXIMIZE)) {
     3630              WinGetMaxPosition(hwndChild, &swp);
     3631              WinSetWindowPos(hwndChild,
     3632                              HWND_TOP,
     3633                              swp.x,
     3634                              swp.y,
     3635                              swp.cx, swp.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3636              WinSetWindowUShort(hwndChild,
     3637                                QWS_XRESTORE,
     3638                                (USHORT) (ulWidth * ulCurCol) + Rectl.xLeft);
     3639              WinSetWindowUShort(hwndChild,
     3640                                QWS_YRESTORE,
     3641                                (USHORT) (Rectl.yTop -
     3642                                           (ulHeight * (ulCurRow + 1))));
     3643              WinSetWindowUShort(hwndChild, QWS_CXRESTORE, (USHORT) ulWidth);
     3644              WinSetWindowUShort(hwndChild, QWS_CYRESTORE, (USHORT) ulHeight);
     3645            }
     3646            else
     3647              WinSetWindowPos(hwndChild,
     3648                              HWND_TOP,
     3649                              (ulWidth * ulCurCol) + Rectl.xLeft,
     3650                              Rectl.yTop - (ulHeight * (ulCurRow + 1)),
     3651                              ulWidth,
     3652                              ulHeight,
     3653                              SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3654            hwndChild = WinGetNextWindow(henum);
     3655          }
     3656        }
     3657        if ((ulNumRows - ulCurRow) <= ulExtraCols) {
     3658          ulNumCols--;
     3659          ulExtraCols--;
     3660        }
    36533661      }
    36543662    }
     
    36603668
    36613669static VOID ResizeChildren(HWND hwndClient, SHORT oldcx, SHORT oldcy,
    3662                            SHORT newcx, SHORT newcy)
     3670                           SHORT newcx, SHORT newcy)
    36633671{
    36643672  /*
     
    36783686    while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
    36793687      if (!WinQueryWindowUShort(hwndChild, QWS_ID))
    3680         continue;
     3688        continue;
    36813689      if (WinQueryWindowPos(hwndChild, &swp)) {
    3682         if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
    3683           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3684           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3685           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3686           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3687         }
    3688         else if (swp.fl & SWP_MAXIMIZE) {
    3689           swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
    3690           swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
    3691           swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
    3692           swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
    3693         }
    3694         cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
    3695         cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
    3696         x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
    3697         y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
    3698         if (x < 0)
    3699           x = 0;
    3700         if (y < 0)
    3701           y = 0;
    3702         ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
    3703         uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
    3704         ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
    3705         ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
    3706         if (ux + ucx > newcx)
    3707           ucx = newcx - ux;
    3708         if (uy + ucy > newcy)
    3709           ucy = newcy - uy;
    3710 
    3711         if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
    3712           WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
    3713                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3714         else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3715           WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
    3716           WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
    3717           WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
    3718                           SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
    3719           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3720           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3721           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3722           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3723         }
    3724         else {
    3725           WinGetMaxPosition(hwndChild, &swp);
    3726           WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3727                           SWP_MOVE | SWP_SIZE | SWP_SHOW);
    3728           WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
    3729           WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
    3730           WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
    3731           WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
    3732         }
     3690        if (swp.fl & (SWP_MINIMIZE | SWP_HIDE)) {
     3691          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3692          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3693          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3694          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3695        }
     3696        else if (swp.fl & SWP_MAXIMIZE) {
     3697          swp.x = WinQueryWindowUShort(hwndChild, QWS_XRESTORE);
     3698          swp.y = WinQueryWindowUShort(hwndChild, QWS_YRESTORE);
     3699          swp.cx = WinQueryWindowUShort(hwndChild, QWS_CXRESTORE);
     3700          swp.cy = WinQueryWindowUShort(hwndChild, QWS_CYRESTORE);
     3701        }
     3702        cx = (swp.cx) ? (LONG) (((double)oldcx * 100.0) / (double)swp.cx) : 0;
     3703        cy = (swp.cy) ? (LONG) (((double)oldcy * 100.0) / (double)swp.cy) : 0;
     3704        x = (swp.x) ? (LONG) (((double)oldcx * 100.0) / (double)swp.x) : 0;
     3705        y = (swp.y) ? (LONG) (((double)oldcy * 100.0) / (double)swp.y) : 0;
     3706        if (x < 0)
     3707          x = 0;
     3708        if (y < 0)
     3709          y = 0;
     3710        ux = (x) ? (LONG) (((double)newcx * 100.0) / (double)x) : 0;
     3711        uy = (y) ? (LONG) (((double)newcy * 100.0) / (double)y) : 0;
     3712        ucx = (cx) ? (LONG) (((double)newcx * 100.0) / (double)cx) : 0;
     3713        ucy = (cy) ? (LONG) (((double)newcy * 100.0) / (double)cy) : 0;
     3714        if (ux + ucx > newcx)
     3715          ucx = newcx - ux;
     3716        if (uy + ucy > newcy)
     3717          ucy = newcy - uy;
     3718
     3719        if (!(swp.fl & (SWP_MINIMIZE | SWP_HIDE | SWP_MAXIMIZE)))
     3720          WinSetWindowPos(hwndChild, HWND_TOP, ux, uy, ucx, ucy,
     3721                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3722        else if (swp.fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3723          WinSetWindowUShort(hwndChild, QWS_XMINIMIZE, (USHORT) - 1);
     3724          WinSetWindowUShort(hwndChild, QWS_YMINIMIZE, (USHORT) - 1);
     3725          WinSetWindowPos(hwndChild, HWND_TOP, 0, 0, 0, 0,
     3726                          SWP_SIZE | SWP_MOVE | SWP_FOCUSDEACTIVATE);
     3727          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3728          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3729          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3730          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3731        }
     3732        else {
     3733          WinGetMaxPosition(hwndChild, &swp);
     3734          WinSetWindowPos(hwndChild, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
     3735                          SWP_MOVE | SWP_SIZE | SWP_SHOW);
     3736          WinSetWindowUShort(hwndChild, QWS_XRESTORE, ux);
     3737          WinSetWindowUShort(hwndChild, QWS_YRESTORE, uy);
     3738          WinSetWindowUShort(hwndChild, QWS_CXRESTORE, ucx);
     3739          WinSetWindowUShort(hwndChild, QWS_CYRESTORE, ucy);
     3740        }
    37333741      }
    37343742    }
     
    37463754
    37473755      if (!fNoTreeGap) {
    3748         INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    3749         if (swp.y < height)
    3750           swp.y = height;        // Force bottom to position
     3756        INT height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     3757        if (swp.y < height)
     3758          swp.y = height;        // Force bottom to position
    37513759      }
    37523760      else
    3753         swp.y = 0;                // Force bottom to position
     3761        swp.y = 0;                // Force bottom to position
    37543762
    37553763      swp.cy = (Rectl.yTop - Rectl.yBottom) - swp.y;
    37563764      if (swp.cy < 0)
    3757         swp.cy = 0;
     3765        swp.cy = 0;
    37583766
    37593767      if (swp.x != 0)
    3760         swp.x = 0;                // Left align
     3768        swp.x = 0;                // Left align
    37613769
    37623770      // AdjustSizeOfClient can return bogus xRight values - fixme someday
    37633771      if (Rectl.xRight >= Rectl.xLeft) {
    3764         if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
    3765           swp.cx = Rectl.xRight - Rectl.xLeft;
     3772        if (swp.x + swp.cx > Rectl.xRight - Rectl.xLeft)
     3773          swp.cx = Rectl.xRight - Rectl.xLeft;
    37663774      }
    37673775      WinSetWindowPos(hwndTree, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
    3768                       SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
     3776                      SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_RESTORE);
    37693777    }
    37703778  }
     
    37943802
    37953803static MRESULT EXPENTRY ChildFrameButtonProc(HWND hwnd,
    3796                                              ULONG msg,
    3797                                              MPARAM mp1, MPARAM mp2)
     3804                                             ULONG msg,
     3805                                             MPARAM mp1, MPARAM mp2)
    37983806{
    37993807  USHORT id;
     
    38093817    if (fOtherHelp) {
    38103818      if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
    3811           && !WinQueryCapture(HWND_DESKTOP)) {
    3812         id = WinQueryWindowUShort(hwnd, QWS_ID);
    3813         switch (id) {
    3814         case IDM_OPENWALK:
    3815           MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
    3816           break;
    3817         case IDM_USERLIST:
    3818           MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
    3819           break;
    3820         }
     3819          && !WinQueryCapture(HWND_DESKTOP)) {
     3820        id = WinQueryWindowUShort(hwnd, QWS_ID);
     3821        switch (id) {
     3822        case IDM_OPENWALK:
     3823          MakeBubble(hwnd, FALSE, GetPString(IDS_WALKBUTTONHELP));
     3824          break;
     3825        case IDM_USERLIST:
     3826          MakeBubble(hwnd, FALSE, GetPString(IDS_QUICKBUTTONHELP));
     3827          break;
     3828        }
    38213829      }
    38223830    }
     
    38323840      switch (id) {
    38333841      case IDM_OPENWALK:
    3834         switch (msg) {
    3835         case WM_BUTTON2CLICK:
    3836           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3837               (KC_ALT | KC_SHIFT | KC_CTRL))
    3838             cmd = IDM_GREP;
    3839           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3840             CascadeChildren(hwndMain);
     3842        switch (msg) {
     3843        case WM_BUTTON2CLICK:
     3844          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3845              (KC_ALT | KC_SHIFT | KC_CTRL))
     3846            cmd = IDM_GREP;
     3847          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3848            CascadeChildren(hwndMain);
    38413849
    38423850#ifdef NEVER
    3843           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3844             cmd = IDM_SYSINFO;
     3851          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3852            cmd = IDM_SYSINFO;
    38453853#endif
    38463854
    3847           else if (shiftstate & KC_SHIFT)
    3848             cmd = IDM_WINDOWDLG;
    3849           else if (shiftstate & KC_CTRL)
    3850             cmd = IDM_SEEALL;
    3851           else if (shiftstate & KC_ALT)
    3852             TileChildren(hwndMain, TRUE);
    3853           else
    3854             cmd = IDM_WALKDIR;
    3855           break;
    3856         case WM_BUTTON3CLICK:
    3857           TileChildren(hwndMain, TRUE);
    3858           break;
    3859         }
    3860         break;
     3855          else if (shiftstate & KC_SHIFT)
     3856            cmd = IDM_WINDOWDLG;
     3857          else if (shiftstate & KC_CTRL)
     3858            cmd = IDM_SEEALL;
     3859          else if (shiftstate & KC_ALT)
     3860            TileChildren(hwndMain, TRUE);
     3861          else
     3862            cmd = IDM_WALKDIR;
     3863          break;
     3864        case WM_BUTTON3CLICK:
     3865          TileChildren(hwndMain, TRUE);
     3866          break;
     3867        }
     3868        break;
    38613869      case IDM_USERLIST:
    3862         switch (msg) {
    3863         case WM_BUTTON2CLICK:
    3864           if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
    3865               (KC_ALT | KC_SHIFT | KC_CTRL))
    3866             cmd = IDM_COLORPALETTE;
    3867           else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
    3868             cmd = IDM_HIDEMENU;
    3869           else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
    3870             cmd = IDM_NOTEBOOK;
    3871           else if (shiftstate & KC_SHIFT)
    3872             cmd = IDM_TOOLTITLES;
    3873           else if (shiftstate & KC_CTRL)
    3874             cmd = IDM_TEXTTOOLS;
    3875           else if (shiftstate & KC_ALT)
    3876             cmd = IDM_FONTPALETTE;
    3877           else
    3878             cmd = IDM_TOOLBAR;
    3879           break;
    3880         case WM_BUTTON3CLICK:
    3881           cmd = IDM_DRIVEBAR;
    3882           break;
    3883         }
    3884         break;
     3870        switch (msg) {
     3871        case WM_BUTTON2CLICK:
     3872          if ((shiftstate & (KC_ALT | KC_SHIFT | KC_CTRL)) ==
     3873              (KC_ALT | KC_SHIFT | KC_CTRL))
     3874            cmd = IDM_COLORPALETTE;
     3875          else if ((shiftstate & (KC_ALT | KC_CTRL)) == (KC_ALT | KC_CTRL))
     3876            cmd = IDM_HIDEMENU;
     3877          else if ((shiftstate & (KC_ALT | KC_SHIFT)) == (KC_ALT | KC_SHIFT))
     3878            cmd = IDM_NOTEBOOK;
     3879          else if (shiftstate & KC_SHIFT)
     3880            cmd = IDM_TOOLTITLES;
     3881          else if (shiftstate & KC_CTRL)
     3882            cmd = IDM_TEXTTOOLS;
     3883          else if (shiftstate & KC_ALT)
     3884            cmd = IDM_FONTPALETTE;
     3885          else
     3886            cmd = IDM_TOOLBAR;
     3887          break;
     3888        case WM_BUTTON3CLICK:
     3889          cmd = IDM_DRIVEBAR;
     3890          break;
     3891        }
     3892        break;
    38853893      }                                 // switch id
    38863894
    38873895      if (cmd) {
    3888         PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
    3889                 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
     3896        PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT),
     3897                WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
    38903898      }
    38913899    }
     
    38963904    if (id == IDM_OPENWALK) {
    38973905      if (!emphasized) {
    3898         emphasized = TRUE;
    3899         DrawTargetEmphasis(hwnd, emphasized);
     3906        emphasized = TRUE;
     3907        DrawTargetEmphasis(hwnd, emphasized);
    39003908      }
    39013909      if (AcceptOneDrop(hwnd, mp1, mp2))
    3902         return MRFROM2SHORT(DOR_DROP, DO_MOVE);
     3910        return MRFROM2SHORT(DOR_DROP, DO_MOVE);
    39033911    }
    39043912    return MRFROM2SHORT(DOR_NEVERDROP, 0);
     
    39203928
    39213929      if (emphasized) {
    3922         emphasized = FALSE;
    3923         DrawTargetEmphasis(hwnd, emphasized);
     3930        emphasized = FALSE;
     3931        DrawTargetEmphasis(hwnd, emphasized);
    39243932      }
    39253933      if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
    3926         if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
    3927           OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
    3928         }
     3934        if (MakeValidDir(szFrom) && !FindDirCnrByName(szFrom, TRUE)) {
     3935          OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, szFrom);
     3936        }
    39293937      }
    39303938    }
     
    39393947
    39403948static MRESULT EXPENTRY MainFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
    3941                                         MPARAM mp2)
     3949                                        MPARAM mp2)
    39423950{
    39433951  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
     
    39513959      pswp = (SWP *) mp1;
    39523960      if (fDataMin && !fAmClosing) {
    3953         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    3954 
    3955           SWP swp;
    3956 
    3957           WinQueryWindowPos(hwnd, &swp);
    3958           PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
    3959           HideNote();
    3960         }
    3961         else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    3962           if (DataHwnd)
    3963             PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
    3964         }
     3961        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
     3962
     3963          SWP swp;
     3964
     3965          WinQueryWindowPos(hwnd, &swp);
     3966          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     3967          HideNote();
     3968        }
     3969        else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
     3970          if (DataHwnd)
     3971            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     3972        }
    39653973      }
    39663974      if (!fAmClosing) {
    3967         if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    3968           HideNote();
     3975        if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
     3976          HideNote();
    39693977      }
    39703978    }
     
    39893997  case WM_CONTROL:
    39903998    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
    3991                       mp2);
     3999                      mp2);
    39924000
    39934001  case WM_COMMAND:
     
    40094017
    40104018      if (mr && mp2) {
    4011         prectl = (PRECTL) mp1;
    4012         if (prectl->yBottom != prectl->yTop) {
    4013           {
    4014             HPS hps;
    4015             POINTL aptl[TXTBOX_COUNT];
    4016 
    4017             hps = WinGetPS(hwndStatus);
    4018             if (hps) {
    4019               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4020               bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4021               WinReleasePS(hps);
    4022             }
    4023           }
    4024           prectl->yBottom += (sheight + 4);
    4025           prectl->yTop -= (sheight + 4);
    4026           if (fMoreButtons) {
    4027 
    4028             HPS hps;
    4029             POINTL aptl[TXTBOX_COUNT];
    4030 
    4031             hps = WinGetPS(hwndName);
    4032             if (hps) {
    4033               GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4034               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4035               WinReleasePS(hps);
    4036             }
    4037             prectl->yBottom += (bheight + 4);
    4038             prectl->yTop -= (bheight + 4);
    4039           }
    4040           if (fToolbar) {
    4041             if (!fTextTools)
    4042               prectl->yTop -= ((fToolTitles) ? 50 : 40);
    4043             else
    4044               prectl->yTop -= 32;
    4045           }
    4046           if (fDrivebar) {
    4047             ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
    4048                         ((prectl->xRight -
    4049                            (WinQuerySysValue(HWND_DESKTOP,
    4050                                              SV_CYSIZEBORDER) * 2)) - 4));
    4051             prectl->yTop -= (16 * (DriveLines * 18));
    4052           }
    4053           if (fUserComboBox) {
    4054             if (!aheight) {
    4055 
    4056               SWP swpTemp;
    4057 
    4058               WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4059                                 &swpTemp);
    4060               aheight = swpTemp.cy;
    4061             }
    4062             prectl->yTop -= (aheight + 6L);
    4063           }
    4064           if (fAutoView) {
    4065             AutoviewHeight = min(AutoviewHeight,
    4066                                 (prectl->yTop - prectl->yBottom) - 116);
    4067             AutoviewHeight = max(AutoviewHeight, 36);
    4068             prectl->yBottom += (AutoviewHeight + 6);
    4069           }
    4070         }
     4019        prectl = (PRECTL) mp1;
     4020        if (prectl->yBottom != prectl->yTop) {
     4021          {
     4022            HPS hps;
     4023            POINTL aptl[TXTBOX_COUNT];
     4024
     4025            hps = WinGetPS(hwndStatus);
     4026            if (hps) {
     4027              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4028              bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4029              WinReleasePS(hps);
     4030            }
     4031          }
     4032          prectl->yBottom += (sheight + 4);
     4033          prectl->yTop -= (sheight + 4);
     4034          if (fMoreButtons) {
     4035
     4036            HPS hps;
     4037            POINTL aptl[TXTBOX_COUNT];
     4038
     4039            hps = WinGetPS(hwndName);
     4040            if (hps) {
     4041              GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4042              bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4043              WinReleasePS(hps);
     4044            }
     4045            prectl->yBottom += (bheight + 4);
     4046            prectl->yTop -= (bheight + 4);
     4047          }
     4048          if (fToolbar) {
     4049            if (!fTextTools)
     4050              prectl->yTop -= ((fToolTitles) ? 50 : 40);
     4051            else
     4052              prectl->yTop -= 32;
     4053          }
     4054          if (fDrivebar) {
     4055            ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     4056                        ((prectl->xRight -
     4057                           (WinQuerySysValue(HWND_DESKTOP,
     4058                                             SV_CYSIZEBORDER) * 2)) - 4));
     4059            prectl->yTop -= (16 * (DriveLines * 18));
     4060          }
     4061          if (fUserComboBox) {
     4062            if (!aheight) {
     4063
     4064              SWP swpTemp;
     4065
     4066              WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4067                                &swpTemp);
     4068              aheight = swpTemp.cy;
     4069            }
     4070            prectl->yTop -= (aheight + 6L);
     4071          }
     4072          if (fAutoView) {
     4073            AutoviewHeight = min(AutoviewHeight,
     4074                                (prectl->yTop - prectl->yBottom) - 116);
     4075            AutoviewHeight = max(AutoviewHeight, 36);
     4076            prectl->yBottom += (AutoviewHeight + 6);
     4077          }
     4078        }
    40714079      }
    40724080      return mr;
     
    40924100      pswp = (PSWP) mp1;
    40934101      {
    4094         SHORT x;
    4095 
    4096         for (x = 0; x < soldCount; x++) {
    4097           if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
    4098             pswpClient = pswp;
    4099             break;
    4100           }
    4101           pswp++;
    4102         }
     4102        SHORT x;
     4103
     4104        for (x = 0; x < soldCount; x++) {
     4105          if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
     4106            pswpClient = pswp;
     4107            break;
     4108          }
     4109          pswp++;
     4110        }
    41034111      }
    41044112
    41054113      {
    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         if (fMoreButtons) {
    4116           hps = WinGetPS(hwndName);
    4117           if (hps) {
    4118             GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
    4119             bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    4120             WinReleasePS(hps);
    4121           }
    4122         }
     4114        HPS hps;
     4115        POINTL aptl[TXTBOX_COUNT];
     4116
     4117        hps = WinGetPS(hwndStatus);
     4118        if (hps) {
     4119          GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4120          bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4121          WinReleasePS(hps);
     4122        }
     4123        if (fMoreButtons) {
     4124          hps = WinGetPS(hwndName);
     4125          if (hps) {
     4126            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     4127            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     4128            WinReleasePS(hps);
     4129          }
     4130        }
    41234131      }
    41244132      pswpNew = (PSWP) mp1 + soldCount;
     
    41304138      pswpNew->y = swpClient.y + 2;
    41314139      if (!fSplitStatus)
    4132         width = swpClient.cx - (16 + (sheight * 2) + 4);
     4140        width = swpClient.cx - (16 + (sheight * 2) + 4);
    41334141      else
    4134         width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
     4142        width = (swpClient.cx - (16 + (sheight * 2) + 4)) / 2;
    41354143      width = max(width, 10);
    41364144      if (fSplitStatus)
    4137         pswpNew->cx = width - 6;
     4145        pswpNew->cx = width - 6;
    41384146      else
    4139         pswpNew->cx = width - 8;
     4147        pswpNew->cx = width - 8;
    41404148      pswpNew->cy = sheight;
    41414149      pswpClient->y = pswpNew->y + pswpNew->cy + 3;
     
    41444152
    41454153      if (fSplitStatus) {
    4146         pswpNew = (PSWP) mp1 + (soldCount + 1);
    4147         *pswpNew = *pswpClient;
    4148         pswpNew->hwnd = hwndStatus2;
    4149         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4150         pswpNew->x = width + 8;
    4151         pswpNew->y = swpClient.y + 2;
    4152         pswpNew->cx = width - 6;
    4153         pswpNew->cy = sheight;
    4154         sCount++;
     4154        pswpNew = (PSWP) mp1 + (soldCount + 1);
     4155        *pswpNew = *pswpClient;
     4156        pswpNew->hwnd = hwndStatus2;
     4157        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4158        pswpNew->x = width + 8;
     4159        pswpNew->y = swpClient.y + 2;
     4160        pswpNew->cx = width - 6;
     4161        pswpNew->cy = sheight;
     4162        sCount++;
    41554163      }
    41564164      else {
    4157         WinShowWindow(hwndStatus2, FALSE);
    4158         WinSetWindowText(hwndStatus2, NullStr);
     4165        WinShowWindow(hwndStatus2, FALSE);
     4166        WinSetWindowText(hwndStatus2, NullStr);
    41594167      }
    41604168
    41614169      if (fToolbar) {
    4162         if (fTextTools)
    4163           theight = 32L;
    4164         else if (!fToolTitles)
    4165           theight = 40L;
    4166         pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
    4167         *pswpNew = *pswpClient;
    4168         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
    4169         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4170         pswpNew->x = swpClient.x + 2;
    4171         pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    4172         pswpNew->cx = swpClient.cx - 4;
    4173         pswpNew->cy = theight - 4;
    4174         pswpClient->cy -= theight;
    4175         sCount++;
     4170        if (fTextTools)
     4171          theight = 32L;
     4172        else if (!fToolTitles)
     4173          theight = 40L;
     4174        pswpNew = (PSWP) mp1 + (soldCount + 1 + (fSplitStatus != FALSE));
     4175        *pswpNew = *pswpClient;
     4176        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     4177        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4178        pswpNew->x = swpClient.x + 2;
     4179        pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
     4180        pswpNew->cx = swpClient.cx - 4;
     4181        pswpNew->cy = theight - 4;
     4182        pswpClient->cy -= theight;
     4183        sCount++;
    41764184      }
    41774185      else
    4178         WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     4186        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
    41794187
    41804188      if (fDrivebar) {
    4181         ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
    4182         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4183                                 (fSplitStatus != FALSE) +
    4184                                 (fToolbar != FALSE));
    4185         *pswpNew = *pswpClient;
    4186         pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
    4187         pswpNew->hwndInsertBehind = HWND_BOTTOM;
    4188         pswpNew->x = swpClient.x + 2;
    4189         dheight += ((dheight - 2) * DriveLines);
    4190         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    4191         if (fToolbar)
    4192           pswpNew->y -= theight;
    4193         pswpNew->cx = swpClient.cx - 4;
    4194         pswpNew->cy = dheight - 4;
    4195         pswpClient->cy -= dheight;
    4196         sCount++;
     4189        ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
     4190        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4191                                (fSplitStatus != FALSE) +
     4192                                (fToolbar != FALSE));
     4193        *pswpNew = *pswpClient;
     4194        pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     4195        pswpNew->hwndInsertBehind = HWND_BOTTOM;
     4196        pswpNew->x = swpClient.x + 2;
     4197        dheight += ((dheight - 2) * DriveLines);
     4198        pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
     4199        if (fToolbar)
     4200          pswpNew->y -= theight;
     4201        pswpNew->cx = swpClient.cx - 4;
     4202        pswpNew->cy = dheight - 4;
     4203        pswpClient->cy -= dheight;
     4204        sCount++;
    41974205      }
    41984206      else
    4199         WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
     4207        WinShowWindow(WinWindowFromID(hwnd, MAIN_DRIVES), FALSE);
    42004208
    42014209      if (fAutoView) {
    4202         pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4203                                 (fToolbar != FALSE) +
    4204                                 (fDrivebar != FALSE) +
    4205                                 (fSplitStatus != FALSE));
    4206         *pswpNew = *pswpClient;
    4207         pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    4208         pswpNew->x = pswpClient->x + 3;
    4209         pswpNew->y = pswpClient->y + 3;
    4210         if (fMoreButtons)
    4211           pswpNew->y += (bheight + 4);
    4212         pswpNew->cx = pswpClient->cx - 6;
    4213         AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
    4214         AutoviewHeight = max(AutoviewHeight, 36);
    4215         pswpNew->cy = AutoviewHeight;
    4216         pswpClient->y += (AutoviewHeight + 6);
    4217         pswpClient->cy -= (AutoviewHeight + 6);
    4218         sCount++;
    4219         WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     4210        pswpNew = (PSWP) mp1 + (soldCount + 1 +
     4211                                (fToolbar != FALSE) +
     4212                                (fDrivebar != FALSE) +
     4213                                (fSplitStatus != FALSE));
     4214        *pswpNew = *pswpClient;
     4215        pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     4216        pswpNew->x = pswpClient->x + 3;
     4217        pswpNew->y = pswpClient->y + 3;
     4218        if (fMoreButtons)
     4219          pswpNew->y += (bheight + 4);
     4220        pswpNew->cx = pswpClient->cx - 6;
     4221        AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
     4222        AutoviewHeight = max(AutoviewHeight, 36);
     4223        pswpNew->cy = AutoviewHeight;
     4224        pswpClient->y += (AutoviewHeight + 6);
     4225        pswpClient->cy -= (AutoviewHeight + 6);
     4226        sCount++;
     4227        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
    42204228      }
    42214229      else {
    4222         WinShowWindow(hwndAutoview, FALSE);
    4223         WinShowWindow(hwndAutoMLE, FALSE);
     4230        WinShowWindow(hwndAutoview, FALSE);
     4231        WinShowWindow(hwndAutoMLE, FALSE);
    42244232      }
    42254233
    42264234      pswpNew = (PSWP) mp1 + (soldCount + 1 +
    4227                               (fToolbar != FALSE) +
    4228                               (fDrivebar != FALSE) +
    4229                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4235                              (fToolbar != FALSE) +
     4236                              (fDrivebar != FALSE) +
     4237                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42304238      *pswpNew = *pswpClient;
    42314239      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_OPENWALK);
     
    42364244      sCount++;
    42374245      pswpNew = (PSWP) mp1 + (soldCount + 2 +
    4238                               (fToolbar != FALSE) +
    4239                               (fDrivebar != FALSE) +
    4240                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4246                              (fToolbar != FALSE) +
     4247                              (fDrivebar != FALSE) +
     4248                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42414249      *pswpNew = *pswpClient;
    42424250      pswpNew->hwnd = WinWindowFromID(hwnd, IDM_USERLIST);
     
    42474255      sCount++;
    42484256      pswpNew = (PSWP) mp1 + (soldCount + 3 +
    4249                               (fToolbar != FALSE) +
    4250                               (fDrivebar != FALSE) +
    4251                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4257                              (fToolbar != FALSE) +
     4258                              (fDrivebar != FALSE) +
     4259                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42524260      *pswpNew = *pswpClient;
    42534261      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
     
    42584266      sCount++;
    42594267      pswpNew = (PSWP) mp1 + (soldCount + 4 +
    4260                               (fToolbar != FALSE) +
    4261                               (fDrivebar != FALSE) +
    4262                               (fSplitStatus != FALSE) + (fAutoView != FALSE));
     4268                              (fToolbar != FALSE) +
     4269                              (fDrivebar != FALSE) +
     4270                              (fSplitStatus != FALSE) + (fAutoView != FALSE));
    42634271      *pswpNew = *pswpClient;
    42644272      pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     
    42694277      sCount++;
    42704278      if (fUserComboBox) {
    4271         if (!aheight) {
    4272 
    4273           SWP swpTemp;
    4274 
    4275           WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    4276                             &swpTemp);
    4277           aheight = swpTemp.cy;
    4278         }
    4279         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4280                                 (fToolbar != FALSE) +
    4281                                 (fSplitStatus != FALSE) +
    4282                                 (fDrivebar != FALSE) + (fAutoView != FALSE));
    4283         *pswpNew = *pswpClient;
    4284         pswpNew->hwnd = hwndDrivelist;
    4285         pswpNew->x = swpClient.x;
    4286         pswpNew->cx = 48;
    4287         pswpClient->cy -= (aheight + 6L);
    4288         pswpNew->y = pswpClient->y;
    4289         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4290         sCount++;
    4291         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4292                                 (fToolbar != FALSE) +
    4293                                 (fDrivebar != FALSE) +
    4294                                 (fSplitStatus != FALSE) +
    4295                                 (fAutoView != FALSE));
    4296         *pswpNew = *pswpClient;
    4297         pswpNew->hwnd = hwndStatelist;
    4298         pswpNew->x = swpClient.x + 48;
    4299         pswpNew->cx = (swpClient.cx - 48) / 7;
    4300         pswpNew->y = pswpClient->y;
    4301         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4302         sCount++;
    4303         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4304                                 (fToolbar != FALSE) +
    4305                                 (fDrivebar != FALSE) +
    4306                                 (fSplitStatus != FALSE) +
    4307                                 (fAutoView != FALSE));
    4308         *pswpNew = *pswpClient;
    4309         pswpNew->hwnd = hwndCmdlist;
    4310         pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
    4311         pswpNew->cx = (swpClient.cx - 48) / 5 +
    4312           ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
    4313         pswpNew->y = pswpClient->y;
    4314         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4315         sCount++;
    4316         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4317                                 (fToolbar != FALSE) +
    4318                                 (fDrivebar != FALSE) +
    4319                                 (fSplitStatus != FALSE) +
    4320                                 (fAutoView != FALSE));
    4321         *pswpNew = *pswpClient;
    4322         pswpNew->hwnd = hwndUserlist;
    4323         pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
    4324         pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
    4325           ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
    4326         pswpNew->y = pswpClient->y;
    4327         pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4328         sCount++;
    4329         if (fToolbar) {
    4330           pswpNew = (PSWP) mp1 + (soldCount + 9 +
    4331                                   (fToolbar != FALSE) +
    4332                                   (fDrivebar != FALSE) +
    4333                                   (fSplitStatus != FALSE) +
    4334                                   (fAutoView != FALSE));
    4335           *pswpNew = *pswpClient;
    4336           pswpNew->hwnd = hwndButtonlist;
    4337           pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
    4338           pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
    4339           pswpNew->y = pswpClient->y;
    4340           pswpNew->cy = pswpClient->cy + (aheight + 5L);
    4341           sCount++;
    4342         }
    4343         else
    4344           WinShowWindow(hwndButtonlist, FALSE);
     4279        if (!aheight) {
     4280
     4281          SWP swpTemp;
     4282
     4283          WinQueryWindowPos(WinWindowFromID(hwndDrivelist, CBID_EDIT),
     4284                            &swpTemp);
     4285          aheight = swpTemp.cy;
     4286        }
     4287        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4288                                (fToolbar != FALSE) +
     4289                                (fSplitStatus != FALSE) +
     4290                                (fDrivebar != FALSE) + (fAutoView != FALSE));
     4291        *pswpNew = *pswpClient;
     4292        pswpNew->hwnd = hwndDrivelist;
     4293        pswpNew->x = swpClient.x;
     4294        pswpNew->cx = 48;
     4295        pswpClient->cy -= (aheight + 6L);
     4296        pswpNew->y = pswpClient->y;
     4297        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4298        sCount++;
     4299        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4300                                (fToolbar != FALSE) +
     4301                                (fDrivebar != FALSE) +
     4302                                (fSplitStatus != FALSE) +
     4303                                (fAutoView != FALSE));
     4304        *pswpNew = *pswpClient;
     4305        pswpNew->hwnd = hwndStatelist;
     4306        pswpNew->x = swpClient.x + 48;
     4307        pswpNew->cx = (swpClient.cx - 48) / 7;
     4308        pswpNew->y = pswpClient->y;
     4309        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4310        sCount++;
     4311        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4312                                (fToolbar != FALSE) +
     4313                                (fDrivebar != FALSE) +
     4314                                (fSplitStatus != FALSE) +
     4315                                (fAutoView != FALSE));
     4316        *pswpNew = *pswpClient;
     4317        pswpNew->hwnd = hwndCmdlist;
     4318        pswpNew->x = swpClient.x + 48 + ((swpClient.cx - 48) / 7);
     4319        pswpNew->cx = (swpClient.cx - 48) / 5 +
     4320          ((swpClient.cx - 48) / 5) - ((swpClient.cx - 48) / 7);
     4321        pswpNew->y = pswpClient->y;
     4322        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4323        sCount++;
     4324        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4325                                (fToolbar != FALSE) +
     4326                                (fDrivebar != FALSE) +
     4327                                (fSplitStatus != FALSE) +
     4328                                (fAutoView != FALSE));
     4329        *pswpNew = *pswpClient;
     4330        pswpNew->hwnd = hwndUserlist;
     4331        pswpNew->x = swpClient.x + 48 + (((swpClient.cx - 48) / 5) * 2);
     4332        pswpNew->cx = ((swpClient.x + swpClient.cx) - pswpNew->x) -
     4333          ((fToolbar) ? ((swpClient.cx - 48) / 7) : 0);
     4334        pswpNew->y = pswpClient->y;
     4335        pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4336        sCount++;
     4337        if (fToolbar) {
     4338          pswpNew = (PSWP) mp1 + (soldCount + 9 +
     4339                                  (fToolbar != FALSE) +
     4340                                  (fDrivebar != FALSE) +
     4341                                  (fSplitStatus != FALSE) +
     4342                                  (fAutoView != FALSE));
     4343          *pswpNew = *pswpClient;
     4344          pswpNew->hwnd = hwndButtonlist;
     4345          pswpNew->x = swpClient.cx - ((swpClient.cx - 48) / 7) + 4;
     4346          pswpNew->cx = (swpClient.x + swpClient.cx) - pswpNew->x;
     4347          pswpNew->y = pswpClient->y;
     4348          pswpNew->cy = pswpClient->cy + (aheight + 5L);
     4349          sCount++;
     4350        }
     4351        else
     4352          WinShowWindow(hwndButtonlist, FALSE);
    43454353      }
    43464354      else {
    4347         WinShowWindow(hwndUserlist, FALSE);
    4348         WinShowWindow(hwndDrivelist, FALSE);
    4349         WinShowWindow(hwndStatelist, FALSE);
    4350         WinShowWindow(hwndButtonlist, FALSE);
    4351         WinShowWindow(hwndCmdlist, FALSE);
     4355        WinShowWindow(hwndUserlist, FALSE);
     4356        WinShowWindow(hwndDrivelist, FALSE);
     4357        WinShowWindow(hwndStatelist, FALSE);
     4358        WinShowWindow(hwndButtonlist, FALSE);
     4359        WinShowWindow(hwndCmdlist, FALSE);
    43524360      }
    43534361      {
    4354         PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
    4355         SHORT x;
    4356 
    4357         pswpNew = (PSWP) mp1 + (soldCount + 5 +
    4358                                 (fToolbar != FALSE) +
    4359                                 (fDrivebar != FALSE) +
    4360                                 (fSplitStatus != FALSE) +
    4361                                 (fAutoView != FALSE) +
    4362                                 ((fUserComboBox != FALSE) * 4) +
    4363                                 (fUserComboBox != FALSE &&
    4364                                 fToolbar != FALSE));
    4365         pswp = (PSWP) mp1;
    4366         for (x = 0; x < soldCount; x++) {
    4367           if (!pswpTitlebar &&
    4368               WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
    4369             pswpTitlebar = pswp;
    4370           else if (!pswpMinbutton &&
    4371                    WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
    4372             pswpMinbutton = pswp;
    4373           if (pswpTitlebar && pswpMinbutton)
    4374             break;
    4375           pswp++;
    4376         }
    4377         if (pswpMinbutton && pswpTitlebar) {
    4378           *pswpNew = *pswpMinbutton;
    4379           pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
    4380           pswpNew->cy = pswpMinbutton->cy + 3;
    4381           pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
    4382           pswpTitlebar->cx -= (pswpNew->cx - 1);
    4383           pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
    4384           pswpNew->y = pswpMinbutton->y - 1;
    4385           sCount++;
    4386         }
    4387         else
    4388           WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
     4362        PSWP pswpTitlebar = (PSWP) 0, pswpMinbutton = (PSWP) 0;
     4363        SHORT x;
     4364
     4365        pswpNew = (PSWP) mp1 + (soldCount + 5 +
     4366                                (fToolbar != FALSE) +
     4367                                (fDrivebar != FALSE) +
     4368                                (fSplitStatus != FALSE) +
     4369                                (fAutoView != FALSE) +
     4370                                ((fUserComboBox != FALSE) * 4) +
     4371                                (fUserComboBox != FALSE &&
     4372                                fToolbar != FALSE));
     4373        pswp = (PSWP) mp1;
     4374        for (x = 0; x < soldCount; x++) {
     4375          if (!pswpTitlebar &&
     4376              WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_TITLEBAR)
     4377            pswpTitlebar = pswp;
     4378          else if (!pswpMinbutton &&
     4379                   WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_MINMAX)
     4380            pswpMinbutton = pswp;
     4381          if (pswpTitlebar && pswpMinbutton)
     4382            break;
     4383          pswp++;
     4384        }
     4385        if (pswpMinbutton && pswpTitlebar) {
     4386          *pswpNew = *pswpMinbutton;
     4387          pswpNew->hwnd = WinWindowFromID(hwnd, IDM_IDEALSIZE);
     4388          pswpNew->cy = pswpMinbutton->cy + 3;
     4389          pswpNew->cx = min(pswpNew->cy, (pswpMinbutton->cx / 2) + 3);
     4390          pswpTitlebar->cx -= (pswpNew->cx - 1);
     4391          pswpNew->x = pswpTitlebar->x + (pswpTitlebar->cx);
     4392          pswpNew->y = pswpMinbutton->y - 1;
     4393          sCount++;
     4394        }
     4395        else
     4396          WinShowWindow(WinWindowFromID(hwnd, IDM_IDEALSIZE), FALSE);
    43894397      }
    43904398
    43914399      if (fMoreButtons) {
    43924400
    4393         LONG lastx;
    4394 
    4395         pswpNew = (PSWP) mp1 + (soldCount + 6 +
    4396                                 (fToolbar != FALSE) +
    4397                                 (fDrivebar != FALSE) +
    4398                                 (fSplitStatus != FALSE) +
    4399                                 (fAutoView != FALSE) +
    4400                                 ((fUserComboBox != FALSE) * 4) +
    4401                                 (fUserComboBox != FALSE &&
    4402                                 fToolbar != FALSE));
    4403         *pswpNew = *pswpClient;
    4404         pswpNew->hwnd = hwndName;
    4405         pswpNew->x = swpClient.x + 3;
    4406         pswpNew->y = swpClient.y + (sheight + 6);
    4407         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    4408         lastx = pswpNew->x + pswpNew->cx;
    4409         pswpNew->cy = bheight;
    4410         pswpClient->y += (bheight + 4);
    4411         pswpClient->cy -= (bheight + 4);
    4412         sCount++;
    4413         pswpNew = (PSWP) mp1 + (soldCount + 7 +
    4414                                 (fToolbar != FALSE) +
    4415                                 (fDrivebar != FALSE) +
    4416                                 (fSplitStatus != FALSE) +
    4417                                 (fAutoView != FALSE) +
    4418                                 ((fUserComboBox != FALSE) * 4) +
    4419                                 (fUserComboBox != FALSE &&
    4420                                 fToolbar != FALSE));
    4421         *pswpNew = *pswpClient;
    4422         pswpNew->hwnd = hwndDate;
    4423         pswpNew->x = lastx + 3;
    4424         pswpNew->y = swpClient.y + (sheight + 6);
    4425         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    4426         lastx = pswpNew->x + pswpNew->cx;
    4427         pswpNew->cy = bheight;
    4428         sCount++;
    4429         pswpNew = (PSWP) mp1 + (soldCount + 8 +
    4430                                 (fToolbar != FALSE) +
    4431                                 (fDrivebar != FALSE) +
    4432                                 (fSplitStatus != FALSE) +
    4433                                 (fAutoView != FALSE) +
    4434                                 ((fUserComboBox != FALSE) * 4) +
    4435                                 (fUserComboBox != FALSE &&
    4436                                 fToolbar != FALSE));
    4437         *pswpNew = *pswpClient;
    4438         pswpNew->hwnd = hwndAttr;
    4439         pswpNew->x = lastx + 3;
    4440         pswpNew->y = swpClient.y + (sheight + 6);
    4441         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    4442         pswpNew->cy = bheight;
    4443         sCount++;
     4401        LONG lastx;
     4402
     4403        pswpNew = (PSWP) mp1 + (soldCount + 6 +
     4404                                (fToolbar != FALSE) +
     4405                                (fDrivebar != FALSE) +
     4406                                (fSplitStatus != FALSE) +
     4407                                (fAutoView != FALSE) +
     4408                                ((fUserComboBox != FALSE) * 4) +
     4409                                (fUserComboBox != FALSE &&
     4410                                fToolbar != FALSE));
     4411        *pswpNew = *pswpClient;
     4412        pswpNew->hwnd = hwndName;
     4413        pswpNew->x = swpClient.x + 3;
     4414        pswpNew->y = swpClient.y + (sheight + 6);
     4415        pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     4416        lastx = pswpNew->x + pswpNew->cx;
     4417        pswpNew->cy = bheight;
     4418        pswpClient->y += (bheight + 4);
     4419        pswpClient->cy -= (bheight + 4);
     4420        sCount++;
     4421        pswpNew = (PSWP) mp1 + (soldCount + 7 +
     4422                                (fToolbar != FALSE) +
     4423                                (fDrivebar != FALSE) +
     4424                                (fSplitStatus != FALSE) +
     4425                                (fAutoView != FALSE) +
     4426                                ((fUserComboBox != FALSE) * 4) +
     4427                                (fUserComboBox != FALSE &&
     4428                                fToolbar != FALSE));
     4429        *pswpNew = *pswpClient;
     4430        pswpNew->hwnd = hwndDate;
     4431        pswpNew->x = lastx + 3;
     4432        pswpNew->y = swpClient.y + (sheight + 6);
     4433        pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     4434        lastx = pswpNew->x + pswpNew->cx;
     4435        pswpNew->cy = bheight;
     4436        sCount++;
     4437        pswpNew = (PSWP) mp1 + (soldCount + 8 +
     4438                                (fToolbar != FALSE) +
     4439                                (fDrivebar != FALSE) +
     4440                                (fSplitStatus != FALSE) +
     4441                                (fAutoView != FALSE) +
     4442                                ((fUserComboBox != FALSE) * 4) +
     4443                                (fUserComboBox != FALSE &&
     4444                                fToolbar != FALSE));
     4445        *pswpNew = *pswpClient;
     4446        pswpNew->hwnd = hwndAttr;
     4447        pswpNew->x = lastx + 3;
     4448        pswpNew->y = swpClient.y + (sheight + 6);
     4449        pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
     4450        pswpNew->cy = bheight;
     4451        sCount++;
    44444452      }
    44454453      else {
    4446         WinShowWindow(hwndAttr, FALSE);
    4447         WinShowWindow(hwndName, FALSE);
    4448         WinShowWindow(hwndDate, FALSE);
     4454        WinShowWindow(hwndAttr, FALSE);
     4455        WinShowWindow(hwndName, FALSE);
     4456        WinShowWindow(hwndDate, FALSE);
    44494457      }
    44504458      return MRFROMSHORT(sCount);
     
    44594467      sCount += 6;
    44604468      if (fSplitStatus)
    4461         sCount++;
     4469        sCount++;
    44624470      if (fToolbar)
    4463         sCount++;
     4471        sCount++;
    44644472      if (fUserComboBox) {
    4465         sCount += 4;
    4466         if (fToolbar)
    4467           sCount++;
     4473        sCount += 4;
     4474        if (fToolbar)
     4475          sCount++;
    44684476      }
    44694477      if (fDrivebar)
    4470         sCount++;
     4478        sCount++;
    44714479      if (fAutoView)
    4472         sCount++;
     4480        sCount++;
    44734481      if (fMoreButtons)
    4474         sCount += 3;
     4482        sCount += 3;
    44754483      return MRFROMSHORT(sCount);
    44764484    }
     
    44934501      // DbgMsg(pszSrcFile, __LINE__, "IDM_CONTEXTMENU %x", hwnd);
    44944502      if (hwnd != NULLHANDLE) {
    4495         HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
    4496         USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
    4497         switch (id) {
    4498         case MAIN_SETUPLIST:
    4499         case MAIN_USERLIST:
    4500         case MAIN_CMDLIST:
    4501           // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
    4502           WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
    4503         }
     4503        HWND hwndParent = WinQueryWindow(hwnd, QW_PARENT);
     4504        USHORT id = WinQueryWindowUShort(hwndParent, QWS_ID);
     4505        switch (id) {
     4506        case MAIN_SETUPLIST:
     4507        case MAIN_USERLIST:
     4508        case MAIN_CMDLIST:
     4509          // DbgMsg(pszSrcFile, __LINE__, "WM_CONTEXTMENU");
     4510          WinPostMsg(hwnd, WM_CONTEXTMENU, 0, 0);
     4511        }
    45044512      }
    45054513    }
     
    45304538      wa.size = sizeof(wa);
    45314539      pci =
    4532         (PCNRITEM)
    4533         WinSendMsg(WinWindowFromID
    4534                    (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
    4535                    CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
    4536                    MPFROMSHORT(CRA_CURSORED));
     4540        (PCNRITEM)
     4541        WinSendMsg(WinWindowFromID
     4542                   (WinWindowFromID(hwndTree, FID_CLIENT), TREE_CNR),
     4543                   CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
     4544                   MPFROMSHORT(CRA_CURSORED));
    45374545      if (pci && (INT) pci != -1) {
    4538         strcpy(wa.szCurrentPath1, pci->pszFileName);
    4539         MakeValidDir(wa.szCurrentPath1);
     4546        strcpy(wa.szCurrentPath1, pci->pszFileName);
     4547        MakeValidDir(wa.szCurrentPath1);
    45404548      }
    45414549      else
    4542         save_dir2(wa.szCurrentPath1);
     4550        save_dir2(wa.szCurrentPath1);
    45434551      TopWindowName(hwndMain, (HWND) 0, wa.szCurrentPath2);
    45444552      if (!*wa.szCurrentPath2)
    4545         strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
     4553        strcpy(wa.szCurrentPath2, wa.szCurrentPath1);
    45464554      MakeValidDir(wa.szCurrentPath2);
    45474555      if (WinDlgBox(HWND_DESKTOP,
    4548                     hwnd,
    4549                     WalkTwoCmpDlgProc,
    4550                     FM3ModHandle,
    4551                     WALK2_FRAME,
    4552                     MPFROMP(&wa)) &&
    4553           !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
    4554         if (!*dircompare) {
    4555 
    4556           COMPARE *cmp;
    4557 
    4558           cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
    4559           if (cmp) {
    4560             cmp->size = sizeof(COMPARE);
    4561             strcpy(cmp->leftdir, wa.szCurrentPath1);
    4562             strcpy(cmp->rightdir, wa.szCurrentPath2);
    4563             cmp->hwndParent = hwnd;
    4564             cmp->dcd.hwndParent = hwnd;
    4565             WinDlgBox(HWND_DESKTOP,
    4566                       HWND_DESKTOP,
    4567                       CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
    4568           }
    4569         }
    4570         else {
    4571 
    4572           CHAR szPath1[CCHMAXPATH];
    4573           CHAR szPath2[CCHMAXPATH];
    4574           runemf2(SEPARATE,
    4575                   HWND_DESKTOP, pszSrcFile, __LINE__,
    4576                   NULL, NULL,
    4577                   "%s %s %s",
    4578                   dircompare,
    4579                   BldQuotedFileName(szPath1, wa.szCurrentPath1),
    4580                   BldQuotedFileName(szPath2, wa.szCurrentPath2));
    4581         }
     4556                    hwnd,
     4557                    WalkTwoCmpDlgProc,
     4558                    FM3ModHandle,
     4559                    WALK2_FRAME,
     4560                    MPFROMP(&wa)) &&
     4561          !IsFile(wa.szCurrentPath1) && !IsFile(wa.szCurrentPath2)) {
     4562        if (!*dircompare) {
     4563
     4564          COMPARE *cmp;
     4565
     4566          cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
     4567          if (cmp) {
     4568            cmp->size = sizeof(COMPARE);
     4569            strcpy(cmp->leftdir, wa.szCurrentPath1);
     4570            strcpy(cmp->rightdir, wa.szCurrentPath2);
     4571            cmp->hwndParent = hwnd;
     4572            cmp->dcd.hwndParent = hwnd;
     4573            WinDlgBox(HWND_DESKTOP,
     4574                      HWND_DESKTOP,
     4575                      CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
     4576          }
     4577        }
     4578        else {
     4579
     4580          CHAR szPath1[CCHMAXPATH];
     4581          CHAR szPath2[CCHMAXPATH];
     4582          runemf2(SEPARATE,
     4583                  HWND_DESKTOP, pszSrcFile, __LINE__,
     4584                  NULL, NULL,
     4585                  "%s %s %s",
     4586                  dircompare,
     4587                  BldQuotedFileName(szPath1, wa.szCurrentPath1),
     4588                  BldQuotedFileName(szPath2, wa.szCurrentPath2));
     4589        }
    45824590      }
    45834591    }
     
    45914599  case IDM_CLI:
    45924600    if (fSplitStatus &&
    4593         hwndStatus2 &&
    4594         !WinIsWindow(WinQueryAnchorBlock(hwnd),
    4595                      WinWindowFromID(hwndStatus2, COMMAND_LINE)))
     4601        hwndStatus2 &&
     4602        !WinIsWindow(WinQueryAnchorBlock(hwnd),
     4603                     WinWindowFromID(hwndStatus2, COMMAND_LINE)))
    45964604      PostMsg(hwndStatus2, UM_CLICKED, MPVOID, MPVOID);
    45974605    break;
     
    46064614      bstrip(temp);
    46074615      if (*temp &&
    4608           !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
    4609         if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
    4610           add_udir(TRUE, path);
    4611           if (fUdirsChanged)
    4612             save_udirs();
    4613           WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4614         }
    4615         else {
    4616           if (!remove_udir(path))
    4617             Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
    4618           else {
    4619             if (fUdirsChanged)
    4620               save_udirs();
    4621             WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    4622           }
    4623         }
     4616          !DosQueryPathInfo(temp, FIL_QUERYFULLNAME, path, sizeof(path))) {
     4617        if (SHORT1FROMMP(mp1) == IDM_ADDTOUSERLIST) {
     4618          add_udir(TRUE, path);
     4619          if (fUdirsChanged)
     4620            save_udirs();
     4621          WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4622        }
     4623        else {
     4624          if (!remove_udir(path))
     4625            Runtime_Error(pszSrcFile, __LINE__, "remove_udir");
     4626          else {
     4627            if (fUdirsChanged)
     4628              save_udirs();
     4629            WinSendMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
     4630          }
     4631        }
    46244632      }
    46254633    }
     
    46364644      // Complain if attempting to use reserved name
    46374645      if (stricmp(szStateName, GetPString(IDS_STATETEXT)) == 0 ||
    4638           stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
     4646          stricmp(szStateName, GetPString(IDS_FM2TEMPTEXT)) == 0)
    46394647      {
    4640         saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4641                GetPString(IDS_WARNINGTEXT),
    4642                "\"%s\" is a reserved state name", szStateName);
     4648        saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4649               GetPString(IDS_WARNINGTEXT),
     4650               "\"%s\" is a reserved state name", szStateName);
    46434651      }
    46444652      // Ignore request if blank
    46454653      else if (*szStateName) {
    4646         BOOL fAbortOperation = FALSE;
    4647         if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
    4648         {
    4649           if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
    4650               GetPString(IDS_WARNINGTEXT),
    4651               GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
    4652               fAbortOperation = TRUE;
    4653         }
    4654         if (!fAbortOperation) {
    4655           if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
    4656             // Save
    4657             INT nSaved = SaveDirCnrState(hwnd, szStateName);
    4658             if (nSaved >= 0) {
    4659               INT ret = add_setup(szStateName);
    4660               if (ret == 0) {
    4661                 WinSendMsg(hwndStatelist, LM_INSERTITEM,
    4662                            MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
    4663                 save_setups();
    4664               }
    4665               else if (ret != 1) {
    4666                 saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4667                        GetPString(IDS_WARNINGTEXT),
    4668                        "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
    4669                 WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4670               }
    4671             }
    4672             else {
    4673               saymsg(MB_ENTER | MB_ICONASTERISK,
    4674                      hwnd,
    4675                      GetPString(IDS_WARNINGTEXT),
    4676                      "State data save failed");
    4677               WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
    4678             }
    4679           }
    4680           else {
    4681             // Delete
    4682             ULONG numsaves = 0, size, x;
    4683             CHAR s[STATE_NAME_MAX_BYTES + 80];
    4684 
    4685             INT ret = remove_setup(szStateName);
    4686             if (ret == 1)
    4687               save_setups();
    4688             sprintf(s, "%s.NumDirsLastTime", szStateName);
    4689             size = sizeof(ULONG);
    4690             if (!PrfQueryProfileData(fmprof,
    4691                                      FM3Str,
    4692                                      s,
    4693                                      (PVOID)&numsaves,
    4694                                      &size)) {
    4695               saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    4696                      GetPString(IDS_WARNINGTEXT),
    4697                      GetPString(IDS_DOESNTEXISTTEXT), szStateName);
    4698             }
    4699             else if (!size)
    4700               Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    4701             else {
    4702               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
    4703               for (x = 0; x < numsaves; x++) {
    4704                 sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
    4705                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4706                 sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
    4707                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4708                 sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
    4709                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4710                 sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
    4711                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4712                 sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
    4713                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4714                 sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
    4715                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4716                 sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
    4717                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4718                 sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
    4719                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4720                 sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
    4721                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4722                 sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
    4723                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4724                 sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
    4725                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4726                 sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
    4727                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4728                 sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
    4729                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4730                 sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
    4731                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4732                 sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
    4733                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4734                 sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
    4735                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4736                 sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
    4737                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4738                 sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
    4739                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4740                 sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
    4741                 PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4742               }
    4743               sprintf(s, "%s.LastTreePos", szStateName);
    4744               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4745               sprintf(s, "%s.MySizeLastTime", szStateName);
    4746               PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
    4747             }
    4748             PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
    4749           }
    4750         }
     4654        BOOL fAbortOperation = FALSE;
     4655        if (!fNoSaveState && fSaveState && stricmp(szStateName, GetPString(IDS_SHUTDOWNSTATE)) == 0)
     4656        {
     4657          if (saymsg(MB_YESNO | MB_DEFBUTTON2 | MB_ICONASTERISK, hwnd,
     4658              GetPString(IDS_WARNINGTEXT),
     4659              GetPString(IDS_SHUTDOWNSTATE_WARNING), szStateName) == MBID_NO)
     4660              fAbortOperation = TRUE;
     4661        }
     4662        if (!fAbortOperation) {
     4663          if (SHORT1FROMMP(mp1) == IDM_SAVEDIRCNRSTATE) {
     4664            // Save
     4665            INT nSaved = SaveDirCnrState(hwnd, szStateName);
     4666            if (nSaved >= 0) {
     4667              INT ret = add_setup(szStateName);
     4668              if (ret == 0) {
     4669                WinSendMsg(hwndStatelist, LM_INSERTITEM,
     4670                           MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(szStateName));
     4671                save_setups();
     4672              }
     4673              else if (ret != 1) {
     4674                saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4675                       GetPString(IDS_WARNINGTEXT),
     4676                       "\"%s\" state name add failed", szStateName);      // 15 Apr 07 SHL failed
     4677                WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4678              }
     4679            }
     4680            else {
     4681              saymsg(MB_ENTER | MB_ICONASTERISK,
     4682                     hwnd,
     4683                     GetPString(IDS_WARNINGTEXT),
     4684                     "State data save failed");
     4685              WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
     4686            }
     4687          }
     4688          else {
     4689            // Delete
     4690            ULONG numsaves = 0, size, x;
     4691            CHAR s[STATE_NAME_MAX_BYTES + 80];
     4692
     4693            INT ret = remove_setup(szStateName);
     4694            if (ret == 1)
     4695              save_setups();
     4696            sprintf(s, "%s.NumDirsLastTime", szStateName);
     4697            size = sizeof(ULONG);
     4698            if (!PrfQueryProfileData(fmprof,
     4699                                     FM3Str,
     4700                                     s,
     4701                                     (PVOID)&numsaves,
     4702                                     &size)) {
     4703              saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     4704                     GetPString(IDS_WARNINGTEXT),
     4705                     GetPString(IDS_DOESNTEXISTTEXT), szStateName);
     4706            }
     4707            else if (!size)
     4708              Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
     4709            else {
     4710              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0L);
     4711              for (x = 0; x < numsaves; x++) {
     4712                sprintf(s, "%s.DirCnrPos.%lu", szStateName, x);
     4713                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4714                sprintf(s, "%s.DirCnrDir.%lu", szStateName, x);
     4715                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4716                sprintf(s, "%s.DirCnrSort.%lu", szStateName, x);
     4717                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4718                sprintf(s, "%s.DirCnrFilter.%lu", szStateName, x);
     4719                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4720                sprintf(s, "%s.DirCnrView.%lu", szStateName, x);
     4721                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4722                sprintf(s, "%s.DirCnr.%lu.DetailsLongname", szStateName, x);
     4723                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4724                sprintf(s, "%s.DirCnr.%lu.DetailsSubject", szStateName, x);
     4725                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4726                sprintf(s, "%s.DirCnr.%lu.DetailsSize", szStateName, x);
     4727                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4728                sprintf(s, "%s.DirCnr.%lu.DetailsEA", szStateName, x);
     4729                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4730                sprintf(s, "%s.DirCnr.%lu.DetailsAttr", szStateName, x);
     4731                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4732                sprintf(s, "%s.DirCnr.%lu.DetailsIcon", szStateName, x);
     4733                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4734                sprintf(s, "%s.DirCnr.%lu.DetailsLWDate", szStateName, x);
     4735                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4736                sprintf(s, "%s.DirCnr.%lu.DetailsLWTime", szStateName, x);
     4737                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4738                sprintf(s, "%s.DirCnr.%lu.DetailsLADate", szStateName, x);
     4739                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4740                sprintf(s, "%s.DirCnr.%lu.DetailsLATime", szStateName, x);
     4741                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4742                sprintf(s, "%s.DirCnr.%lu.DetailsCRDate", szStateName, x);
     4743                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4744                sprintf(s, "%s.DirCnr.%lu.DetailsCRTime", szStateName, x);
     4745                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4746                sprintf(s, "%s.DirCnr.%lu.Backgroundcolor", szStateName, x);
     4747                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4748                sprintf(s, "%s.DirCnr.%lu.Fontnamesize", szStateName, x);
     4749                PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4750              }
     4751              sprintf(s, "%s.LastTreePos", szStateName);
     4752              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4753              sprintf(s, "%s.MySizeLastTime", szStateName);
     4754              PrfWriteProfileData(fmprof, FM3Str, s, NULL, 0);
     4755            }
     4756            PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     4757          }
     4758        }
    47514759      }
    47524760    }
     
    47614769      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    47624770      if (swp.fl & SWP_MAXIMIZE) {
    4763         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
    4764                    MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    4765         WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     4771        WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_SYSCOMMAND,
     4772                   MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     4773        WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    47664774      }
    47674775      WinGetMaxPosition(WinQueryWindow(hwnd, QW_PARENT), &swpD);
     
    47714779      swpD.cy -= (icz + bsz);
    47724780      if (swp.x == swpD.x && swp.y == swpD.y &&
    4773           swp.cx == swpD.cx && swp.cy == swpD.cy &&
    4774           // fixme to be #defined someday
    4775           WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
    4776           WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
    4777         swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
    4778         swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
    4779         swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
    4780         swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
     4781          swp.cx == swpD.cx && swp.cy == swpD.cy &&
     4782          // fixme to be #defined someday
     4783          WinQueryWindowUShort(hwnd, QWL_USER + 10) &&
     4784          WinQueryWindowUShort(hwnd, QWL_USER + 14)) {
     4785        swpD.x = WinQueryWindowUShort(hwnd, QWL_USER + 8);
     4786        swpD.cx = WinQueryWindowUShort(hwnd, QWL_USER + 10);
     4787        swpD.y = WinQueryWindowUShort(hwnd, QWL_USER + 12);
     4788        swpD.cy = WinQueryWindowUShort(hwnd, QWL_USER + 14);
    47814789      }
    47824790      else {
    4783         WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
    4784         WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
    4785         WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
    4786         WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
     4791        WinSetWindowUShort(hwnd, QWL_USER + 8, (USHORT) swp.x);
     4792        WinSetWindowUShort(hwnd, QWL_USER + 10, (USHORT) swp.cx);
     4793        WinSetWindowUShort(hwnd, QWL_USER + 12, (USHORT) swp.y);
     4794        WinSetWindowUShort(hwnd, QWL_USER + 14, (USHORT) swp.cy);
    47874795      }
    47884796      WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP,
    4789                       swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
     4797                      swpD.x, swpD.y, swpD.cx, swpD.cy, SWP_MOVE | SWP_SIZE);
    47904798    }
    47914799    break;
     
    47934801  case IDM_BLINK:
    47944802    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4795                     SWP_MINIMIZE);
     4803                    SWP_MINIMIZE);
    47964804    WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
    4797                     SWP_RESTORE | SWP_ZORDER);
     4805                    SWP_RESTORE | SWP_ZORDER);
    47984806    break;
    47994807
     
    48034811
    48044812      if (hwndTop)
    4805         WinSetFocus(HWND_DESKTOP, hwndTop);
     4813        WinSetFocus(HWND_DESKTOP, hwndTop);
    48064814    }
    48074815    break;
     
    48254833  case IDM_QUICKSETTINGS:
    48264834    WinDlgBox(HWND_DESKTOP,
    4827               hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
     4835              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMLONG(mp1));
    48284836    break;
    48294837
     
    48314839  case IDM_VIEWINFS:
    48324840    WinDlgBox(HWND_DESKTOP,
    4833               HWND_DESKTOP,
    4834               ViewInfProc,
    4835               FM3ModHandle,
    4836               VINF_FRAME,
    4837               ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
    4838                MPFROMP(NullStr) : MPVOID));
     4841              HWND_DESKTOP,
     4842              ViewInfProc,
     4843              FM3ModHandle,
     4844              VINF_FRAME,
     4845              ((SHORT1FROMMP(mp1) == IDM_VIEWHELPS) ?
     4846               MPFROMP(NullStr) : MPVOID));
    48394847    break;
    48404848
     
    48464854      TopWindowName(hwnd, (HWND) 0, newpath);
    48474855      if (WinDlgBox(HWND_DESKTOP,
    4848                     hwnd,
    4849                     WalkAllDlgProc,
    4850                     FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
    4851         OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
     4856                    hwnd,
     4857                    WalkAllDlgProc,
     4858                    FM3ModHandle, WALK_FRAME, MPFROMP(newpath)) && *newpath)
     4859        OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, newpath);
    48524860    }
    48534861    break;
     
    48704878      if (SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    48714879
    4872         RECTL rcl;
    4873         ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
    4874 
    4875         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4876         rcl.yBottom += icz;
    4877         rcl.yTop -= icz;
    4878         rcl.xLeft += icz;
    4879         rcl.xRight -= icz;
    4880         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4880        RECTL rcl;
     4881        ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2L;
     4882
     4883        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4884        rcl.yBottom += icz;
     4885        rcl.yTop -= icz;
     4886        rcl.xLeft += icz;
     4887        rcl.xRight -= icz;
     4888        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    48814889      }
    48824890      else {
    48834891
    4884         RECTL rcl;
    4885 
    4886         WinQueryWindowRect(HWND_DESKTOP, &rcl);
    4887         rcl.yBottom += 8;
    4888         rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
    4889         rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
    4890         rcl.xRight -= 8;
    4891         WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
     4892        RECTL rcl;
     4893
     4894        WinQueryWindowRect(HWND_DESKTOP, &rcl);
     4895        rcl.yBottom += 8;
     4896        rcl.yTop = (rcl.yTop / 2) + (rcl.yTop / 7);
     4897        rcl.xLeft = (rcl.xRight / 2) - (rcl.xRight / 7);
     4898        rcl.xRight -= 8;
     4899        WinSendMsg(hwndHelp, HM_SET_COVERPAGE_SIZE, MPFROMP(&rcl), MPVOID);
    48924900      }
    48934901      switch (SHORT1FROMMP(mp1)) {
    48944902      case IDM_HELPCONTEXT:
    4895         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4896                    MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
    4897         break;
     4903        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4904                   MPFROM2SHORT(HELP_CONTEXT, 0), MPFROMSHORT(HM_RESOURCEID));
     4905        break;
    48984906
    48994907      case IDM_HELPMOUSE:
    4900         if (hwndHelp)
    4901           WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4902                      MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
    4903         break;
     4908        if (hwndHelp)
     4909          WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4910                     MPFROM2SHORT(HELP_MOUSE, 0), MPFROMSHORT(HM_RESOURCEID));
     4911        break;
    49044912
    49054913      case IDM_HELPPIX:
    4906         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4907                    MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
    4908         break;
     4914        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4915                   MPFROM2SHORT(HELP_BITMAP1, 0), MPFROMSHORT(HM_RESOURCEID));
     4916        break;
    49094917
    49104918      case IDM_HELPTUTOR:
    4911         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4912                    MPFROM2SHORT(HELP_TUTORIAL, 0),
    4913                    MPFROMSHORT(HM_RESOURCEID));
    4914         break;
     4919        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4920                   MPFROM2SHORT(HELP_TUTORIAL, 0),
     4921                   MPFROMSHORT(HM_RESOURCEID));
     4922        break;
    49154923
    49164924      case IDM_HELPHINTS:
    4917         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4918                    MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
    4919         break;
     4925        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4926                   MPFROM2SHORT(HELP_HINTS, 0), MPFROMSHORT(HM_RESOURCEID));
     4927        break;
    49204928
    49214929      case IDM_HELPGENERAL:
    4922         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4923                    MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
    4924         break;
     4930        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4931                   MPFROM2SHORT(HELP_MAIN, 0), MPFROMSHORT(HM_RESOURCEID));
     4932        break;
    49254933      case IDM_HELPKEYS:
    4926         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4927                    MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
    4928         break;
     4934        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4935                   MPFROM2SHORT(HELP_KEYS, 0), MPFROMSHORT(HM_RESOURCEID));
     4936        break;
    49294937
    49304938      case IDM_HELP:
    49314939      case IDM_HELPCONTENTS:
    4932         WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
    4933         break;
     4940        WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
     4941        break;
    49344942
    49354943      case IDM_HELPUSERLIST:
    4936         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
    4937                    MPFROM2SHORT(HELP_USERLISTS, 0),
    4938                    MPFROMSHORT(HM_RESOURCEID));
    4939         break;
     4944        WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
     4945                   MPFROM2SHORT(HELP_USERLISTS, 0),
     4946                   MPFROMSHORT(HM_RESOURCEID));
     4947        break;
    49404948      }
    49414949    }
     
    49484956  case IDM_ABOUT:
    49494957    WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, FM3ModHandle,
    4950               ABT_FRAME, MPVOID);
     4958              ABT_FRAME, MPVOID);
    49514959    break;
    49524960
     
    49624970
    49634971      if (!DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR,
    4964                            (PVOID) & version, (ULONG) sizeof(version))) {
    4965         if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
    4966           if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
    4967             palette = "<WP_HIRESCLRPAL>";
    4968           else
    4969             palette = "<WP_LORESCLRPAL>";
    4970         }
     4972                           (PVOID) & version, (ULONG) sizeof(version))) {
     4973        if (version[0] > 20L || (version[0] == 20L && version[1] > 29L)) {
     4974          if (SHORT1FROMMP(mp1) == IDM_HICOLORPALETTE)
     4975            palette = "<WP_HIRESCLRPAL>";
     4976          else
     4977            palette = "<WP_LORESCLRPAL>";
     4978        }
    49714979      }
    49724980      OpenObject(palette, Default, hwnd);
     
    49844992      hWPSObject = WinQueryObject("<WP_SCHPAL>");
    49854993      if (hWPSObject != NULLHANDLE)
    4986         WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
    4987                         "Spring:PM_Spring,Summer:PM_Summer,"
    4988                         "System:PM_System,Windows:PM_Windows;"
    4989                         "OPEN=DEFAULT");
     4994        WinSetObjectData(hWPSObject, "SCHEMES=Winter:PM_Winter,"
     4995                        "Spring:PM_Spring,Summer:PM_Summer,"
     4996                        "System:PM_System,Windows:PM_Windows;"
     4997                        "OPEN=DEFAULT");
    49904998    }
    49914999    break;
     
    49985006  case IDM_SYSINFO:
    49995007    WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, SysInfoDlgProc, FM3ModHandle,
    5000               SYS_FRAME, NULL);
     5008              SYS_FRAME, NULL);
    50015009    break;
    50025010#endif
     
    50085016
    50095017      if (hwndTree)
    5010         pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
    5011                                     MPFROMLONG(CMA_FIRST),
    5012                                     MPFROMSHORT(CRA_CURSORED));
     5018        pci = (PCNRITEM) WinSendMsg(hwndTree, CM_QUERYRECORDEMPHASIS,
     5019                                    MPFROMLONG(CMA_FIRST),
     5020                                    MPFROMSHORT(CRA_CURSORED));
    50135021      if (pci && (INT) pci != -1) {
    5014         strcpy(path, pci->pszFileName);
    5015         MakeValidDir(path);
     5022        strcpy(path, pci->pszFileName);
     5023        MakeValidDir(path);
    50165024      }
    50175025      else
    5018         save_dir2(path);
     5026        save_dir2(path);
    50195027      WinDlgBox(HWND_DESKTOP, hwnd, InstantDlgProc, FM3ModHandle,
    5020                 BAT_FRAME, MPFROMP(path));
     5028                BAT_FRAME, MPFROMP(path));
    50215029    }
    50225030    break;
     
    50325040      TopWindowName(hwnd, (HWND) 0, path);
    50335041      if (SHORT1FROMMP(mp1) == IDM_DOSCOMMANDLINE)
    5034         env = GetCmdSpec(TRUE);
     5042        env = GetCmdSpec(TRUE);
    50355043      else if (SHORT1FROMMP(mp1) != IDM_COMMANDLINE) {
    5036         env = "WINOS2.COM";
    5037         type = SEPARATE | FULLSCREEN;
     5044        env = "WINOS2.COM";
     5045        type = SEPARATE | FULLSCREEN;
    50385046      }
    50395047      runemf2(type, hwnd, pszSrcFile, __LINE__,
    5040               path, NULL, "%s", env);
     5048              path, NULL, "%s", env);
    50415049    }
    50425050    break;
     
    50445052  case IDM_KILLPROC:
    50455053    WinDlgBox(HWND_DESKTOP, hwnd, KillDlgProc, FM3ModHandle,
    5046               KILL_FRAME, NULL);
     5054              KILL_FRAME, NULL);
    50475055    break;
    50485056
     
    50595067  case IDM_AUTOVIEW:
    50605068    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5061                 &fAutoView, TRUE, "AutoView");
     5069                &fAutoView, TRUE, "AutoView");
    50625070  AutoChange:
    50635071    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5064             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5072            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50655073    if (fAutoView) {
    50665074
     
    50715079      hwndDir = TopWindowName(hwnd, (HWND) 0, s);
    50725080      if (hwndDir) {
    5073         hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
    5074         if (hwndDir) {
    5075           hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
    5076           if (hwndDir) {
    5077             pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
    5078                                         MPFROMLONG(CMA_FIRST),
    5079                                         MPFROMSHORT(CRA_CURSORED));
    5080             if (pci && (INT) pci != -1 &&
    5081                 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
    5082               WinSendMsg(hwnd,
    5083                         UM_LOADFILE,
    5084                         MPFROMP(pci->pszFileName),
    5085                         (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
    5086                         MPVOID : MPFROMLONG(1));
    5087           }
    5088         }
     5081        hwndDir = WinWindowFromID(hwndDir, FID_CLIENT);
     5082        if (hwndDir) {
     5083          hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
     5084          if (hwndDir) {
     5085            pci = (PCNRITEM) WinSendMsg(hwndDir, CM_QUERYRECORDEMPHASIS,
     5086                                        MPFROMLONG(CMA_FIRST),
     5087                                        MPFROMSHORT(CRA_CURSORED));
     5088            if (pci && (INT) pci != -1 &&
     5089                (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
     5090              WinSendMsg(hwnd,
     5091                        UM_LOADFILE,
     5092                        MPFROMP(pci->pszFileName),
     5093                        (SHORT1FROMMP(mp1) == IDM_AUTOVIEW) ?
     5094                        MPVOID : MPFROMLONG(1));
     5095          }
     5096        }
    50895097      }
    50905098    }
     
    50935101  case IDM_TEXTTOOLS:
    50945102    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5095                 &fTextTools, TRUE, "TextTools");
     5103                &fTextTools, TRUE, "TextTools");
    50965104    BuildTools(hwndToolback, TRUE);
    50975105    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5098             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5106            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    50995107    break;
    51005108
    51015109  case IDM_TOOLTITLES:
    51025110    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5103                 &fToolTitles, TRUE, "ToolTitles");
     5111                &fToolTitles, TRUE, "ToolTitles");
    51045112    BuildTools(hwndToolback, TRUE);
    51055113    PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5106             MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5114            MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    51075115    break;
    51085116
     
    51125120      MenuInvisible = MenuInvisible ? FALSE : TRUE;
    51135121      if (MenuInvisible) {
    5114         WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
    5115         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5116                                            FID_SYSMENU), IDM_HIDEMENU,
    5117                            GetPString(IDS_UNHIDEMENUTEXT));
     5122        WinSetParent(hwndMenu, HWND_OBJECT, FALSE);
     5123        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5124                                           FID_SYSMENU), IDM_HIDEMENU,
     5125                           GetPString(IDS_UNHIDEMENUTEXT));
    51185126      }
    51195127      else {
    5120         WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
    5121         WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5122                                            FID_SYSMENU), IDM_HIDEMENU,
    5123                            GetPString(IDS_HIDEMENUTEXT));
     5128        WinSetParent(hwndMenu, WinQueryWindow(hwnd, QW_PARENT), FALSE);
     5129        WinSetMenuItemText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     5130                                           FID_SYSMENU), IDM_HIDEMENU,
     5131                           GetPString(IDS_HIDEMENUTEXT));
    51245132      }
    51255133      PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_UPDATEFRAME,
    5126               MPFROMLONG(FCF_MENU), MPVOID);
     5134              MPFROMLONG(FCF_MENU), MPVOID);
    51275135      PrfWriteProfileData(fmprof, FM3Str, "MenuInvisible",
    5128                           &MenuInvisible, sizeof(BOOL));
     5136                          &MenuInvisible, sizeof(BOOL));
    51295137    }
    51305138    break;
     
    51395147
    51405148      if (Collector)
    5141         already = TRUE;
     5149        already = TRUE;
    51425150      if (!already && !fAutoTile && !fExternalCollector)
    5143         GetNextWindowPos(hwnd, &swp, NULL, NULL);
     5151        GetNextWindowPos(hwnd, &swp, NULL, NULL);
    51445152      hwndC = StartCollector(fExternalCollector ? HWND_DESKTOP : hwnd, 4);
    51455153      if (hwndC) {
    5146         if (!already && !fAutoTile && !fExternalCollector)
    5147           WinSetWindowPos(hwndC, HWND_TOP,
    5148                           swp.x, swp.y, swp.cx, swp.cy,
    5149                           SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
    5150         else if (fAutoTile && !already)
    5151           TileChildren(hwnd, TRUE);
    5152         WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
    5153                         SWP_ACTIVATE);
    5154         if (SHORT1FROMMP(mp1) == IDM_GREP)
    5155           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5156                   MPFROM2SHORT(IDM_GREP, 0), MPVOID);
    5157         if (SHORT1FROMMP(mp1) == IDM_SEEALL)
    5158           PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
    5159                   MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
     5154        if (!already && !fAutoTile && !fExternalCollector)
     5155          WinSetWindowPos(hwndC, HWND_TOP,
     5156                          swp.x, swp.y, swp.cx, swp.cy,
     5157                          SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
     5158        else if (fAutoTile && !already)
     5159          TileChildren(hwnd, TRUE);
     5160        WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE |
     5161                        SWP_ACTIVATE);
     5162        if (SHORT1FROMMP(mp1) == IDM_GREP)
     5163          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5164                  MPFROM2SHORT(IDM_GREP, 0), MPVOID);
     5165        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     5166          PostMsg(WinWindowFromID(hwndC, FID_CLIENT), WM_COMMAND,
     5167                  MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
    51605168      }
    51615169    }
     
    51685176
    51695177      if (!toolhead || !toolhead->next) {
    5170         firsttool = (toolhead) ? toolhead->id : 0;
    5171         break;
     5178        firsttool = (toolhead) ? toolhead->id : 0;
     5179        break;
    51725180      }
    51735181      tool = find_tool(firsttool);
    51745182      if (!tool)
    5175         tool = toolhead;
     5183        tool = toolhead;
    51765184      if (SHORT1FROMMP(mp1) == IDM_TOOLRIGHT) {
    5177         tool = prev_tool(tool, TRUE);
    5178         firsttool = tool->id;
     5185        tool = prev_tool(tool, TRUE);
     5186        firsttool = tool->id;
    51795187      }
    51805188      else {
    5181         tool = next_tool(tool, TRUE);
    5182         firsttool = tool->id;
     5189        tool = next_tool(tool, TRUE);
     5190        firsttool = tool->id;
    51835191      }
    51845192      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5185                                   MAIN_TOOLS));
     5193                                  MAIN_TOOLS));
    51865194    }
    51875195    break;
     
    51935201  case IDM_TOOLBAR:
    51945202    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5195                 IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
     5203                IDM_TOOLSUBMENU, &fToolbar, TRUE, "Toolbar");
    51965204    BuildTools(hwndToolback, TRUE);
    51975205    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5198                                   MAIN_TOOLS), fToolbar);
     5206                                  MAIN_TOOLS), fToolbar);
    51995207    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    5200                WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5208               WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52015209    if (fDrivebar)
    52025210      WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5203                                         MAIN_DRIVES), NULL, TRUE);
     5211                                        MAIN_DRIVES), NULL, TRUE);
    52045212    break;
    52055213
    52065214  case IDM_DRIVEBAR:
    52075215    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5208                 IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
     5216                IDM_DRIVEBAR, &fDrivebar, TRUE, "Drivebar");
    52095217    WinShowWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5210                                   MAIN_DRIVES), fDrivebar);
     5218                                  MAIN_DRIVES), fDrivebar);
    52115219    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5212             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5220            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52135221    PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
    52145222    break;
     
    52165224  case IDM_USERLIST:
    52175225    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5218                 SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
     5226                SHORT1FROMMP(mp1), &fUserComboBox, TRUE, "UserComboBox");
    52195227    WinShowWindow(hwndUserlist, fUserComboBox);
    52205228    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5221             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5229            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52225230    PostMsg(hwnd, UM_FILLUSERLIST, MPVOID, MPVOID);
    52235231    PostMsg(hwnd, UM_FILLSETUPLIST, MPVOID, MPVOID);
     
    52315239    WinSetWindowText(hwndAttr, NullStr);
    52325240    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5233                 SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
     5241                SHORT1FROMMP(mp1), &fMoreButtons, TRUE, "MoreButtons");
    52345242    if (fMoreButtons) {
    52355243
     
    52395247
    52405248      if (hwndTemp) {
    5241         WinSetFocus(HWND_DESKTOP, hwnd);
    5242         WinSetFocus(HWND_DESKTOP, hwndTemp);
     5249        WinSetFocus(HWND_DESKTOP, hwnd);
     5250        WinSetFocus(HWND_DESKTOP, hwndTemp);
    52435251      }
    52445252    }
    52455253    PostMsg(WinQueryWindow(hwnd, QW_PARENT),
    5246             WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
     5254            WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER), MPVOID);
    52475255    break;
    52485256
    52495257  case IDM_TOGGLEDRAGDIALOG:
    52505258    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5251                 IDM_TOGGLEDRAGDIALOG,
    5252                 &fDragndropDlg,
    5253                 TRUE,
    5254                 "Drag&DropDlg");
     5259                IDM_TOGGLEDRAGDIALOG,
     5260                &fDragndropDlg,
     5261                TRUE,
     5262                "Drag&DropDlg");
    52555263    break;
    52565264
    52575265  case IDM_SYNCUPDATES:
    52585266    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5259                 IDM_SYNCUPDATES,
    5260                 &fSyncUpdates,
    5261                 TRUE,
    5262                 "SyncUpdates");
     5267                IDM_SYNCUPDATES,
     5268                &fSyncUpdates,
     5269                TRUE,
     5270                "SyncUpdates");
    52635271    break;
    52645272
     
    52705278      WinQueryWindowPos(hwnd, &swp);
    52715279      WinSetWindowPos(hwndTree, HWND_TOP, 0, swp.cy - swpT.cy, 0, 0,
    5272                       SWP_MOVE);
     5280                      SWP_MOVE);
    52735281    }
    52745282    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER), SHORT1FROMMP(mp1),
    5275                 &fFreeTree, TRUE, "FreeTree");
     5283                &fFreeTree, TRUE, "FreeTree");
    52765284    if (fAutoTile)
    52775285      TileChildren(hwnd, TRUE);
     
    52805288  case IDM_AUTOTILE:
    52815289    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5282                 SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
     5290                SHORT1FROMMP(mp1), &fAutoTile, TRUE, "AutoTile");
    52835291    if (fAutoTile)
    52845292      TileChildren(hwnd, TRUE);
     
    52875295  case IDM_TILEBACKWARDS:
    52885296    SetMenuCheck(WinQueryWindowULong(hwnd, QWL_USER),
    5289                 SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
     5297                SHORT1FROMMP(mp1), &fTileBackwards, TRUE, "TileBackwards");
    52905298    if (fAutoTile)
    52915299      TileChildren(hwnd, TRUE);
     
    53325340  default:
    53335341    if (!SwitchCommand((HWND) WinQueryWindowULong(hwnd, QWL_USER),
    5334                        SHORT1FROMMP(mp1))) {
     5342                       SHORT1FROMMP(mp1))) {
    53355343      if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    5336           SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    5337 
    5338         INT x;
    5339         HWND hwndCnr;
    5340 
    5341         if (!cmdloaded)
    5342           load_commands();
    5343         hwndCnr = TopWindow(hwnd, (HWND) 0);
    5344         hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
    5345                                     UM_CONTAINERHWND, MPVOID, MPVOID);
    5346         if (!hwndCnr) {
    5347           Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
    5348           break;
    5349         }
    5350         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    5351         if (x >= 0) {
    5352           x++;
    5353           RunCommand(hwndCnr, x);
    5354           if (fUnHilite) {
    5355 
    5356             PCNRITEM pci;
    5357             DIRCNRDATA *dcd = NULL;
    5358 
    5359             // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
    5360             if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
    5361               dcd = INSTDATA(hwndCnr);
    5362             pci = (PCNRITEM) WinSendMsg(hwndCnr,
    5363                                         CM_QUERYRECORDEMPHASIS,
    5364                                         MPFROMLONG(CMA_FIRST),
    5365                                         MPFROMSHORT(CRA_CURSORED));
    5366             if (pci && (INT) pci != -1 &&
    5367                 (pci->rc.flRecordAttr & CRA_SELECTED))
    5368             {
    5369               UnHilite(hwnd,
    5370                        TRUE,
    5371                        dcd ? &dcd->lastselection : NULL,
    5372                        dcd ? dcd ->ulItemsToUnHilite : 0);
    5373             }
    5374           }
    5375         }
     5344          SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
     5345
     5346        INT x;
     5347        HWND hwndCnr;
     5348
     5349        if (!cmdloaded)
     5350          load_commands();
     5351        hwndCnr = TopWindow(hwnd, (HWND) 0);
     5352        hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     5353                                    UM_CONTAINERHWND, MPVOID, MPVOID);
     5354        if (!hwndCnr) {
     5355          Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
     5356          break;
     5357        }
     5358        x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     5359        if (x >= 0) {
     5360          x++;
     5361          RunCommand(hwndCnr, x);
     5362          if (fUnHilite) {
     5363
     5364            PCNRITEM pci;
     5365            DIRCNRDATA *dcd = NULL;
     5366
     5367            // 12 May 07 SHL fixme to understand? backwards maybe? looking for DIR_CNR?
     5368            if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     5369              dcd = INSTDATA(hwndCnr);
     5370            pci = (PCNRITEM) WinSendMsg(hwndCnr,
     5371                                        CM_QUERYRECORDEMPHASIS,
     5372                                        MPFROMLONG(CMA_FIRST),
     5373                                        MPFROMSHORT(CRA_CURSORED));
     5374            if (pci && (INT) pci != -1 &&
     5375                (pci->rc.flRecordAttr & CRA_SELECTED))
     5376            {
     5377              UnHilite(hwnd,
     5378                       TRUE,
     5379                       dcd ? &dcd->lastselection : NULL,
     5380                       dcd ? dcd ->ulItemsToUnHilite : 0);
     5381            }
     5382          }
     5383        }
    53765384      }
    53775385      else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    5378                SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
    5379         if (!qtloaded)
    5380           load_quicktools();
    5381         if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
    5382           if (fToolsChanged)
    5383             save_tools(NULL);
    5384           if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
    5385             load_tools(NULL);
    5386           else {
    5387             strcpy(lasttoolbox,
    5388                    quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    5389             PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
    5390           }
    5391           BuildTools(hwndToolback, TRUE);
    5392         }
     5386               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
     5387        if (!qtloaded)
     5388          load_quicktools();
     5389        if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
     5390          if (fToolsChanged)
     5391            save_tools(NULL);
     5392          if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
     5393            load_tools(NULL);
     5394          else {
     5395            strcpy(lasttoolbox,
     5396                   quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
     5397            PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
     5398          }
     5399          BuildTools(hwndToolback, TRUE);
     5400        }
    53935401      }
    53945402      else {
    53955403
    5396         HWND hwndActive;
    5397 
    5398         hwndActive = TopWindow(hwnd, (HWND) 0);
    5399         if (hwndActive)
    5400           PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
    5401                   WM_COMMAND, mp1, mp2);
     5404        HWND hwndActive;
     5405
     5406        hwndActive = TopWindow(hwnd, (HWND) 0);
     5407        if (hwndActive)
     5408          PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     5409                  WM_COMMAND, mp1, mp2);
    54025410      }
    54035411    }
     
    54085416
    54095417static MRESULT EXPENTRY MainWMOnce(HWND hwnd, ULONG msg, MPARAM mp1,
    5410                                    MPARAM mp2)
     5418                                   MPARAM mp2)
    54115419{
    54125420  TID tid;
     
    54315439    if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
    54325440      Runtime_Error(pszSrcFile, __LINE__,
    5433                     GetPString(IDS_COULDNTSTARTTHREADTEXT));
     5441                    GetPString(IDS_COULDNTSTARTTHREADTEXT));
    54345442      PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
    54355443      return 0;
     
    54505458
    54515459    if (!WinCreateWindow(hwndFrame,
    5452                         WC_BUTTON,
    5453                         "I",
    5454                         WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
    5455                         ((swp.cx -
    5456                            WinQuerySysValue(HWND_DESKTOP,
    5457                                             SV_CXMINMAXBUTTON)) -
    5458                           WinQuerySysValue(HWND_DESKTOP,
    5459                                            SV_CXMINMAXBUTTON) / 2) -
    5460                         WinQuerySysValue(HWND_DESKTOP,
    5461                                           SV_CXSIZEBORDER),
    5462                         (swp.cy - WinQuerySysValue(HWND_DESKTOP,
    5463                                                     SV_CYMINMAXBUTTON)) -
    5464                         WinQuerySysValue(HWND_DESKTOP,
    5465                                           SV_CYSIZEBORDER),
    5466                         WinQuerySysValue(HWND_DESKTOP,
    5467                                           SV_CXMINMAXBUTTON) / 2,
    5468                         WinQuerySysValue(HWND_DESKTOP,
    5469                                           SV_CYMINMAXBUTTON),
    5470                         hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
     5460                        WC_BUTTON,
     5461                        "I",
     5462                        WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
     5463                        ((swp.cx -
     5464                           WinQuerySysValue(HWND_DESKTOP,
     5465                                            SV_CXMINMAXBUTTON)) -
     5466                          WinQuerySysValue(HWND_DESKTOP,
     5467                                           SV_CXMINMAXBUTTON) / 2) -
     5468                        WinQuerySysValue(HWND_DESKTOP,
     5469                                          SV_CXSIZEBORDER),
     5470                        (swp.cy - WinQuerySysValue(HWND_DESKTOP,
     5471                                                    SV_CYMINMAXBUTTON)) -
     5472                        WinQuerySysValue(HWND_DESKTOP,
     5473                                          SV_CYSIZEBORDER),
     5474                        WinQuerySysValue(HWND_DESKTOP,
     5475                                          SV_CXMINMAXBUTTON) / 2,
     5476                        WinQuerySysValue(HWND_DESKTOP,
     5477                                          SV_CYMINMAXBUTTON),
     5478                        hwnd, HWND_TOP, IDM_IDEALSIZE, NULL, NULL)) {
    54715479      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54725480    }
    54735481    else {
    54745482      WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_IDEALSIZE),
    5475                         IdealButtonProc);
     5483                        IdealButtonProc);
    54765484      SetPresParams(WinWindowFromID(hwndFrame,
    5477                                     IDM_IDEALSIZE),
    5478                     NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
     5485                                    IDM_IDEALSIZE),
     5486                    NULL, NULL, NULL, GetPString(IDS_10SYSTEMVIOTEXT));
    54795487    }
    54805488
    54815489    hwndTmp = WinCreateWindow(hwndFrame,
    5482                               WC_BUTTON,
    5483                               "#1019",
    5484                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5485                               BS_BITMAP,
    5486                               swp.cx - 46,
    5487                               swp.y + 2,
    5488                               24,
    5489                               22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
     5490                              WC_BUTTON,
     5491                              "#1019",
     5492                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5493                              BS_BITMAP,
     5494                              swp.cx - 46,
     5495                              swp.y + 2,
     5496                              24,
     5497                              22, hwnd, HWND_TOP, IDM_OPENWALK, NULL, NULL);
    54905498    if (!hwndTmp)
    54915499      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    54925500
    54935501    hwndTmp = WinCreateWindow(hwndFrame,
    5494                               WC_BUTTON,
    5495                               "#3062",
    5496                               WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
    5497                               BS_BITMAP,
    5498                               swp.cx - 22,
    5499                               swp.y + 2,
    5500                               24,
    5501                               22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
     5502                              WC_BUTTON,
     5503                              "#3062",
     5504                              WS_VISIBLE | BS_PUSHBUTTON | BS_NOPOINTERFOCUS |
     5505                              BS_BITMAP,
     5506                              swp.cx - 22,
     5507                              swp.y + 2,
     5508                              24,
     5509                              22, hwnd, HWND_TOP, IDM_USERLIST, NULL, NULL);
    55025510    if (!hwndTmp)
    55035511      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55045512
    55055513    hwndUserlist = WinCreateWindow(hwndFrame,
    5506                                    WC_COMBOBOX,
    5507                                    (PSZ) NULL,
    5508                                    WS_VISIBLE | CBS_DROPDOWN |
    5509                                    LS_HORZSCROLL,
    5510                                    (swp.x +
    5511                                     WinQuerySysValue(HWND_DESKTOP,
    5512                                                      SV_CXSIZEBORDER) + 48L),
    5513                                    (swp.cy -
    5514                                     WinQuerySysValue(HWND_DESKTOP,
    5515                                                      SV_CYSIZEBORDER)) - 60,
    5516                                    ((swp.cx -
    5517                                      (WinQuerySysValue(HWND_DESKTOP,
    5518                                                        SV_CXSIZEBORDER) *
    5519                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5520                                    MAIN_USERLIST, NULL, NULL);
     5514                                   WC_COMBOBOX,
     5515                                   (PSZ) NULL,
     5516                                   WS_VISIBLE | CBS_DROPDOWN |
     5517                                   LS_HORZSCROLL,
     5518                                   (swp.x +
     5519                                    WinQuerySysValue(HWND_DESKTOP,
     5520                                                     SV_CXSIZEBORDER) + 48L),
     5521                                   (swp.cy -
     5522                                    WinQuerySysValue(HWND_DESKTOP,
     5523                                                     SV_CYSIZEBORDER)) - 60,
     5524                                   ((swp.cx -
     5525                                     (WinQuerySysValue(HWND_DESKTOP,
     5526                                                       SV_CXSIZEBORDER) *
     5527                                      2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5528                                   MAIN_USERLIST, NULL, NULL);
    55215529    if (!hwndUserlist)
    55225530      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55235531    hwndCmdlist = WinCreateWindow(hwndFrame,
    5524                                   WC_COMBOBOX,
    5525                                   (PSZ) NULL,
    5526                                   WS_VISIBLE | CBS_DROPDOWN |
    5527                                   LS_HORZSCROLL,
    5528                                   (swp.x +
    5529                                    WinQuerySysValue(HWND_DESKTOP,
    5530                                                     SV_CXSIZEBORDER) + 48L),
    5531                                   (swp.cy -
    5532                                    WinQuerySysValue(HWND_DESKTOP,
    5533                                                     SV_CYSIZEBORDER)) - 60,
    5534                                   ((swp.cx -
    5535                                     (WinQuerySysValue(HWND_DESKTOP,
    5536                                                       SV_CXSIZEBORDER) * 2)) -
    5537                                    64L), 60L, hwndFrame, HWND_TOP,
    5538                                   MAIN_CMDLIST, NULL, NULL);
     5532                                  WC_COMBOBOX,
     5533                                  (PSZ) NULL,
     5534                                  WS_VISIBLE | CBS_DROPDOWN |
     5535                                  LS_HORZSCROLL,
     5536                                  (swp.x +
     5537                                   WinQuerySysValue(HWND_DESKTOP,
     5538                                                    SV_CXSIZEBORDER) + 48L),
     5539                                  (swp.cy -
     5540                                   WinQuerySysValue(HWND_DESKTOP,
     5541                                                    SV_CYSIZEBORDER)) - 60,
     5542                                  ((swp.cx -
     5543                                    (WinQuerySysValue(HWND_DESKTOP,
     5544                                                      SV_CXSIZEBORDER) * 2)) -
     5545                                   64L), 60L, hwndFrame, HWND_TOP,
     5546                                  MAIN_CMDLIST, NULL, NULL);
    55395547    if (!hwndCmdlist)
    55405548      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55415549    WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    55425550    hwndStatelist = WinCreateWindow(hwndFrame,
    5543                                     WC_COMBOBOX,
    5544                                     (PSZ) NULL,
    5545                                     WS_VISIBLE | CBS_DROPDOWN |
    5546                                     LS_HORZSCROLL,
    5547                                     (swp.x +
    5548                                      WinQuerySysValue(HWND_DESKTOP,
    5549                                                       SV_CXSIZEBORDER) + 48L),
    5550                                     (swp.cy -
    5551                                      WinQuerySysValue(HWND_DESKTOP,
    5552                                                       SV_CYSIZEBORDER)) - 60,
    5553                                     ((swp.cx -
    5554                                       (WinQuerySysValue(HWND_DESKTOP,
    5555                                                         SV_CXSIZEBORDER) *
    5556                                        2)) - 64L), 60L, hwndFrame, HWND_TOP,
    5557                                     MAIN_SETUPLIST, NULL, NULL);
     5551                                    WC_COMBOBOX,
     5552                                    (PSZ) NULL,
     5553                                    WS_VISIBLE | CBS_DROPDOWN |
     5554                                    LS_HORZSCROLL,
     5555                                    (swp.x +
     5556                                     WinQuerySysValue(HWND_DESKTOP,
     5557                                                      SV_CXSIZEBORDER) + 48L),
     5558                                    (swp.cy -
     5559                                     WinQuerySysValue(HWND_DESKTOP,
     5560                                                      SV_CYSIZEBORDER)) - 60,
     5561                                    ((swp.cx -
     5562                                      (WinQuerySysValue(HWND_DESKTOP,
     5563                                                        SV_CXSIZEBORDER) *
     5564                                       2)) - 64L), 60L, hwndFrame, HWND_TOP,
     5565                                    MAIN_SETUPLIST, NULL, NULL);
    55585566    if (!hwndStatelist)
    55595567      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55605568
    55615569    hwndDrivelist = WinCreateWindow(hwndFrame,
    5562                                     WC_COMBOBOX,
    5563                                     (PSZ) NULL,
    5564                                     WS_VISIBLE | CBS_DROPDOWN,
    5565                                     (swp.x +
    5566                                      WinQuerySysValue(HWND_DESKTOP,
    5567                                                       SV_CXSIZEBORDER)),
    5568                                     (swp.cy -
    5569                                      WinQuerySysValue(HWND_DESKTOP,
    5570                                                       SV_CYSIZEBORDER)) - 60,
    5571                                     48L,
    5572                                     60L,
    5573                                     hwndFrame,
    5574                                     HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
     5570                                    WC_COMBOBOX,
     5571                                    (PSZ) NULL,
     5572                                    WS_VISIBLE | CBS_DROPDOWN,
     5573                                    (swp.x +
     5574                                     WinQuerySysValue(HWND_DESKTOP,
     5575                                                      SV_CXSIZEBORDER)),
     5576                                    (swp.cy -
     5577                                     WinQuerySysValue(HWND_DESKTOP,
     5578                                                      SV_CYSIZEBORDER)) - 60,
     5579                                    48L,
     5580                                    60L,
     5581                                    hwndFrame,
     5582                                    HWND_TOP, MAIN_DRIVELIST, NULL, NULL);
    55755583    if (!hwndDrivelist)
    55765584      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55775585    SetPresParams(hwndDrivelist,
    5578                   NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
     5586                  NULL, NULL, NULL, GetPString(IDS_10SYSTEMMONOTEXT));
    55795587    hwndButtonlist = WinCreateWindow(hwndFrame,
    5580                                      WC_COMBOBOX,
    5581                                      (PSZ) NULL,
    5582                                      WS_VISIBLE | CBS_DROPDOWN |
    5583                                      LS_HORZSCROLL,
    5584                                      (swp.cx -
    5585                                       WinQuerySysValue(HWND_DESKTOP,
    5586                                                        SV_CXSIZEBORDER)) -
    5587                                      164L,
    5588                                      (swp.cy -
    5589                                       WinQuerySysValue(HWND_DESKTOP,
    5590                                                        SV_CYSIZEBORDER)) - 60,
    5591                                      164L, 60L, hwndFrame, HWND_TOP,
    5592                                      MAIN_BUTTONLIST, NULL, NULL);
     5588                                     WC_COMBOBOX,
     5589                                     (PSZ) NULL,
     5590                                     WS_VISIBLE | CBS_DROPDOWN |
     5591                                     LS_HORZSCROLL,
     5592                                     (swp.cx -
     5593                                      WinQuerySysValue(HWND_DESKTOP,
     5594                                                       SV_CXSIZEBORDER)) -
     5595                                     164L,
     5596                                     (swp.cy -
     5597                                      WinQuerySysValue(HWND_DESKTOP,
     5598                                                       SV_CYSIZEBORDER)) - 60,
     5599                                     164L, 60L, hwndFrame, HWND_TOP,
     5600                                     MAIN_BUTTONLIST, NULL, NULL);
    55935601    if (!hwndButtonlist)
    55945602      Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
    55955603    WinSendMsg(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5596                EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     5604               EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    55975605    WinSendMsg(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5598                EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
     5606               EM_SETTEXTLIMIT, MPFROM2SHORT(STATE_NAME_MAX_BYTES, 0), MPVOID);
    55995607    WinSendMsg(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5600                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5608               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56015609    WinSendMsg(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5602                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5610               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56035611    WinSendMsg(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5604                EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
     5612               EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
    56055613
    56065614    oldproc = WinSubclassWindow(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5607                                 DropDownListProc);
     5615                                DropDownListProc);
    56085616    WinSetWindowPtr(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5609                     QWL_USER, (PVOID) oldproc);
     5617                    QWL_USER, (PVOID) oldproc);
    56105618    oldproc = WinSubclassWindow(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5611                                 DropDownListProc);
     5619                                DropDownListProc);
    56125620    WinSetWindowPtr(WinWindowFromID(hwndCmdlist, CBID_EDIT),
    5613                     QWL_USER, (PVOID) oldproc);
     5621                    QWL_USER, (PVOID) oldproc);
    56145622    oldproc = WinSubclassWindow(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5615                                 DropDownListProc);
     5623                                DropDownListProc);
    56165624    WinSetWindowPtr(WinWindowFromID(hwndButtonlist, CBID_EDIT),
    5617                     QWL_USER, (PVOID) oldproc);
     5625                    QWL_USER, (PVOID) oldproc);
    56185626    oldproc = WinSubclassWindow(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5619                                 DropDownListProc);
     5627                                DropDownListProc);
    56205628    WinSetWindowPtr(WinWindowFromID(hwndStatelist, CBID_EDIT),
    5621                     QWL_USER, (PVOID) oldproc);
     5629                    QWL_USER, (PVOID) oldproc);
    56225630    oldproc = WinSubclassWindow(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5623                                 DropDownListProc);
     5631                                DropDownListProc);
    56245632    WinSetWindowPtr(WinWindowFromID(hwndDrivelist, CBID_EDIT),
    5625                     QWL_USER, (PVOID) oldproc);
     5633                    QWL_USER, (PVOID) oldproc);
    56265634    oldproc = WinSubclassWindow(hwndUserlist, DropDownListProc);
    56275635    WinSetWindowPtr(hwndUserlist, QWL_USER, (PVOID) oldproc);
     
    56355643    WinSetWindowPtr(hwndButtonlist, QWL_USER, (PVOID) oldproc);
    56365644    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5637                                 ChildFrameButtonProc);
     5645                                ChildFrameButtonProc);
    56385646    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_USERLIST),
    5639                     QWL_USER, (PVOID) oldproc);
     5647                    QWL_USER, (PVOID) oldproc);
    56405648    oldproc = WinSubclassWindow(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5641                                 ChildFrameButtonProc);
     5649                                ChildFrameButtonProc);
    56425650    WinSetWindowPtr(WinWindowFromID(hwndFrame, IDM_OPENWALK),
    5643                     QWL_USER, (PVOID) oldproc);
     5651                    QWL_USER, (PVOID) oldproc);
    56445652    hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
    56455653    WinSendMsg(hwnd, UM_ADDTOMENU, MPVOID, MPVOID);
     
    56555663    hwndSysMenu = WinWindowFromID(hwndFrame, FID_SYSMENU);
    56565664    idSysMenu = SHORT1FROMMR(WinSendMsg(hwndSysMenu,
    5657                                         MM_ITEMIDFROMPOSITION,
    5658                                         MPVOID, MPVOID));
     5665                                        MM_ITEMIDFROMPOSITION,
     5666                                        MPVOID, MPVOID));
    56595667    WinSendMsg(hwndSysMenu,
    5660                MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
     5668               MM_QUERYITEM, MPFROM2SHORT(idSysMenu, 0), MPFROMP(&mit));
    56615669    hwndSysSubMenu = mit.hwndSubMenu;
    56625670    mi.iPosition = MIT_END;
     
    56675675    mi.id = IDM_IDEALSIZE;
    56685676    WinSendMsg(hwndSysSubMenu,
    5669                MM_INSERTITEM,
    5670                MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
     5677               MM_INSERTITEM,
     5678               MPFROMP(&mi), MPFROMP(GetPString(IDS_IDEALMENUTEXT)));
    56715679    mi.afStyle = MIS_TEXT;
    56725680    mi.id = IDM_HIDEMENU;
    56735681    WinSendMsg(hwndSysSubMenu,
    5674                MM_INSERTITEM,
    5675                MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
     5682               MM_INSERTITEM,
     5683               MPFROMP(&mi), MPFROMP(GetPString(IDS_HIDEMENUTEXT)));
    56765684    SetSysMenu(hwndSysMenu);
    56775685
    56785686    size = sizeof(BOOL);
    56795687    if (PrfQueryProfileData(fmprof,
    5680                             FM3Str,
    5681                             "MenuInvisible", &temp, &size) && size && temp)
     5688                            FM3Str,
     5689                            "MenuInvisible", &temp, &size) && size && temp)
    56825690      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HIDEMENU, 0), MPVOID);
    56835691    size = sizeof(BOOL);
    56845692    if (PrfQueryProfileData(fmprof,
    5685                             FM3Str, "FreeTree", &temp, &size) && size && temp)
     5693                            FM3Str, "FreeTree", &temp, &size) && size && temp)
    56865694      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_FREETREE, 0), MPVOID);
    56875695    size = sizeof(BOOL);
    56885696    if (PrfQueryProfileData(fmprof,
    5689                             FM3Str,
    5690                             "AutoTile", &temp, &size) && size && !temp)
     5697                            FM3Str,
     5698                            "AutoTile", &temp, &size) && size && !temp)
    56915699      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_AUTOTILE, 0), MPVOID);
    56925700    size = sizeof(BOOL);
    56935701    if (PrfQueryProfileData(fmprof,
    5694                             FM3Str, "Toolbar", &temp, &size) && size && !temp)
     5702                            FM3Str, "Toolbar", &temp, &size) && size && !temp)
    56955703      WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
    56965704
     
    57175725      hwndTree = StartTreeCnr(hwnd, 4);
    57185726      if (!hwndTree)
    5719         WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     5727        WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
    57205728      else {
    5721         if (!fSaveState ||
    5722             !PrfQueryProfileData(fmprof,
    5723                                 FM3Str,
    5724                                 "LastTreePos",
    5725                                 &swp, &size) || size != sizeof(SWP)) {
    5726 
    5727           INT ratio, height = 0;
    5728 
    5729           if (!fNoTreeGap)
    5730             height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
    5731           size = sizeof(ratio);
    5732           if (!PrfQueryProfileData(fmprof,
    5733                                    FM3Str,
    5734                                    "TreeWindowRatio",
    5735                                    (PVOID) & ratio,
    5736                                    &size) || size < sizeof(ratio))
    5737             ratio = 400;
    5738           WinSetWindowPos(hwndTree,
    5739                           HWND_TOP,
    5740                           0,
    5741                           height,
    5742                           (swp.cx * 100) / ratio,
    5743                           swp.cy - height,
    5744                           SWP_SHOW | SWP_SIZE | SWP_MOVE |
    5745                           SWP_ACTIVATE | SWP_ZORDER);
    5746         }
    5747         else
    5748           WinSetWindowPos(hwndTree,
    5749                           HWND_TOP,
    5750                           swp.x,
    5751                           swp.y,
    5752                           swp.cx,
    5753                           swp.cy,
    5754                           swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
    5755                           SWP_ZORDER | SWP_ACTIVATE);
     5729        if (!fSaveState ||
     5730            !PrfQueryProfileData(fmprof,
     5731                                FM3Str,
     5732                                "LastTreePos",
     5733                                &swp, &size) || size != sizeof(SWP)) {
     5734
     5735          INT ratio, height = 0;
     5736
     5737          if (!fNoTreeGap)
     5738            height = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 2;
     5739          size = sizeof(ratio);
     5740          if (!PrfQueryProfileData(fmprof,
     5741                                   FM3Str,
     5742                                   "TreeWindowRatio",
     5743                                   (PVOID) & ratio,
     5744                                   &size) || size < sizeof(ratio))
     5745            ratio = 400;
     5746          WinSetWindowPos(hwndTree,
     5747                          HWND_TOP,
     5748                          0,
     5749                          height,
     5750                          (swp.cx * 100) / ratio,
     5751                          swp.cy - height,
     5752                          SWP_SHOW | SWP_SIZE | SWP_MOVE |
     5753                          SWP_ACTIVATE | SWP_ZORDER);
     5754        }
     5755        else
     5756          WinSetWindowPos(hwndTree,
     5757                          HWND_TOP,
     5758                          swp.x,
     5759                          swp.y,
     5760                          swp.cx,
     5761                          swp.cy,
     5762                          swp.fl | SWP_MOVE | SWP_SIZE | SWP_SHOW |
     5763                          SWP_ZORDER | SWP_ACTIVATE);
    57565764      }
    57575765      ResizeTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5758                                   MAIN_TOOLS));
     5766                                  MAIN_TOOLS));
    57595767    }
    57605768    PostMsg(MainObjectHwnd, UM_SETUP3, mp1, mp2);
     
    57675775      PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszStatename), MPVOID);
    57685776      if (!add_setup(pszStatename))
    5769               save_setups();
     5777              save_setups();
    57705778    }
    57715779    PostMsg(MainObjectHwnd, UM_SETUP4, mp1, mp2);
     
    57785786
    57795787      for (x = 1; x < argc; x++) {
    5780         if (*argv[x] == '/' || *argv[x] == ';')
    5781           continue;
    5782         if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
    5783           OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
     5788        if (*argv[x] == '/' || *argv[x] == ';')
     5789          continue;
     5790        if (!IsFile(argv[x]) && !FindDirCnrByName(argv[x], FALSE))
     5791          OpenDirCnr((HWND) 0, hwndMain, hwndTree, TRUE, argv[x]);
    57845792      }
    57855793    }
     
    57995807      hwndActive = TopWindow(hwnd, hwndTree);
    58005808      if (hwndActive)
    5801         WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
     5809        WinSetWindowPos(hwndActive, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
    58025810    }
    58035811    if (fStartMinimized || fReminimize)
     
    58105818      PostMsg(hwnd, WM_COMMAND, MPFROMLONG(IDM_QUICKSETTINGS), MPVOID);
    58115819    }
    5812 #   ifdef FORTIFY
    5813     Fortify_EnterScope();
    5814 #    endif
    58155820    return 0;
    58165821  }
     
    58235828  switch (msg) {
    58245829  case WM_CREATE:
     5830#   ifdef FORTIFY
     5831    Fortify_EnterScope();
     5832#   endif
    58255833  case UM_SETUP:
    58265834  case UM_SETUP2:
     
    58325840  case WM_CONTROLPOINTER:
    58335841    if (!fNoFinger &&
    5834         (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
    5835         SHORT1FROMMP(mp1) == IDM_USERLIST))
     5842        (SHORT1FROMMP(mp1) == IDM_OPENWALK ||
     5843        SHORT1FROMMP(mp1) == IDM_USERLIST))
    58365844      return MRFROMLONG(hptrFinger);
    58375845    break;
     
    58735881    if (mp1) {
    58745882      if (fUserComboBox)
    5875         WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
    5876                         (CHAR *)mp1);
     5883        WinSetWindowText(WinWindowFromID(hwndUserlist, CBID_EDIT),
     5884                        (CHAR *)mp1);
    58775885      if (add_udir(FALSE, (CHAR *)mp1)) {
    5878         if (fUserComboBox && fAutoAddDirs) {
    5879           WinSendMsg(hwndUserlist, LM_INSERTITEM,
    5880                      MPFROM2SHORT(LIT_SORTASCENDING, 0),
    5881                      MPFROMP((CHAR *)mp1));
    5882         }
     5886        if (fUserComboBox && fAutoAddDirs) {
     5887          WinSendMsg(hwndUserlist, LM_INSERTITEM,
     5888                     MPFROM2SHORT(LIT_SORTASCENDING, 0),
     5889                     MPFROMP((CHAR *)mp1));
     5890        }
    58835891      }
    58845892    }
     
    59125920      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
    59135921      if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
    5914         WinStoreWindowPos(FM2Str,
    5915                           "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
    5916         if (!fNoSaveState && fSaveState)
    5917           SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
     5922        WinStoreWindowPos(FM2Str,
     5923                          "MainWindowPos", WinQueryWindow(hwnd, QW_PARENT));
     5924        if (!fNoSaveState && fSaveState)
     5925          SaveDirCnrState(hwnd, GetPString(IDS_SHUTDOWNSTATE));
    59185926      }
    59195927    }
     
    59255933    case 1:
    59265934      {
    5927         HWND hwndCurrent;
    5928         ULONG wmsg;
    5929 
    5930         wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
    5931         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5932         PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
    5933                                                        FID_CLIENT), wmsg,
    5934                                        MPVOID, MPVOID), mp1, mp2);
     5935        HWND hwndCurrent;
     5936        ULONG wmsg;
     5937
     5938        wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
     5939        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5940        PortholeInit((HWND) WinSendMsg(WinWindowFromID(hwndCurrent,
     5941                                                       FID_CLIENT), wmsg,
     5942                                       MPVOID, MPVOID), mp1, mp2);
    59355943      }
    59365944      break;
     
    59505958       */
    59515959      {
    5952         HWND hwndMenu, hwndSubMenu;
    5953         MENUITEM mi;
    5954 
    5955         hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
    5956         memset(&mi, 0, sizeof(mi));
    5957         mi.iPosition = MIT_END;
    5958         mi.afStyle = MIS_TEXT;
    5959         if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
    5960                         MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
    5961           break;
    5962         hwndSubMenu = mi.hwndSubMenu;
    5963         SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
     5960        HWND hwndMenu, hwndSubMenu;
     5961        MENUITEM mi;
     5962
     5963        hwndMenu = WinQueryWindowULong(hwnd, QWL_USER);
     5964        memset(&mi, 0, sizeof(mi));
     5965        mi.iPosition = MIT_END;
     5966        mi.afStyle = MIS_TEXT;
     5967        if (!WinSendMsg(hwndMenu, MM_QUERYITEM,
     5968                        MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
     5969          break;
     5970        hwndSubMenu = mi.hwndSubMenu;
     5971        SetupWinList(hwndSubMenu, hwnd, WinQueryWindow(hwnd, QW_PARENT));
    59645972      }
    59655973      break;
     
    59675975    default:
    59685976      {
    5969         HWND hwndCurrent;
    5970 
    5971         hwndCurrent = TopWindow(hwnd, (HWND) 0);
    5972         if (hwndCurrent)
    5973           WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
     5977        HWND hwndCurrent;
     5978
     5979        hwndCurrent = TopWindow(hwnd, (HWND) 0);
     5980        if (hwndCurrent)
     5981          WinSendMsg(hwndCurrent, UM_INITMENU, mp1, mp2);
    59745982      }
    59755983      break;
     
    59795987  case UM_ADDTOMENU:
    59805988    AddToMenu((CHAR *)mp1, WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    5981                                             FID_MENU));
     5989                                            FID_MENU));
    59825990    return 0;
    59835991
     
    59926000      info = cmdhead;
    59936001      while (info) {
    5994         WinSendMsg(hwndCmdlist, LM_INSERTITEM,
    5995                    MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
    5996         info = info->next;
     6002        WinSendMsg(hwndCmdlist, LM_INSERTITEM,
     6003                   MPFROM2SHORT(LIT_END, 0), MPFROMP(info->title));
     6004        info = info->next;
    59976005      }
    59986006    }
     
    60186026      ulSearchCount = 1;
    60196027      if (!DosFindFirst("*.TLS", &hDir, FILE_READONLY | FILE_ARCHIVED,
    6020                         &findbuf, sizeof(FILEFINDBUF3),
    6021                         &ulSearchCount, FIL_STANDARD)) {
    6022         do {
    6023           priority_bumped();
    6024           if (!foundit) {
    6025             thisone = FALSE;
    6026             p = strrchr(lasttoolbox, '\\');
    6027             if (!p)
    6028               p = lasttoolbox;
    6029             else
    6030               p++;
    6031             if (!stricmp(findbuf.achName, p))
    6032               thisone = TRUE;
    6033           }
    6034           p = strrchr(findbuf.achName, '.');
    6035           if (p)
    6036             *p = 0;
    6037           sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
    6038                                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6039                                        MPFROMP(findbuf.achName));
    6040           if (!foundit && thisone && sSelect >= 0) {
    6041             WinSendMsg(hwndButtonlist, LM_SELECTITEM,
    6042                        MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
    6043             foundit = TRUE;
    6044           }
    6045         }
    6046         while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
    6047                             &ulSearchCount));
    6048         DosFindClose(hDir);
    6049         priority_bumped();
     6028                        &findbuf, sizeof(FILEFINDBUF3),
     6029                        &ulSearchCount, FIL_STANDARD)) {
     6030        do {
     6031          priority_bumped();
     6032          if (!foundit) {
     6033            thisone = FALSE;
     6034            p = strrchr(lasttoolbox, '\\');
     6035            if (!p)
     6036              p = lasttoolbox;
     6037            else
     6038              p++;
     6039            if (!stricmp(findbuf.achName, p))
     6040              thisone = TRUE;
     6041          }
     6042          p = strrchr(findbuf.achName, '.');
     6043          if (p)
     6044            *p = 0;
     6045          sSelect = (SHORT) WinSendMsg(hwndButtonlist, LM_INSERTITEM,
     6046                                       MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6047                                       MPFROMP(findbuf.achName));
     6048          if (!foundit && thisone && sSelect >= 0) {
     6049            WinSendMsg(hwndButtonlist, LM_SELECTITEM,
     6050                       MPFROM2SHORT(sSelect, 0), MPFROMLONG(TRUE));
     6051            foundit = TRUE;
     6052          }
     6053        }
     6054        while (!DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3),
     6055                            &ulSearchCount));
     6056        DosFindClose(hDir);
     6057        priority_bumped();
    60506058      }
    60516059      WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     
    60666074
    60676075      if (!loadedudirs)
    6068         load_udirs();
     6076        load_udirs();
    60696077      DosError(FERR_DISABLEHARDERR);
    60706078      DosQCurDisk(&ulDriveNum, &ulDriveMap);
    60716079      info = udirhead;
    60726080      while (info) {
    6073         if (IsFullName(info->path) &&
    6074             !(driveflags[toupper(*info->path) - 'A'] &
    6075               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6076           DosError(FERR_DISABLEHARDERR);
    6077           hDir = HDIR_CREATE;
    6078           ulSearchCount = 1;
    6079           if (!IsRoot(info->path))
    6080             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6081                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6082                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6083                               &findbuf, sizeof(FILEFINDBUF3),
    6084                               &ulSearchCount, FIL_STANDARD);
    6085           else {
    6086             rc = 0;
    6087             findbuf.attrFile = FILE_DIRECTORY;
    6088           }
    6089           priority_bumped();
    6090           if (!rc) {
    6091             if (!IsRoot(info->path))
    6092               DosFindClose(hDir);
    6093             if (findbuf.attrFile & FILE_DIRECTORY)
    6094               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6095                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6096                         MPFROMP(info->path));
    6097             else {
    6098               temp = info->next;
    6099               remove_udir(info->path);
    6100               info = temp;
    6101               continue;
    6102             }
    6103           }
    6104           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6105             temp = info->next;
    6106             remove_udir(info->path);
    6107             info = temp;
    6108             continue;
    6109           }
    6110         }
    6111         info = info->next;
     6081        if (IsFullName(info->path) &&
     6082            !(driveflags[toupper(*info->path) - 'A'] &
     6083              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6084          DosError(FERR_DISABLEHARDERR);
     6085          hDir = HDIR_CREATE;
     6086          ulSearchCount = 1;
     6087          if (!IsRoot(info->path))
     6088            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6089                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6090                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6091                              &findbuf, sizeof(FILEFINDBUF3),
     6092                              &ulSearchCount, FIL_STANDARD);
     6093          else {
     6094            rc = 0;
     6095            findbuf.attrFile = FILE_DIRECTORY;
     6096          }
     6097          priority_bumped();
     6098          if (!rc) {
     6099            if (!IsRoot(info->path))
     6100              DosFindClose(hDir);
     6101            if (findbuf.attrFile & FILE_DIRECTORY)
     6102              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6103                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6104                        MPFROMP(info->path));
     6105            else {
     6106              temp = info->next;
     6107              remove_udir(info->path);
     6108              info = temp;
     6109              continue;
     6110            }
     6111          }
     6112          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6113            temp = info->next;
     6114            remove_udir(info->path);
     6115            info = temp;
     6116            continue;
     6117          }
     6118        }
     6119        info = info->next;
    61126120      }
    61136121      info = ldirhead;
    61146122      while (info) {
    6115         if (IsFullName(info->path) &&
    6116             !(driveflags[toupper(*info->path) - 'A'] &
    6117               (DRIVE_IGNORE | DRIVE_INVALID))) {
    6118           DosError(FERR_DISABLEHARDERR);
    6119           hDir = HDIR_CREATE;
    6120           ulSearchCount = 1;
    6121           if (!IsRoot(info->path))
    6122             rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
    6123                               MUST_HAVE_DIRECTORY | FILE_READONLY |
    6124                               FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
    6125                               &findbuf, sizeof(FILEFINDBUF3),
    6126                               &ulSearchCount, FIL_STANDARD);
    6127           else {
    6128             rc = 0;
    6129             findbuf.attrFile = FILE_DIRECTORY;
    6130           }
    6131           priority_bumped();
    6132           if (!rc) {
    6133             if (!IsRoot(info->path))
    6134               DosFindClose(hDir);
    6135             if (findbuf.attrFile & FILE_DIRECTORY)
    6136               WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6137                         MPFROM2SHORT(LIT_SORTASCENDING, 0),
    6138                         MPFROMP(info->path));
    6139             else {
    6140               temp = info->next;
    6141               remove_udir(info->path);
    6142               info = temp;
    6143               continue;
    6144             }
    6145           }
    6146           else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
    6147             temp = info->next;
    6148             remove_udir(info->path);
    6149             info = temp;
    6150             continue;
    6151           }
    6152         }
    6153         info = info->next;
     6123        if (IsFullName(info->path) &&
     6124            !(driveflags[toupper(*info->path) - 'A'] &
     6125              (DRIVE_IGNORE | DRIVE_INVALID))) {
     6126          DosError(FERR_DISABLEHARDERR);
     6127          hDir = HDIR_CREATE;
     6128          ulSearchCount = 1;
     6129          if (!IsRoot(info->path))
     6130            rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
     6131                              MUST_HAVE_DIRECTORY | FILE_READONLY |
     6132                              FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
     6133                              &findbuf, sizeof(FILEFINDBUF3),
     6134                              &ulSearchCount, FIL_STANDARD);
     6135          else {
     6136            rc = 0;
     6137            findbuf.attrFile = FILE_DIRECTORY;
     6138          }
     6139          priority_bumped();
     6140          if (!rc) {
     6141            if (!IsRoot(info->path))
     6142              DosFindClose(hDir);
     6143            if (findbuf.attrFile & FILE_DIRECTORY)
     6144              WinSendMsg(hwndUserlist, LM_INSERTITEM,
     6145                        MPFROM2SHORT(LIT_SORTASCENDING, 0),
     6146                        MPFROMP(info->path));
     6147            else {
     6148              temp = info->next;
     6149              remove_udir(info->path);
     6150              info = temp;
     6151              continue;
     6152            }
     6153          }
     6154          else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
     6155            temp = info->next;
     6156            remove_udir(info->path);
     6157            info = temp;
     6158            continue;
     6159          }
     6160        }
     6161        info = info->next;
    61546162      }
    61556163      WinSendMsg(hwndUserlist, LM_INSERTITEM,
    6156                 MPFROM2SHORT(0, 0),
    6157                 MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
     6164                MPFROM2SHORT(0, 0),
     6165                MPFROMP(GetPString(IDS_NEWDIRECTORYTEXT)));
    61586166      WinSetWindowText(hwndUserlist, GetPString(IDS_COMMONDIRTEXT));
    61596167    }
     
    61696177  case WM_SIZE:
    61706178    ResizeChildren(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1),
    6171                    SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
     6179                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
    61726180    break;
    61736181
     
    61836191      hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
    61846192      if (hps) {
    6185         WinQueryWindowRect(hwnd, &rcl);
    6186         WinFillRect(hps, &rcl, CLR_PALEGRAY);
    6187         WinEndPaint(hps);
     6193        WinQueryWindowRect(hwnd, &rcl);
     6194        WinFillRect(hps, &rcl, CLR_PALEGRAY);
     6195        WinEndPaint(hps);
    61886196      }
    61896197    }
     
    61996207      switch (SHORT2FROMMP(mp1)) {
    62006208      case CBN_ENTER:
    6201         {
    6202           HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
    6203                                         SHORT1FROMMP(mp1));
    6204           CHAR path[CCHMAXPATH];
    6205           ULONG ul;
    6206 
    6207           switch (SHORT1FROMMP(mp1)) {
    6208           case MAIN_USERLIST:
    6209             ul = CCHMAXPATH;
    6210             break;
    6211           case MAIN_SETUPLIST:
    6212             ul = STATE_NAME_MAX_BYTES;
    6213             break;
    6214           default:
    6215             ul = 13;                    // fixme to not be hardcoded
    6216           }
    6217 
    6218           SetShiftState();
    6219           WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
    6220           bstrip(path);
    6221           if (*path) {
    6222             if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
    6223               if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
    6224                 if (!LastDir ||
    6225                     !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
    6226                                 UM_CONTAINERDIR, MPFROMP(path), MPVOID))
    6227                   save_dir2(path);
    6228                 if (!PMMkDir(hwnd, path, TRUE)) {
    6229                   WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
    6230                   break;
    6231                 }
    6232               }
    6233               if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
    6234 
    6235                 HWND hwndDir;
    6236 
    6237                 if ((fUserListSwitches &&
    6238                      !(shiftstate & KC_SHIFT)) ||
    6239                     (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
    6240                   hwndDir = FindDirCnr(hwnd);
    6241                   if (hwndDir) {
    6242                     WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
    6243                     break;
    6244                   }
    6245                 }
    6246                 OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
    6247               }
    6248             }
    6249             else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
    6250               ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
    6251                                                           FID_CLIENT),
    6252                                           TREE_CNR), path, FALSE, TRUE);
    6253               WinSetFocus(HWND_DESKTOP, hwndTree);
    6254             }
    6255             else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
    6256               strcat(path, ".TLS");
    6257               load_tools(path);
    6258               PrfWriteProfileString(fmprof,
    6259                                     FM3Str, "LastToolBox", lasttoolbox);
    6260               BuildTools(hwndToolback, TRUE);
    6261               WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
    6262             }
    6263             else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
    6264               CHAR szKey[80];
    6265               ULONG size, numsaves = 0;
    6266 
    6267               SetShiftState();
    6268               size = sizeof(ULONG);
    6269               sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
    6270               if (!PrfQueryProfileData(fmprof,
    6271                                        FM3Str,
    6272                                        szKey,
    6273                                        (PVOID)&numsaves,
    6274                                        &size))
    6275               {
    6276                 if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
    6277                   saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
    6278                         GetPString(IDS_WARNINGTEXT),
    6279                         GetPString(IDS_DOESNTEXISTTEXT), path);
    6280                 }
    6281                 else {
    6282                   Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
    6283                              IDS_PRFQUERYPROFILEDATA);
    6284                 }
    6285               }
    6286               else {
    6287                 char *pszStateName;
    6288                 if ((shiftstate & KC_SHIFT) == 0)
    6289                   PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
    6290                 pszStateName = xstrdup(path, pszSrcFile, __LINE__);
    6291                 if (!pszStateName) {
    6292                   // Fall back if out of memory - already complained
    6293                   if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
    6294                     // Autotile requested or forced
    6295                     PostMsg(MainObjectHwnd,
    6296                             UM_RESTORE,
    6297                             MPVOID,
    6298                             MPFROMLONG(1));                // Autotile
    6299                   }
    6300                 }
    6301                 else if (!PostMsg(MainObjectHwnd,
    6302                                   UM_RESTORE,
    6303                                   MPFROMP(pszStateName),
    6304                                   MPVOID)) {
    6305                   free(pszStateName);
    6306                 }
    6307               }
    6308             }
    6309             else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
    6310 
    6311               SHORT sSelect;
    6312 
    6313               sSelect = (SHORT) WinSendMsg(hwndCmdlist,
    6314                                            LM_QUERYSELECTION,
    6315                                            MPFROMSHORT(LIT_FIRST), MPVOID);
    6316               if (sSelect >= 0)
    6317                 WinPostMsg(hwnd,
    6318                            WM_COMMAND,
    6319                            MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
    6320                            MPVOID);
    6321               WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
    6322             }
    6323           }
    6324         }
    6325         break;
     6209        {
     6210          HWND hwndUL = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     6211                                        SHORT1FROMMP(mp1));
     6212          CHAR path[CCHMAXPATH];
     6213          ULONG ul;
     6214
     6215          switch (SHORT1FROMMP(mp1)) {
     6216          case MAIN_USERLIST:
     6217            ul = CCHMAXPATH;
     6218            break;
     6219          case MAIN_SETUPLIST:
     6220            ul = STATE_NAME_MAX_BYTES;
     6221            break;
     6222          default:
     6223            ul = 13;                    // fixme to not be hardcoded
     6224          }
     6225
     6226          SetShiftState();
     6227          WinQueryWindowText(WinWindowFromID(hwndUL, CBID_EDIT), ul, path);
     6228          bstrip(path);
     6229          if (*path) {
     6230            if (SHORT1FROMMP(mp1) == MAIN_USERLIST) {
     6231              if (!strcmp(path, GetPString(IDS_NEWDIRECTORYTEXT))) {
     6232                if (!LastDir ||
     6233                    !WinSendMsg(WinQueryWindow(LastDir, QW_PARENT),
     6234                                UM_CONTAINERDIR, MPFROMP(path), MPVOID))
     6235                  save_dir2(path);
     6236                if (!PMMkDir(hwnd, path, TRUE)) {
     6237                  WinSetWindowText(hwndUL, GetPString(IDS_COMMONDIRTEXT));
     6238                  break;
     6239                }
     6240              }
     6241              if (!IsFile(path) && !FindDirCnrByName(path, TRUE)) {
     6242
     6243                HWND hwndDir;
     6244
     6245                if ((fUserListSwitches &&
     6246                     !(shiftstate & KC_SHIFT)) ||
     6247                    (!fUserListSwitches && (shiftstate & KC_SHIFT))) {
     6248                  hwndDir = FindDirCnr(hwnd);
     6249                  if (hwndDir) {
     6250                    WinSendMsg(LastDir, UM_SETDIR, MPFROMP(path), MPVOID);
     6251                    break;
     6252                  }
     6253                }
     6254                OpenDirCnr((HWND) 0, hwndMain, hwndTree, FALSE, path);
     6255              }
     6256            }
     6257            else if (SHORT1FROMMP(mp1) == MAIN_DRIVELIST) {
     6258              ShowTreeRec(WinWindowFromID(WinWindowFromID(hwndTree,
     6259                                                          FID_CLIENT),
     6260                                          TREE_CNR), path, FALSE, TRUE);
     6261              WinSetFocus(HWND_DESKTOP, hwndTree);
     6262            }
     6263            else if (SHORT1FROMMP(mp1) == MAIN_BUTTONLIST) {
     6264              strcat(path, ".TLS");
     6265              load_tools(path);
     6266              PrfWriteProfileString(fmprof,
     6267                                    FM3Str, "LastToolBox", lasttoolbox);
     6268              BuildTools(hwndToolback, TRUE);
     6269              WinSetWindowText(hwndButtonlist, GetPString(IDS_TOOLBOXTEXT));
     6270            }
     6271            else if (SHORT1FROMMP(mp1) == MAIN_SETUPLIST) {
     6272              CHAR szKey[80];
     6273              ULONG size, numsaves = 0;
     6274
     6275              SetShiftState();
     6276              size = sizeof(ULONG);
     6277              sprintf(szKey, "%s.NumDirsLastTime", path);       // path is state name
     6278              if (!PrfQueryProfileData(fmprof,
     6279                                       FM3Str,
     6280                                       szKey,
     6281                                       (PVOID)&numsaves,
     6282                                       &size))
     6283              {
     6284                if ((WinGetLastError(WinQueryAnchorBlock(hwnd)) & 0xffff) == PMERR_NOT_IN_IDX) {
     6285                  saymsg(MB_ENTER | MB_ICONASTERISK, hwnd,
     6286                        GetPString(IDS_WARNINGTEXT),
     6287                        GetPString(IDS_DOESNTEXISTTEXT), path);
     6288                }
     6289                else {
     6290                  Win_Error2(hwnd, hwnd, __FILE__, __LINE__,
     6291                             IDS_PRFQUERYPROFILEDATA);
     6292                }
     6293              }
     6294              else {
     6295                char *pszStateName;
     6296                if ((shiftstate & KC_SHIFT) == 0)
     6297                  PostMsg(MainObjectHwnd, UM_RESTORE, MPVOID, MPFROMLONG(2));
     6298                pszStateName = xstrdup(path, pszSrcFile, __LINE__);
     6299                if (!pszStateName) {
     6300                  // Fall back if out of memory - already complained
     6301                  if ((shiftstate & KC_SHIFT) != 0 || fAutoTile) {
     6302                    // Autotile requested or forced
     6303                    PostMsg(MainObjectHwnd,
     6304                            UM_RESTORE,
     6305                            MPVOID,
     6306                            MPFROMLONG(1));                // Autotile
     6307                  }
     6308                }
     6309                else if (!PostMsg(MainObjectHwnd,
     6310                                  UM_RESTORE,
     6311                                  MPFROMP(pszStateName),
     6312                                  MPVOID)) {
     6313                  free(pszStateName);
     6314                }
     6315              }
     6316            }
     6317            else if (SHORT1FROMMP(mp1) == MAIN_CMDLIST) {
     6318
     6319              SHORT sSelect;
     6320
     6321              sSelect = (SHORT) WinSendMsg(hwndCmdlist,
     6322                                           LM_QUERYSELECTION,
     6323                                           MPFROMSHORT(LIT_FIRST), MPVOID);
     6324              if (sSelect >= 0)
     6325                WinPostMsg(hwnd,
     6326                           WM_COMMAND,
     6327                           MPFROM2SHORT(IDM_COMMANDSTART + sSelect, 0),
     6328                           MPVOID);
     6329              WinSetWindowText(hwndCmdlist, GetPString(IDS_COMMANDSTEXT));
     6330            }
     6331          }
     6332        }
     6333        break;
    63266334
    63276335      default:
    6328         break;
     6336        break;
    63296337      }
    63306338      break;
     
    63466354  case WM_CLOSE:
    63476355    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6348                WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
     6356               WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
    63496357    WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
    63506358    fAmClosing = TRUE;
    63516359    WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
    6352                WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
     6360               WM_SYSCOMMAND, MPFROM2SHORT(SC_MINIMIZE, 0), MPVOID);
    63536361    if (CloseChildren(hwnd)) {
    63546362      fAmClosing = FALSE;
    63556363      if (fAutoTile)
    6356         PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
     6364        PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TILE, 0), MPVOID);
    63576365      return 0;
    63586366    }
    63596367    if (hwndTree) {
    63606368      if (!PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID))
    6361         WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
     6369        WinSendMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
    63626370    }
    63636371    DosSleep(1);
     
    63736381      // Try to restore saved shutdown state
    63746382      char *pszDefaultStateName = xstrdup(GetPString(IDS_SHUTDOWNSTATE),
    6375                                           pszSrcFile, __LINE__);
     6383                                          pszSrcFile, __LINE__);
    63766384      if (pszDefaultStateName) {
    6377         if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
    6378           // 05 Feb 08 SHL fixme to complain?
    6379           free(pszDefaultStateName);
     6385        if (!PostMsg(MainObjectHwnd, UM_RESTORE, MPFROMP(pszDefaultStateName), MPVOID))
     6386          // 05 Feb 08 SHL fixme to complain?
     6387          free(pszDefaultStateName);
    63806388      }
    63816389    }
     
    63866394    if (mp1)
    63876395      return MRFROMLONG(OpenDirCnr((HWND) 0,
    6388                                    hwndMain,
    6389                                    hwndTree, (BOOL) mp2, (char *)mp1));
     6396                                   hwndMain,
     6397                                   hwndTree, (BOOL) mp2, (char *)mp1));
    63906398    return 0;
    63916399
     
    63946402    if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
    63956403      WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
    6396 #     ifdef FORTIFY
    6397       free_commands();
    6398       free_associations();
    6399       free_udirs();
    6400       free_ldir();
    6401       free_archivers();
    6402       free_tools();
    6403       Fortify_LeaveScope();
    6404 #      endif
     6404#   ifdef FORTIFY
     6405    free_commands();
     6406    free_associations();
     6407    free_udirs();
     6408    free_ldir();
     6409    free_archivers();
     6410    free_tools();
     6411    free_setups();
     6412    Fortify_LeaveScope();
     6413#   endif
    64056414    break;
    64066415  }
  • trunk/dll/makelist.c

    r1063 r1077  
    1515  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    1616  29 Feb 08 GKY Use xfree where appropriate
     17  17 Jul 08 SHL Add SetListOwner for Fortify support
    1718
    1819***********************************************************************/
     
    260261    for (x = 0; list[x]; x++) {
    261262      if (item == list[x]) {
    262         free(list[x]);
     263        free(list[x]);
    263264        list[x] = NULL;
    264265        for (y = x;; y++) {
     
    272273        }
    273274#       ifdef FORTIFY
    274         Fortify_LeaveScope();
     275        Fortify_LeaveScope();
    275276#        endif
    276277        break;
     
    301302}
    302303
     304#ifdef FORTIFY
     305
     306VOID SetListOwner(LISTINFO *li)
     307{
     308  if (li) {
     309    CHAR **list = li->list;
     310    if (list) {
     311      UINT x;
     312      for (x = 0; list[x]; x++)
     313        Fortify_ChangeOwner(list[x]);
     314    }
     315    Fortify_ChangeOwner(li);
     316  }
     317}
     318
     319#endif // FORTIFY
     320
    303321#pragma alloc_text(MAKELIST,AddToList,AddToFileList,BuildList,FreeListInfo,FreeList)
    304322#pragma alloc_text(MAKELIST,SortList,BuildArcList,RemoveFromList,CombineLists)
     323#ifdef FORTIFY
     324#pragma alloc_text(MAKELIST,SetListOwner)
     325#endif // FORTIFY
  • trunk/dll/makelist.h

    r1029 r1077  
    1111  05 Jan 08 SHL Move makelist.c definitions here
    1212  22 Jun 08 GKY Change variable type to fix compiler warning
     13  17 Jul 08 SHL Add SetListOwner for Fortify support
    1314
    1415***********************************************************************/
     
    8485CHAR **CombineLists(CHAR **prime, CHAR **add);
    8586
     87#ifdef FORTIFY
     88VOID SetListOwner(LISTINFO *li);
     89#endif // FORTIFY
     90
    8691#endif // MAKELIST_H
  • trunk/dll/misc.c

    r1065 r1077  
    4242  29 Feb 08 GKY Use xfree where appropriate
    4343  08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
    44                 keys using a "DirCnr." prefix
     44                keys using a "DirCnr." prefix
    4545  19 Jun 08 JBS Ticket 239: Fix LoadDetailsSwitches so INI file is read correctly and details
    46                 switches are set correctly.
     46                switches are set correctly.
    4747  11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
    48                 all the details view settings (both the global variables and those in the
    49                 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     48                all the details view settings (both the global variables and those in the
     49                DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
     50  17 Jul 08 SHL Add GetTidForWindow for Fortify support
    5051
    5152***********************************************************************/
     
    5556#include <ctype.h>
    5657#include <share.h>
    57 #include <malloc.h>                  // _heapmin
     58#include <malloc.h>                     // _heapmin
    5859
    5960#define INCL_DOS
     
    6465#include "fm3dlg.h"
    6566#include "fm3str.h"
    66 #include "pathutil.h"               // BldQuotedFileName
    67 #include "errutil.h"                // Dos_Error...
    68 #include "strutil.h"                // GetPString
    69 #include "command.h"                // LINKCMDS
     67#include "pathutil.h"                   // BldQuotedFileName
     68#include "errutil.h"                    // Dos_Error...
     69#include "strutil.h"                    // GetPString
     70#include "command.h"                    // LINKCMDS
    7071#include "fm3dll.h"
     72#include "misc.h"
    7173#include "fortify.h"
    7274
     
    112114    return yes;
    113115}
     116
     117#ifdef FORTIFY
     118
     119/**
     120 * Return tid for fm/2 window
     121 * window must exist and must be created by fm/2
     122 * @param hwnd is window handle
     123 * @returns tid or -1 if error
     124 */
     125
     126INT GetTidForWindow(HWND hwnd)
     127{
     128    PIB *ppib;
     129    TIB *ptib;
     130    LONG tid = -1;
     131    APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
     132
     133    if (rc) {
     134      Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     135                "DosGetInfoBlocks");
     136    }
     137    else {
     138      PID pid;
     139      TID tid;
     140      if (!WinQueryWindowProcess(hwnd, &pid, &tid))
     141        Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for %X", hwnd);
     142      else if (pid != ppib->pib_ulpid)
     143        Runtime_Error(pszSrcFile, __LINE__, "hwnd %X not created by fm/2", hwnd);
     144      else
     145        tid = ptib->tib_ptib2->tib2_ultid;
     146    }
     147    return tid;
     148}
     149
     150#endif // FORTIFY
    114151
    115152VOID SetShiftState(VOID)
     
    710747          USHORT len;
    711748          CHAR *eaval;
    712           LONG retlen;
    713           PSZ psz;
     749          LONG retlen;
     750          PSZ psz;
    714751
    715752          retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
    716753          szSubject[retlen + 1] = 0;
    717           bstrip(szSubject);
    718           if (pci->pszSubject != NullStr) {
    719             if (retlen == 0) {
    720               psz = pci->pszSubject;
    721               pci->pszSubject = NullStr;
    722               xfree(psz, pszSrcFile, __LINE__);
    723             }
    724             else
    725               pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
    726           }
    727           else {
    728             pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
    729             if (!pci->pszSubject)
    730               return FALSE;
    731           }
     754          bstrip(szSubject);
     755          if (pci->pszSubject != NullStr) {
     756            if (retlen == 0) {
     757              psz = pci->pszSubject;
     758              pci->pszSubject = NullStr;
     759              xfree(psz, pszSrcFile, __LINE__);
     760            }
     761            else
     762              pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
     763          }
     764          else {
     765            pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
     766            if (!pci->pszSubject)
     767              return FALSE;
     768          }
    732769          len = strlen(szSubject);
    733770          if (len)
     
    772809
    773810          CHAR longname[CCHMAXPATHCOMP];
    774           LONG retlen;
    775           PSZ psz;
     811          LONG retlen;
     812          PSZ psz;
    776813
    777814          *longname = 0;
    778815          retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
    779816          longname[retlen + 1] = 0;
    780           chop_at_crnl(longname);
    781           bstrip(longname);
    782           WinSetWindowText(hwndMLE, longname);
    783           if (pci->pszLongName != NullStr) {
    784             if (retlen == 0) {
    785               psz = pci->pszLongName;
    786               pci->pszLongName = NullStr;
    787               xfree(psz, pszSrcFile, __LINE__);
    788             }
    789             else
    790               pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
    791           }
    792           else {
    793             pci->pszLongName = xmalloc(retlen + 1, pszSrcFile, __LINE__);
    794             if (!pci->pszLongName)
    795               return FALSE;
    796           }
     817          chop_at_crnl(longname);
     818          bstrip(longname);
     819          WinSetWindowText(hwndMLE, longname);
     820          if (pci->pszLongName != NullStr) {
     821            if (retlen == 0) {
     822              psz = pci->pszLongName;
     823              pci->pszLongName = NullStr;
     824              xfree(psz, pszSrcFile, __LINE__);
     825            }
     826            else
     827              pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
     828          }
     829          else {
     830            pci->pszLongName = xmalloc(retlen + 1, pszSrcFile, __LINE__);
     831            if (!pci->pszLongName)
     832              return FALSE;
     833          }
    797834          return (MRESULT) WriteLongName(pci->pszFileName, longname);
    798835        }
     
    9801017    *ex.environment = 0;
    9811018    ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
    982                     EXEC_FRAME, &ex);
     1019                    EXEC_FRAME, &ex);
    9831020    if (ret == 1) {
    9841021      lastflags = ex.flags;
    9851022      return runemf2(ex.flags, hwnd, pszSrcFile, __LINE__, path,
    986                      *ex.environment ? ex.environment : NULL,
    987                      "%s", pszCmdLine) != -1;
     1023                     *ex.environment ? ex.environment : NULL,
     1024                     "%s", pszCmdLine) != -1;
    9881025    }
    9891026    else if (ret != 0)
     
    21572194#pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
    21582195#pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
     2196
     2197#ifdef FORTIFY
     2198#pragma alloc_text(MISC1,GetTidForWindow)
     2199#endif // FORTIFY
     2200
    21592201#pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
    21602202#pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
  • trunk/dll/objwin.c

    r1063 r1077  
    7777                   IDS_WINCREATEWINDOW);
    7878      else {
    79 #       ifdef FORTIFY
    80         Fortify_EnterScope();
    81 #        endif
     79#       ifdef FORTIFY
     80        Fortify_EnterScope();
     81#       endif
    8282        WinSetWindowPtr(ObjectHwnd, QWL_USER, args);
    8383        /* initially populate container */
     84        // 18 Jul 08 SHL fixme to know if this really kills WM_CREATE
    8485        WinSendMsg(ObjectHwnd, UM_SETUP, MPVOID, MPVOID);
    8586        PostMsg(ObjectHwnd, UM_RESCAN, MPVOID, MPVOID);
     
    8889          WinDispatchMsg(hab2, &qmsg2);
    8990        WinDestroyWindow(ObjectHwnd);
    90 #           ifdef FORTIFY
     91#       ifdef FORTIFY
    9192        {
     93          // Allow container to close and free data
    9294          HWND hwndCnr = ((DIRCNRDATA *)args)->hwndCnr;
    9395          USHORT i;
    94           // Allow container to close and free data
    95           for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++) {
    96             DosSleep(50);
    97           }
     96          for (i = 0; WinIsWindow(hab2, hwndCnr) && i < 10; i++)
     97            DosSleep(50);
    9898          Fortify_LeaveScope();
    9999        }
    100 #            endif
     100#       endif
    101101      }
    102102      WinDestroyMsgQueue(hmq2);
  • trunk/dll/treecnr.c

    r1063 r1077  
    6666#include "strutil.h"                    // GetPString
    6767#include "notebook.h"                   // CfgDlgProc
    68 #include "command.h"                    // RunCommand
     68#include "command.h"                    // RunCommand
    6969#include "fm3dll.h"
    7070
     
    544544  switch (msg) {
    545545  case WM_CREATE:
     546    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
    546547    break;
    547548
     
    628629
    629630  case UM_SETUP:
     631#   ifdef FORTIFY
     632    Fortify_EnterScope();
     633#   endif
    630634    dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    631635    if (!dcd)
    632636      Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
    633637    else {
     638#     ifdef FORTIFY
     639      Fortify_ChangeOwner(dcd);
     640#     endif
    634641      dcd->hwndObject = hwnd;
    635642      if (ParentIsDesktop(hwnd, dcd->hwndParent))
     
    785792      else {
    786793        WORKER *wk;
    787 #       ifdef FORTIFY
    788         Fortify_EnterScope();
    789 #        endif
     794#       ifdef FORTIFY
     795        Fortify_EnterScope();
     796#       endif
    790797        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    791798        if (!wk)
     
    802809            Runtime_Error(pszSrcFile, __LINE__,
    803810                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    804             free(wk);
     811            free(wk);
    805812            FreeListInfo((LISTINFO *) mp1);
    806813          }
    807814        }
    808 #       ifdef FORTIFY
    809         Fortify_LeaveScope();
    810 #        endif
     815#       ifdef FORTIFY
     816        Fortify_LeaveScope();
     817#       endif
    811818      }
    812819    }
     
    814821
    815822  case UM_ACTION:
     823#   ifdef FORTIFY
     824    Fortify_EnterScope();
     825#   endif
    816826    if (mp1) {
    817 
     827#     ifdef FORTIFY
     828      Fortify_ChangeOwner(mp1);
     829#     endif
    818830      dcd = WinQueryWindowPtr(hwnd, QWL_USER);
    819831      if (!dcd)
     
    821833      else {
    822834        WORKER *wk;
    823 #       ifdef FORTIFY
    824         Fortify_EnterScope();
    825 #        endif
    826835        wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    827836        if (!wk)
     
    838847            Runtime_Error(pszSrcFile, __LINE__,
    839848                          GetPString(IDS_COULDNTSTARTTHREADTEXT));
    840             free(wk);
     849            free(wk);
    841850            FreeListInfo((LISTINFO *) mp1);
    842851          }
    843852        }
    844 #      ifdef FORTIFY
    845        Fortify_LeaveScope();
    846 #       endif
    847       }
    848     }
     853      }
     854    }
     855#   ifdef FORTIFY
     856    Fortify_LeaveScope();
     857#   endif
    849858    return 0;
    850859
     
    862871#     ifdef FORTIFY
    863872      Fortify_LeaveScope();
    864 #      endif
     873#     endif
    865874      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
    866875    }
     
    879888
    880889  switch (msg) {
     890  case WM_CREATE:
     891    DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2);  // 18 Jul 08 SHL fixme
     892    break;
     893
    881894  case DM_PRINTOBJECT:
    882895    return MRFROMLONG(DRR_TARGET);
     
    11721185         * first time through -- set things up
    11731186         */
    1174 
    11751187        CNRINFO cnri;
     1188
     1189#       ifdef FORTIFY
     1190        Fortify_EnterScope();
     1191#       endif
    11761192
    11771193        RestorePresParams(hwnd, "TreeCnr");
     
    21732189
    21742190      if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
    2175         hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
    2176                            (CHAR *)mp2, dcd->hwndFrame);
     2191        hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
     2192                           (CHAR *)mp2, dcd->hwndFrame);
    21772193      else
    2178         hwnd = StartMLEEditor(dcd->hwndParent,
    2179                               (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
     2194        hwnd = StartMLEEditor(dcd->hwndParent,
     2195                              (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
    21802196      free((CHAR *)mp2);
    21812197      return MRFROMLONG(hwnd);
     
    27612777          LISTINFO *li;
    27622778          ULONG action = UM_ACTION;
    2763 #         ifdef FORTIFY
    2764           Fortify_EnterScope();
    2765 #         endif
     2779#         ifdef FORTIFY
     2780          Fortify_EnterScope();
     2781#         endif
    27662782          li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    27672783          if (li) {
     
    27712787            if (!li->list || !li->list[0]) {
    27722788              free(li);
    2773 #             ifdef FORTIFY
    2774               Fortify_LeaveScope();
    2775 #              endif
    27762789              break;
    27772790            }
     
    27892802                mp1 = MPFROM2SHORT(IDM_INFO, SHORT2FROMMP(mp1));
    27902803                li->type = IDM_INFO;
    2791                 break;
    27922804              }
    27932805            }
     
    28112823            case IDM_MCIPLAY:
    28122824              action = UM_MASSACTION;
    2813               break;
    28142825            }
    28152826            if (SHORT1FROMMP(mp1) == IDM_SHADOW ||
     
    28212832            }
    28222833          }
     2834#         ifdef FORTIFY
     2835          Fortify_LeaveScope();
     2836#         endif
    28232837        }
    28242838        break;
     
    29352949    EmptyCnr(hwnd);
    29362950    if (apphead) {
    2937 
    29382951      APPNOTIFY *info, *next;
    2939 
    29402952      info = apphead;
    29412953      while (info) {
     
    29462958      apphead = apptail = NULL;
    29472959    }
    2948     break;
    2949   }
     2960#   ifdef FORTIFY
     2961    // if (dcd)
     2962    //  Fortify_ChangeScope(dcd, -1);
     2963    Fortify_LeaveScope();
     2964    // if (dcd)
     2965    //  Fortify_ChangeScope(dcd, -1);
     2966#   endif
     2967    break; // WM_DESTROY
     2968  } // switch
    29502969  if (dcd && dcd->oldproc){
    29512970      return dcd->oldproc(hwnd, msg, mp1, mp2);
     
    29983017#   ifdef FORTIFY
    29993018    Fortify_EnterScope();
    3000 #    endif
     3019#   endif
    30013020    dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
    30023021    if (!dcd) {
     
    30073026    else {
    30083027      SWP swp;
    3009 
    30103028      WinQueryWindowPos(hwndFrame, &swp);
    30113029      if (*(ULONG *) realappname == FM3UL) {
     
    30823100                   IDS_WINCREATEWINDOW);
    30833101        PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
    3084         free(dcd);
    3085 #       ifdef FORTIFY
    3086         Fortify_LeaveScope();
    3087 #        endif
     3102        free(dcd);
     3103        dcd = 0;
    30883104        hwndFrame = (HWND) 0;
    30893105      }
     
    31093125      }
    31103126    }
     3127#   ifdef FORTIFY
     3128    if (dcd)
     3129      Fortify_ChangeScope(dcd, -1);
     3130    Fortify_LeaveScope();
     3131    if (dcd)
     3132      Fortify_ChangeScope(dcd, +1);
     3133#   endif
    31113134  }
    31123135  return hwndFrame;
  • trunk/dll/ufortify.h

    r1015 r1077  
    88 *   User options for fortify. Changes to this file require fortify.c to be
    99 * recompiled, but nothing else.
     10 */
     11
     12 /* 18 Jul 08 SHL Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT
    1013 */
    1114
     
    4548/* #define FORTIFY_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
    4649/* #define FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */
     50#define FORTIFY_VERBOSE_SCOPE_ENTER_EXIT        /* Log all scope entry and exit */
    4751
    4852/* #define FORTIFY_NO_PERCENT_P */       /* sprintf() doesn't support %p */
  • trunk/dll/walkem.c

    r1039 r1077  
    33
    44  $Id$
     5
     6  Misc persistent lists support
    57
    68  Copyright (c) 1993-98 M. Kimes
     
    4749#include "errutil.h"                    // Dos_Error...
    4850#include "strutil.h"                    // GetPString
    49 #include "notebook.h"                   // targetdirectory
     51#include "notebook.h"                   // targetdirectory
    5052#include "fm3dll.h"
    5153#include "fortify.h"
     54#include "walkem.h"
    5255
    5356#pragma data_seg(DATA1)
     
    309312  return lookup_setup(name, LS_DELETE);
    310313}
     314
     315#ifdef FORTIFY
     316
     317VOID free_setups(VOID)
     318{
     319  LINKDIRS *pld = pFirstSetup;
     320  while (pld) {
     321    LINKDIRS *next = pld->next;
     322    free(pld->path);
     323    free(pld);
     324    pld = next;
     325  }
     326  pFirstSetup = NULL;
     327}
     328
     329#endif // FORTIFY
    311330
    312331VOID load_udirs(VOID)
     
    460479            else
    461480              last->next = info;
    462           }
     481          }
    463482          return TRUE;
    464483        }
     
    707726      PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
    708727      WinSetWindowPos(hwnd,
    709                       HWND_TOP,
    710                       swp.x,
    711                       swp.y,
    712                       swp.cx,
    713                       swp.cy,
    714                       swp.fl);
     728                      HWND_TOP,
     729                      swp.x,
     730                      swp.y,
     731                      swp.cx,
     732                      swp.cy,
     733                      swp.fl);
    715734    }
    716735    PosOverOkay(hwnd);
     
    11951214      }
    11961215      {
    1197         SWP swp;
    1198         ULONG size = sizeof(SWP);
    1199 
    1200         WinQueryWindowPos(hwnd, &swp);
    1201         PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
    1202                             size);
     1216        SWP swp;
     1217        ULONG size = sizeof(SWP);
     1218
     1219        WinQueryWindowPos(hwnd, &swp);
     1220        PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
     1221                            size);
    12031222      }
    12041223      if (wa->changed)
     
    12161235    case DID_CANCEL:
    12171236      {
    1218         SWP swp;
    1219         ULONG size = sizeof(SWP);
    1220 
    1221         WinQueryWindowPos(hwnd, &swp);
    1222         PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
    1223                             size);
     1237        SWP swp;
     1238        ULONG size = sizeof(SWP);
     1239
     1240        WinQueryWindowPos(hwnd, &swp);
     1241        PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
     1242                            size);
    12241243      }
    12251244      if (wa->changed)
    1226         WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
     1245        WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
    12271246      free(wa);
    12281247      WinDismissDlg(hwnd, 0);
     
    12321251
    12331252  case WM_CLOSE:
    1234         break;
     1253        break;
    12351254  }
    12361255  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    13361355      PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
    13371356      WinSetWindowPos(hwnd,
    1338                       HWND_TOP,
    1339                       swp.x,
    1340                       swp.y,
    1341                       swp.cx,
    1342                       swp.cy,
    1343                       swp.fl);
     1357                      HWND_TOP,
     1358                      swp.x,
     1359                      swp.y,
     1360                      swp.cx,
     1361                      swp.cy,
     1362                      swp.fl);
    13441363    }
    13451364    if (!*wa->szCurrentPath1)
     
    16141633      WinQueryWindowPos(hwnd, &swp);
    16151634      PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
    1616                           size);
     1635                          size);
    16171636      }
    16181637      WinDismissDlg(hwnd, 1);
     
    16331652      WinQueryWindowPos(hwnd, &swp);
    16341653      PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
    1635                           size);
     1654                          size);
    16361655      }
    16371656      WinDismissDlg(hwnd, 0);
  • trunk/dll/worker.c

    r1075 r1077  
    2525  26 Aug 07 SHL Revert to DosSleep(0)
    2626  29 Feb 08 GKY Refactor global command line variables to notebook.h
    27   22 Jun 08 GKY Made Felete move to xworkplace trash can  on systems that have it
     27  22 Jun 08 GKY Made Felete move to xworkplace trash can on systems that have it
    2828  16 JUL 08 GKY Use TMP directory for temp files
    2929
     
    5151#include "errutil.h"                    // Dos_Error...
    5252#include "strutil.h"                    // GetPString
    53 #include "notebook.h"                   // External viewers
     53#include "notebook.h"                   // External viewers
    5454#include "fm3dll.h"
    5555
     
    8585#      endif
    8686        li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
    87         if (li) {
     87        if (li) {
    8888          wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
    8989          if (wk) {
     
    105105                            GetPString(IDS_COULDNTSTARTTHREADTEXT));
    106106              FreeListInfo(wk->li);
    107               free(wk);
    108 #             ifdef FORTIFY
    109               Fortify_LeaveScope();
    110 #              endif
     107              free(wk);
     108#             ifdef FORTIFY
     109              Fortify_LeaveScope();
     110#              endif
    111111            }
    112112          }
     
    10011001  if (wk) {
    10021002#   ifdef FORTIFY
     1003    // Fortify_ChangeOwner(wk);
    10031004    Fortify_EnterScope();
    1004 #    endif
     1005#   endif
    10051006    if (wk->li && wk->li->list && wk->li->list[0]) {
    10061007      hab2 = WinInitialize(0);
     
    10681069              if (total > 1000) {
    10691070
    1070                 FILE *fp;
    1071                 CHAR szTempFile[CCHMAXPATH];
    1072 
    1073                 BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
     1071                FILE *fp;
     1072                CHAR szTempFile[CCHMAXPATH];
     1073
     1074                BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
    10741075                fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
    10751076                if (fp) {
     
    10781079                    fprintf(fp, "%s\n", wk->li->list[x]);
    10791080                  fprintf(fp, ";end\n");
    1080                   fclose(fp);
    1081                   strrev(szTempFile);
    1082                   strcat(szTempFile, "@/");
    1083                   strrev(szTempFile);
     1081                  fclose(fp);
     1082                  strrev(szTempFile);
     1083                  strcat(szTempFile, "@/");
     1084                  strrev(szTempFile);
    10841085                  RunFM2Util("FM2PLAY.EXE", szTempFile);
    10851086                }
     
    14501451              CHAR prompt[CCHMAXPATH * 3];
    14511452              APIRET error;
    1452               HOBJECT hObjectdest, hObjectofObject;
     1453              HOBJECT hObjectdest, hObjectofObject;
    14531454
    14541455              for (x = 0; wk->li->list[x]; x++) {
     
    15741575                  AddNote(prompt);
    15751576                  DosError(FERR_DISABLEHARDERR);
    1576                   if (wk->li->type == IDM_DELETE){
    1577                     hObjectdest = WinQueryObject("<XWP_TRASHCAN>");
    1578                     if (hObjectdest != NULLHANDLE){
    1579                       hObjectofObject = WinQueryObject(wk->li->list[x]);
    1580                       error = WinMoveObject(hObjectofObject, hObjectdest, 0);
    1581                     }
    1582                     else
    1583                       error = DosDelete(wk->li->list[x]);
    1584                   }
     1577                  if (wk->li->type == IDM_DELETE){
     1578                    hObjectdest = WinQueryObject("<XWP_TRASHCAN>");
     1579                    if (hObjectdest != NULLHANDLE){
     1580                      hObjectofObject = WinQueryObject(wk->li->list[x]);
     1581                      error = WinMoveObject(hObjectofObject, hObjectdest, 0);
     1582                    }
     1583                    else
     1584                      error = DosDelete(wk->li->list[x]);
     1585                  }
    15851586                  else
    15861587                    error = DosForceDelete(wk->li->list[x]);
     
    15891590                    make_deleteable(wk->li->list[x]);
    15901591                    if (wk->li->type == IDM_DELETE){
    1591                       hObjectdest = WinQueryObject("<XWP_TRASHCAN>");
    1592                       if (hObjectdest != NULLHANDLE){
    1593                         hObjectofObject = WinQueryObject(wk->li->list[x]);
    1594                         error = WinMoveObject(hObjectofObject, hObjectdest, 0);
    1595                       }
    1596                       else
    1597                         error = DosDelete(wk->li->list[x]);
    1598                     }
     1592                      hObjectdest = WinQueryObject("<XWP_TRASHCAN>");
     1593                      if (hObjectdest != NULLHANDLE){
     1594                        hObjectofObject = WinQueryObject(wk->li->list[x]);
     1595                        error = WinMoveObject(hObjectofObject, hObjectdest, 0);
     1596                      }
     1597                      else
     1598                        error = DosDelete(wk->li->list[x]);
     1599                    }
    15991600                    else
    16001601                      error = DosForceDelete(wk->li->list[x]);
Note: See TracChangeset for help on using the changeset viewer.