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