source: trunk/dll/mainwnd2.c@ 1505

Last change on this file since 1505 was 1498, checked in by Gregg Young, 16 years ago

Changes to get FM2 to compile with the latest watcom 1.9 beta (mostly type casts of CHAR CONSTANT * to CHAR *). Changes to get the environment settings working everywhere again (broken by the change that moved commands to the INI); Added an environment size variable (set to 2048 which was the largest I found hard coded). Still need to find everywhere the environment size is set and use this variable.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: mainwnd2.c 1498 2010-01-18 00:57: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
42***********************************************************************/
43
44#include <stdlib.h>
45#include <string.h>
46#include <share.h>
47// #include <process.h> // _beginthread
48
49#define INCL_DOS
50#define INCL_WIN
51#define INCL_GPI
52#define INCL_LONGLONG
53
54#include "fm3dll.h"
55#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
56#include "killproc.h" // Data declaration(s)
57#include "grep.h" // Data declaration(s)
58#include "autoview.h" // Data declaration(s)
59#include "dircnrs.h" // Data declaration(s)
60#include "worker.h" // Data declaration(s)
61#include "init.h" // Data declaration(s)
62#include "fm3dlg.h"
63#include "fm3str.h"
64#include "tools.h"
65#include "datamin.h"
66#include "comp.h" // COMPARE
67#include "pathutil.h" // BldQuotedFileName
68#include "errutil.h" // Dos_Error...
69#include "strutil.h" // GetPString
70#include "notebook.h" // CfgDlgProc
71#include "command.h" // RunCommand
72#include "misc.h" // BoxWindow, FixSwitchList, SetConditionalCascade
73 // SetSysMenu
74#include "mainwnd.h" // CloseChildren, MainWMCommand, MakeMainObjWin, ResizeDrives
75 // TopWindow
76#include "common.h" // CommonCreateMainChildren, CommonMainWndProc
77#include "notify.h" // HideNote
78#include "mainwnd2.h"
79#include "remap.h" // RemapDlgProc
80#include "treecnr.h" // StartTreeCnr
81#include "walkem.h" // WalkTwoCmpDlgProc, WalkTwoSetDlgProc
82#include "dirs.h" // switch_to
83#include "filter.h" // Filter
84#include "collect.h" // StartCollector
85#include "select.h" // UnHilite
86#include "valid.h" // MakeValidDir
87#include "systemf.h" // runemf2
88#include "wrappers.h" // xfree
89#include "fortify.h"
90#include "excputil.h" // xbeginthread
91
92typedef struct
93{
94 USHORT size;
95 USHORT dummy;
96 HWND hwndDir1;
97 HWND hwndDir2;
98 HWND hwndCurr;
99 HWND hwndLastDir;
100 HWND hwndMax;
101}
102PERSON1DATA;
103
104// Data definitions
105static PSZ pszSrcFile = __FILE__;
106static ULONG TreeWidth;
107
108#pragma data_seg(GLOBAL1)
109PFNWP PFNWPFrame;
110
111#pragma data_seg(GLOBAL2)
112CHAR realappname[12];
113
114static MRESULT EXPENTRY MainFrameWndProc2(HWND hwnd, ULONG msg, MPARAM mp1,
115 MPARAM mp2)
116{
117 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
118
119 switch (msg) {
120 case WM_ADJUSTWINDOWPOS:
121 {
122 SWP *pswp;
123
124 pswp = (SWP *) mp1;
125 if (pswp->fl & (SWP_SHOW | SWP_RESTORE))
126 PostMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_SIZE, MPVOID, MPVOID);
127 if (fDataMin && !fAmClosing) {
128 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE)) {
129
130 SWP swp;
131
132 WinQueryWindowPos(hwnd, &swp);
133 PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(swp.fl), MPVOID);
134 HideNote();
135 }
136 else if (pswp->fl & (SWP_SHOW | SWP_RESTORE)) {
137 if (DataHwnd)
138 PostMsg(DataHwnd, WM_CLOSE, MPVOID, MPVOID);
139 }
140 }
141 if (!fAmClosing) {
142 if (pswp->fl & (SWP_HIDE | SWP_MINIMIZE))
143 HideNote();
144 }
145 }
146 break;
147
148 case UM_FOCUSME:
149 CreateDataBar(HWND_DESKTOP, (ULONG) mp1);
150 return 0;
151
152 case WM_BUTTON1UP:
153 case WM_BUTTON2UP:
154 case WM_BUTTON3UP:
155 case WM_MOUSEMOVE:
156 case WM_CHORD:
157 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
158 break;
159
160 case WM_CHAR:
161 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
162 break;
163
164 case WM_CONTROL:
165 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL, mp1,
166 mp2);
167
168 case WM_COMMAND:
169 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
170
171 case WM_CALCFRAMERECT:
172 {
173 MRESULT mr;
174 PRECTL prectl;
175 LONG sheight = 20, bheight = 20;
176
177 mr = (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
178 PFNWPFrame(hwnd, msg, mp1, mp2);
179
180 /*
181 * Calculate the position of the client rectangle.
182 * Otherwise, we'll see a lot of redraw when we move the
183 * client during WM_FORMATFRAME.
184 */
185
186 if (mr && mp2) {
187 prectl = (PRECTL) mp1;
188 if (prectl->yBottom != prectl->yTop) {
189 {
190 HPS hps;
191 POINTL aptl[TXTBOX_COUNT];
192
193 hps = WinGetPS(hwndStatus);
194 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
195 WinReleasePS(hps);
196 sheight = aptl[TXTBOX_TOPLEFT].y + 6;
197 hps = WinGetPS(hwndName);
198 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
199 WinReleasePS(hps);
200 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
201 }
202 prectl->yBottom += (sheight + 4);
203 prectl->yTop -= (sheight + 4);
204 prectl->yBottom += (bheight + 4);
205 prectl->yTop -= (bheight + 4);
206 if (fToolbar) {
207 if (!fTextTools)
208 prectl->yTop -= ((fToolTitles) ? 50 : 40);
209 else
210 prectl->yTop -= 32;
211 }
212 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES),
213 ((prectl->xRight -
214 (WinQuerySysValue(HWND_DESKTOP,
215 SV_CYSIZEBORDER) * 2)) - 4));
216 prectl->yTop -= (16 * (DriveLines * 22));
217 prectl->yTop -= 2;
218 if (fAutoView) {
219 AutoviewHeight = min(AutoviewHeight,
220 (prectl->yTop - prectl->yBottom) - 116);
221 AutoviewHeight = max(AutoviewHeight, 44);
222 prectl->yBottom += (AutoviewHeight + 6);
223 }
224 }
225 }
226 return mr;
227 }
228
229 case WM_FORMATFRAME:
230 {
231 SHORT sCount, soldCount;
232 PSWP pswp, pswpClient, pswpNew;
233 SWP swpClient;
234 ULONG theight = 48L, dheight = DRIVE_BUTTON_HEIGHT, bheight = 20, sheight = 20;
235 LONG width, lastx;
236
237 sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
238 PFNWPFrame(hwnd, msg, mp1, mp2));
239 soldCount = sCount;
240 /*
241 * Reformat the frame to "squeeze" the client
242 * and make room for status window sibling beneath
243 * and toolbar above (if toolbar's on) and userlists
244 * (if userlists are on).
245 */
246
247 pswp = (PSWP) mp1;
248 {
249 SHORT x;
250
251 for (x = 0; x < sCount; x++) {
252 if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
253 pswpClient = pswp;
254 break;
255 }
256 pswp++;
257 }
258 }
259
260 {
261 HPS hps;
262 POINTL aptl[TXTBOX_COUNT];
263
264 hps = WinGetPS(hwndStatus);
265 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
266 WinReleasePS(hps);
267 bheight = sheight = aptl[TXTBOX_TOPLEFT].y + 6;
268 hps = WinGetPS(hwndName);
269 GpiQueryTextBox(hps, 6, "$`WjgT", TXTBOX_COUNT, aptl);
270 WinReleasePS(hps);
271 bheight = aptl[TXTBOX_TOPLEFT].y + 6;
272 }
273
274 pswpNew = (PSWP) mp1 + soldCount;
275 *pswpNew = *pswpClient;
276 swpClient = *pswpClient;
277 pswpNew->hwnd = hwndStatus;
278 pswpNew->x = swpClient.x + 3;
279 pswpNew->y = swpClient.y + 2;
280 width = (swpClient.cx / 2) - 6;
281 width = max(width, 10);
282 pswpNew->cx = width - 6;
283 pswpNew->cy = sheight;
284 pswpClient->y = pswpNew->y + pswpNew->cy + 3;
285 pswpClient->cy = (swpClient.cy - pswpNew->cy) - 3;
286 sCount++;
287
288 pswpNew = (PSWP) mp1 + (soldCount + 1);
289 *pswpNew = *pswpClient;
290 pswpNew->hwnd = hwndStatus2;
291 pswpNew->x = width + 8;
292 pswpNew->y = swpClient.y + 2;
293 pswpNew->cx = width - 6;
294 pswpNew->cy = sheight;
295 sCount++;
296
297 if (fToolbar) {
298 if (fTextTools)
299 theight = 32L;
300 else if (!fToolTitles)
301 theight = 40L;
302 pswpNew = (PSWP) mp1 + (soldCount + 2);
303 *pswpNew = *pswpClient;
304 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_TOOLS);
305 pswpNew->x = swpClient.x + 2;
306 pswpNew->y = (swpClient.y + swpClient.cy) - (theight - 2);
307 pswpNew->cx = swpClient.cx - 4;
308 pswpNew->cy = theight - 4;
309 pswpClient->cy -= theight;
310 sCount++;
311 }
312 else
313 WinShowWindow(WinWindowFromID(hwnd, MAIN_TOOLS), FALSE);
314
315 ResizeDrives(WinWindowFromID(hwnd, MAIN_DRIVES), pswpClient->cx - 4);
316 pswpNew = (PSWP) mp1 + (soldCount + 2 + (fToolbar != FALSE));
317 *pswpNew = *pswpClient;
318 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_DRIVES);
319 pswpNew->x = swpClient.x + 2;
320 dheight += ((dheight) * DriveLines);
321 pswpNew->y = (swpClient.y + swpClient.cy) - (dheight);
322 if (fToolbar)
323 pswpNew->y -= theight;
324 pswpNew->cx = swpClient.cx - 4;
325 pswpNew->cy = dheight;
326 pswpClient->cy -= dheight;
327 pswpClient->cy -= 2;
328 sCount++;
329
330 if (fAutoView) {
331 pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE));
332 *pswpNew = *pswpClient;
333 pswpNew->hwnd = (fComments) ? hwndAutoMLE : hwndAutoview;
334 pswpNew->x = pswpClient->x + 3;
335 pswpNew->y = pswpClient->y + 3;
336 if (fMoreButtons)
337 pswpNew->y += (bheight + 4);
338 pswpNew->cx = pswpClient->cx - 6;
339 AutoviewHeight = min(AutoviewHeight, pswpClient->cy - 116);
340 AutoviewHeight = max(AutoviewHeight, 44);
341 pswpNew->cy = AutoviewHeight;
342 pswpClient->y += (AutoviewHeight + 6);
343 pswpClient->cy -= (AutoviewHeight + 6);
344 sCount++;
345 WinShowWindow((fComments) ? hwndAutoview : hwndAutoMLE, FALSE);
346 }
347 else {
348 WinShowWindow(hwndAutoview, FALSE);
349 WinShowWindow(hwndAutoMLE, FALSE);
350 }
351
352 pswpNew = (PSWP) mp1 + (soldCount + 3 + (fToolbar != FALSE) +
353 (fAutoView != FALSE));
354 *pswpNew = *pswpClient;
355 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LED);
356 pswpNew->x = (swpClient.x + swpClient.cx) - 12;
357 pswpNew->y = swpClient.y;
358 pswpNew->cx = 12;
359 pswpNew->cy = 12;
360 sCount++;
361
362 pswpNew = (PSWP) mp1 + (soldCount + 4 + (fToolbar != FALSE) +
363 (fAutoView != FALSE));
364 *pswpNew = *pswpClient;
365 pswpNew->hwnd = WinWindowFromID(hwnd, MAIN_LEDHDR);
366 pswpNew->x = (swpClient.x + swpClient.cx) - 12;
367 pswpNew->y = swpClient.y + 12;
368 pswpNew->cx = 12;
369 pswpNew->cy = sheight - 8;
370 sCount++;
371
372 pswpNew = (PSWP) mp1 + (soldCount + 5 + (fToolbar != FALSE) +
373 (fAutoView != FALSE));
374 *pswpNew = *pswpClient;
375 pswpNew->hwnd = hwndName;
376 pswpNew->x = swpClient.x + 3;
377 pswpNew->y = swpClient.y + (sheight + 6);
378 pswpNew->cx = ((swpClient.cx / 2) + (swpClient.cx / 5)) - 3;
379 lastx = pswpNew->x + pswpNew->cx;
380 pswpNew->cy = bheight;
381 pswpClient->y += (bheight + 4);
382 pswpClient->cy -= (bheight + 4);
383 sCount++;
384
385 pswpNew = (PSWP) mp1 + (soldCount + 6 + (fToolbar != FALSE) +
386 (fAutoView != FALSE));
387 *pswpNew = *pswpClient;
388 pswpNew->hwnd = hwndDate;
389 pswpNew->x = lastx + 3;
390 pswpNew->y = swpClient.y + (sheight + 6);
391 pswpNew->cx = (swpClient.cx / 6) + (swpClient.cx / 16) - 3;
392 lastx = pswpNew->x + pswpNew->cx;
393 pswpNew->cy = bheight;
394 sCount++;
395
396 pswpNew = (PSWP) mp1 + (soldCount + 7 + (fToolbar != FALSE) +
397 (fAutoView != FALSE));
398 *pswpNew = *pswpClient;
399 pswpNew->hwnd = hwndAttr;
400 pswpNew->x = lastx + 3;
401 pswpNew->y = swpClient.y + (sheight + 6);
402 pswpNew->cx = (swpClient.cx - pswpNew->x) - 1;
403 pswpNew->cy = bheight;
404 sCount++;
405
406 return MRFROMSHORT(sCount);
407 }
408
409 case WM_QUERYFRAMECTLCOUNT:
410 {
411 SHORT sCount;
412
413 sCount = (SHORT) ((oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
414 PFNWPFrame(hwnd, msg, mp1, mp2));
415 sCount += 8;
416 if (fToolbar)
417 sCount++;
418 if (fAutoView)
419 sCount++;
420 return MRFROMSHORT(sCount);
421 }
422
423 case WM_CLOSE:
424 WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), msg, mp1, mp2);
425 return 0;
426 }
427 return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
428 PFNWPFrame(hwnd, msg, mp1, mp2);
429}
430
431static MRESULT EXPENTRY MainWMCommand2(HWND hwnd, ULONG msg, MPARAM mp1,
432 MPARAM mp2)
433{
434 PERSON1DATA *pd;
435
436 SetShiftState();
437 switch (SHORT1FROMMP(mp1)) {
438 case IDM_TOAUTOMLE:
439 case IDM_CLI:
440 case IDM_CREATETOOL:
441 case IDM_ABOUT:
442 case IDM_WINFULLSCREEN:
443 case IDM_DOSCOMMANDLINE:
444 case IDM_INIVIEWER:
445 case IDM_INIVIEWERFM2:
446 case IDM_INIVIEWERSYS:
447 case IDM_EDITASSOC:
448 case IDM_COMMANDLINE:
449 case IDM_KILLPROC:
450 case IDM_TOOLBAR:
451 case IDM_TEXTTOOLS:
452 case IDM_TOOLTITLES:
453 case IDM_TOOLLEFT:
454 case IDM_TOOLRIGHT:
455 case IDM_AUTOVIEWCOMMENTS:
456 case IDM_AUTOVIEWFILE:
457 case IDM_AUTOVIEW:
458// case IDM_SYSINFO:
459 case IDM_HIDENOTEWND:
460 case IDM_SHOWNOTEWND:
461 case IDM_INSTANT:
462 case IDM_HELPCONTEXT:
463 case IDM_HELPHINTS:
464 case IDM_HELPPIX:
465 case IDM_KILLME:
466 case IDM_EXIT:
467 case IDM_HELPTUTOR:
468 case IDM_HELPCONTENTS:
469 case IDM_HELPGENERAL:
470 case IDM_HELPKEYS:
471 case IDM_HELPMOUSE:
472 case IDM_HELP:
473 case IDM_FONTPALETTE:
474 case IDM_HICOLORPALETTE:
475 case IDM_COLORPALETTE:
476 case IDM_SYSTEMCLOCK:
477 return MainWMCommand(hwnd, msg, mp1, mp2);
478
479 case IDM_REMAP:
480 WinDlgBox(HWND_DESKTOP,
481 hwnd, RemapDlgProc, FM3ModHandle, MAP_FRAME, NULL);
482 break;
483
484 case IDM_TWODIRS: // Menu action
485 case IDM_WINDOWDLG: // Toolbar action
486 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
487 if (pd) {
488
489 WALK2 wa;
490
491 memset(&wa, 0, sizeof(wa));
492 wa.size = sizeof(wa);
493 *wa.szCurrentPath1 = 0;
494 WinSendMsg(pd->hwndDir1,
495 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
496 MakeValidDir(wa.szCurrentPath1);
497 *wa.szCurrentPath2 = 0;
498 WinSendMsg(pd->hwndDir2,
499 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
500 MakeValidDir(wa.szCurrentPath2);
501 if (WinDlgBox(HWND_DESKTOP,
502 hwnd,
503 WalkTwoSetDlgProc,
504 FM3ModHandle,
505 WALK2_FRAME,
506 MPFROMP(&wa)) &&
507 (IsRoot(wa.szCurrentPath1) ||
508 !IsFile(wa.szCurrentPath1)) &&
509 (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
510 WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1,
511 FID_CLIENT), DIR_CNR),
512 UM_SETDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
513 WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2,
514 FID_CLIENT), DIR_CNR),
515 UM_SETDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
516 }
517 }
518 break;
519
520 case IDM_COMPARE:
521 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
522 if (pd) {
523
524 WALK2 wa;
525
526 memset(&wa, 0, sizeof(wa));
527 wa.size = sizeof(wa);
528 *wa.szCurrentPath1 = 0;
529 WinSendMsg(pd->hwndDir1,
530 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
531 MakeValidDir(wa.szCurrentPath1);
532 *wa.szCurrentPath2 = 0;
533 WinSendMsg(pd->hwndDir2,
534 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
535 MakeValidDir(wa.szCurrentPath2);
536 if (WinDlgBox(HWND_DESKTOP,
537 hwnd,
538 WalkTwoCmpDlgProc,
539 FM3ModHandle,
540 WALK2_FRAME,
541 MPFROMP(&wa)) &&
542 (IsRoot(wa.szCurrentPath1) ||
543 !IsFile(wa.szCurrentPath1)) &&
544 (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
545 if (!*dircompare) {
546
547 COMPARE *cmp;
548
549 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
550 if (cmp) {
551 cmp->size = sizeof(COMPARE);
552 strcpy(cmp->leftdir, wa.szCurrentPath1);
553 strcpy(cmp->rightdir, wa.szCurrentPath2);
554 cmp->hwndParent = hwnd;
555 cmp->dcd.hwndParent = hwnd;
556 WinDlgBox(HWND_DESKTOP,
557 HWND_DESKTOP,
558 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
559 }
560 }
561 else {
562 CHAR szPath1[CCHMAXPATH];
563 CHAR szPath2[CCHMAXPATH];
564 runemf2(SEPARATE,
565 HWND_DESKTOP, pszSrcFile, __LINE__,
566 NULL, NULL,
567 "%s %s %s",
568 dircompare,
569 BldQuotedFileName(szPath1, wa.szCurrentPath1),
570 BldQuotedFileName(szPath2, wa.szCurrentPath2));
571 }
572 }
573 }
574 break;
575
576 case IDM_VTREE:
577 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
578 if (hwndTree) {
579 WinShowWindow(hwndTree, FALSE);
580 PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
581 hwndTree = (HWND) 0;
582 }
583 else {
584
585 ULONG size = sizeof(ULONG);
586
587 hwndTree = StartTreeCnr(hwnd, 3);
588 PrfQueryProfileData(fmprof,
589 realappname,
590 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
591 TreeWidth = max(TreeWidth, 80);
592 }
593 {
594 BOOL dummy = (hwndTree != (HWND) 0);
595
596 PrfWriteProfileData(fmprof,
597 realappname,
598 "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
599 }
600 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
601 break;
602
603 case IDM_TILEBACKWARDS:
604 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
605 fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
606 PrfWriteProfileData(fmprof,
607 (CHAR *) FM3Str,
608 "TileBackwards",
609 (PVOID) & fTileBackwards, sizeof(BOOL));
610 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
611 break;
612
613 case IDM_NEXTWINDOW:
614 case IDM_PREVWINDOW:
615 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
616 if (pd) {
617
618 HWND hwndFocus;
619
620 if (hwndTree) {
621 if (pd->hwndMax) {
622 if (hwndTree == pd->hwndCurr)
623 hwndFocus = pd->hwndMax;
624 else
625 hwndFocus = hwndTree;
626 }
627 else {
628 if (hwndTree == pd->hwndCurr)
629 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
630 pd->hwndDir1 : pd->hwndDir2;
631 else if (pd->hwndDir1 == pd->hwndCurr)
632 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
633 pd->hwndDir2 : hwndTree;
634 else
635 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
636 hwndTree : pd->hwndDir1;
637 }
638 }
639 else {
640 if (pd->hwndMax)
641 hwndFocus = pd->hwndMax;
642 else
643 hwndFocus = pd->hwndCurr == pd->hwndDir1 ?
644 pd->hwndDir2 : pd->hwndDir1;
645 }
646 WinSetFocus(HWND_DESKTOP, hwndFocus);
647 }
648 break;
649
650 case IDM_NOTEBOOK:
651 case IDM_DIRCNRSETTINGS:
652 case IDM_DIRVIEWSETTINGS:
653 case IDM_DIRSORTSETTINGS:
654 case IDM_COLLECTORVIEWSETTINGS:
655 case IDM_COLLECTORSORTSETTINGS:
656 case IDM_ARCHIVERSETTINGS:
657 case IDM_TREECNRVIEWSETTINGS:
658 case IDM_TREECNRSORTSETTINGS:
659 case IDM_VIEWERSETTINGS:
660 case IDM_VIEWERSETTINGS2:
661 case IDM_COMPARESETTINGS:
662 case IDM_MONOLITHICSETTINGS:
663 case IDM_GENERALSETTINGS:
664 case IDM_SCANSETTINGS:
665 case IDM_BUBBLESSETTINGS:
666 WinDlgBox(HWND_DESKTOP,
667 hwnd,
668 CfgDlgProc,
669 FM3ModHandle,
670 CFG_FRAME,
671 MPFROMLONG(mp1)); // 15 Feb 08 SHL
672 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
673 break;
674
675 case IDM_SEEALL:
676 case IDM_GREP:
677 case IDM_COLLECTOR:
678 {
679 HWND hwndC;
680
681 hwndC = StartCollector(HWND_DESKTOP, 4);
682 if (hwndC) {
683 WinSetWindowPos(hwndC,
684 HWND_TOP,
685 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
686 if (SHORT1FROMMP(mp1) == IDM_GREP)
687 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
688 WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
689 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
690 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
691 WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
692 }
693 }
694 break;
695
696 case IDM_EDITCOMMANDS:
697 EditCommands(hwnd);
698 break;
699
700 default:
701 if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
702 SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
703 if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
704 WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
705 break;
706 }
707 else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
708 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
709
710 INT x;
711 HWND hwndCnr;
712
713 if (!cmdloaded)
714 load_commands();
715 hwndCnr = TopWindow(hwnd, (HWND) 0);
716 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
717 UM_CONTAINERHWND, MPVOID, MPVOID);
718 if (!hwndCnr) {
719 Runtime_Error(pszSrcFile, __LINE__, NULL);
720 break;
721 }
722 x = SHORT1FROMMP(mp1);// - IDM_COMMANDSTART;
723 if (x >= 0) {
724 //x++;
725 RunCommand(hwndCnr, x);
726 if (fUnHilite) {
727
728 PCNRITEM pci;
729 DIRCNRDATA *dcd = NULL;
730
731 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
732 dcd = INSTDATA(hwndCnr);
733 pci = (PCNRITEM) WinSendMsg(hwndCnr,
734 CM_QUERYRECORDEMPHASIS,
735 MPFROMLONG(CMA_FIRST),
736 MPFROMSHORT(CRA_CURSORED));
737 if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
738 UnHilite(hwnd,
739 TRUE,
740 dcd ? &dcd->lastselection : NULL,
741 dcd ? dcd->ulItemsToUnHilite : 0);
742 }
743 }
744 }
745 }
746 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
747 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
748 if (!qtloaded)
749 load_quicktools();
750 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
751 if (fToolsChanged)
752 save_tools(NULL);
753 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
754 load_tools(NULL);
755 else {
756 strcpy(lasttoolbar,
757 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
758 PrfWriteProfileString(fmprof, appname, "LastToolbar", lasttoolbar);
759 }
760 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
761 }
762 }
763 else {
764
765 HWND hwndActive;
766
767 hwndActive = TopWindow(hwnd, (HWND) 0);
768 if (hwndActive)
769 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
770 }
771 break;
772 }
773 return 0;
774}
775
776static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
777 MPARAM mp2)
778{
779 PERSON1DATA *pd;
780
781 switch (msg) {
782 case WM_CREATE:
783 {
784 TID tid;
785
786 WinQueryWindowProcess(hwnd, &mypid, &tid);
787 }
788 hwndMain = hwnd;
789 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
790 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
791 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
792 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
793 if (xbeginthread(MakeMainObjWin,
794 245760,
795 MPVOID,
796 pszSrcFile,
797 __LINE__) == -1)
798 {
799 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
800 return 0;
801 }
802 else
803 DosSleep(32);//05 Aug 07 GKY 64
804
805 pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
806 if (!pd)
807 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
808 else {
809 pd->size = sizeof(PERSON1DATA);
810 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
811 }
812 {
813 SWP swp;
814 PFNWP oldproc;
815
816 /*
817 * create frame children (not client children, frame children)
818 */
819 DosSleep(1);
820 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
821 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
822 (PFNWP) MainFrameWndProc2);
823 if (oldproc)
824 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
825 CommonCreateMainChildren(hwnd, &swp);
826
827 {
828 HWND hwndMenu;
829
830 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
831 WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
832 CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
833 SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
834 if (fProtectOnly) {
835 WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
836 WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
837 }
838 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
839 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
840 }
841 }
842 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
843 FID_TITLEBAR), "FM/2 Lite");
844 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
845 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
846 break;
847
848 case UM_SETUP:
849 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
850 if (pd) {
851
852 CHAR s[CCHMAXPATH];
853 ULONG size;
854 DIRCNRDATA *dcd;
855 HWND hwndC;
856 BOOL dummy = TRUE;
857
858 size = sizeof(BOOL);
859 PrfQueryProfileData(fmprof, realappname, "FM/4 TreeUp",
860 (PVOID) &dummy, &size);
861 if (dummy) {
862 size = sizeof(ULONG);
863 hwndTree = StartTreeCnr(hwnd, 3);
864 PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth",
865 (PVOID) &TreeWidth, &size);
866 TreeWidth = max(TreeWidth, 80);
867 }
868 size = sizeof(BOOL);
869 if (PrfQueryProfileData(fmprof, appname, "Toolbar", &dummy, &size) &&
870 size && !dummy)
871 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
872
873 size = sizeof(s);
874 *s = 0;
875 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1", s, &size) && *s)
876 MakeValidDir(s);
877 else
878 save_dir(s);
879 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
880 StartDirCnr(hwnd, s, (HWND) 0, 3);
881 size = sizeof(s);
882 *s = 0;
883 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2", s, &size) && *s)
884 MakeValidDir(s);
885 else
886 save_dir(s);
887 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
888 if (fInitialDriveScan) {
889 DosPostEventSem(hevInitialCnrScanComplete);
890 DosCloseEventSem(hevInitialCnrScanComplete);
891 fInitialDriveScan = FALSE;
892 }
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 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1461 if (hwndHelp)
1462 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1463 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1464 }
1465 return hwndFrame;
1466}
1467
1468#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
1469#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
1470#pragma alloc_text(PERSON13,MainWMCommand2)
Note: See TracBrowser for help on using the repository browser.