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