source: trunk/dll/mainwnd2.c@ 1673

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

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

  • 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 1673 2012-12-30 18:51:01Z gyoung $
5
6 fm/4 main window
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2005, 2010 Steven H. Levine
10
11 23 May 05 SHL Use datamin.h
12 26 May 05 SHL Comments and localize code
13 06 Aug 05 SHL Renames
14 02 Jan 06 SHL Use QWL_USER more
15 02 Jan 06 SHL Map IDM_WINDOWDLG to match IBM_TWODIRS
16 17 Jul 06 SHL Use Runtime_Error
17 30 Mar 07 GKY Remove GetPString for window class names
18 12 May 07 SHL Pass ulItemsToUnHilite to UnHilite
19 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
20 07 Aug 07 SHL Use BldQuotedFileName
21 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
22 10 Jan 08 SHL Sync with CfgDlgProc mods
23 19 Jan 08 GKY Rework Utilities menu
24 14 Feb 08 SHL Rework to support settings menu conditional cascade
25 29 Feb 08 GKY Use xfree where appropriate
26 27 Aug 08 JBS Ticket 259: Support saving/restoring toolbars with states
27 01 Sep 08 GKY Add bmps for default toolbars
28 10 Dec 08 SHL Integrate exception handler support
29 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
30 Dos/Win programs from being inserted into the execute dialog with message why.
31 21 Jun 09 GKY Added drive letter to bitmap buttons in drive bar; Eliminate static drive
32 letter windows; Use button ID to identify drive letter for processing.
33 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
34 12 Sep 09 GKY Add FM3.INI User ini and system ini to submenu for view ini
35 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
36 profile calls for user settings that work and are setable in more than one
37 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
38 aren't user settable; realappname should be used for setting applicable to
39 one or more miniapp but not to FM/2
40 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
41 11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem
42 never being posted
43 12 Aug 12 GKY Allow for selection of include subdirectories or a list file on initial startup of compare dirs
44
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 // create frame children (not client children, frame children)
822 DosSleep(1);
823 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
824 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
825 (PFNWP) MainFrameWndProc2);
826 if (oldproc)
827 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
828 CommonCreateMainChildren(hwnd, &swp);
829
830 {
831 HWND hwndMenu;
832
833 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
834 WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
835 CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
836 SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
837 if (fProtectOnly) {
838 WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
839 WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
840 }
841 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
842 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
843 }
844 }
845 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
846 FID_TITLEBAR), "FM/2 Lite");
847 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
848 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
849 break;
850
851 case UM_SETUP:
852 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
853 if (pd) {
854
855 CHAR s[CCHMAXPATH];
856 ULONG size;
857 DIRCNRDATA *dcd;
858 HWND hwndC;
859 BOOL dummy = TRUE;
860
861 size = sizeof(BOOL);
862 PrfQueryProfileData(fmprof, realappname, "FM/4 TreeUp",
863 (PVOID) &dummy, &size);
864 if (dummy) {
865 size = sizeof(ULONG);
866 hwndTree = StartTreeCnr(hwnd, 3);
867 PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth",
868 (PVOID) &TreeWidth, &size);
869 TreeWidth = max(TreeWidth, 80);
870 }
871 size = sizeof(BOOL);
872 if (PrfQueryProfileData(fmprof, appname, "Toolbar", &dummy, &size) &&
873 size && !dummy)
874 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
875
876 size = sizeof(s);
877 *s = 0;
878 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1", s, &size) && *s)
879 MakeValidDir(s);
880 else
881 save_dir(s);
882 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
883 StartDirCnr(hwnd, s, (HWND) 0, 3);
884 size = sizeof(s);
885 *s = 0;
886 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2", s, &size) && *s)
887 MakeValidDir(s);
888 else
889 save_dir(s);
890 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
891 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
892
893 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
894 if (hwndC) {
895 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
896 if (dcd) {
897 size = sizeof(INT);
898 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
899 (PVOID) & dcd->sortFlags,
900 &size) && size == sizeof(INT)) {
901 if (!dcd->sortFlags)
902 dcd->sortFlags = SORT_PATHNAME;
903 }
904 size = sizeof(MASK);
905 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
906 (PVOID) & dcd->mask, &size) && size) {
907 if (*dcd->mask.szMask)
908 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
909 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
910 }
911 *(dcd->mask.prompt) = 0;
912 size = sizeof(ULONG);
913 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.View",
914 (PVOID) & dcd->flWindowAttr,
915 &size) && size == sizeof(ULONG)) {
916
917 CNRINFO cnri;
918
919 memset(&cnri, 0, sizeof(CNRINFO));
920 cnri.cb = sizeof(CNRINFO);
921 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
922 CM_QUERYCNRINFO,
923 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
924 cnri.flWindowAttr = dcd->flWindowAttr;
925 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
926 CM_SETCNRINFO,
927 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
928 }
929 }
930 }
931 }
932
933 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
934 if (hwndC) {
935 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
936 if (dcd) {
937 size = sizeof(INT);
938 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
939 (PVOID) & dcd->sortFlags,
940 &size) && size == sizeof(INT)) {
941 if (!dcd->sortFlags)
942 dcd->sortFlags = SORT_PATHNAME;
943 }
944 size = sizeof(MASK);
945 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
946 (PVOID) & dcd->mask, &size) && size) {
947 if (*dcd->mask.szMask)
948 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
949 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
950 }
951 *(dcd->mask.prompt) = 0;
952 size = sizeof(ULONG);
953 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.View",
954 (PVOID) & dcd->flWindowAttr,
955 &size) && size == sizeof(ULONG)) {
956
957 CNRINFO cnri;
958
959 memset(&cnri, 0, sizeof(CNRINFO));
960 cnri.cb = sizeof(CNRINFO);
961 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
962 CM_QUERYCNRINFO,
963 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
964 cnri.flWindowAttr = dcd->flWindowAttr;
965 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
966 CM_SETCNRINFO,
967 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
968 }
969 }
970 }
971 }
972 }
973 {
974 ULONG which = 0, size = sizeof(ULONG);
975
976 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Max",
977 (PVOID) & which,
978 &size) && size == sizeof(ULONG) && which) {
979 PostMsg(hwnd,
980 UM_MAXIMIZE,
981 MPFROMLONG(((which == 1) ?
982 pd->hwndDir1 : pd->hwndDir2)), MPVOID);
983 }
984 }
985 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
986 if (!hwndTree)
987 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
988 load_tools(NULL);
989 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
990 fRunning = TRUE;
991 return 0;
992
993 case WM_SAVEAPPLICATION:
994 WinStoreWindowPos((CHAR *) FM2Str,
995 "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
996 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
997 if (pd) {
998
999 CHAR s[CCHMAXPATH];
1000 HWND hwndC;
1001 DIRCNRDATA *dcd;
1002 ULONG flWindowAttr;
1003
1004 *s = 0;
1005 WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
1006 if (*s) {
1007 MakeValidDir(s);
1008 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
1009 }
1010 *s = 0;
1011 WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
1012 if (*s) {
1013 MakeValidDir(s);
1014 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
1015 }
1016 flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
1017 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
1018 PrfWriteProfileData(fmprof,
1019 realappname,
1020 "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
1021 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
1022 if (hwndC) {
1023 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
1024 if (dcd) {
1025 flWindowAttr = dcd->flWindowAttr;
1026 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
1027 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1028 if (dcd->lastattr) {
1029 if (dcd->lastattr & CV_TEXT)
1030 flWindowAttr |= CV_TEXT;
1031 else if (dcd->lastattr & CV_DETAIL)
1032 flWindowAttr |= CV_DETAIL;
1033 else if (dcd->lastattr & CV_ICON)
1034 flWindowAttr |= CV_ICON;
1035 else
1036 flWindowAttr |= CV_NAME;
1037 }
1038 else
1039 flWindowAttr |= CV_NAME;
1040 }
1041 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
1042 (PVOID) & dcd->sortFlags, sizeof(INT));
1043 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
1044 (PVOID) & dcd->mask, sizeof(MASK));
1045 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.View",
1046 (PVOID) & flWindowAttr, sizeof(ULONG));
1047 }
1048 }
1049
1050 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
1051 if (hwndC) {
1052 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
1053 if (dcd) {
1054 flWindowAttr = dcd->flWindowAttr;
1055 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
1056 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1057 if (dcd->lastattr) {
1058 if (dcd->lastattr & CV_TEXT)
1059 flWindowAttr |= CV_TEXT;
1060 else if (dcd->lastattr & CV_DETAIL)
1061 flWindowAttr |= CV_DETAIL;
1062 else if (dcd->lastattr & CV_ICON)
1063 flWindowAttr |= CV_ICON;
1064 else
1065 flWindowAttr |= CV_NAME;
1066 }
1067 else
1068 flWindowAttr |= CV_NAME;
1069 }
1070 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
1071 (PVOID) & dcd->sortFlags, sizeof(INT));
1072 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
1073 (PVOID) & dcd->mask, sizeof(MASK));
1074 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.View",
1075 (PVOID) & flWindowAttr, sizeof(ULONG));
1076 }
1077 }
1078 }
1079 break;
1080 }
1081 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1082}
1083
1084MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1085{
1086 PERSON1DATA *pd;
1087
1088 switch (msg) {
1089 case WM_SAVEAPPLICATION:
1090 case UM_SETUP:
1091 case WM_CREATE:
1092 return MainWMOnce2(hwnd, msg, mp1, mp2);
1093
1094 case UM_THREADUSE:
1095 case UM_LOADFILE:
1096 case UM_BUILDDRIVEBAR:
1097 case WM_TIMER:
1098 return CommonMainWndProc(hwnd, msg, mp1, mp2);
1099
1100 case UM_SETUP2:
1101 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1102 if (pd) {
1103 if (mp1) {
1104 if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
1105 BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
1106 if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
1107 BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
1108 if (hwndTree)
1109 BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
1110 }
1111 else {
1112 if (hwndTree)
1113 BoxWindow(hwndTree,
1114 (HPS) 0,
1115 (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
1116 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
1117 BoxWindow(pd->hwndDir1,
1118 (HPS) 0,
1119 (pd->hwndDir1 == pd->hwndCurr) ?
1120 CLR_RED :
1121 (pd->hwndDir1 == pd->hwndLastDir) ?
1122 CLR_DARKRED : CLR_PALEGRAY);
1123 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
1124 BoxWindow(pd->hwndDir2,
1125 (HPS) 0,
1126 (pd->hwndDir2 == pd->hwndCurr) ?
1127 CLR_RED :
1128 (pd->hwndDir2 == pd->hwndLastDir) ?
1129 CLR_DARKRED : CLR_PALEGRAY);
1130 }
1131 }
1132 return 0;
1133
1134 case WM_BUTTON1DOWN:
1135 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1136 if (hwndTree) {
1137
1138 SWP swp;
1139
1140 WinQueryWindowPos(hwndTree, &swp);
1141 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1142 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
1143
1144 SWP swpC;
1145 TRACKINFO track;
1146
1147 WinQueryWindowPos(hwnd, &swpC);
1148 track.cxBorder = 4;
1149 track.cyBorder = 4;
1150 track.cxGrid = 1;
1151 track.cyGrid = 1;
1152 track.cxKeyboard = 8;
1153 track.cyKeyboard = 8;
1154 track.rclTrack.yBottom = 2;
1155 track.rclTrack.yTop = swpC.cy - 4;
1156 track.rclTrack.xLeft = 2;
1157 track.rclTrack.xRight = swp.x + swp.cx + 2;
1158 track.rclBoundary = track.rclTrack;
1159 track.rclBoundary.xRight = swpC.cx - 80;
1160 track.ptlMinTrackSize.x = 80;
1161 track.ptlMinTrackSize.y = swpC.cy - 4;
1162 track.ptlMaxTrackSize.x = swpC.cx - 80;
1163 track.ptlMaxTrackSize.y = swpC.cy - 4;
1164 track.fs = TF_RIGHT;
1165 if (WinTrackRect(hwnd, (HPS) 0, &track)) {
1166 TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
1167 PrfWriteProfileData(fmprof,
1168 realappname,
1169 "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
1170 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1171 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1172 }
1173 return (MRESULT) TRUE;
1174 }
1175 }
1176 break;
1177
1178 case WM_MOUSEMOVE:
1179 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1180 if (hwndTree) {
1181
1182 SWP swp;
1183
1184 if (WinQueryWindowPos(hwndTree, &swp)) {
1185 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1186 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
1187 WinSetPointer(HWND_DESKTOP, hptrEW);
1188 else
1189 WinSetPointer(HWND_DESKTOP, hptrArrow);
1190 }
1191 else
1192 WinSetPointer(HWND_DESKTOP, hptrArrow);
1193 }
1194 return (MRESULT) TRUE;
1195
1196 case WM_BUTTON1UP:
1197 case WM_BUTTON2UP:
1198 case WM_BUTTON3UP:
1199 case WM_CHAR:
1200 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1201 break;
1202
1203 case UM_ADVISEFOCUS:
1204 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1205 if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
1206 if ((HWND) mp1 != hwndTree)
1207 pd->hwndLastDir = (HWND) mp1;
1208 pd->hwndCurr = (HWND) mp1;
1209 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1210 }
1211 return 0;
1212
1213 case UM_MAXIMIZE:
1214 if (mp1) {
1215 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1216 if (pd) {
1217 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1218 if (pd->hwndMax != (HWND) mp1) {
1219 pd->hwndMax = (HWND) mp1;
1220 WinSetFocus(HWND_DESKTOP, pd->hwndMax);
1221 }
1222 else
1223 pd->hwndMax = (HWND) 0;
1224 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1225 }
1226 }
1227 return 0;
1228
1229 case WM_INITMENU:
1230 switch (SHORT1FROMMP(mp1)) {
1231 case IDM_FILESMENU:
1232 case IDM_VIEWSMENU:
1233 case IDM_DETAILSSETUP:
1234 case IDM_COMMANDSMENU:
1235 case IDM_SORTSUBMENU:
1236 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1237 if (pd)
1238 WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
1239 break;
1240 case IDM_CONFIGMENU:
1241 WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
1242 WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
1243 break;
1244 case IDM_TOOLSUBMENU:
1245 WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
1246 WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
1247 WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
1248 break;
1249 case IDM_WINDOWSMENU:
1250 WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
1251 WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
1252 SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
1253 break;
1254 }
1255 break;
1256
1257 case WM_SETFOCUS:
1258 if (mp2)
1259 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1260 break;
1261
1262 case UM_FOCUSME:
1263 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1264 if (pd)
1265 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
1266 return 0;
1267
1268 case UM_RESCAN:
1269 return 0;
1270
1271 case UM_SIZE:
1272 {
1273 SWP swp;
1274
1275 if (WinQueryWindowPos(hwnd, &swp)) {
1276 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1277 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
1278 }
1279 else
1280 return 0;
1281 }
1282 // intentional fallthru
1283 case WM_SIZE:
1284 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1285 if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
1286 if (hwndTree)
1287 WinSetWindowPos(hwndTree,
1288 HWND_TOP,
1289 2,
1290 2,
1291 TreeWidth - 4,
1292 SHORT2FROMMP(mp2) - 4,
1293 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1294 else
1295 TreeWidth = 0;
1296 if (!pd->hwndMax) {
1297 if (fTileBackwards) {
1298 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1299 (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
1300 TreeWidth) + 2,
1301 2,
1302 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1303 SHORT2FROMMP(mp2) - 4,
1304 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1305 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1306 TreeWidth + 2,
1307 2,
1308 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1309 SHORT2FROMMP(mp2) - 4,
1310 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1311 }
1312 else {
1313 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1314 TreeWidth + 2,
1315 2,
1316 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1317 (SHORT2FROMMP(mp2) / 2) - 4,
1318 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1319 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1320 TreeWidth + 2,
1321 (SHORT2FROMMP(mp2) / 2) + 2,
1322 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1323 (SHORT2FROMMP(mp2) / 2) - 4,
1324 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1325 }
1326 }
1327 else {
1328
1329 HWND hwndOther;
1330
1331 WinSetWindowPos(pd->hwndMax, HWND_TOP,
1332 TreeWidth + 2,
1333 2,
1334 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1335 SHORT2FROMMP(mp2) - 4,
1336 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1337 hwndOther = (pd->hwndMax == pd->hwndDir1) ?
1338 pd->hwndDir2 : pd->hwndDir1;
1339 WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
1340 }
1341 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1342 }
1343 if (msg == UM_SIZE)
1344 return 0;
1345 break;
1346
1347 case WM_ERASEBACKGROUND:
1348 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
1349 return 0;
1350
1351 case WM_PAINT:
1352 {
1353 HPS hps;
1354 RECTL rcl;
1355
1356 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
1357 if (hps) {
1358 WinQueryWindowRect(hwnd, &rcl);
1359 WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
1360 WinEndPaint(hps);
1361 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1362 }
1363 }
1364 break;
1365
1366 case UM_COMMAND:
1367 case WM_COMMAND:
1368 return MainWMCommand2(hwnd, msg, mp1, mp2);
1369
1370 case WM_CLOSE:
1371 fAmClosing = TRUE;
1372 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
1373 CloseChildren(hwnd);
1374 PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
1375 DosSleep(1);
1376 return 0;
1377
1378 case UM_CLOSE:
1379 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1380 return 0;
1381
1382 case WM_DESTROY:
1383 hwndMain = (HWND) 0;
1384 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1385 xfree(pd, pszSrcFile, __LINE__);
1386 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1387 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1388 break;
1389 }
1390 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1391}
1392
1393HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
1394{
1395 HWND hwndFrame, hwndClient;
1396 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1397 FCF_SIZEBORDER | FCF_MINMAX |
1398 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1399
1400 {
1401 INT x;
1402
1403 for (x = 1; x < argc; x++) {
1404 if (*argv[x] == '+' && !argv[x][1])
1405 fLogFile = TRUE;
1406 if (*argv[x] == '-') {
1407 if (argv[x][1])
1408 strcpy(profile, &argv[x][1]);
1409 }
1410 }
1411 }
1412 {
1413 CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
1414 FILESTATUS3 fsa;
1415
1416 if (PrfQueryProfileString(HINI_USERPROFILE,
1417 (CHAR *) FM2Str,
1418 "Home", NULL, inipath, sizeof(inipath))) {
1419 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
1420 if (fsa.attrFile & FILE_DIRECTORY) {
1421 if (DosQueryPathInfo(inipath,
1422 FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
1423 strcpy(fullpath, inipath);
1424 switch_to(fullpath);
1425 }
1426 }
1427 }
1428 }
1429
1430 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1431 WS_VISIBLE,
1432 &FrameFlags,
1433 (CHAR *) WC_MAINWND2,
1434 NULL,
1435 WS_VISIBLE | WS_ANIMATE,
1436 FM3ModHandle, MAIN2_FRAME, &hwndClient);
1437 if (hwndFrame) {
1438 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
1439 if (!WinRestoreWindowPos((CHAR *) FM2Str, "MainWindowPos2", hwndFrame)) {
1440
1441 ULONG fl = SWP_MOVE | SWP_SIZE;
1442 RECTL rcl;
1443 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1444 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1445
1446 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1447 rcl.yBottom += icz;
1448 rcl.yTop -= bsz;
1449 rcl.xLeft += bsz;
1450 rcl.xRight -= bsz;
1451 WinSetWindowPos(hwndFrame,
1452 HWND_TOP,
1453 rcl.xLeft,
1454 rcl.yBottom,
1455 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1456 }
1457 if (fLogFile) {
1458 CHAR *modea = "a+";
1459
1460 LogFileHandle = xfsopen("FM2.LOG", modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
1461 }
1462 if (hwndHelp)
1463 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1464 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1465 }
1466 return hwndFrame;
1467}
1468
1469#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
1470#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
1471#pragma alloc_text(PERSON13,MainWMCommand2)
Note: See TracBrowser for help on using the repository browser.