source: trunk/dll/mainwnd2.c@ 1670

Last change on this file since 1670 was 1670, checked in by Gregg Young, 13 years ago

Add ability to change and save PresParam to compare dialog (Ticket 443) Fix loading of a list file in the right compare container (Ticket 489) Allow for selection of include subdirectories or a list file on initial startup of compare dirs (Ticket 145)

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