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