Changeset 133 for trunk/dll/mainwnd2.c


Ignore:
Timestamp:
May 25, 2005, 1:28:12 AM (20 years ago)
Author:
root
Message:

Use datamin.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mainwnd2.c

    r2 r133  
     1
     2/***********************************************************************
     3
     4  $Id$
     5
     6  Main window
     7
     8  Copyright (c) 1993-98 M. Kimes
     9  Copyright (c) 2005 Steven H.Levine
     10
     11  23 May 05 SHL Use datamin.h
     12
     13***********************************************************************/
     14
    115#define INCL_DOS
    216#define INCL_WIN
     
    923#include <ctype.h>
    1024#include <share.h>
     25
    1126#include "fm3dll.h"
    1227#include "fm3dlg.h"
    1328#include "fm3str.h"
    1429#include "tools.h"
    15 
    16 typedef struct {
    17   USHORT  size;
    18   USHORT  dummy;
    19   HWND    hwndDir1;
    20   HWND    hwndDir2;
    21   HWND    hwndCurr;
    22   HWND    hwndLastDir;
    23   HWND    hwndMax;
    24 } PERSON1DATA;
    25 
    26 extern TOOL  *toolhead;
     30#include "datamin.h"
     31
     32typedef struct
     33{
     34  USHORT size;
     35  USHORT dummy;
     36  HWND hwndDir1;
     37  HWND hwndDir2;
     38  HWND hwndCurr;
     39  HWND hwndLastDir;
     40  HWND hwndMax;
     41}
     42PERSON1DATA;
     43
     44extern TOOL *toolhead;
    2745
    2846#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
     
    3048#pragma alloc_text(PERSON13,MainWMCommand2)
    3149
    32 
    33 MRESULT EXPENTRY MainFrameWndProc2 (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    34 
    35   PFNWP oldproc = (PFNWP)WinQueryWindowPtr(hwnd,0);
    36 
    37   switch(msg) {
    38     case WM_ADJUSTWINDOWPOS:
    39       {
    40         SWP *pswp;
    41 
    42         pswp = (SWP *)mp1;
    43         if(pswp->fl & (SWP_SHOW | SWP_RESTORE))
    44           PostMsg(WinWindowFromID(hwnd,FID_CLIENT),UM_SIZE,MPVOID,MPVOID);
    45         if(fDataMin && !fAmClosing) {
    46           if(pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
    47 
    48             SWP swp;
    49 
    50             WinQueryWindowPos(hwnd,&swp);
    51             PostMsg(hwnd,UM_FOCUSME,MPFROMLONG(swp.fl),MPVOID);
    52             HideNote();
    53           }
    54           else if(pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
    55             if(DataHwnd)
    56               PostMsg(DataHwnd,WM_CLOSE,MPVOID,MPVOID);
    57           }
    58         }
    59         if(!fAmClosing) {
    60           if(pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
    61             HideNote();
    62         }
    63       }
     50MRESULT EXPENTRY MainFrameWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     51{
     52
     53  PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, 0);
     54
     55  switch (msg)
     56  {
     57  case WM_ADJUSTWINDOWPOS:
     58    {
     59      SWP *pswp;
     60
     61      pswp = (SWP *) mp1;
     62      if (pswp -> fl & (SWP_SHOW | SWP_RESTORE))
     63        PostMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_SIZE, MPVOID, MPVOID);
     64      if (fDataMin && !fAmClosing)
     65      {
     66        if (pswp -> fl & (SWP_HIDE | SWP_MINIMIZE))
     67        {
     68
     69          SWP swp;
     70
     71          WinQueryWindowPos(hwnd, &swp);
     72          PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
     73          HideNote();
     74        }
     75        else if (pswp -> fl & (SWP_SHOW | SWP_RESTORE))
     76        {
     77          if (DataHwnd)
     78            PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
     79        }
     80      }
     81      if (!fAmClosing)
     82      {
     83        if (pswp -> fl & (SWP_HIDE | SWP_MINIMIZE))
     84          HideNote();
     85      }
     86    }
     87    break;
     88
     89  case UM_FOCUSME:
     90    CreateDataBar(HWND_DESKTOP, (ULONG) mp1);
     91    return 0;
     92
     93  case WM_BUTTON1UP:
     94  case WM_BUTTON2UP:
     95  case WM_BUTTON3UP:
     96  case WM_MOUSEMOVE:
     97  case WM_CHORD:
     98    shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
     99    break;
     100
     101  case WM_CHAR:
     102    shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
     103    break;
     104
     105  case WM_CONTROL:
     106    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1, mp2);
     107
     108  case WM_COMMAND:
     109    return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
     110
     111  case WM_CALCFRAMERECT:
     112    {
     113      MRESULT mr;
     114      PRECTL prectl;
     115      LONG sheight = 20, bheight = 20;
     116
     117      mr = (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
     118        PFNWPFrame(hwnd, msg, mp1, mp2);
     119
     120      /*
     121       * Calculate the position of the client rectangle.
     122       * Otherwise,  we'll see a lot of redraw when we move the
     123       * client during WM_FORMATFRAME.
     124       */
     125
     126      if (mr && mp2)
     127      {
     128        prectl = (PRECTL) mp1;
     129        if (prectl -> yBottom != prectl -> yTop)
     130        {
     131          {
     132            HPS hps;
     133            POINTL aptl[TXTBOX_COUNT];
     134
     135            hps = WinGetPS(hwndStatus);
     136            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     137            WinReleasePS(hps);
     138            sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     139            hps = WinGetPS(hwndName);
     140            GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     141            WinReleasePS(hps);
     142            bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     143          }
     144          prectl -> yBottom += (sheight + 4);
     145          prectl -> yTop -= (sheight + 4);
     146          prectl -> yBottom += (bheight + 4);
     147          prectl -> yTop -= (bheight + 4);
     148          if (fToolbar)
     149          {
     150            if (!fTextTools)
     151              prectl -> yTop -= ((fToolTitles) ? 50 : 40);
     152            else
     153              prectl -> yTop -= 32;
     154          }
     155          ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     156                       ((prectl -> xRight -
     157                         (WinQuerySysValue(HWND_DESKTOP,
     158                                           SV_CYSIZEBORDER) * 2)) - 4));
     159          prectl -> yTop -= (16 * (DriveLines * 18));
     160          prectl -> yTop -= 2;
     161          if (fAutoView)
     162          {
     163            AutoviewHeight = min(AutoviewHeight,
     164                                 (prectl -> yTop - prectl -> yBottom) - 116);
     165            AutoviewHeight = max(AutoviewHeight, 36);
     166            prectl -> yBottom += (AutoviewHeight + 6);
     167          }
     168        }
     169      }
     170      return mr;
     171    }
     172
     173  case WM_FORMATFRAME:
     174    {
     175      SHORT sCount, soldCount;
     176      PSWP pswp, pswpClient, pswpNew;
     177      SWP swpClient;
     178      ULONG theight = 48L, dheight = 20, bheight = 20, sheight = 20;
     179      LONG width, lastx;
     180
     181      sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
     182                        PFNWPFrame(hwnd, msg, mp1, mp2));
     183      soldCount = sCount;
     184      /*
     185       * Reformat the frame to "squeeze" the client
     186       * and make room for status window sibling beneath
     187       * and toolbar above (if toolbar's on) and userlists
     188       * (if userlists are on).
     189       */
     190
     191      pswp = (PSWP) mp1;
     192      {
     193        SHORT x;
     194
     195        for (x = 0; x < sCount; x++)
     196        {
     197          if (WinQueryWindowUShort(pswp -> hwnd, QWS_ID) == FID_CLIENT)
     198          {
     199            pswpClient = pswp;
     200            break;
     201          }
     202          pswp++;
     203        }
     204      }
     205
     206      {
     207        HPS hps;
     208        POINTL aptl[TXTBOX_COUNT];
     209
     210        hps = WinGetPS(hwndStatus);
     211        GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     212        WinReleasePS(hps);
     213        bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
     214        hps = WinGetPS(hwndName);
     215        GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
     216        WinReleasePS(hps);
     217        bheight = aptl[TXTBOX_TOPLEFT].y + 6;
     218      }
     219
     220      pswpNew = (PSWP) mp1 + soldCount;
     221      *pswpNew = *pswpClient;
     222      swpClient = *pswpClient;
     223      pswpNew -> hwnd = hwndStatus;
     224      pswpNew -> x = swpClient.x + 3;
     225      pswpNew -> y = swpClient.y + 2;
     226      width = (swpClient.cx / 2) - 6;
     227      width = max(width, 10);
     228      pswpNew -> cx = width - 6;
     229      pswpNew -> cy = sheight;
     230      pswpClient -> y = pswpNew -> y + pswpNew -> cy + 3;
     231      pswpClient -> cy = (swpClient.cy - pswpNew -> cy) - 3;
     232      sCount++;
     233
     234      pswpNew = (PSWP) mp1 + (soldCount + 1);
     235      *pswpNew = *pswpClient;
     236      pswpNew -> hwnd = hwndStatus2;
     237      pswpNew -> x = width + 8;
     238      pswpNew -> y = swpClient.y + 2;
     239      pswpNew -> cx = width - 6;
     240      pswpNew -> cy = sheight;
     241      sCount++;
     242
     243      if (fToolbar)
     244      {
     245        if (fTextTools)
     246          theight = 32L;
     247        else if (!fToolTitles)
     248          theight = 40L;
     249        pswpNew = (PSWP) mp1 + (soldCount + 2);
     250        *pswpNew = *pswpClient;
     251        pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
     252        pswpNew -> x = swpClient.x + 2;
     253        pswpNew -> y = (swpClient.y + swpClient.cy) - (theight - 2);
     254        pswpNew -> cx = swpClient.cx - 4;
     255        pswpNew -> cy = theight - 4;
     256        pswpClient -> cy -= theight;
     257        sCount++;
     258      }
     259      else
     260        WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
     261
     262      ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
     263                   pswpClient -> cx - 4);
     264      pswpNew = (PSWP) mp1 + (soldCount + 2 + (fToolbar != FALSE));
     265      *pswpNew = *pswpClient;
     266      pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
     267      pswpNew -> x = swpClient.x + 2;
     268      dheight += ((dheight - 2) * DriveLines);
     269      pswpNew -> y = (swpClient.y + swpClient.cy) - (dheight - 2);
     270      if (fToolbar)
     271        pswpNew -> y -= theight;
     272      pswpNew -> cx = swpClient.cx - 4;
     273      pswpNew -> cy = dheight - 4;
     274      pswpClient -> cy -= dheight;
     275      pswpClient -> cy -= 2;
     276      sCount++;
     277
     278      if (fAutoView)
     279      {
     280        pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE));
     281        *pswpNew = *pswpClient;
     282        pswpNew -> hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
     283        pswpNew -> x = pswpClient -> x + 3;
     284        pswpNew -> y = pswpClient -> y + 3;
     285        if (fMoreButtons)
     286          pswpNew -> y += (bheight + 4);
     287        pswpNew -> cx = pswpClient -> cx - 6;
     288        AutoviewHeight = min(AutoviewHeight,
     289                             pswpClient -> cy - 116);
     290        AutoviewHeight = max(AutoviewHeight, 36);
     291        pswpNew -> cy = AutoviewHeight;
     292        pswpClient -> y += (AutoviewHeight + 6);
     293        pswpClient -> cy -= (AutoviewHeight + 6);
     294        sCount++;
     295        WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
     296      }
     297      else
     298      {
     299        WinShowWindow(hwndAutoview, FALSE);
     300        WinShowWindow(hwndAutoMLE, FALSE);
     301      }
     302
     303      pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE) +
     304                              (fAutoView != FALSE));
     305      *pswpNew = *pswpClient;
     306      pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_LED);
     307      pswpNew -> x = (swpClient.x + swpClient.cx) - 12;
     308      pswpNew -> y = swpClient.y;
     309      pswpNew -> cx = 12;
     310      pswpNew -> cy = 12;
     311      sCount++;
     312
     313      pswpNew = (PSWP) mp1 + (soldCount + 4 + (fToolbar != FALSE) +
     314                              (fAutoView != FALSE));
     315      *pswpNew = *pswpClient;
     316      pswpNew -> hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
     317      pswpNew -> x = (swpClient.x + swpClient.cx) - 12;
     318      pswpNew -> y = swpClient.y + 12;
     319      pswpNew -> cx = 12;
     320      pswpNew -> cy = sheight - 8;
     321      sCount++;
     322
     323      pswpNew = (PSWP) mp1 + (soldCount + 5 + (fToolbar != FALSE) +
     324                              (fAutoView != FALSE));
     325      *pswpNew = *pswpClient;
     326      pswpNew -> hwnd = hwndName;
     327      pswpNew -> x = swpClient.x + 3;
     328      pswpNew -> y = swpClient.y + (sheight + 6);
     329      pswpNew -> cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
     330      lastx = pswpNew -> x + pswpNew -> cx;
     331      pswpNew -> cy = bheight;
     332      pswpClient -> y += (bheight + 4);
     333      pswpClient -> cy -= (bheight + 4);
     334      sCount++;
     335
     336      pswpNew = (PSWP) mp1 + (soldCount + 6 + (fToolbar != FALSE) +
     337                              (fAutoView != FALSE));
     338      *pswpNew = *pswpClient;
     339      pswpNew -> hwnd = hwndDate;
     340      pswpNew -> x = lastx + 3;
     341      pswpNew -> y = swpClient.y + (sheight + 6);
     342      pswpNew -> cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
     343      lastx = pswpNew -> x + pswpNew -> cx;
     344      pswpNew -> cy = bheight;
     345      sCount++;
     346
     347      pswpNew = (PSWP) mp1 + (soldCount + 7 + (fToolbar != FALSE) +
     348                              (fAutoView != FALSE));
     349      *pswpNew = *pswpClient;
     350      pswpNew -> hwnd = hwndAttr;
     351      pswpNew -> x = lastx + 3;
     352      pswpNew -> y = swpClient.y + (sheight + 6);
     353      pswpNew -> cx = (swpClient.cx - pswpNew -> x) - 1;
     354      pswpNew -> cy = bheight;
     355      sCount++;
     356
     357      return MRFROMSHORT(sCount);
     358    }
     359
     360  case WM_QUERYFRAMECTLCOUNT:
     361    {
     362      SHORT sCount;
     363
     364      sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
     365                        PFNWPFrame(hwnd, msg, mp1, mp2));
     366      sCount += 8;
     367      if (fToolbar)
     368        sCount++;
     369      if (fAutoView)
     370        sCount++;
     371      return MRFROMSHORT(sCount);
     372    }
     373
     374  case WM_CLOSE:
     375    WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
     376    return 0;
     377  }
     378  return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
     379    PFNWPFrame(hwnd, msg, mp1, mp2);
     380}
     381
     382MRESULT EXPENTRY MainWMCommand2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     383{
     384
     385  PERSON1DATA *pd;
     386
     387  SetShiftState();
     388  switch (SHORT1FROMMP(mp1))
     389  {
     390  case IDM_TOAUTOMLE:
     391  case IDM_CLI:
     392  case IDM_CREATETOOL:
     393  case IDM_ABOUT:
     394  case IDM_WINFULLSCREEN:
     395  case IDM_DOSCOMMANDLINE:
     396  case IDM_INIVIEWER:
     397  case IDM_EDITASSOC:
     398  case IDM_COMMANDLINE:
     399  case IDM_KILLPROC:
     400  case IDM_TOOLBAR:
     401  case IDM_TEXTTOOLS:
     402  case IDM_TOOLTITLES:
     403  case IDM_TOOLLEFT:
     404  case IDM_TOOLRIGHT:
     405  case IDM_AUTOVIEWCOMMENTS:
     406  case IDM_AUTOVIEWFILE:
     407  case IDM_AUTOVIEW:
     408//    case IDM_SYSINFO:
     409  case IDM_HIDENOTEWND:
     410  case IDM_SHOWNOTEWND:
     411  case IDM_INSTANT:
     412  case IDM_HELPCONTEXT:
     413  case IDM_HELPHINTS:
     414  case IDM_HELPPIX:
     415  case IDM_KILLME:
     416  case IDM_EXIT:
     417  case IDM_HELPTUTOR:
     418  case IDM_HELPCONTENTS:
     419  case IDM_HELPGENERAL:
     420  case IDM_HELPKEYS:
     421  case IDM_HELPMOUSE:
     422  case IDM_HELP:
     423    return MainWMCommand(hwnd, msg, mp1, mp2);
     424
     425  case IDM_REMAP:
     426    WinDlgBox(HWND_DESKTOP,
     427              hwnd,
     428              RemapDlgProc,
     429              FM3ModHandle,
     430              MAP_FRAME,
     431              NULL);
     432    break;
     433
     434  case IDM_TWODIRS:
     435    pd = WinQueryWindowPtr(hwnd, 4);
     436    if (pd)
     437    {
     438
     439      WALK2 wa;
     440
     441      memset(&wa, 0, sizeof(wa));
     442      wa.size = sizeof(wa);
     443      *wa.szCurrentPath1 = 0;
     444      WinSendMsg(pd -> hwndDir1,
     445                 UM_CONTAINERDIR,
     446                 MPFROMP(wa.szCurrentPath1),
     447                 MPVOID);
     448      MakeValidDir(wa.szCurrentPath1);
     449      *wa.szCurrentPath2 = 0;
     450      WinSendMsg(pd -> hwndDir2,
     451                 UM_CONTAINERDIR,
     452                 MPFROMP(wa.szCurrentPath2),
     453                 MPVOID);
     454      MakeValidDir(wa.szCurrentPath2);
     455      if (WinDlgBox(HWND_DESKTOP,
     456                    hwnd,
     457                    WalkTwoSetDlgProc,
     458                    FM3ModHandle,
     459                    WALK2_FRAME,
     460                    MPFROMP(&wa)) &&
     461          (IsRoot(wa.szCurrentPath1) ||
     462           !IsFile(wa.szCurrentPath1)) &&
     463          (IsRoot(wa.szCurrentPath2) ||
     464           !IsFile(wa.szCurrentPath2)))
     465      {
     466        WinSendMsg(WinWindowFromID(WinWindowFromID(pd -> hwndDir1,
     467                                                   FID_CLIENT), DIR_CNR),
     468                   UM_SETDIR,
     469                   MPFROMP(wa.szCurrentPath1),
     470                   MPVOID);
     471        WinSendMsg(WinWindowFromID(WinWindowFromID(pd -> hwndDir2,
     472                                                   FID_CLIENT), DIR_CNR),
     473                   UM_SETDIR,
     474                   MPFROMP(wa.szCurrentPath2),
     475                   MPVOID);
     476      }
     477    }
     478    break;
     479
     480  case IDM_COMPARE:
     481    pd = WinQueryWindowPtr(hwnd, 4);
     482    if (pd)
     483    {
     484
     485      WALK2 wa;
     486
     487      memset(&wa, 0, sizeof(wa));
     488      wa.size = sizeof(wa);
     489      *wa.szCurrentPath1 = 0;
     490      WinSendMsg(pd -> hwndDir1,
     491                 UM_CONTAINERDIR,
     492                 MPFROMP(wa.szCurrentPath1),
     493                 MPVOID);
     494      MakeValidDir(wa.szCurrentPath1);
     495      *wa.szCurrentPath2 = 0;
     496      WinSendMsg(pd -> hwndDir2,
     497                 UM_CONTAINERDIR,
     498                 MPFROMP(wa.szCurrentPath2),
     499                 MPVOID);
     500      MakeValidDir(wa.szCurrentPath2);
     501      if (WinDlgBox(HWND_DESKTOP,
     502                    hwnd,
     503                    WalkTwoCmpDlgProc,
     504                    FM3ModHandle,
     505                    WALK2_FRAME,
     506                    MPFROMP(&wa)) &&
     507          (IsRoot(wa.szCurrentPath1) ||
     508           !IsFile(wa.szCurrentPath1)) &&
     509          (IsRoot(wa.szCurrentPath2) ||
     510           !IsFile(wa.szCurrentPath2)))
     511      {
     512        if (!*dircompare)
     513        {
     514
     515          COMPARE *cmp;
     516
     517          cmp = malloc(sizeof(COMPARE));
     518          if (cmp)
     519          {
     520            memset(cmp, 0, sizeof(COMPARE));
     521            cmp -> size = sizeof(COMPARE);
     522            strcpy(cmp -> leftdir, wa.szCurrentPath1);
     523            strcpy(cmp -> rightdir, wa.szCurrentPath2);
     524            cmp -> hwndParent = hwnd;
     525            cmp -> dcd.hwndParent = hwnd;
     526            WinDlgBox(HWND_DESKTOP,
     527                      HWND_DESKTOP,
     528                      CompareDlgProc,
     529                      FM3ModHandle,
     530                      COMP_FRAME,
     531                      MPFROMP(cmp));
     532          }
     533        }
     534        else
     535        {
     536
     537          CHAR *d1 = "\"", *d2 = "\"";
     538
     539          if (!needs_quoting(wa.szCurrentPath1))
     540            *d1 = 0;
     541          if (!needs_quoting(wa.szCurrentPath2))
     542            *d2 = 0;
     543          runemf2(SEPARATE,
     544                  HWND_DESKTOP,
     545                  NULL,
     546                  NULL,
     547                  "%s %s%s%s %s%s%s",
     548                  dircompare,
     549                  d1,
     550                  wa.szCurrentPath1,
     551                  d1,
     552                  d2,
     553                  wa.szCurrentPath2,
     554                  d2);
     555        }
     556      }
     557    }
     558    break;
     559
     560  case IDM_VTREE:
     561    WinSendMsg(hwnd,
     562               UM_SETUP2,
     563               MPFROMLONG(1),
     564               MPVOID);
     565    if (hwndTree)
     566    {
     567      WinShowWindow(hwndTree, FALSE);
     568      PostMsg(hwndTree,
     569              WM_CLOSE,
     570              MPVOID,
     571              MPVOID);
     572      hwndTree = (HWND) 0;
     573    }
     574    else
     575    {
     576
     577      ULONG size = sizeof(ULONG);
     578
     579      hwndTree = StartTreeCnr(hwnd, 3);
     580      PrfQueryProfileData(fmprof,
     581                          realappname,
     582                          "FM/4 TreeWidth",
     583                          (PVOID) & TreeWidth,
     584                          &size);
     585      TreeWidth = max(TreeWidth, 80);
     586    }
     587    {
     588      BOOL dummy = (hwndTree != (HWND) 0);
     589
     590      PrfWriteProfileData(fmprof,
     591                          realappname,
     592                          "FM/4 TreeUp",
     593                          (PVOID) & dummy,
     594                          sizeof(dummy));
     595    }
     596    PostMsg(hwnd,
     597            UM_SIZE,
     598            MPVOID,
     599            MPVOID);
     600    break;
     601
     602  case IDM_TILEBACKWARDS:
     603    WinSendMsg(hwnd,
     604               UM_SETUP2,
     605               MPFROMLONG(1),
     606               MPVOID);
     607    fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
     608    PrfWriteProfileData(fmprof,
     609                        FM3Str,
     610                        "TileBackwards",
     611                        (PVOID) & fTileBackwards,
     612                        sizeof(BOOL));
     613    PostMsg(hwnd,
     614            UM_SIZE,
     615            MPVOID,
     616            MPVOID);
     617    break;
     618
     619  case IDM_NEXTWINDOW:
     620  case IDM_PREVWINDOW:
     621    pd = WinQueryWindowPtr(hwnd, 4);
     622    if (pd)
     623    {
     624
     625      HWND hwndFocus;
     626
     627      if (hwndTree)
     628      {
     629        if (pd -> hwndMax)
     630        {
     631          if (hwndTree == pd -> hwndCurr)
     632            hwndFocus = pd -> hwndMax;
     633          else
     634            hwndFocus = hwndTree;
     635        }
     636        else
     637        {
     638          if (hwndTree == pd -> hwndCurr)
     639            hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
     640              pd -> hwndDir1 : pd -> hwndDir2;
     641          else if (pd -> hwndDir1 == pd -> hwndCurr)
     642            hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
     643              pd -> hwndDir2 : hwndTree;
     644          else
     645            hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
     646              hwndTree : pd -> hwndDir1;
     647        }
     648      }
     649      else
     650      {
     651        if (pd -> hwndMax)
     652          hwndFocus = pd -> hwndMax;
     653        else
     654          hwndFocus = (pd -> hwndCurr == pd -> hwndDir1) ?
     655            pd -> hwndDir2 : pd -> hwndDir1;
     656      }
     657      WinSetFocus(HWND_DESKTOP, hwndFocus);
     658    }
     659    break;
     660
     661  case IDM_NOTEBOOK:
     662    WinDlgBox(HWND_DESKTOP,
     663              hwnd,
     664              CfgDlgProc,
     665              FM3ModHandle,
     666              CFG_FRAME,
     667              MPFROMP(realappname));
     668    PostMsg(hwnd,
     669            UM_SIZE,
     670            MPVOID,
     671            MPVOID);
     672    break;
     673
     674  case IDM_SEEALL:
     675  case IDM_GREP:
     676  case IDM_COLLECTOR:
     677    {
     678      HWND hwndC;
     679
     680      hwndC = StartCollector(HWND_DESKTOP, 4);
     681      if (hwndC)
     682      {
     683        WinSetWindowPos(hwndC,
     684                        HWND_TOP,
     685                        0,
     686                        0,
     687                        0,
     688                        0,
     689                        SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
     690        if (SHORT1FROMMP(mp1) == IDM_GREP)
     691          PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
     692                  WM_COMMAND,
     693                  MPFROM2SHORT(IDM_GREP, 0),
     694                  MPVOID);
     695        if (SHORT1FROMMP(mp1) == IDM_SEEALL)
     696          PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
     697                  WM_COMMAND,
     698                  MPFROM2SHORT(IDM_SEEALL, 0),
     699                  MPVOID);
     700      }
     701    }
     702    break;
     703
     704  case IDM_EDITCOMMANDS:
     705    EditCommands(hwnd);
     706    break;
     707
     708  default:
     709    if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
     710        SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499)
     711    {
     712      if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
     713        WinSwitchToProgram(switches[SHORT1FROMMP(mp1) -
     714                                    IDM_SWITCHSTART]);
    64715      break;
    65 
    66     case UM_FOCUSME:
    67       CreateDataBar(HWND_DESKTOP,(ULONG)mp1);
    68       return 0;
    69 
    70     case WM_BUTTON1UP:
    71     case WM_BUTTON2UP:
    72     case WM_BUTTON3UP:
    73     case WM_MOUSEMOVE:
    74     case WM_CHORD:
    75      shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
    76      break;
    77 
    78     case WM_CHAR:
    79       shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
    80       break;
    81 
    82     case WM_CONTROL:
    83       return WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),UM_CONTROL,mp1,mp2);
    84 
    85     case WM_COMMAND:
    86       return WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),msg,mp1,mp2);
    87 
    88     case WM_CALCFRAMERECT:
    89       {
    90         MRESULT mr;
    91         PRECTL  prectl;
    92         LONG    sheight = 20,bheight = 20;
    93 
    94         mr = (oldproc) ? oldproc(hwnd,msg,mp1,mp2) :
    95                          PFNWPFrame(hwnd, msg, mp1, mp2);
    96 
    97         /*
    98          * Calculate the position of the client rectangle.
    99          * Otherwise,  we'll see a lot of redraw when we move the
    100          * client during WM_FORMATFRAME.
    101          */
    102 
    103         if(mr && mp2) {
    104           prectl = (PRECTL)mp1;
    105           if(prectl->yBottom != prectl->yTop) {
    106             {
    107               HPS    hps;
    108               POINTL aptl[TXTBOX_COUNT];
    109 
    110               hps = WinGetPS(hwndStatus);
    111               GpiQueryTextBox(hps,6,"$`WjgT",TXTBOX_COUNT,aptl);
    112               WinReleasePS(hps);
    113               sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    114               hps = WinGetPS(hwndName);
    115               GpiQueryTextBox(hps,6,"$`WjgT",TXTBOX_COUNT,aptl);
    116               WinReleasePS(hps);
    117               bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    118             }
    119             prectl->yBottom += (sheight + 4);
    120             prectl->yTop -= (sheight + 4);
    121             prectl->yBottom += (bheight + 4);
    122             prectl->yTop -= (bheight + 4);
    123             if(fToolbar) {
    124               if(!fTextTools)
    125                 prectl->yTop -= ((fToolTitles) ? 50 : 40);
    126               else
    127                 prectl->yTop -= 32;
    128             }
    129             ResizeDrives(WinWindowFromID(hwnd,MAIN_DRIVES),
    130                          ((prectl->xRight -
    131                           (WinQuerySysValue(HWND_DESKTOP,
    132                                             SV_CYSIZEBORDER) * 2))- 4));
    133             prectl->yTop -= (16 * (DriveLines * 18));
    134             prectl->yTop -= 2;
    135             if(fAutoView) {
    136               AutoviewHeight = min(AutoviewHeight,
    137                                    (prectl->yTop - prectl->yBottom) - 116);
    138               AutoviewHeight = max(AutoviewHeight,36);
    139               prectl->yBottom += (AutoviewHeight + 6);
    140             }
    141           }
    142         }
    143         return mr;
    144       }
    145 
    146     case WM_FORMATFRAME:
    147       {
    148         SHORT sCount,soldCount;
    149         PSWP  pswp,pswpClient,pswpNew;
    150         SWP   swpClient;
    151         ULONG theight = 48L,dheight = 20,bheight = 20,sheight = 20;
    152         LONG  width,lastx;
    153 
    154         sCount = (SHORT)((oldproc) ? oldproc(hwnd,msg,mp1,mp2) :
    155                                      PFNWPFrame(hwnd, msg, mp1, mp2));
    156         soldCount = sCount;
    157         /*
    158          * Reformat the frame to "squeeze" the client
    159          * and make room for status window sibling beneath
    160          * and toolbar above (if toolbar's on) and userlists
    161          * (if userlists are on).
    162          */
    163 
    164         pswp = (PSWP)mp1;
    165         {
    166           SHORT x;
    167 
    168           for(x = 0;x < sCount;x++) {
    169             if(WinQueryWindowUShort(pswp->hwnd,QWS_ID) == FID_CLIENT) {
    170               pswpClient = pswp;
    171               break;
    172             }
    173             pswp++;
    174           }
    175         }
    176 
    177         {
    178           HPS    hps;
    179           POINTL aptl[TXTBOX_COUNT];
    180 
    181           hps = WinGetPS(hwndStatus);
    182           GpiQueryTextBox(hps,6,"$`WjgT",TXTBOX_COUNT,aptl);
    183           WinReleasePS(hps);
    184           bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
    185           hps = WinGetPS(hwndName);
    186           GpiQueryTextBox(hps,6,"$`WjgT",TXTBOX_COUNT,aptl);
    187           WinReleasePS(hps);
    188           bheight = aptl[TXTBOX_TOPLEFT].y + 6;
    189         }
    190 
    191         pswpNew = (PSWP)mp1 + soldCount;
    192         *pswpNew = *pswpClient;
    193         swpClient = *pswpClient;
    194         pswpNew->hwnd = hwndStatus;
    195         pswpNew->x = swpClient.x + 3;
    196         pswpNew->y = swpClient.y + 2;
    197         width = (swpClient.cx / 2) - 6;
    198         width = max(width,10);
    199         pswpNew->cx = width - 6;
    200         pswpNew->cy = sheight;
    201         pswpClient->y = pswpNew->y + pswpNew->cy + 3;
    202         pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3;
    203         sCount++;
    204 
    205         pswpNew = (PSWP)mp1 + (soldCount + 1);
    206         *pswpNew = *pswpClient;
    207         pswpNew->hwnd = hwndStatus2;
    208         pswpNew->x = width + 8;
    209         pswpNew->y = swpClient.y + 2;
    210         pswpNew->cx = width - 6;
    211         pswpNew->cy = sheight;
    212         sCount++;
    213 
    214         if(fToolbar) {
    215           if(fTextTools)
    216             theight = 32L;
    217           else if(!fToolTitles)
    218             theight = 40L;
    219           pswpNew = (PSWP)mp1 + (soldCount + 2);
    220           *pswpNew = *pswpClient;
    221           pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_TOOLS);
    222           pswpNew->x = swpClient.x + 2;
    223           pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
    224           pswpNew->cx = swpClient.cx - 4;
    225           pswpNew->cy = theight - 4;
    226           pswpClient->cy -= theight;
    227           sCount++;
    228         }
    229         else
    230           WinShowWindow(WinWindowFromID(hwnd,MAIN_TOOLS),FALSE);
    231 
    232         ResizeDrives(WinWindowFromID(hwnd,MAIN_DRIVES),
    233                      pswpClient->cx - 4);
    234         pswpNew = (PSWP)mp1 + (soldCount + 2 + (fToolbar != FALSE));
    235         *pswpNew = *pswpClient;
    236         pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_DRIVES);
    237         pswpNew->x = swpClient.x + 2;
    238         dheight += ((dheight - 2) * DriveLines);
    239         pswpNew->y = (swpClient.y + swpClient.cy) - (dheight - 2);
    240         if(fToolbar)
    241           pswpNew->y -= theight;
    242         pswpNew->cx = swpClient.cx - 4;
    243         pswpNew->cy = dheight - 4;
    244         pswpClient->cy -= dheight;
    245         pswpClient->cy -= 2;
    246         sCount++;
    247 
    248         if(fAutoView) {
    249           pswpNew = (PSWP)mp1 + (soldCount + 3 + (fToolbar != FALSE));
    250           *pswpNew = *pswpClient;
    251           pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
    252           pswpNew->x = pswpClient->x + 3;
    253           pswpNew->y = pswpClient->y + 3;
    254           if(fMoreButtons)
    255             pswpNew->y += (bheight + 4);
    256           pswpNew->cx = pswpClient->cx - 6;
    257           AutoviewHeight = min(AutoviewHeight,
    258                                pswpClient->cy - 116);
    259           AutoviewHeight = max(AutoviewHeight,36);
    260           pswpNew->cy = AutoviewHeight;
    261           pswpClient->y += (AutoviewHeight + 6);
    262           pswpClient->cy -= (AutoviewHeight + 6);
    263           sCount++;
    264           WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE,FALSE);
    265         }
    266         else {
    267           WinShowWindow(hwndAutoview,FALSE);
    268           WinShowWindow(hwndAutoMLE,FALSE);
    269         }
    270 
    271         pswpNew = (PSWP)mp1 + (soldCount + 3 + (fToolbar != FALSE) +
    272                                                (fAutoView != FALSE));
    273         *pswpNew = *pswpClient;
    274         pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_LED);
    275         pswpNew->x = (swpClient.x + swpClient.cx) - 12;
    276         pswpNew->y = swpClient.y;
    277         pswpNew->cx = 12;
    278         pswpNew->cy = 12;
    279         sCount++;
    280 
    281         pswpNew = (PSWP)mp1 + (soldCount + 4 + (fToolbar != FALSE) +
    282                                                (fAutoView != FALSE));
    283         *pswpNew = *pswpClient;
    284         pswpNew->hwnd = WinWindowFromID(hwnd,MAIN_LEDHDR);
    285         pswpNew->x = (swpClient.x + swpClient.cx) - 12;
    286         pswpNew->y = swpClient.y + 12;
    287         pswpNew->cx = 12;
    288         pswpNew->cy = sheight - 8;
    289         sCount++;
    290 
    291         pswpNew = (PSWP)mp1 + (soldCount + 5 + (fToolbar != FALSE) +
    292                                                (fAutoView != FALSE));
    293         *pswpNew = *pswpClient;
    294         pswpNew->hwnd = hwndName;
    295         pswpNew->x = swpClient.x + 3;
    296         pswpNew->y = swpClient.y + (sheight + 6);
    297         pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
    298         lastx = pswpNew->x + pswpNew->cx;
    299         pswpNew->cy = bheight;
    300         pswpClient->y += (bheight + 4);
    301         pswpClient->cy -= (bheight + 4);
    302         sCount++;
    303 
    304         pswpNew = (PSWP)mp1 + (soldCount + 6 + (fToolbar != FALSE) +
    305                                                (fAutoView != FALSE));
    306         *pswpNew = *pswpClient;
    307         pswpNew->hwnd = hwndDate;
    308         pswpNew->x = lastx + 3;
    309         pswpNew->y = swpClient.y + (sheight + 6);
    310         pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
    311         lastx = pswpNew->x + pswpNew->cx;
    312         pswpNew->cy = bheight;
    313         sCount++;
    314 
    315         pswpNew = (PSWP)mp1 + (soldCount + 7 + (fToolbar != FALSE) +
    316                                                (fAutoView != FALSE));
    317         *pswpNew = *pswpClient;
    318         pswpNew->hwnd = hwndAttr;
    319         pswpNew->x = lastx + 3;
    320         pswpNew->y = swpClient.y + (sheight + 6);
    321         pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
    322         pswpNew->cy = bheight;
    323         sCount++;
    324 
    325         return MRFROMSHORT(sCount);
    326       }
    327 
    328     case WM_QUERYFRAMECTLCOUNT:
    329       {
    330         SHORT sCount;
    331 
    332         sCount = (SHORT) ((oldproc) ? oldproc(hwnd,msg,mp1,mp2) :
    333                                       PFNWPFrame(hwnd, msg, mp1, mp2));
    334         sCount += 8;
    335         if(fToolbar)
    336           sCount++;
    337         if(fAutoView)
    338           sCount++;
    339         return MRFROMSHORT(sCount);
    340       }
    341 
    342     case WM_CLOSE:
    343       WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),msg,mp1,mp2);
    344       return 0;
    345   }
    346   return (oldproc) ? oldproc(hwnd,msg,mp1,mp2) :
    347                      PFNWPFrame(hwnd,msg,mp1,mp2);
    348 }
    349 
    350 
    351 MRESULT EXPENTRY MainWMCommand2 (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    352 
    353   PERSON1DATA *pd;
    354 
    355   SetShiftState();
    356   switch(SHORT1FROMMP(mp1)) {
    357     case IDM_TOAUTOMLE:
    358     case IDM_CLI:
    359     case IDM_CREATETOOL:
    360     case IDM_ABOUT:
    361     case IDM_WINFULLSCREEN:
    362     case IDM_DOSCOMMANDLINE:
    363     case IDM_INIVIEWER:
    364     case IDM_EDITASSOC:
    365     case IDM_COMMANDLINE:
    366     case IDM_KILLPROC:
    367     case IDM_TOOLBAR:
    368     case IDM_TEXTTOOLS:
    369     case IDM_TOOLTITLES:
    370     case IDM_TOOLLEFT:
    371     case IDM_TOOLRIGHT:
    372     case IDM_AUTOVIEWCOMMENTS:
    373     case IDM_AUTOVIEWFILE:
    374     case IDM_AUTOVIEW:
    375 //    case IDM_SYSINFO:
    376     case IDM_HIDENOTEWND:
    377     case IDM_SHOWNOTEWND:
    378     case IDM_INSTANT:
    379     case IDM_HELPCONTEXT:
    380     case IDM_HELPHINTS:
    381     case IDM_HELPPIX:
    382     case IDM_KILLME:
    383     case IDM_EXIT:
    384     case IDM_HELPTUTOR:
    385     case IDM_HELPCONTENTS:
    386     case IDM_HELPGENERAL:
    387     case IDM_HELPKEYS:
    388     case IDM_HELPMOUSE:
    389     case IDM_HELP:
    390       return MainWMCommand(hwnd,msg,mp1,mp2);
    391 
    392     case IDM_REMAP:
    393       WinDlgBox(HWND_DESKTOP,
    394                 hwnd,
    395                 RemapDlgProc,
    396                 FM3ModHandle,
    397                 MAP_FRAME,
    398                 NULL);
    399       break;
    400 
    401     case IDM_TWODIRS:
    402       pd = WinQueryWindowPtr(hwnd,4);
    403       if(pd) {
    404 
    405         WALK2 wa;
    406 
    407         memset(&wa,0,sizeof(wa));
    408         wa.size = sizeof(wa);
    409         *wa.szCurrentPath1 = 0;
    410         WinSendMsg(pd->hwndDir1,
    411                    UM_CONTAINERDIR,
    412                    MPFROMP(wa.szCurrentPath1),
    413                    MPVOID);
    414         MakeValidDir(wa.szCurrentPath1);
    415         *wa.szCurrentPath2 = 0;
    416         WinSendMsg(pd->hwndDir2,
    417                    UM_CONTAINERDIR,
    418                    MPFROMP(wa.szCurrentPath2),
    419                    MPVOID);
    420         MakeValidDir(wa.szCurrentPath2);
    421         if(WinDlgBox(HWND_DESKTOP,
    422                      hwnd,
    423                      WalkTwoSetDlgProc,
    424                      FM3ModHandle,
    425                      WALK2_FRAME,
    426                      MPFROMP(&wa)) &&
    427            (IsRoot(wa.szCurrentPath1) ||
    428             !IsFile(wa.szCurrentPath1)) &&
    429            (IsRoot(wa.szCurrentPath2) ||
    430             !IsFile(wa.szCurrentPath2))) {
    431           WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1,
    432                                      FID_CLIENT),DIR_CNR),
    433                      UM_SETDIR,
    434                      MPFROMP(wa.szCurrentPath1),
    435                      MPVOID);
    436           WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2,
    437                                      FID_CLIENT),DIR_CNR),
    438                      UM_SETDIR,
    439                      MPFROMP(wa.szCurrentPath2),
    440                      MPVOID);
    441         }
    442       }
    443       break;
    444 
    445     case IDM_COMPARE:
    446       pd = WinQueryWindowPtr(hwnd,4);
    447       if(pd) {
    448 
    449         WALK2 wa;
    450 
    451         memset(&wa,0,sizeof(wa));
    452         wa.size = sizeof(wa);
    453         *wa.szCurrentPath1 = 0;
    454         WinSendMsg(pd->hwndDir1,
    455                    UM_CONTAINERDIR,
    456                    MPFROMP(wa.szCurrentPath1),
    457                    MPVOID);
    458         MakeValidDir(wa.szCurrentPath1);
    459         *wa.szCurrentPath2 = 0;
    460         WinSendMsg(pd->hwndDir2,
    461                    UM_CONTAINERDIR,
    462                    MPFROMP(wa.szCurrentPath2),
    463                    MPVOID);
    464         MakeValidDir(wa.szCurrentPath2);
    465         if(WinDlgBox(HWND_DESKTOP,
    466                      hwnd,
    467                      WalkTwoCmpDlgProc,
    468                      FM3ModHandle,
    469                      WALK2_FRAME,
    470                      MPFROMP(&wa)) &&
    471            (IsRoot(wa.szCurrentPath1) ||
    472             !IsFile(wa.szCurrentPath1)) &&
    473            (IsRoot(wa.szCurrentPath2) ||
    474             !IsFile(wa.szCurrentPath2))) {
    475           if(!*dircompare) {
    476 
    477             COMPARE *cmp;
    478 
    479             cmp = malloc(sizeof(COMPARE));
    480             if(cmp) {
    481               memset(cmp,0,sizeof(COMPARE));
    482               cmp->size = sizeof(COMPARE);
    483               strcpy(cmp->leftdir,wa.szCurrentPath1);
    484               strcpy(cmp->rightdir,wa.szCurrentPath2);
    485               cmp->hwndParent = hwnd;
    486               cmp->dcd.hwndParent = hwnd;
    487               WinDlgBox(HWND_DESKTOP,
    488                         HWND_DESKTOP,
    489                         CompareDlgProc,
    490                         FM3ModHandle,
    491                         COMP_FRAME,
    492                         MPFROMP(cmp));
    493             }
    494           }
    495           else {
    496 
    497             CHAR *d1 = "\"",*d2 = "\"";
    498 
    499             if(!needs_quoting(wa.szCurrentPath1))
    500               *d1 = 0;
    501             if(!needs_quoting(wa.szCurrentPath2))
    502               *d2 = 0;
    503             runemf2(SEPARATE,
    504                     HWND_DESKTOP,
    505                     NULL,
    506                     NULL,
    507                     "%s %s%s%s %s%s%s",
    508                     dircompare,
    509                     d1,
    510                     wa.szCurrentPath1,
    511                     d1,
    512                     d2,
    513                     wa.szCurrentPath2,
    514                     d2);
    515           }
    516         }
    517       }
    518       break;
    519 
    520     case IDM_VTREE:
    521       WinSendMsg(hwnd,
    522                  UM_SETUP2,
    523                  MPFROMLONG(1),
    524                  MPVOID);
    525       if(hwndTree) {
    526         WinShowWindow(hwndTree,FALSE);
    527         PostMsg(hwndTree,
    528                 WM_CLOSE,
    529                 MPVOID,
    530                 MPVOID);
    531         hwndTree = (HWND)0;
    532       }
    533       else {
    534 
    535         ULONG size = sizeof(ULONG);
    536 
    537         hwndTree = StartTreeCnr(hwnd,3);
    538         PrfQueryProfileData(fmprof,
    539                             realappname,
    540                             "FM/4 TreeWidth",
    541                             (PVOID)&TreeWidth,
    542                             &size);
    543         TreeWidth = max(TreeWidth,80);
    544       }
    545       {
    546         BOOL dummy = (hwndTree != (HWND)0);
    547         PrfWriteProfileData(fmprof,
    548                             realappname,
    549                             "FM/4 TreeUp",
    550                             (PVOID)&dummy,
    551                             sizeof(dummy));
    552       }
    553       PostMsg(hwnd,
    554               UM_SIZE,
    555               MPVOID,
    556               MPVOID);
    557       break;
    558 
    559     case IDM_TILEBACKWARDS:
    560       WinSendMsg(hwnd,
    561                  UM_SETUP2,
    562                  MPFROMLONG(1),
    563                  MPVOID);
    564       fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
    565       PrfWriteProfileData(fmprof,
    566                           FM3Str,
    567                           "TileBackwards",
    568                           (PVOID)&fTileBackwards,
    569                           sizeof(BOOL));
    570       PostMsg(hwnd,
    571               UM_SIZE,
    572               MPVOID,
    573               MPVOID);
    574       break;
    575 
    576     case IDM_NEXTWINDOW:
    577     case IDM_PREVWINDOW:
    578       pd = WinQueryWindowPtr(hwnd,4);
    579       if(pd) {
    580 
    581         HWND hwndFocus;
    582 
    583         if(hwndTree) {
    584           if(pd->hwndMax) {
    585             if(hwndTree == pd->hwndCurr)
    586               hwndFocus = pd->hwndMax;
    587             else
    588               hwndFocus = hwndTree;
    589           }
    590           else {
    591             if(hwndTree == pd->hwndCurr)
    592               hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
    593                            pd->hwndDir1 : pd->hwndDir2;
    594             else if(pd->hwndDir1 == pd->hwndCurr)
    595               hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
    596                            pd->hwndDir2 : hwndTree;
    597             else
    598               hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
    599                            hwndTree : pd->hwndDir1;
    600           }
    601         }
    602         else {
    603           if(pd->hwndMax)
    604             hwndFocus = pd->hwndMax;
    605           else
    606             hwndFocus = (pd->hwndCurr == pd->hwndDir1) ?
    607                          pd->hwndDir2 : pd->hwndDir1;
    608         }
    609         WinSetFocus(HWND_DESKTOP,hwndFocus);
    610       }
    611       break;
    612 
    613     case IDM_NOTEBOOK:
    614       WinDlgBox(HWND_DESKTOP,
    615                 hwnd,
    616                 CfgDlgProc,
    617                 FM3ModHandle,
    618                 CFG_FRAME,
    619                 MPFROMP(realappname));
    620       PostMsg(hwnd,
    621               UM_SIZE,
    622               MPVOID,
    623               MPVOID);
    624       break;
    625 
    626     case IDM_SEEALL:
    627     case IDM_GREP:
    628     case IDM_COLLECTOR:
    629       {
    630         HWND hwndC;
    631 
    632         hwndC = StartCollector(HWND_DESKTOP,4);
    633         if(hwndC) {
    634           WinSetWindowPos(hwndC,
    635                           HWND_TOP,
    636                           0,
    637                           0,
    638                           0,
    639                           0,
    640                           SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
    641           if(SHORT1FROMMP(mp1) == IDM_GREP)
    642             PostMsg(WinWindowFromID(hwndC,FID_CLIENT),
    643                     WM_COMMAND,
    644                     MPFROM2SHORT(IDM_GREP,0),
    645                     MPVOID);
    646           if(SHORT1FROMMP(mp1) == IDM_SEEALL)
    647             PostMsg(WinWindowFromID(hwndC,FID_CLIENT),
    648                     WM_COMMAND,
    649                     MPFROM2SHORT(IDM_SEEALL,0),
    650                     MPVOID);
    651         }
    652       }
    653       break;
    654 
    655     case IDM_EDITCOMMANDS:
    656       EditCommands(hwnd);
    657       break;
    658 
    659     default:
    660       if(SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
    661          SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
    662         if(SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
    663           WinSwitchToProgram(switches[SHORT1FROMMP(mp1) -
    664                                       IDM_SWITCHSTART]);
    665         break;
    666       }
    667       else if(SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
    668               SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
    669 
    670         INT  x;
    671         HWND hwndCnr;
    672 
    673         if(!cmdloaded)
    674           load_commands();
    675         hwndCnr = TopWindow(hwnd,(HWND)0);
    676         hwndCnr = (HWND)WinSendMsg(WinWindowFromID(hwndCnr,FID_CLIENT),
    677                                    UM_CONTAINERHWND,
    678                                    MPVOID,
    679                                    MPVOID);
    680         if(!hwndCnr) {
    681           DosBeep(50,100);
    682           break;
    683         }
    684         x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
    685         if(x >= 0) {
    686           x++;
    687           RunCommand(hwndCnr,x);
    688           if(fUnHilite) {
    689 
    690             PCNRITEM    pci;
    691             DIRCNRDATA *dcd = NULL;
    692 
    693             if(WinQueryWindowUShort(hwndCnr,QWS_ID) != TREE_CNR)
    694               dcd = INSTDATA(hwndCnr);
    695             pci = (PCNRITEM)WinSendMsg(hwndCnr,
    696                                        CM_QUERYRECORDEMPHASIS,
    697                                        MPFROMLONG(CMA_FIRST),
    698                                        MPFROMSHORT(CRA_CURSORED));
    699             if(pci && (INT)pci != -1 &&
    700                (pci->rc.flRecordAttr & CRA_SELECTED))
    701               UnHilite(hwnd,
    702                        TRUE,
    703                        ((dcd) ? &dcd->lastselection : NULL));
    704           }
    705         }
    706       }
    707       else if(SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
    708             SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
    709         if(!qtloaded)
    710           load_quicktools();
    711         if(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
    712           if(fToolsChanged)
    713             save_tools(NULL);
    714           if(!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
    715             load_tools(NULL);
    716           else {
    717             strcpy(lasttoolbox,quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
    718             PrfWriteProfileString(fmprof,
    719                                   FM3Str,
    720                                   "LastToolBox",
    721                                   lasttoolbox);
    722           }
    723           BuildTools(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
    724                                      MAIN_TOOLS),
    725                      TRUE);
    726         }
    727       }
    728       else {
    729 
    730         HWND hwndActive;
    731 
    732         hwndActive = TopWindow(hwnd,(HWND)0);
    733         if(hwndActive)
    734           PostMsg(WinWindowFromID(hwndActive,FID_CLIENT),
    735                   msg,
    736                   mp1,
    737                   mp2);
    738       }
    739       break;
     716    }
     717    else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
     718             SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART)
     719    {
     720
     721      INT x;
     722      HWND hwndCnr;
     723
     724      if (!cmdloaded)
     725        load_commands();
     726      hwndCnr = TopWindow(hwnd, (HWND) 0);
     727      hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
     728                                  UM_CONTAINERHWND,
     729                                  MPVOID,
     730                                  MPVOID);
     731      if (!hwndCnr)
     732      {
     733        DosBeep(50, 100);
     734        break;
     735      }
     736      x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
     737      if (x >= 0)
     738      {
     739        x++;
     740        RunCommand(hwndCnr, x);
     741        if (fUnHilite)
     742        {
     743
     744          PCNRITEM pci;
     745          DIRCNRDATA *dcd = NULL;
     746
     747          if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
     748            dcd = INSTDATA(hwndCnr);
     749          pci = (PCNRITEM) WinSendMsg(hwndCnr,
     750                                      CM_QUERYRECORDEMPHASIS,
     751                                      MPFROMLONG(CMA_FIRST),
     752                                      MPFROMSHORT(CRA_CURSORED));
     753          if (pci && (INT) pci != -1 &&
     754              (pci -> rc.flRecordAttr & CRA_SELECTED))
     755            UnHilite(hwnd,
     756                     TRUE,
     757                     ((dcd) ? &dcd -> lastselection : NULL));
     758        }
     759      }
     760    }
     761    else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
     762             SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50)
     763    {
     764      if (!qtloaded)
     765        load_quicktools();
     766      if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART])
     767      {
     768        if (fToolsChanged)
     769          save_tools(NULL);
     770        if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
     771          load_tools(NULL);
     772        else
     773        {
     774          strcpy(lasttoolbox, quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
     775          PrfWriteProfileString(fmprof,
     776                                FM3Str,
     777                                "LastToolBox",
     778                                lasttoolbox);
     779        }
     780        BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     781                                   MAIN_TOOLS),
     782                   TRUE);
     783      }
     784    }
     785    else
     786    {
     787
     788      HWND hwndActive;
     789
     790      hwndActive = TopWindow(hwnd, (HWND) 0);
     791      if (hwndActive)
     792        PostMsg(WinWindowFromID(hwndActive, FID_CLIENT),
     793                msg,
     794                mp1,
     795                mp2);
     796    }
     797    break;
    740798  }
    741799  return 0;
    742800}
    743801
    744 
    745 MRESULT EXPENTRY MainWMOnce2 (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
     802MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     803{
    746804
    747805  PERSON1DATA *pd;
    748806
    749   switch(msg) {
    750     case WM_CREATE:
    751       {
    752         TID tid;
    753 
    754         WinQueryWindowProcess(hwnd,&mypid,&tid);
    755       }
    756       hwndMain = hwnd;
    757       WinSetWindowUShort(hwnd,8,0);
    758       WinSetWindowUShort(hwnd,10,0);
    759       WinSetWindowUShort(hwnd,12,0);
    760       WinSetWindowUShort(hwnd,16,0);
    761       if(_beginthread(MakeMainObjWin,
    762                       NULL,
    763                       245760,
    764                       MPVOID) == -1) {
    765         PostMsg(hwnd,
    766                 WM_CLOSE,
    767                 MPVOID,
    768                 MPVOID);
    769         return 0;
    770       }
     807  switch (msg)
     808  {
     809  case WM_CREATE:
     810    {
     811      TID tid;
     812
     813      WinQueryWindowProcess(hwnd, &mypid, &tid);
     814    }
     815    hwndMain = hwnd;
     816    WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
     817    WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
     818    WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
     819    WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
     820    if (_beginthread(MakeMainObjWin,
     821                     NULL,
     822                     245760,
     823                     MPVOID) == -1)
     824    {
     825      PostMsg(hwnd,
     826              WM_CLOSE,
     827              MPVOID,
     828              MPVOID);
     829      return 0;
     830    }
     831    else
     832      DosSleep(64);
     833
     834    pd = malloc(sizeof(PERSON1DATA));
     835    if (!pd)
     836      WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     837    else
     838    {
     839      memset(pd, 0, sizeof(PERSON1DATA));
     840      pd -> size = sizeof(PERSON1DATA);
     841      WinSetWindowPtr(hwnd, 4, (PVOID) pd);
     842    }
     843    {
     844      SWP swp;
     845      PFNWP oldproc;
     846
     847      /*
     848       * create frame children (not client children, frame children)
     849       */
     850      DosSleep(1L);
     851      WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
     852      oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
     853                                  (PFNWP) MainFrameWndProc2);
     854      if (oldproc)
     855        WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT),
     856                        0,
     857                        (PVOID) oldproc);
     858      CommonCreateMainChildren(hwnd, &swp);
     859
     860      {
     861        HWND hwndMenu;
     862
     863        hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     864                                   FID_MENU);
     865        WinSetWindowULong(hwnd,
     866                          0,
     867                          hwndMenu);
     868        SetConditionalCascade(hwndMenu,
     869                              IDM_COMMANDSMENU,
     870                              IDM_DOITYOURSELF);
     871        SetConditionalCascade(hwndMenu,
     872                              IDM_TOOLSUBMENU,
     873                              IDM_TOOLBAR);
     874      }
     875    }
     876    WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     877                                     FID_TITLEBAR),
     878                     "FM/2 Lite");
     879    FixSwitchList(WinQueryWindow(hwnd, QW_PARENT),
     880                  NULL);
     881    SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     882                               FID_SYSMENU));
     883    break;
     884
     885  case UM_SETUP:
     886    pd = WinQueryWindowPtr(hwnd, 4);
     887    if (pd)
     888    {
     889
     890      CHAR s[CCHMAXPATH];
     891      ULONG size;
     892      DIRCNRDATA *dcd;
     893      HWND hwndC;
     894      BOOL dummy = TRUE;
     895
     896      size = sizeof(BOOL);
     897      PrfQueryProfileData(fmprof,
     898                          realappname,
     899                          "FM/4 TreeUp",
     900                          (PVOID) & dummy,
     901                          &size);
     902      if (dummy)
     903      {
     904        size = sizeof(ULONG);
     905        hwndTree = StartTreeCnr(hwnd, 3);
     906        PrfQueryProfileData(fmprof,
     907                            realappname,
     908                            "FM/4 TreeWidth",
     909                            (PVOID) & TreeWidth,
     910                            &size);
     911        TreeWidth = max(TreeWidth, 80);
     912      }
     913      size = sizeof(BOOL);
     914      if (PrfQueryProfileData(fmprof,
     915                              FM3Str,
     916                              "Toolbar",
     917                              &dummy,
     918                              &size) &&
     919          size && !dummy)
     920        WinSendMsg(hwnd,
     921                   WM_COMMAND,
     922                   MPFROM2SHORT(IDM_TOOLBAR, 0),
     923                   MPVOID);
     924
     925      size = sizeof(s);
     926      *s = 0;
     927      if (PrfQueryProfileData(fmprof,
     928                              realappname,
     929                              "FM/4 Dir1",
     930                              s,
     931                              &size) &&
     932          *s)
     933        MakeValidDir(s);
    771934      else
    772         DosSleep(64);
    773 
    774       pd = malloc(sizeof(PERSON1DATA));
    775       if(!pd)
    776         WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT));
    777       else {
    778         memset(pd,0,sizeof(PERSON1DATA));
    779         pd->size = sizeof(PERSON1DATA);
    780         WinSetWindowPtr(hwnd,4,(PVOID)pd);
    781       }
    782       {
    783         SWP   swp;
    784         PFNWP oldproc;
    785 
    786         /*
    787          * create frame children (not client children, frame children)
    788          */
    789         DosSleep(1L);
    790         WinQueryWindowPos(WinQueryWindow(hwnd,QW_PARENT),&swp);
    791         oldproc = WinSubclassWindow(WinQueryWindow(hwnd,QW_PARENT),
    792                                     (PFNWP)MainFrameWndProc2);
    793         if(oldproc)
    794           WinSetWindowPtr(WinQueryWindow(hwnd,QW_PARENT),
    795                           0,
    796                           (PVOID)oldproc);
    797         CommonCreateMainChildren(hwnd,&swp);
    798 
    799         {
    800           HWND hwndMenu;
    801 
    802           hwndMenu = WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
    803                                      FID_MENU);
    804           WinSetWindowULong(hwnd,
    805                             0,
    806                             hwndMenu);
    807           SetConditionalCascade(hwndMenu,
    808                                 IDM_COMMANDSMENU,
    809                                 IDM_DOITYOURSELF);
    810           SetConditionalCascade(hwndMenu,
    811                                 IDM_TOOLSUBMENU,
    812                                 IDM_TOOLBAR);
    813         }
    814       }
    815       WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
    816                                        FID_TITLEBAR),
    817                        "FM/2 Lite");
    818       FixSwitchList(WinQueryWindow(hwnd,QW_PARENT),
    819                     NULL);
    820       SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
    821                  FID_SYSMENU));
     935        save_dir(s);
     936      pd -> hwndLastDir = pd -> hwndCurr = pd -> hwndDir1 =
     937        StartDirCnr(hwnd, s, (HWND) 0, 3);
     938      size = sizeof(s);
     939      *s = 0;
     940      if (PrfQueryProfileData(fmprof,
     941                              realappname,
     942                              "FM/4 Dir2",
     943                              s,
     944                              &size) &&
     945          *s)
     946        MakeValidDir(s);
     947      else
     948        save_dir(s);
     949      pd -> hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
     950      WinSetFocus(HWND_DESKTOP,
     951                  pd -> hwndCurr);
     952
     953      hwndC = WinWindowFromID(pd -> hwndDir1, FID_CLIENT);
     954      if (hwndC)
     955      {
     956        dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), 0);
     957        if (dcd)
     958        {
     959          size = sizeof(INT);
     960          if (PrfQueryProfileData(fmprof,
     961                                  realappname,
     962                                  "FM/4 Dir1.Sort",
     963                                  (PVOID) & dcd -> sortFlags,
     964                                  &size) &&
     965              size == sizeof(INT))
     966          {
     967            if (!dcd -> sortFlags)
     968              dcd -> sortFlags = SORT_PATHNAME;
     969          }
     970          size = sizeof(MASK);
     971          if (PrfQueryProfileData(fmprof,
     972                                  realappname,
     973                                  "FM/4 Dir1.Filter",
     974                                  (PVOID) & dcd -> mask,
     975                                  &size) &&
     976              size)
     977          {
     978            if (*dcd -> mask.szMask)
     979              WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     980                         UM_FILTER,
     981                         MPFROMP(dcd -> mask.szMask),
     982                         MPVOID);
     983          }
     984          *(dcd -> mask.prompt) = 0;
     985          size = sizeof(ULONG);
     986          if (PrfQueryProfileData(fmprof,
     987                                  realappname,
     988                                  "FM/4 Dir1.View",
     989                                  (PVOID) & dcd -> flWindowAttr,
     990                                  &size) &&
     991              size == sizeof(ULONG))
     992          {
     993
     994            CNRINFO cnri;
     995
     996            memset(&cnri, 0, sizeof(CNRINFO));
     997            cnri.cb = sizeof(CNRINFO);
     998            if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     999                           CM_QUERYCNRINFO,
     1000                           MPFROMP(&cnri),
     1001                           MPFROMLONG(sizeof(CNRINFO))))
     1002            {
     1003              cnri.flWindowAttr = dcd -> flWindowAttr;
     1004              WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     1005                         CM_SETCNRINFO,
     1006                         MPFROMP(&cnri),
     1007                         MPFROMLONG(CMA_FLWINDOWATTR));
     1008            }
     1009          }
     1010        }
     1011      }
     1012
     1013      hwndC = WinWindowFromID(pd -> hwndDir2, FID_CLIENT);
     1014      if (hwndC)
     1015      {
     1016        dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), 0);
     1017        if (dcd)
     1018        {
     1019          size = sizeof(INT);
     1020          if (PrfQueryProfileData(fmprof,
     1021                                  realappname,
     1022                                  "FM/4 Dir2.Sort",
     1023                                  (PVOID) & dcd -> sortFlags,
     1024                                  &size) &&
     1025              size == sizeof(INT))
     1026          {
     1027            if (!dcd -> sortFlags)
     1028              dcd -> sortFlags = SORT_PATHNAME;
     1029          }
     1030          size = sizeof(MASK);
     1031          if (PrfQueryProfileData(fmprof,
     1032                                  realappname,
     1033                                  "FM/4 Dir2.Filter",
     1034                                  (PVOID) & dcd -> mask,
     1035                                  &size) &&
     1036              size)
     1037          {
     1038            if (*dcd -> mask.szMask)
     1039              WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     1040                         UM_FILTER,
     1041                         MPFROMP(dcd -> mask.szMask),
     1042                         MPVOID);
     1043          }
     1044          *(dcd -> mask.prompt) = 0;
     1045          size = sizeof(ULONG);
     1046          if (PrfQueryProfileData(fmprof,
     1047                                  realappname,
     1048                                  "FM/4 Dir2.View",
     1049                                  (PVOID) & dcd -> flWindowAttr,
     1050                                  &size) &&
     1051              size == sizeof(ULONG))
     1052          {
     1053
     1054            CNRINFO cnri;
     1055
     1056            memset(&cnri, 0, sizeof(CNRINFO));
     1057            cnri.cb = sizeof(CNRINFO);
     1058            if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     1059                           CM_QUERYCNRINFO,
     1060                           MPFROMP(&cnri),
     1061                           MPFROMLONG(sizeof(CNRINFO))))
     1062            {
     1063              cnri.flWindowAttr = dcd -> flWindowAttr;
     1064              WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
     1065                         CM_SETCNRINFO,
     1066                         MPFROMP(&cnri),
     1067                         MPFROMLONG(CMA_FLWINDOWATTR));
     1068            }
     1069          }
     1070        }
     1071      }
     1072    }
     1073    {
     1074      ULONG which = 0, size = sizeof(ULONG);
     1075
     1076      if (PrfQueryProfileData(fmprof,
     1077                              realappname,
     1078                              "FM/4 Max",
     1079                              (PVOID) & which,
     1080                              &size) &&
     1081          size == sizeof(ULONG) &&
     1082          which)
     1083      {
     1084        PostMsg(hwnd,
     1085                UM_MAXIMIZE,
     1086                MPFROMLONG(((which == 1) ?
     1087                            pd -> hwndDir1 :
     1088                            pd -> hwndDir2)),
     1089                MPVOID);
     1090      }
     1091    }
     1092    PostMsg(hwnd,
     1093            UM_SIZE,
     1094            MPVOID,
     1095            MPVOID);
     1096    if (!hwndTree)
     1097      PostMsg(hwnd,
     1098              UM_BUILDDRIVES,
     1099              MPVOID,
     1100              MPVOID);
     1101    load_tools(NULL);
     1102    BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
     1103                               MAIN_TOOLS),
     1104               TRUE);
     1105    fRunning = TRUE;
     1106    return 0;
     1107
     1108  case WM_SAVEAPPLICATION:
     1109    WinStoreWindowPos(FM2Str,
     1110                      "MainWindowPos2",
     1111                      WinQueryWindow(hwnd, QW_PARENT));
     1112    pd = WinQueryWindowPtr(hwnd, 4);
     1113    if (pd)
     1114    {
     1115
     1116      CHAR s[CCHMAXPATH];
     1117      HWND hwndC;
     1118      DIRCNRDATA *dcd;
     1119      ULONG flWindowAttr;
     1120
     1121      *s = 0;
     1122      WinSendMsg(pd -> hwndDir1,
     1123                 UM_CONTAINERDIR,
     1124                 MPFROMP(s),
     1125                 MPVOID);
     1126      if (*s)
     1127      {
     1128        MakeValidDir(s);
     1129        PrfWriteProfileString(fmprof,
     1130                              realappname,
     1131                              "FM/4 Dir1",
     1132                              s);
     1133      }
     1134      *s = 0;
     1135      WinSendMsg(pd -> hwndDir2,
     1136                 UM_CONTAINERDIR,
     1137                 MPFROMP(s),
     1138                 MPVOID);
     1139      if (*s)
     1140      {
     1141        MakeValidDir(s);
     1142        PrfWriteProfileString(fmprof,
     1143                              realappname,
     1144                              "FM/4 Dir2",
     1145                              s);
     1146      }
     1147      flWindowAttr = (pd -> hwndMax == pd -> hwndDir1) ?
     1148        1 :
     1149        (pd -> hwndMax == pd -> hwndDir2) ?
     1150        2 :
     1151        0;
     1152      PrfWriteProfileData(fmprof,
     1153                          realappname,
     1154                          "FM/4 Max",
     1155                          &flWindowAttr,
     1156                          sizeof(flWindowAttr));
     1157      hwndC = WinWindowFromID(pd -> hwndDir1, FID_CLIENT);
     1158      if (hwndC)
     1159      {
     1160        dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), 0);
     1161        if (dcd)
     1162        {
     1163          flWindowAttr = dcd -> flWindowAttr;
     1164          if (!fLeaveTree && (flWindowAttr & CV_TREE))
     1165          {
     1166            flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     1167            if (dcd -> lastattr)
     1168            {
     1169              if (dcd -> lastattr & CV_TEXT)
     1170                flWindowAttr |= CV_TEXT;
     1171              else if (dcd -> lastattr & CV_DETAIL)
     1172                flWindowAttr |= CV_DETAIL;
     1173              else if (dcd -> lastattr & CV_ICON)
     1174                flWindowAttr |= CV_ICON;
     1175              else
     1176                flWindowAttr |= CV_NAME;
     1177            }
     1178            else
     1179              flWindowAttr |= CV_NAME;
     1180          }
     1181          PrfWriteProfileData(fmprof,
     1182                              realappname,
     1183                              "FM/4 Dir1.Sort",
     1184                              (PVOID) & dcd -> sortFlags,
     1185                              sizeof(INT));
     1186          PrfWriteProfileData(fmprof,
     1187                              realappname,
     1188                              "FM/4 Dir1.Filter",
     1189                              (PVOID) & dcd -> mask,
     1190                              sizeof(MASK));
     1191          PrfWriteProfileData(fmprof,
     1192                              realappname,
     1193                              "FM/4 Dir1.View",
     1194                              (PVOID) & flWindowAttr,
     1195                              sizeof(ULONG));
     1196        }
     1197      }
     1198
     1199      hwndC = WinWindowFromID(pd -> hwndDir2, FID_CLIENT);
     1200      if (hwndC)
     1201      {
     1202        dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), 0);
     1203        if (dcd)
     1204        {
     1205          flWindowAttr = dcd -> flWindowAttr;
     1206          if (!fLeaveTree && (flWindowAttr & CV_TREE))
     1207          {
     1208            flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
     1209            if (dcd -> lastattr)
     1210            {
     1211              if (dcd -> lastattr & CV_TEXT)
     1212                flWindowAttr |= CV_TEXT;
     1213              else if (dcd -> lastattr & CV_DETAIL)
     1214                flWindowAttr |= CV_DETAIL;
     1215              else if (dcd -> lastattr & CV_ICON)
     1216                flWindowAttr |= CV_ICON;
     1217              else
     1218                flWindowAttr |= CV_NAME;
     1219            }
     1220            else
     1221              flWindowAttr |= CV_NAME;
     1222          }
     1223          PrfWriteProfileData(fmprof,
     1224                              realappname,
     1225                              "FM/4 Dir2.Sort",
     1226                              (PVOID) & dcd -> sortFlags,
     1227                              sizeof(INT));
     1228          PrfWriteProfileData(fmprof,
     1229                              realappname,
     1230                              "FM/4 Dir2.Filter",
     1231                              (PVOID) & dcd -> mask,
     1232                              sizeof(MASK));
     1233          PrfWriteProfileData(fmprof,
     1234                              realappname,
     1235                              "FM/4 Dir2.View",
     1236                              (PVOID) & flWindowAttr,
     1237                              sizeof(ULONG));
     1238        }
     1239      }
     1240    }
     1241    break;
     1242  }
     1243  return WinDefWindowProc(hwnd, msg, mp1, mp2);
     1244}
     1245
     1246MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     1247{
     1248
     1249  PERSON1DATA *pd;
     1250
     1251  switch (msg)
     1252  {
     1253  case WM_SAVEAPPLICATION:
     1254  case UM_SETUP:
     1255  case WM_CREATE:
     1256    return MainWMOnce2(hwnd, msg, mp1, mp2);
     1257
     1258  case UM_THREADUSE:
     1259  case UM_LOADFILE:
     1260  case UM_BUILDDRIVES:
     1261    return CommonMainWndProc(hwnd, msg, mp1, mp2);
     1262
     1263  case UM_SETUP2:
     1264    pd = WinQueryWindowPtr(hwnd, 4);
     1265    if (pd)
     1266    {
     1267      if (mp1)
     1268      {
     1269        if (pd -> hwndDir1 &&
     1270            (!pd -> hwndMax || pd -> hwndMax == pd -> hwndDir1))
     1271          BoxWindow(pd -> hwndDir1,
     1272                    (HPS) 0,
     1273                    CLR_PALEGRAY);
     1274        if (pd -> hwndDir2 &&
     1275            (!pd -> hwndMax || pd -> hwndMax == pd -> hwndDir2))
     1276          BoxWindow(pd -> hwndDir2,
     1277                    (HPS) 0,
     1278                    CLR_PALEGRAY);
     1279        if (hwndTree)
     1280          BoxWindow(hwndTree,
     1281                    (HPS) 0,
     1282                    CLR_PALEGRAY);
     1283      }
     1284      else
     1285      {
     1286        if (hwndTree)
     1287          BoxWindow(hwndTree,
     1288                    (HPS) 0,
     1289                    (pd -> hwndCurr == hwndTree) ?
     1290                    CLR_RED :
     1291                    CLR_WHITE);
     1292        if (!pd -> hwndMax ||
     1293            pd -> hwndMax == pd -> hwndDir1)
     1294          BoxWindow(pd -> hwndDir1,
     1295                    (HPS) 0,
     1296                    (pd -> hwndDir1 == pd -> hwndCurr) ?
     1297                    CLR_RED :
     1298                    (pd -> hwndDir1 == pd -> hwndLastDir) ?
     1299                    CLR_DARKRED :
     1300                    CLR_PALEGRAY);
     1301        if (!pd -> hwndMax ||
     1302            pd -> hwndMax == pd -> hwndDir2)
     1303          BoxWindow(pd -> hwndDir2,
     1304                    (HPS) 0,
     1305                    (pd -> hwndDir2 == pd -> hwndCurr) ?
     1306                    CLR_RED :
     1307                    (pd -> hwndDir2 == pd -> hwndLastDir) ?
     1308                    CLR_DARKRED :
     1309                    CLR_PALEGRAY);
     1310      }
     1311    }
     1312    return 0;
     1313
     1314  case WM_BUTTON1DOWN:
     1315    shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
     1316    if (hwndTree)
     1317    {
     1318
     1319      SWP swp;
     1320
     1321      WinQueryWindowPos(hwndTree, &swp);
     1322      if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
     1323          SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
     1324      {
     1325
     1326        SWP swpC;
     1327        TRACKINFO track;
     1328
     1329        WinQueryWindowPos(hwnd, &swpC);
     1330        track.cxBorder = 4;
     1331        track.cyBorder = 4;
     1332        track.cxGrid = 1;
     1333        track.cyGrid = 1;
     1334        track.cxKeyboard = 8;
     1335        track.cyKeyboard = 8;
     1336        track.rclTrack.yBottom = 2;
     1337        track.rclTrack.yTop = swpC.cy - 4;
     1338        track.rclTrack.xLeft = 2;
     1339        track.rclTrack.xRight = swp.x + swp.cx + 2;
     1340        track.rclBoundary = track.rclTrack;
     1341        track.rclBoundary.xRight = swpC.cx - 80;
     1342        track.ptlMinTrackSize.x = 80;
     1343        track.ptlMinTrackSize.y = swpC.cy - 4;
     1344        track.ptlMaxTrackSize.x = swpC.cx - 80;
     1345        track.ptlMaxTrackSize.y = swpC.cy - 4;
     1346        track.fs = TF_RIGHT;
     1347        if (WinTrackRect(hwnd, (HPS) 0, &track))
     1348        {
     1349          TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
     1350          PrfWriteProfileData(fmprof,
     1351                              realappname,
     1352                              "FM/4 TreeWidth",
     1353                              &TreeWidth,
     1354                              sizeof(ULONG));
     1355          WinSendMsg(hwnd,
     1356                     UM_SETUP2,
     1357                     MPFROMLONG(1),
     1358                     MPVOID);
     1359          PostMsg(hwnd,
     1360                  UM_SIZE,
     1361                  MPVOID,
     1362                  MPVOID);
     1363        }
     1364        return (MRESULT) TRUE;
     1365      }
     1366    }
     1367    break;
     1368
     1369  case WM_MOUSEMOVE:
     1370    shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
     1371    if (hwndTree)
     1372    {
     1373
     1374      SWP swp;
     1375
     1376      if (WinQueryWindowPos(hwndTree, &swp))
     1377      {
     1378        if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
     1379            SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
     1380          WinSetPointer(HWND_DESKTOP, hptrEW);
     1381        else
     1382          WinSetPointer(HWND_DESKTOP, hptrArrow);
     1383      }
     1384      else
     1385        WinSetPointer(HWND_DESKTOP, hptrArrow);
     1386    }
     1387    return (MRESULT) TRUE;
     1388
     1389  case WM_BUTTON1UP:
     1390  case WM_BUTTON2UP:
     1391  case WM_BUTTON3UP:
     1392  case WM_CHAR:
     1393    shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
     1394    break;
     1395
     1396  case UM_ADVISEFOCUS:
     1397    pd = WinQueryWindowPtr(hwnd, 4);
     1398    if (mp1 &&
     1399        pd &&
     1400        (HWND) mp1 != pd -> hwndCurr)
     1401    {
     1402      if ((HWND) mp1 != hwndTree)
     1403        pd -> hwndLastDir = (HWND) mp1;
     1404      pd -> hwndCurr = (HWND) mp1;
     1405      WinSendMsg(hwnd,
     1406                 UM_SETUP2,
     1407                 MPVOID,
     1408                 MPVOID);
     1409    }
     1410    return 0;
     1411
     1412  case UM_MAXIMIZE:
     1413    if (mp1)
     1414    {
     1415      pd = WinQueryWindowPtr(hwnd, 4);
     1416      if (pd)
     1417      {
     1418        WinSendMsg(hwnd,
     1419                   UM_SETUP2,
     1420                   MPFROMLONG(1),
     1421                   MPVOID);
     1422        if (pd -> hwndMax != (HWND) mp1)
     1423        {
     1424          pd -> hwndMax = (HWND) mp1;
     1425          WinSetFocus(HWND_DESKTOP,
     1426                      pd -> hwndMax);
     1427        }
     1428        else
     1429          pd -> hwndMax = (HWND) 0;
     1430        PostMsg(hwnd,
     1431                UM_SIZE,
     1432                MPVOID,
     1433                MPVOID);
     1434      }
     1435    }
     1436    return 0;
     1437
     1438  case WM_INITMENU:
     1439    switch (SHORT1FROMMP(mp1))
     1440    {
     1441    case IDM_FILESMENU:
     1442    case IDM_VIEWSMENU:
     1443    case IDM_DETAILSSETUP:
     1444    case IDM_COMMANDSMENU:
     1445    case IDM_SORTSUBMENU:
     1446      pd = WinQueryWindowPtr(hwnd, 4);
     1447      if (pd)
     1448        WinSendMsg(pd -> hwndCurr,
     1449                   UM_INITMENU,
     1450                   mp1,
     1451                   mp2);
    8221452      break;
    823 
    824     case UM_SETUP:
    825       pd = WinQueryWindowPtr(hwnd,4);
    826       if(pd) {
    827 
    828         CHAR        s[CCHMAXPATH];
    829         ULONG       size;
    830         DIRCNRDATA *dcd;
    831         HWND        hwndC;
    832         BOOL        dummy = TRUE;
    833 
    834         size  = sizeof(BOOL);
    835         PrfQueryProfileData(fmprof,
    836                             realappname,
    837                             "FM/4 TreeUp",
    838                             (PVOID)&dummy,
    839                             &size);
    840         if(dummy) {
    841           size = sizeof(ULONG);
    842           hwndTree = StartTreeCnr(hwnd,3);
    843           PrfQueryProfileData(fmprof,
    844                               realappname,
    845                               "FM/4 TreeWidth",
    846                               (PVOID)&TreeWidth,
    847                               &size);
    848           TreeWidth = max(TreeWidth,80);
    849         }
    850         size = sizeof(BOOL);
    851         if(PrfQueryProfileData(fmprof,
    852                                FM3Str,
    853                                "Toolbar",
    854                                &dummy,
    855                                &size) &&
    856            size && !dummy)
    857           WinSendMsg(hwnd,
    858                      WM_COMMAND,
    859                      MPFROM2SHORT(IDM_TOOLBAR,0),
    860                      MPVOID);
    861 
    862         size = sizeof(s);
    863         *s = 0;
    864         if(PrfQueryProfileData(fmprof,
    865                                realappname,
    866                                "FM/4 Dir1",
    867                                s,
    868                                &size) &&
    869            *s)
    870           MakeValidDir(s);
    871         else
    872           save_dir(s);
    873         pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
    874           StartDirCnr(hwnd,s,(HWND)0,3);
    875         size = sizeof(s);
    876         *s = 0;
    877         if(PrfQueryProfileData(fmprof,
    878                                realappname,
    879                                "FM/4 Dir2",
    880                                s,
    881                                &size) &&
    882            *s)
    883           MakeValidDir(s);
    884         else
    885           save_dir(s);
    886         pd->hwndDir2 = StartDirCnr(hwnd,s,(HWND)0,3);
    887         WinSetFocus(HWND_DESKTOP,
    888                     pd->hwndCurr);
    889 
    890         hwndC = WinWindowFromID(pd->hwndDir1,FID_CLIENT);
    891         if(hwndC) {
    892           dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR),0);
    893           if(dcd) {
    894             size = sizeof(INT);
    895             if(PrfQueryProfileData(fmprof,
    896                                    realappname,
    897                                    "FM/4 Dir1.Sort",
    898                                    (PVOID)&dcd->sortFlags,
    899                                    &size) &&
    900                size == sizeof(INT)) {
    901               if(!dcd->sortFlags)
    902                 dcd->sortFlags = SORT_PATHNAME;
    903             }
    904             size = sizeof(MASK);
    905             if(PrfQueryProfileData(fmprof,
    906                                    realappname,
    907                                    "FM/4 Dir1.Filter",
    908                                    (PVOID)&dcd->mask,
    909                                    &size) &&
    910                size) {
    911               if(*dcd->mask.szMask)
    912                 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    913                            UM_FILTER,
    914                            MPFROMP(dcd->mask.szMask),
    915                            MPVOID);
    916             }
    917             *(dcd->mask.prompt) = 0;
    918             size = sizeof(ULONG);
    919             if(PrfQueryProfileData(fmprof,
    920                                    realappname,
    921                                    "FM/4 Dir1.View",
    922                                    (PVOID)&dcd->flWindowAttr,
    923                                    &size) &&
    924                size == sizeof(ULONG)) {
    925 
    926               CNRINFO cnri;
    927 
    928               memset(&cnri,0,sizeof(CNRINFO));
    929               cnri.cb = sizeof(CNRINFO);
    930               if(WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    931                             CM_QUERYCNRINFO,
    932                             MPFROMP(&cnri),
    933                             MPFROMLONG(sizeof(CNRINFO)))) {
    934                 cnri.flWindowAttr = dcd->flWindowAttr;
    935                 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    936                            CM_SETCNRINFO,
    937                            MPFROMP(&cnri),
    938                            MPFROMLONG(CMA_FLWINDOWATTR));
    939               }
    940             }
    941           }
    942         }
    943 
    944         hwndC = WinWindowFromID(pd->hwndDir2,FID_CLIENT);
    945         if(hwndC) {
    946           dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR),0);
    947           if(dcd) {
    948             size = sizeof(INT);
    949             if(PrfQueryProfileData(fmprof,
    950                                    realappname,
    951                                    "FM/4 Dir2.Sort",
    952                                    (PVOID)&dcd->sortFlags,
    953                                    &size) &&
    954                size == sizeof(INT)) {
    955               if(!dcd->sortFlags)
    956                 dcd->sortFlags = SORT_PATHNAME;
    957             }
    958             size = sizeof(MASK);
    959             if(PrfQueryProfileData(fmprof,
    960                                    realappname,
    961                                    "FM/4 Dir2.Filter",
    962                                    (PVOID)&dcd->mask,
    963                                    &size) &&
    964                size) {
    965               if(*dcd->mask.szMask)
    966                 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    967                            UM_FILTER,
    968                            MPFROMP(dcd->mask.szMask),
    969                            MPVOID);
    970             }
    971             *(dcd->mask.prompt) = 0;
    972             size = sizeof(ULONG);
    973             if(PrfQueryProfileData(fmprof,
    974                                    realappname,
    975                                    "FM/4 Dir2.View",
    976                                    (PVOID)&dcd->flWindowAttr,
    977                                    &size) &&
    978                size == sizeof(ULONG)) {
    979 
    980               CNRINFO cnri;
    981 
    982               memset(&cnri,0,sizeof(CNRINFO));
    983               cnri.cb = sizeof(CNRINFO);
    984               if(WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    985                             CM_QUERYCNRINFO,
    986                             MPFROMP(&cnri),
    987                             MPFROMLONG(sizeof(CNRINFO)))) {
    988                 cnri.flWindowAttr = dcd->flWindowAttr;
    989                 WinSendMsg(WinWindowFromID(hwndC,DIR_CNR),
    990                            CM_SETCNRINFO,
    991                            MPFROMP(&cnri),
    992                            MPFROMLONG(CMA_FLWINDOWATTR));
    993               }
    994             }
    995           }
    996         }
    997       }
    998       {
    999         ULONG which = 0,size = sizeof(ULONG);
    1000 
    1001         if(PrfQueryProfileData(fmprof,
    1002                                realappname,
    1003                                "FM/4 Max",
    1004                                (PVOID)&which,
    1005                                &size) &&
    1006            size == sizeof(ULONG) &&
    1007            which) {
    1008           PostMsg(hwnd,
    1009                   UM_MAXIMIZE,
    1010                   MPFROMLONG(((which == 1) ?
    1011                               pd->hwndDir1 :
    1012                               pd->hwndDir2)),
    1013                   MPVOID);
    1014         }
    1015       }
     1453    case IDM_CONFIGMENU:
     1454      WinCheckMenuItem((HWND) mp2,
     1455                       IDM_TOOLSUBMENU,
     1456                       fToolbar);
     1457      WinCheckMenuItem((HWND) mp2,
     1458                       IDM_AUTOVIEW,
     1459                       fAutoView);
     1460      break;
     1461    case IDM_TOOLSUBMENU:
     1462      WinCheckMenuItem((HWND) mp2,
     1463                       IDM_TOOLBAR,
     1464                       fToolbar);
     1465      WinCheckMenuItem((HWND) mp2,
     1466                       IDM_TEXTTOOLS,
     1467                       fTextTools);
     1468      WinCheckMenuItem((HWND) mp2,
     1469                       IDM_TOOLTITLES,
     1470                       fToolTitles);
     1471      break;
     1472    case IDM_WINDOWSMENU:
     1473      WinCheckMenuItem((HWND) mp2,
     1474                       IDM_VTREE,
     1475                       (hwndTree != (HWND) 0));
     1476      WinCheckMenuItem((HWND) mp2,
     1477                       IDM_TILEBACKWARDS,
     1478                       fTileBackwards);
     1479      SetupWinList((HWND) mp2,
     1480                   hwnd,
     1481                   WinQueryWindow(hwnd, QW_PARENT));
     1482      break;
     1483    }
     1484    break;
     1485
     1486  case WM_SETFOCUS:
     1487    if (mp2)
    10161488      PostMsg(hwnd,
    1017               UM_SIZE,
    1018               MPVOID,
    1019               MPVOID);
    1020       if(!hwndTree)
    1021         PostMsg(hwnd,
    1022                 UM_BUILDDRIVES,
    1023                 MPVOID,
    1024                 MPVOID);
    1025       load_tools(NULL);
    1026       BuildTools(WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),
    1027                                  MAIN_TOOLS),
    1028                  TRUE);
    1029       fRunning = TRUE;
     1489              UM_FOCUSME,
     1490              MPVOID,
     1491              MPVOID);
     1492    break;
     1493
     1494  case UM_FOCUSME:
     1495    pd = WinQueryWindowPtr(hwnd, 4);
     1496    if (pd)
     1497      WinSetFocus(HWND_DESKTOP,
     1498                  pd -> hwndCurr);
     1499    return 0;
     1500
     1501  case UM_RESCAN:
     1502    return 0;
     1503
     1504  case UM_SIZE:
     1505    {
     1506      SWP swp;
     1507
     1508      if (WinQueryWindowPos(hwnd, &swp))
     1509      {
     1510        mp1 = MPFROM2SHORT(swp.cx, swp.cy);
     1511        mp2 = MPFROM2SHORT(swp.cx, swp.cy);
     1512      }
     1513      else
     1514        return 0;
     1515    }
     1516    /* intentional fallthru */
     1517  case WM_SIZE:
     1518    pd = WinQueryWindowPtr(hwnd, 4);
     1519    if (mp1 &&
     1520        mp2 &&
     1521        pd &&
     1522        pd -> hwndDir1 &&
     1523        pd -> hwndDir2)
     1524    {
     1525      if (hwndTree)
     1526        WinSetWindowPos(hwndTree,
     1527                        HWND_TOP,
     1528                        2,
     1529                        2,
     1530                        TreeWidth - 4,
     1531                        SHORT2FROMMP(mp2) - 4,
     1532                        SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1533      else
     1534        TreeWidth = 0;
     1535      if (!pd -> hwndMax)
     1536      {
     1537        if (fTileBackwards)
     1538        {
     1539          WinSetWindowPos(pd -> hwndDir1, HWND_TOP,
     1540                          (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
     1541                           TreeWidth) + 2,
     1542                          2,
     1543                          ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
     1544                          SHORT2FROMMP(mp2) - 4,
     1545                          SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1546          WinSetWindowPos(pd -> hwndDir2, HWND_TOP,
     1547                          TreeWidth + 2,
     1548                          2,
     1549                          ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
     1550                          SHORT2FROMMP(mp2) - 4,
     1551                          SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1552        }
     1553        else
     1554        {
     1555          WinSetWindowPos(pd -> hwndDir1, HWND_TOP,
     1556                          TreeWidth + 2,
     1557                          2,
     1558                          (SHORT1FROMMP(mp2) - TreeWidth) - 4,
     1559                          (SHORT2FROMMP(mp2) / 2) - 4,
     1560                          SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1561          WinSetWindowPos(pd -> hwndDir2, HWND_TOP,
     1562                          TreeWidth + 2,
     1563                          (SHORT2FROMMP(mp2) / 2) + 2,
     1564                          (SHORT1FROMMP(mp2) - TreeWidth) - 4,
     1565                          (SHORT2FROMMP(mp2) / 2) - 4,
     1566                          SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1567        }
     1568      }
     1569      else
     1570      {
     1571
     1572        HWND hwndOther;
     1573
     1574        WinSetWindowPos(pd -> hwndMax, HWND_TOP,
     1575                        TreeWidth + 2,
     1576                        2,
     1577                        (SHORT1FROMMP(mp2) - TreeWidth) - 4,
     1578                        SHORT2FROMMP(mp2) - 4,
     1579                        SWP_SHOW | SWP_MOVE | SWP_SIZE);
     1580        hwndOther = (pd -> hwndMax == pd -> hwndDir1) ?
     1581          pd -> hwndDir2 : pd -> hwndDir1;
     1582        WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
     1583      }
     1584      WinSendMsg(hwnd,
     1585                 UM_SETUP2,
     1586                 MPVOID,
     1587                 MPVOID);
     1588    }
     1589    if (msg == UM_SIZE)
    10301590      return 0;
    1031 
    1032     case WM_SAVEAPPLICATION:
    1033       WinStoreWindowPos(FM2Str,
    1034                         "MainWindowPos2",
    1035                         WinQueryWindow(hwnd,QW_PARENT));
    1036       pd = WinQueryWindowPtr(hwnd,4);
    1037       if(pd) {
    1038 
    1039         CHAR        s[CCHMAXPATH];
    1040         HWND        hwndC;
    1041         DIRCNRDATA *dcd;
    1042         ULONG       flWindowAttr;
    1043 
    1044         *s = 0;
    1045         WinSendMsg(pd->hwndDir1,
    1046                    UM_CONTAINERDIR,
    1047                    MPFROMP(s),
    1048                    MPVOID);
    1049         if(*s) {
    1050           MakeValidDir(s);
    1051           PrfWriteProfileString(fmprof,
    1052                                 realappname,
    1053                                 "FM/4 Dir1",
    1054                                 s);
    1055         }
    1056         *s = 0;
    1057         WinSendMsg(pd->hwndDir2,
    1058                    UM_CONTAINERDIR,
    1059                    MPFROMP(s),
    1060                    MPVOID);
    1061         if(*s) {
    1062           MakeValidDir(s);
    1063           PrfWriteProfileString(fmprof,
    1064                                 realappname,
    1065                                 "FM/4 Dir2",
    1066                                 s);
    1067         }
    1068         flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
    1069                  1 :
    1070                  (pd->hwndMax == pd->hwndDir2) ?
    1071                   2 :
    1072                   0;
    1073         PrfWriteProfileData(fmprof,
    1074                             realappname,
    1075                             "FM/4 Max",
    1076                             &flWindowAttr,
    1077                             sizeof(flWindowAttr));
    1078         hwndC = WinWindowFromID(pd->hwndDir1,FID_CLIENT);
    1079         if(hwndC) {
    1080           dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR),0);
    1081           if(dcd) {
    1082             flWindowAttr = dcd->flWindowAttr;
    1083             if(!fLeaveTree && (flWindowAttr & CV_TREE)) {
    1084               flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    1085               if(dcd->lastattr) {
    1086                 if(dcd->lastattr & CV_TEXT)
    1087                   flWindowAttr |= CV_TEXT;
    1088                 else if(dcd->lastattr & CV_DETAIL)
    1089                   flWindowAttr |= CV_DETAIL;
    1090                 else if(dcd->lastattr & CV_ICON)
    1091                   flWindowAttr |= CV_ICON;
    1092                 else
    1093                   flWindowAttr |= CV_NAME;
    1094               }
    1095               else
    1096                 flWindowAttr |= CV_NAME;
    1097             }
    1098             PrfWriteProfileData(fmprof,
    1099                                 realappname,
    1100                                 "FM/4 Dir1.Sort",
    1101                                 (PVOID)&dcd->sortFlags,
    1102                                 sizeof(INT));
    1103             PrfWriteProfileData(fmprof,
    1104                                 realappname,
    1105                                 "FM/4 Dir1.Filter",
    1106                                 (PVOID)&dcd->mask,
    1107                                 sizeof(MASK));
    1108             PrfWriteProfileData(fmprof,
    1109                                 realappname,
    1110                                 "FM/4 Dir1.View",
    1111                                 (PVOID)&flWindowAttr,
    1112                                 sizeof(ULONG));
    1113           }
    1114         }
    1115 
    1116         hwndC = WinWindowFromID(pd->hwndDir2,FID_CLIENT);
    1117         if(hwndC) {
    1118           dcd = WinQueryWindowPtr(WinWindowFromID(hwndC,DIR_CNR),0);
    1119           if(dcd) {
    1120             flWindowAttr = dcd->flWindowAttr;
    1121             if(!fLeaveTree && (flWindowAttr & CV_TREE)) {
    1122               flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
    1123               if(dcd->lastattr) {
    1124                 if(dcd->lastattr & CV_TEXT)
    1125                   flWindowAttr |= CV_TEXT;
    1126                 else if(dcd->lastattr & CV_DETAIL)
    1127                   flWindowAttr |= CV_DETAIL;
    1128                 else if(dcd->lastattr & CV_ICON)
    1129                   flWindowAttr |= CV_ICON;
    1130                 else
    1131                   flWindowAttr |= CV_NAME;
    1132               }
    1133               else
    1134                 flWindowAttr |= CV_NAME;
    1135             }
    1136             PrfWriteProfileData(fmprof,
    1137                                 realappname,
    1138                                 "FM/4 Dir2.Sort",
    1139                                 (PVOID)&dcd->sortFlags,
    1140                                 sizeof(INT));
    1141             PrfWriteProfileData(fmprof,
    1142                                 realappname,
    1143                                 "FM/4 Dir2.Filter",
    1144                                 (PVOID)&dcd->mask,
    1145                                 sizeof(MASK));
    1146             PrfWriteProfileData(fmprof,
    1147                                 realappname,
    1148                                 "FM/4 Dir2.View",
    1149                                 (PVOID)&flWindowAttr,
    1150                                 sizeof(ULONG));
    1151           }
    1152         }
    1153       }
    1154       break;
     1591    break;
     1592
     1593  case WM_ERASEBACKGROUND:
     1594    WinFillRect((HPS) mp1,
     1595                (PRECTL) mp2,
     1596                0x00d0d0d0);
     1597    return 0;
     1598
     1599  case WM_PAINT:
     1600    {
     1601      HPS hps;
     1602      RECTL rcl;
     1603
     1604      hps = WinBeginPaint(hwnd,
     1605                          NULLHANDLE,
     1606                          NULL);
     1607      if (hps)
     1608      {
     1609        WinQueryWindowRect(hwnd, &rcl);
     1610        WinFillRect(hps,
     1611                    (PRECTL) & rcl,
     1612                    CLR_PALEGRAY);
     1613        WinEndPaint(hps);
     1614        WinSendMsg(hwnd,
     1615                   UM_SETUP2,
     1616                   MPVOID,
     1617                   MPVOID);
     1618      }
     1619    }
     1620    break;
     1621
     1622  case UM_COMMAND:
     1623  case WM_COMMAND:
     1624    return MainWMCommand2(hwnd, msg, mp1, mp2);
     1625
     1626  case WM_CLOSE:
     1627    fAmClosing = TRUE;
     1628    WinSendMsg(hwnd,
     1629               WM_SAVEAPPLICATION,
     1630               MPVOID,
     1631               MPVOID);
     1632    CloseChildren(hwnd);
     1633    PostMsg(hwnd,
     1634            UM_CLOSE,
     1635            MPVOID,
     1636            MPVOID);
     1637    DosSleep(1L);
     1638    return 0;
     1639
     1640  case UM_CLOSE:
     1641    WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
     1642    return 0;
     1643
     1644  case WM_DESTROY:
     1645    hwndMain = (HWND) 0;
     1646    pd = WinQueryWindowPtr(hwnd, 4);
     1647    if (pd)
     1648      free(pd);
     1649    if (!PostMsg((HWND) 0,
     1650                 WM_QUIT,
     1651                 MPVOID,
     1652                 MPVOID))
     1653      WinSendMsg((HWND) 0,
     1654                 WM_QUIT,
     1655                 MPVOID,
     1656                 MPVOID);
     1657    break;
    11551658  }
    1156   return WinDefWindowProc(hwnd,msg,mp1,mp2);
     1659  return WinDefWindowProc(hwnd, msg, mp1, mp2);
    11571660}
    11581661
    1159 
    1160 MRESULT EXPENTRY MainWndProc2 (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    1161 
    1162   PERSON1DATA *pd;
    1163 
    1164   switch(msg) {
    1165     case WM_SAVEAPPLICATION:
    1166     case UM_SETUP:
    1167     case WM_CREATE:
    1168       return MainWMOnce2(hwnd,msg,mp1,mp2);
    1169 
    1170     case UM_THREADUSE:
    1171     case UM_LOADFILE:
    1172     case UM_BUILDDRIVES:
    1173       return CommonMainWndProc(hwnd,msg,mp1,mp2);
    1174 
    1175     case UM_SETUP2:
    1176       pd = WinQueryWindowPtr(hwnd,4);
    1177       if(pd) {
    1178         if(mp1) {
    1179           if(pd->hwndDir1 &&
    1180              (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
    1181             BoxWindow(pd->hwndDir1,
    1182                       (HPS)0,
    1183                       CLR_PALEGRAY);
    1184           if(pd->hwndDir2 &&
    1185              (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
    1186             BoxWindow(pd->hwndDir2,
    1187                       (HPS)0,
    1188                       CLR_PALEGRAY);
    1189           if(hwndTree)
    1190             BoxWindow(hwndTree,
    1191                       (HPS)0,
    1192                       CLR_PALEGRAY);
    1193         }
    1194         else {
    1195           if(hwndTree)
    1196             BoxWindow(hwndTree,
    1197                       (HPS)0,
    1198                       (pd->hwndCurr == hwndTree) ?
    1199                        CLR_RED :
    1200                        CLR_WHITE);
    1201           if(!pd->hwndMax ||
    1202              pd->hwndMax == pd->hwndDir1)
    1203             BoxWindow(pd->hwndDir1,
    1204                       (HPS)0,
    1205                       (pd->hwndDir1 == pd->hwndCurr) ?
    1206                        CLR_RED :
    1207                        (pd->hwndDir1 == pd->hwndLastDir) ?
    1208                         CLR_DARKRED :
    1209                         CLR_PALEGRAY);
    1210           if(!pd->hwndMax ||
    1211              pd->hwndMax == pd->hwndDir2)
    1212             BoxWindow(pd->hwndDir2,
    1213                       (HPS)0,
    1214                       (pd->hwndDir2 == pd->hwndCurr) ?
    1215                        CLR_RED :
    1216                        (pd->hwndDir2 == pd->hwndLastDir) ?
    1217                         CLR_DARKRED :
    1218                         CLR_PALEGRAY);
    1219         }
    1220       }
    1221       return 0;
    1222 
    1223     case WM_BUTTON1DOWN:
    1224       shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
    1225       if(hwndTree) {
    1226 
    1227         SWP swp;
    1228 
    1229         WinQueryWindowPos(hwndTree,&swp);
    1230         if(SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
    1231            SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
    1232 
    1233           SWP       swpC;
    1234           TRACKINFO track;
    1235 
    1236           WinQueryWindowPos(hwnd,&swpC);
    1237           track.cxBorder = 4;
    1238           track.cyBorder = 4;
    1239           track.cxGrid = 1;
    1240           track.cyGrid = 1;
    1241           track.cxKeyboard = 8;
    1242           track.cyKeyboard = 8;
    1243           track.rclTrack.yBottom = 2;
    1244           track.rclTrack.yTop = swpC.cy - 4;
    1245           track.rclTrack.xLeft = 2;
    1246           track.rclTrack.xRight = swp.x + swp.cx + 2;
    1247           track.rclBoundary = track.rclTrack;
    1248           track.rclBoundary.xRight = swpC.cx - 80;
    1249           track.ptlMinTrackSize.x = 80;
    1250           track.ptlMinTrackSize.y = swpC.cy - 4;
    1251           track.ptlMaxTrackSize.x = swpC.cx - 80;
    1252           track.ptlMaxTrackSize.y = swpC.cy - 4;
    1253           track.fs = TF_RIGHT;
    1254           if(WinTrackRect(hwnd,(HPS)0,&track)) {
    1255             TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
    1256             PrfWriteProfileData(fmprof,
    1257                                 realappname,
    1258                                 "FM/4 TreeWidth",
    1259                                 &TreeWidth,
    1260                                 sizeof(ULONG));
    1261             WinSendMsg(hwnd,
    1262                        UM_SETUP2,
    1263                        MPFROMLONG(1),
    1264                        MPVOID);
    1265             PostMsg(hwnd,
    1266                     UM_SIZE,
    1267                     MPVOID,
    1268                     MPVOID);
    1269           }
    1270           return (MRESULT)TRUE;
    1271         }
    1272       }
    1273       break;
    1274 
    1275     case WM_MOUSEMOVE:
    1276       shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
    1277       if(hwndTree) {
    1278 
    1279         SWP swp;
    1280 
    1281         if(WinQueryWindowPos(hwndTree,&swp)) {
    1282           if(SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
    1283              SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
    1284             WinSetPointer(HWND_DESKTOP,hptrEW);
    1285           else
    1286             WinSetPointer(HWND_DESKTOP,hptrArrow);
    1287         }
    1288         else
    1289           WinSetPointer(HWND_DESKTOP,hptrArrow);
    1290       }
    1291       return (MRESULT)TRUE;
    1292 
    1293     case WM_BUTTON1UP:
    1294     case WM_BUTTON2UP:
    1295     case WM_BUTTON3UP:
    1296     case WM_CHAR:
    1297       shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
    1298       break;
    1299 
    1300     case UM_ADVISEFOCUS:
    1301       pd = WinQueryWindowPtr(hwnd,4);
    1302       if(mp1 &&
    1303          pd &&
    1304          (HWND)mp1 != pd->hwndCurr) {
    1305         if((HWND)mp1 != hwndTree)
    1306           pd->hwndLastDir = (HWND)mp1;
    1307         pd->hwndCurr = (HWND)mp1;
    1308         WinSendMsg(hwnd,
    1309                    UM_SETUP2,
    1310                    MPVOID,
    1311                    MPVOID);
    1312       }
    1313       return 0;
    1314 
    1315     case UM_MAXIMIZE:
    1316       if(mp1) {
    1317         pd = WinQueryWindowPtr(hwnd,4);
    1318         if(pd) {
    1319           WinSendMsg(hwnd,
    1320                      UM_SETUP2,
    1321                      MPFROMLONG(1),
    1322                      MPVOID);
    1323           if(pd->hwndMax != (HWND)mp1) {
    1324             pd->hwndMax = (HWND)mp1;
    1325             WinSetFocus(HWND_DESKTOP,
    1326                         pd->hwndMax);
    1327           }
    1328           else
    1329             pd->hwndMax = (HWND)0;
    1330           PostMsg(hwnd,
    1331                   UM_SIZE,
    1332                   MPVOID,
    1333                   MPVOID);
    1334         }
    1335       }
    1336       return 0;
    1337 
    1338     case WM_INITMENU:
    1339       switch(SHORT1FROMMP(mp1)) {
    1340         case IDM_FILESMENU:
    1341         case IDM_VIEWSMENU:
    1342         case IDM_DETAILSSETUP:
    1343         case IDM_COMMANDSMENU:
    1344         case IDM_SORTSUBMENU:
    1345           pd = WinQueryWindowPtr(hwnd,4);
    1346           if(pd)
    1347             WinSendMsg(pd->hwndCurr,
    1348                        UM_INITMENU,
    1349                        mp1,
    1350                        mp2);
    1351           break;
    1352         case IDM_CONFIGMENU:
    1353           WinCheckMenuItem((HWND)mp2,
    1354                            IDM_TOOLSUBMENU,
    1355                            fToolbar);
    1356           WinCheckMenuItem((HWND)mp2,
    1357                            IDM_AUTOVIEW,
    1358                            fAutoView);
    1359           break;
    1360         case IDM_TOOLSUBMENU:
    1361           WinCheckMenuItem((HWND)mp2,
    1362                            IDM_TOOLBAR,
    1363                            fToolbar);
    1364           WinCheckMenuItem((HWND)mp2,
    1365                            IDM_TEXTTOOLS,
    1366                            fTextTools);
    1367           WinCheckMenuItem((HWND)mp2,
    1368                            IDM_TOOLTITLES,
    1369                            fToolTitles);
    1370           break;
    1371         case IDM_WINDOWSMENU:
    1372           WinCheckMenuItem((HWND)mp2,
    1373                            IDM_VTREE,
    1374                            (hwndTree != (HWND)0));
    1375           WinCheckMenuItem((HWND)mp2,
    1376                            IDM_TILEBACKWARDS,
    1377                            fTileBackwards);
    1378           SetupWinList((HWND)mp2,
    1379                        hwnd,
    1380                        WinQueryWindow(hwnd,QW_PARENT));
    1381           break;
    1382       }
    1383       break;
    1384 
    1385     case WM_SETFOCUS:
    1386       if(mp2)
    1387         PostMsg(hwnd,
    1388                 UM_FOCUSME,
    1389                 MPVOID,
    1390                 MPVOID);
    1391       break;
    1392 
    1393     case UM_FOCUSME:
    1394       pd = WinQueryWindowPtr(hwnd,4);
    1395       if(pd)
    1396         WinSetFocus(HWND_DESKTOP,
    1397                     pd->hwndCurr);
    1398       return 0;
    1399 
    1400     case UM_RESCAN:
    1401       return 0;
    1402 
    1403     case UM_SIZE:
    1404       {
    1405         SWP swp;
    1406 
    1407         if(WinQueryWindowPos(hwnd,&swp)) {
    1408           mp1 = MPFROM2SHORT(swp.cx,swp.cy);
    1409           mp2 = MPFROM2SHORT(swp.cx,swp.cy);
    1410         }
    1411         else
    1412           return 0;
    1413       }
    1414       /* intentional fallthru */
    1415     case WM_SIZE:
    1416       pd = WinQueryWindowPtr(hwnd,4);
    1417       if(mp1 &&
    1418          mp2 &&
    1419          pd &&
    1420          pd->hwndDir1 &&
    1421          pd->hwndDir2) {
    1422         if(hwndTree)
    1423           WinSetWindowPos(hwndTree,
    1424                           HWND_TOP,
    1425                           2,
    1426                           2,
    1427                           TreeWidth - 4,
    1428                           SHORT2FROMMP(mp2) - 4,
    1429                           SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1430         else
    1431           TreeWidth = 0;
    1432         if(!pd->hwndMax) {
    1433           if(fTileBackwards) {
    1434             WinSetWindowPos(pd->hwndDir1,HWND_TOP,
    1435                             (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
    1436                               TreeWidth) + 2,
    1437                             2,
    1438                             ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
    1439                             SHORT2FROMMP(mp2) - 4,
    1440                             SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1441             WinSetWindowPos(pd->hwndDir2,HWND_TOP,
    1442                             TreeWidth + 2,
    1443                             2,
    1444                             ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
    1445                             SHORT2FROMMP(mp2) - 4,
    1446                             SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1447           }
    1448           else {
    1449             WinSetWindowPos(pd->hwndDir1,HWND_TOP,
    1450                             TreeWidth + 2,
    1451                             2,
    1452                             (SHORT1FROMMP(mp2) - TreeWidth) - 4,
    1453                             (SHORT2FROMMP(mp2) / 2) - 4,
    1454                             SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1455             WinSetWindowPos(pd->hwndDir2,HWND_TOP,
    1456                             TreeWidth + 2,
    1457                             (SHORT2FROMMP(mp2) / 2) + 2,
    1458                             (SHORT1FROMMP(mp2) - TreeWidth) - 4,
    1459                             (SHORT2FROMMP(mp2) / 2) - 4,
    1460                             SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1461           }
    1462         }
    1463         else {
    1464 
    1465           HWND hwndOther;
    1466 
    1467           WinSetWindowPos(pd->hwndMax,HWND_TOP,
    1468                           TreeWidth + 2,
    1469                           2,
    1470                           (SHORT1FROMMP(mp2) - TreeWidth) - 4,
    1471                           SHORT2FROMMP(mp2) - 4,
    1472                           SWP_SHOW | SWP_MOVE | SWP_SIZE);
    1473           hwndOther = (pd->hwndMax == pd->hwndDir1) ?
    1474                        pd->hwndDir2 : pd->hwndDir1;
    1475           WinSetWindowPos(hwndOther,HWND_BOTTOM,0,0,0,0,SWP_HIDE);
    1476         }
    1477         WinSendMsg(hwnd,
    1478                    UM_SETUP2,
    1479                    MPVOID,
    1480                    MPVOID);
    1481       }
    1482       if(msg == UM_SIZE)
    1483         return 0;
    1484       break;
    1485 
    1486     case WM_ERASEBACKGROUND:
    1487       WinFillRect((HPS)mp1,
    1488                   (PRECTL)mp2,
    1489                   0x00d0d0d0);
    1490       return 0;
    1491 
    1492     case WM_PAINT:
    1493       {
    1494         HPS    hps;
    1495         RECTL  rcl;
    1496 
    1497         hps = WinBeginPaint(hwnd,
    1498                             NULLHANDLE,
    1499                             NULL);
    1500         if(hps) {
    1501           WinQueryWindowRect(hwnd,&rcl);
    1502           WinFillRect(hps,
    1503                       (PRECTL)&rcl,
    1504                       CLR_PALEGRAY);
    1505           WinEndPaint(hps);
    1506           WinSendMsg(hwnd,
    1507                      UM_SETUP2,
    1508                      MPVOID,
    1509                      MPVOID);
    1510         }
    1511       }
    1512       break;
    1513 
    1514     case UM_COMMAND:
    1515     case WM_COMMAND:
    1516       return MainWMCommand2(hwnd,msg,mp1,mp2);
    1517 
    1518     case WM_CLOSE:
    1519       fAmClosing = TRUE;
    1520       WinSendMsg(hwnd,
    1521                  WM_SAVEAPPLICATION,
    1522                  MPVOID,
    1523                  MPVOID);
    1524       CloseChildren(hwnd);
    1525       PostMsg(hwnd,
    1526               UM_CLOSE,
    1527               MPVOID,
    1528               MPVOID);
    1529       DosSleep(1L);
    1530       return 0;
    1531 
    1532     case UM_CLOSE:
    1533       WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT));
    1534       return 0;
    1535 
    1536     case WM_DESTROY:
    1537       hwndMain = (HWND)0;
    1538       pd = WinQueryWindowPtr(hwnd,4);
    1539       if(pd)
    1540         free(pd);
    1541       if(!PostMsg((HWND)0,
    1542                   WM_QUIT,
    1543                   MPVOID,
    1544                   MPVOID))
    1545         WinSendMsg((HWND)0,
    1546                    WM_QUIT,
    1547                    MPVOID,
    1548                    MPVOID);
    1549       break;
    1550   }
    1551   return WinDefWindowProc(hwnd,msg,mp1,mp2);
    1552 }
    1553 
    1554 
    1555 HWND StartFM32 (HAB hab,INT argc,CHAR **argv) {
    1556 
    1557   HWND  hwndFrame,hwndClient;
    1558   ULONG FrameFlags = FCF_TITLEBAR      | FCF_SYSMENU      |
    1559                      FCF_SIZEBORDER    | FCF_MINMAX       |
    1560                      FCF_ACCELTABLE    | FCF_MENU         |
    1561                      FCF_ICON          | FCF_TASKLIST     |
    1562                      FCF_NOBYTEALIGN;
     1662HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
     1663{
     1664
     1665  HWND hwndFrame, hwndClient;
     1666  ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
     1667  FCF_SIZEBORDER | FCF_MINMAX |
     1668  FCF_ACCELTABLE | FCF_MENU |
     1669  FCF_ICON | FCF_TASKLIST |
     1670  FCF_NOBYTEALIGN;
    15631671
    15641672  {
    15651673    INT x;
    15661674
    1567     for(x = 1;x < argc;x++) {
    1568       if(*argv[x] == '+' && !argv[x][1])
    1569         fLogFile = TRUE;
    1570       if(*argv[x] == '-') {
    1571         if(argv[x][1])
    1572           strcpy(profile,&argv[x][1]);
     1675    for (x = 1; x < argc; x++)
     1676    {
     1677      if (*argv[x] == '+' && !argv[x][1])
     1678        fLogFile = TRUE;
     1679      if (*argv[x] == '-')
     1680      {
     1681        if (argv[x][1])
     1682          strcpy(profile, &argv[x][1]);
    15731683      }
    15741684    }
    15751685  }
    15761686  {
    1577     CHAR        inipath[CCHMAXPATH],fullpath[CCHMAXPATH];
     1687    CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
    15781688    FILESTATUS3 fsa;
    15791689
    1580     if(PrfQueryProfileString(HINI_USERPROFILE,
    1581                              FM2Str,
    1582                              "Home",
    1583                              NULL,
    1584                              inipath,
    1585                              sizeof(inipath))) {
    1586       if(!DosQueryPathInfo(inipath,
    1587                            FIL_STANDARD,
    1588                            &fsa,
    1589                            (ULONG)sizeof(fsa))) {
    1590         if(fsa.attrFile & FILE_DIRECTORY) {
    1591           if(DosQueryPathInfo(inipath,
    1592                               FIL_QUERYFULLNAME,
    1593                               fullpath,
    1594                               sizeof(fullpath)))
    1595             strcpy(fullpath,inipath);
    1596           switch_to(fullpath);
    1597         }
     1690    if (PrfQueryProfileString(HINI_USERPROFILE,
     1691                              FM2Str,
     1692                              "Home",
     1693                              NULL,
     1694                              inipath,
     1695                              sizeof(inipath)))
     1696    {
     1697      if (!DosQueryPathInfo(inipath,
     1698                            FIL_STANDARD,
     1699                            &fsa,
     1700                            (ULONG) sizeof(fsa)))
     1701      {
     1702        if (fsa.attrFile & FILE_DIRECTORY)
     1703        {
     1704          if (DosQueryPathInfo(inipath,
     1705                               FIL_QUERYFULLNAME,
     1706                               fullpath,
     1707                               sizeof(fullpath)))
     1708            strcpy(fullpath, inipath);
     1709          switch_to(fullpath);
     1710        }
    15981711      }
    15991712    }
     
    16011714
    16021715  hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
    1603                                  WS_VISIBLE,
    1604                                  &FrameFlags,
    1605                                  GetPString(IDS_WCMAINWND2),
    1606                                  NULL,
    1607                                  WS_VISIBLE | WS_ANIMATE,
    1608                                  FM3ModHandle,
    1609                                  MAIN2_FRAME,
    1610                                  &hwndClient);
    1611   if(hwndFrame) {
    1612     if(!WinRestoreWindowPos(FM2Str,
    1613                             "MainWindowPos2",
    1614                             hwndFrame)) {
    1615 
    1616       ULONG fl  = SWP_MOVE | SWP_SIZE;
     1716                                 WS_VISIBLE,
     1717                                 &FrameFlags,
     1718                                 GetPString(IDS_WCMAINWND2),
     1719                                 NULL,
     1720                                 WS_VISIBLE | WS_ANIMATE,
     1721                                 FM3ModHandle,
     1722                                 MAIN2_FRAME,
     1723                                 &hwndClient);
     1724  if (hwndFrame)
     1725  {
     1726    if (!WinRestoreWindowPos(FM2Str,
     1727                             "MainWindowPos2",
     1728                             hwndFrame))
     1729    {
     1730
     1731      ULONG fl = SWP_MOVE | SWP_SIZE;
    16171732      RECTL rcl;
    1618       ULONG icz = WinQuerySysValue(HWND_DESKTOP,SV_CYICON) * 3L;
    1619       ULONG bsz = WinQuerySysValue(HWND_DESKTOP,SV_CYSIZEBORDER);
    1620 
    1621       WinQueryWindowRect(HWND_DESKTOP,&rcl);
     1733      ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
     1734      ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
     1735
     1736      WinQueryWindowRect(HWND_DESKTOP, &rcl);
    16221737      rcl.yBottom += icz;
    16231738      rcl.yTop -= bsz;
     
    16251740      rcl.xRight -= bsz;
    16261741      WinSetWindowPos(hwndFrame,
    1627                       HWND_TOP,
    1628                       rcl.xLeft,
    1629                       rcl.yBottom,
    1630                       rcl.xRight - rcl.xLeft,
    1631                       rcl.yTop - rcl.yBottom,
    1632                       fl);
    1633     }
    1634     if(fLogFile)
    1635       LogFileHandle = _fsopen("FM2.LOG","a+",SH_DENYWR);
    1636     if(hwndHelp)
    1637       WinAssociateHelpInstance(hwndHelp,hwndFrame);
     1742                      HWND_TOP,
     1743                      rcl.xLeft,
     1744                      rcl.yBottom,
     1745                      rcl.xRight - rcl.xLeft,
     1746                      rcl.yTop - rcl.yBottom,
     1747                      fl);
     1748    }
     1749    if (fLogFile)
     1750      LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
     1751    if (hwndHelp)
     1752      WinAssociateHelpInstance(hwndHelp, hwndFrame);
    16381753    PostMsg(hwndClient,
    1639             UM_SETUP,
    1640             MPFROMLONG(argc),
    1641             MPFROMP(argv));
     1754            UM_SETUP,
     1755            MPFROMLONG(argc),
     1756            MPFROMP(argv));
    16421757  }
    16431758  return hwndFrame;
Note: See TracChangeset for help on using the changeset viewer.