source: trunk/dll/mainwnd2.c@ 1880

Last change on this file since 1880 was 1880, checked in by Gregg Young, 10 years ago

Remove dead code and comments from remaining c files. #if 0 and #if NEVER were not addressed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: mainwnd2.c 1880 2015-10-12 18:26:16Z gyoung $
5
6 fm/4 main window
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2005, 2010 Steven H. Levine
10
11 23 May 05 SHL Use datamin.h
12 26 May 05 SHL Comments and localize code
13 06 Aug 05 SHL Renames
14 02 Jan 06 SHL Use QWL_USER more
15 02 Jan 06 SHL Map IDM_WINDOWDLG to match IBM_TWODIRS
16 17 Jul 06 SHL Use Runtime_Error
17 30 Mar 07 GKY Remove GetPString for window class names
18 12 May 07 SHL Pass ulItemsToUnHilite to UnHilite
19 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
20 07 Aug 07 SHL Use BldQuotedFileName
21 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
22 10 Jan 08 SHL Sync with CfgDlgProc mods
23 19 Jan 08 GKY Rework Utilities menu
24 14 Feb 08 SHL Rework to support settings menu conditional cascade
25 29 Feb 08 GKY Use xfree where appropriate
26 27 Aug 08 JBS Ticket 259: Support saving/restoring toolbars with states
27 01 Sep 08 GKY Add bmps for default toolbars
28 10 Dec 08 SHL Integrate exception handler support
29 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
30 Dos/Win programs from being inserted into the execute dialog with message why.
31 21 Jun 09 GKY Added drive letter to bitmap buttons in drive bar; Eliminate static drive
32 letter windows; Use button ID to identify drive letter for processing.
33 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
34 12 Sep 09 GKY Add FM3.INI User ini and system ini to submenu for view ini
35 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
36 profile calls for user settings that work and are setable in more than one
37 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
38 aren't user settable; realappname should be used for setting applicable to
39 one or more miniapp but not to FM/2
40 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
41 11 Apr 10 GKY Fix drive tree rescan failure and program hang caused by event sem
42 never being posted
43 12 Aug 12 GKY Allow for selection of include subdirectories or a list file on initial startup of compare dirs
44 28 Jun 14 GKY Fix errors identified with CPPCheck;
45
46***********************************************************************/
47
48#include <stdlib.h>
49#include <string.h>
50#include <share.h>
51
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 BOOL yes;
439
440 SetShiftState();
441 switch (SHORT1FROMMP(mp1)) {
442 case IDM_TOAUTOMLE:
443 case IDM_CLI:
444 case IDM_CREATETOOL:
445 case IDM_ABOUT:
446 case IDM_WINFULLSCREEN:
447 case IDM_DOSCOMMANDLINE:
448 case IDM_INIVIEWER:
449 case IDM_INIVIEWERFM2:
450 case IDM_INIVIEWERSYS:
451 case IDM_EDITASSOC:
452 case IDM_COMMANDLINE:
453 case IDM_KILLPROC:
454 case IDM_TOOLBAR:
455 case IDM_TEXTTOOLS:
456 case IDM_TOOLTITLES:
457 case IDM_TOOLLEFT:
458 case IDM_TOOLRIGHT:
459 case IDM_AUTOVIEWCOMMENTS:
460 case IDM_AUTOVIEWFILE:
461 case IDM_AUTOVIEW:
462 case IDM_CONFIRMDELETE: // 2014-05-17 SHL
463 case IDM_TOGGLEDRAGDIALOG: // 2014-05-15 SHL
464 case IDM_HIDENOTEWND:
465 case IDM_SHOWNOTEWND:
466 case IDM_INSTANT:
467 case IDM_HELPCONTEXT:
468 case IDM_HELPHINTS:
469 case IDM_HELPPIX:
470 case IDM_KILLME:
471 case IDM_EXIT:
472 case IDM_HELPTUTOR:
473 case IDM_HELPCONTENTS:
474 case IDM_HELPGENERAL:
475 case IDM_HELPKEYS:
476 case IDM_HELPMOUSE:
477 case IDM_HELP:
478 case IDM_FONTPALETTE:
479 case IDM_HICOLORPALETTE:
480 case IDM_COLORPALETTE:
481 case IDM_SYSTEMCLOCK:
482 return MainWMCommand(hwnd, msg, mp1, mp2);
483
484 case IDM_REMAP:
485 WinDlgBox(HWND_DESKTOP,
486 hwnd, RemapDlgProc, FM3ModHandle, MAP_FRAME, NULL);
487 break;
488
489 case IDM_TWODIRS: // Menu action
490 case IDM_WINDOWDLG: // Toolbar action
491 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
492 if (pd) {
493
494 WALK2 wa;
495
496 memset(&wa, 0, sizeof(wa));
497 wa.size = sizeof(wa);
498 *wa.szCurrentPath1 = 0;
499 WinSendMsg(pd->hwndDir1,
500 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
501 MakeValidDir(wa.szCurrentPath1);
502 *wa.szCurrentPath2 = 0;
503 WinSendMsg(pd->hwndDir2,
504 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
505 MakeValidDir(wa.szCurrentPath2);
506 if (WinDlgBox(HWND_DESKTOP,
507 hwnd,
508 WalkTwoSetDlgProc,
509 FM3ModHandle,
510 WALK2_FRAME,
511 MPFROMP(&wa)) &&
512 (IsRoot(wa.szCurrentPath1) ||
513 !IsFile(wa.szCurrentPath1)) &&
514 (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
515 WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir1,
516 FID_CLIENT), DIR_CNR),
517 UM_SETDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
518 WinSendMsg(WinWindowFromID(WinWindowFromID(pd->hwndDir2,
519 FID_CLIENT), DIR_CNR),
520 UM_SETDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
521 }
522 }
523 break;
524
525 case IDM_COMPARE:
526 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
527 if (pd) {
528
529 WALK2 wa;
530
531 memset(&wa, 0, sizeof(wa));
532 wa.size = sizeof(wa);
533 *wa.szCurrentPath1 = 0;
534 WinSendMsg(pd->hwndDir1,
535 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath1), MPVOID);
536 MakeValidDir(wa.szCurrentPath1);
537 *wa.szCurrentPath2 = 0;
538 WinSendMsg(pd->hwndDir2,
539 UM_CONTAINERDIR, MPFROMP(wa.szCurrentPath2), MPVOID);
540 MakeValidDir(wa.szCurrentPath2);
541 if (WinDlgBox(HWND_DESKTOP,
542 hwnd,
543 WalkTwoCmpDlgProc,
544 FM3ModHandle,
545 WALK2_FRAME,
546 MPFROMP(&wa)) &&
547 (IsRoot(wa.szCurrentPath1) ||
548 !IsFile(wa.szCurrentPath1)) &&
549 (IsRoot(wa.szCurrentPath2) || !IsFile(wa.szCurrentPath2))) {
550 if (!*dircompare) {
551
552 COMPARE *cmp;
553
554 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
555 if (cmp) {
556 cmp->size = sizeof(COMPARE);
557 strcpy(cmp->leftdir, wa.szCurrentPath1);
558 strcpy(cmp->rightdir, wa.szCurrentPath2);
559 cmp->listfile = wa.listfile;
560 cmp->includesubdirs = wa.includesubdirs;
561 cmp->hwndParent = hwnd;
562 cmp->dcd.hwndParent = hwnd;
563 WinDlgBox(HWND_DESKTOP,
564 HWND_DESKTOP,
565 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
566 }
567 }
568 else {
569 CHAR szPath1[CCHMAXPATH];
570 CHAR szPath2[CCHMAXPATH];
571 runemf2(SEPARATE,
572 HWND_DESKTOP, pszSrcFile, __LINE__,
573 NULL, NULL,
574 "%s %s %s",
575 dircompare,
576 BldQuotedFileName(szPath1, wa.szCurrentPath1),
577 BldQuotedFileName(szPath2, wa.szCurrentPath2));
578 }
579 }
580 }
581 break;
582
583 case IDM_VTREE:
584 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
585 if (hwndTree) {
586 // Hide
587 WinShowWindow(hwndTree, FALSE);
588 PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
589 hwndTree = NULLHANDLE;
590 }
591 else {
592 // Create tree window if needed and make visible
593 ULONG size = sizeof(ULONG);
594 hwndTree = StartTreeCnr(hwnd, 3);
595 PrfQueryProfileData(fmprof, realappname,
596 "FM/4 TreeWidth", (PVOID)&TreeWidth, &size);
597 TreeWidth = max(TreeWidth, 80);
598 }
599 yes = hwndTree != NULLHANDLE;
600 PrfWriteProfileData(fmprof, realappname,
601 "FM/4 TreeUp", (PVOID)&yes, sizeof(yes));
602 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
603 break;
604
605 case IDM_TILEBACKWARDS:
606 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
607 fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
608 PrfWriteProfileData(fmprof,
609 FM3Str,
610 "TileBackwards",
611 (PVOID) & fTileBackwards, sizeof(BOOL));
612 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
613 break;
614
615 case IDM_NEXTWINDOW:
616 case IDM_PREVWINDOW:
617 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
618 if (pd) {
619
620 HWND hwndFocus;
621
622 if (hwndTree) {
623 if (pd->hwndMax) {
624 if (hwndTree == pd->hwndCurr)
625 hwndFocus = pd->hwndMax;
626 else
627 hwndFocus = hwndTree;
628 }
629 else {
630 if (hwndTree == pd->hwndCurr)
631 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
632 pd->hwndDir1 : pd->hwndDir2;
633 else if (pd->hwndDir1 == pd->hwndCurr)
634 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
635 pd->hwndDir2 : hwndTree;
636 else
637 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
638 hwndTree : pd->hwndDir1;
639 }
640 }
641 else {
642 if (pd->hwndMax)
643 hwndFocus = pd->hwndMax;
644 else
645 hwndFocus = pd->hwndCurr == pd->hwndDir1 ?
646 pd->hwndDir2 : pd->hwndDir1;
647 }
648 WinSetFocus(HWND_DESKTOP, hwndFocus);
649 }
650 break;
651
652 case IDM_NOTEBOOK:
653 case IDM_DIRCNRSETTINGS:
654 case IDM_DIRVIEWSETTINGS:
655 case IDM_DIRSORTSETTINGS:
656 case IDM_COLLECTORVIEWSETTINGS:
657 case IDM_COLLECTORSORTSETTINGS:
658 case IDM_ARCHIVERSETTINGS:
659 case IDM_TREECNRVIEWSETTINGS:
660 case IDM_TREECNRSORTSETTINGS:
661 case IDM_VIEWERSETTINGS:
662 case IDM_VIEWERSETTINGS2:
663 case IDM_COMPARESETTINGS:
664 case IDM_MONOLITHICSETTINGS:
665 case IDM_GENERALSETTINGS:
666 case IDM_SCANSETTINGS:
667 case IDM_BUBBLESSETTINGS:
668 WinDlgBox(HWND_DESKTOP,
669 hwnd,
670 CfgDlgProc,
671 FM3ModHandle,
672 CFG_FRAME,
673 MPFROMLONG(mp1)); // 15 Feb 08 SHL
674 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
675 break;
676
677 case IDM_SEEALL:
678 case IDM_GREP:
679 case IDM_COLLECTOR:
680 {
681 HWND hwndC;
682
683 hwndC = StartCollector(HWND_DESKTOP, 4);
684 if (hwndC) {
685 WinSetWindowPos(hwndC,
686 HWND_TOP,
687 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
688 if (SHORT1FROMMP(mp1) == IDM_GREP)
689 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
690 WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
691 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
692 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
693 WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
694 }
695 }
696 break;
697
698 case IDM_EDITCOMMANDS:
699 EditCommands(hwnd);
700 break;
701
702 default:
703 if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
704 SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
705 if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
706 WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
707 break;
708 }
709 else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
710 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
711
712 INT x;
713 HWND hwndCnr;
714
715 if (!cmdloaded)
716 load_commands();
717 hwndCnr = TopWindow(hwnd, (HWND) 0);
718 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
719 UM_CONTAINERHWND, MPVOID, MPVOID);
720 if (!hwndCnr) {
721 Runtime_Error(pszSrcFile, __LINE__, NULL);
722 break;
723 }
724 x = SHORT1FROMMP(mp1);
725 if (x >= 0) {
726 RunCommand(hwndCnr, x);
727 if (fUnHilite) {
728
729 PCNRITEM pci;
730 DIRCNRDATA *dcd = NULL;
731
732 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
733 dcd = INSTDATA(hwndCnr);
734 pci = (PCNRITEM) WinSendMsg(hwndCnr,
735 CM_QUERYRECORDEMPHASIS,
736 MPFROMLONG(CMA_FIRST),
737 MPFROMSHORT(CRA_CURSORED));
738 if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
739 UnHilite(hwnd,
740 TRUE,
741 dcd ? &dcd->lastselection : NULL,
742 dcd ? dcd->ulItemsToUnHilite : 0);
743 }
744 }
745 }
746 }
747 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
748 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 51) {
749 if (!qtloaded)
750 load_quicktools();
751 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]) {
752 if (fToolsChanged)
753 save_tools(NULL);
754 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]))
755 load_tools(NULL);
756 else {
757 strcpy(lasttoolbar,
758 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART - 1]);
759 PrfWriteProfileString(fmprof, appname, "LastToolbar", lasttoolbar);
760 }
761 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
762 }
763 }
764 else {
765
766 HWND hwndActive;
767
768 hwndActive = TopWindow(hwnd, (HWND) 0);
769 if (hwndActive)
770 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
771 }
772 break;
773 }
774 return 0;
775}
776
777static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
778 MPARAM mp2)
779{
780 PERSON1DATA *pd;
781 TID tid;
782 SWP swp;
783 PFNWP oldproc;
784 HWND hwndMenu;
785 DIRCNRDATA *dcd;
786 HWND hwndC;
787 ULONG which;
788 ULONG size;
789 BOOL yes;
790
791 switch (msg) {
792 case WM_CREATE:
793 WinQueryWindowProcess(hwnd, &mypid, &tid);
794 hwndMain = hwnd;
795
796 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
797 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
798 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
799 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
800 if (xbeginthread(MakeMainObjWin,
801 245760,
802 MPVOID,
803 pszSrcFile,
804 __LINE__) == -1)
805 {
806 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
807 return 0;
808 }
809 else
810 DosSleep(32);
811
812 pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
813 if (!pd)
814 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
815 else {
816 pd->size = sizeof(PERSON1DATA);
817 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
818 }
819
820 // create frame children (not client children, frame children)
821 DosSleep(1);
822 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
823 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
824 (PFNWP) MainFrameWndProc2);
825 if (oldproc)
826 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
827
828 CommonCreateMainChildren(hwnd, &swp);
829
830 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
831 WinSetWindowULong(hwnd, QWL_USER, hwndMenu);
832
833 // 2014-05-15 SHL FIXME to be sure needed
834 // WinCheckMenuItem(hwndMenu, IDM_TOGGLEDRAGDIALOG, fDragndropDlg); // 2014-05-15 SHL
835
836 CfgMenuInit(hwndMenu, FALSE); // 14 Feb 08 SHL
837 SetConditionalCascade(hwndMenu, IDM_COMMANDLINESUBMENU, IDM_COMMANDLINE);
838
839 if (fProtectOnly) {
840 WinEnableMenuItem(hwndMenu, IDM_DOSCOMMANDLINE, FALSE);
841 WinEnableMenuItem(hwndMenu, IDM_WINFULLSCREEN, FALSE);
842 }
843
844 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
845 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
846
847 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
848 FID_TITLEBAR), "FM/2 Lite");
849
850 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
851 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
852 break;
853
854 case UM_SETUP:
855 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
856 if (pd) {
857 CHAR s[CCHMAXPATH];
858 yes = TRUE;
859 size = sizeof(BOOL);
860 PrfQueryProfileData(fmprof, realappname,
861 "FM/4 TreeUp", (PVOID)&yes, &size);
862 if (yes) {
863 hwndTree = StartTreeCnr(hwnd, 3);
864 size = sizeof(TreeWidth);
865 PrfQueryProfileData(fmprof, realappname, "FM/4 TreeWidth",
866 (PVOID)&TreeWidth, &size);
867 TreeWidth = max(TreeWidth, 80);
868 }
869 size = sizeof(BOOL);
870 if (PrfQueryProfileData(fmprof, appname, "Toolbar", &yes, &size) &&
871 size &&
872 !yes)
873 {
874 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
875 }
876
877 size = sizeof(s);
878 *s = 0;
879 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1", s, &size) && *s)
880 MakeValidDir(s);
881 else
882 save_dir(s);
883 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
884 StartDirCnr(hwnd, s, (HWND) 0, 3);
885 size = sizeof(s);
886 *s = 0;
887 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2", s, &size) && *s)
888 MakeValidDir(s);
889 else
890 save_dir(s);
891 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
892 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
893
894 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
895 if (hwndC) {
896 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
897 if (dcd) {
898 size = sizeof(INT);
899 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
900 (PVOID) & dcd->sortFlags,
901 &size) && size == sizeof(INT)) {
902 if (!dcd->sortFlags)
903 dcd->sortFlags = SORT_PATHNAME;
904 }
905 size = sizeof(MASK);
906 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
907 (PVOID) & dcd->mask, &size) && size) {
908 if (*dcd->mask.szMask)
909 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
910 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
911 }
912 *(dcd->mask.prompt) = 0;
913 size = sizeof(ULONG);
914 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir1.View",
915 (PVOID) & dcd->flWindowAttr,
916 &size) && size == sizeof(ULONG)) {
917
918 CNRINFO cnri;
919
920 memset(&cnri, 0, sizeof(CNRINFO));
921 cnri.cb = sizeof(CNRINFO);
922 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
923 CM_QUERYCNRINFO,
924 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
925 cnri.flWindowAttr = dcd->flWindowAttr;
926 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
927 CM_SETCNRINFO,
928 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
929 }
930 }
931 }
932 }
933
934 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
935 if (hwndC) {
936 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
937 if (dcd) {
938 size = sizeof(INT);
939 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
940 (PVOID) & dcd->sortFlags,
941 &size) && size == sizeof(INT)) {
942 if (!dcd->sortFlags)
943 dcd->sortFlags = SORT_PATHNAME;
944 }
945 size = sizeof(MASK);
946 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
947 (PVOID) & dcd->mask, &size) && size) {
948 if (*dcd->mask.szMask)
949 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
950 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
951 }
952 *(dcd->mask.prompt) = 0;
953 size = sizeof(ULONG);
954 if (PrfQueryProfileData(fmprof, realappname, "FM/4 Dir2.View",
955 (PVOID) & dcd->flWindowAttr,
956 &size) && size == sizeof(ULONG)) {
957
958 CNRINFO cnri;
959
960 memset(&cnri, 0, sizeof(CNRINFO));
961 cnri.cb = sizeof(CNRINFO);
962 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
963 CM_QUERYCNRINFO,
964 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
965 cnri.flWindowAttr = dcd->flWindowAttr;
966 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
967 CM_SETCNRINFO,
968 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
969 }
970 }
971 }
972 }
973 //}
974 // 2014-06-11 SHL Initialize view, sort and filter button text
975 if (pd->hwndDir1) {
976 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
977 if (hwndC) {
978 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
979 if (dcd && dcd->hwndCnr)
980 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
981 }
982 }
983 if (pd->hwndDir2) {
984 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
985 if (hwndC) {
986 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
987 if (dcd && dcd->hwndCnr)
988 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
989 }
990 }
991
992 which = 0;
993 size = sizeof(ULONG);
994 if (PrfQueryProfileData(fmprof,
995 realappname,
996 "FM/4 Max",
997 (PVOID)&which,
998 &size) &&
999 size == sizeof(ULONG) &&
1000 which)
1001 {
1002 PostMsg(hwnd,
1003 UM_MAXIMIZE,
1004 MPFROMLONG(((which == 1) ?
1005 pd->hwndDir1 : pd->hwndDir2)), MPVOID);
1006 }
1007 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1008 if (!hwndTree)
1009 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
1010 load_tools(NULL);
1011 PostMsg(hwndToolback, UM_SETUP2, MPVOID, MPVOID);
1012 fRunning = TRUE;
1013 } //if pd
1014 return 0;
1015
1016 case WM_SAVEAPPLICATION:
1017 WinStoreWindowPos((CHAR *) FM2Str,
1018 "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
1019 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1020 if (pd) {
1021
1022 CHAR s[CCHMAXPATH];
1023 HWND hwndC;
1024 DIRCNRDATA *dcd;
1025 ULONG flWindowAttr;
1026
1027 *s = 0;
1028 WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
1029 if (*s) {
1030 MakeValidDir(s);
1031 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
1032 }
1033 *s = 0;
1034 WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
1035 if (*s) {
1036 MakeValidDir(s);
1037 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
1038 }
1039 flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
1040 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
1041 PrfWriteProfileData(fmprof,
1042 realappname,
1043 "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
1044 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
1045 if (hwndC) {
1046 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
1047 if (dcd) {
1048 flWindowAttr = dcd->flWindowAttr;
1049 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
1050 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1051 if (dcd->lastattr) {
1052 if (dcd->lastattr & CV_TEXT)
1053 flWindowAttr |= CV_TEXT;
1054 else if (dcd->lastattr & CV_DETAIL)
1055 flWindowAttr |= CV_DETAIL;
1056 else if (dcd->lastattr & CV_ICON)
1057 flWindowAttr |= CV_ICON;
1058 else
1059 flWindowAttr |= CV_NAME;
1060 }
1061 else
1062 flWindowAttr |= CV_NAME;
1063 }
1064 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Sort",
1065 (PVOID) & dcd->sortFlags, sizeof(INT));
1066 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.Filter",
1067 (PVOID) & dcd->mask, sizeof(MASK));
1068 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir1.View",
1069 (PVOID) & flWindowAttr, sizeof(ULONG));
1070 }
1071 }
1072
1073 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
1074 if (hwndC) {
1075 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
1076 if (dcd) {
1077 flWindowAttr = dcd->flWindowAttr;
1078 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
1079 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1080 if (dcd->lastattr) {
1081 if (dcd->lastattr & CV_TEXT)
1082 flWindowAttr |= CV_TEXT;
1083 else if (dcd->lastattr & CV_DETAIL)
1084 flWindowAttr |= CV_DETAIL;
1085 else if (dcd->lastattr & CV_ICON)
1086 flWindowAttr |= CV_ICON;
1087 else
1088 flWindowAttr |= CV_NAME;
1089 }
1090 else
1091 flWindowAttr |= CV_NAME;
1092 }
1093 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Sort",
1094 (PVOID) & dcd->sortFlags, sizeof(INT));
1095 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.Filter",
1096 (PVOID) & dcd->mask, sizeof(MASK));
1097 PrfWriteProfileData(fmprof, realappname, "FM/4 Dir2.View",
1098 (PVOID) & flWindowAttr, sizeof(ULONG));
1099 }
1100 }
1101 }
1102 break;
1103 }
1104 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1105}
1106
1107MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1108{
1109 PERSON1DATA *pd;
1110
1111 switch (msg) {
1112 case WM_SAVEAPPLICATION:
1113 case UM_SETUP:
1114 case WM_CREATE:
1115 return MainWMOnce2(hwnd, msg, mp1, mp2);
1116
1117 case UM_THREADUSE:
1118 case UM_LOADFILE:
1119 case UM_BUILDDRIVEBAR:
1120 case WM_TIMER:
1121 return CommonMainWndProc(hwnd, msg, mp1, mp2);
1122
1123 case UM_SETUP2:
1124 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1125 if (pd) {
1126 if (mp1) {
1127 if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
1128 BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
1129 if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
1130 BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
1131 if (hwndTree)
1132 BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
1133 }
1134 else {
1135 if (hwndTree)
1136 BoxWindow(hwndTree,
1137 (HPS) 0,
1138 (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
1139 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
1140 BoxWindow(pd->hwndDir1,
1141 (HPS) 0,
1142 (pd->hwndDir1 == pd->hwndCurr) ?
1143 CLR_RED :
1144 (pd->hwndDir1 == pd->hwndLastDir) ?
1145 CLR_DARKRED : CLR_PALEGRAY);
1146 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
1147 BoxWindow(pd->hwndDir2,
1148 (HPS) 0,
1149 (pd->hwndDir2 == pd->hwndCurr) ?
1150 CLR_RED :
1151 (pd->hwndDir2 == pd->hwndLastDir) ?
1152 CLR_DARKRED : CLR_PALEGRAY);
1153 }
1154 }
1155 return 0;
1156
1157 case WM_BUTTON1DOWN:
1158 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1159 if (hwndTree) {
1160
1161 SWP swp;
1162
1163 WinQueryWindowPos(hwndTree, &swp);
1164 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1165 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
1166
1167 SWP swpC;
1168 TRACKINFO track;
1169
1170 WinQueryWindowPos(hwnd, &swpC);
1171 track.cxBorder = 4;
1172 track.cyBorder = 4;
1173 track.cxGrid = 1;
1174 track.cyGrid = 1;
1175 track.cxKeyboard = 8;
1176 track.cyKeyboard = 8;
1177 track.rclTrack.yBottom = 2;
1178 track.rclTrack.yTop = swpC.cy - 4;
1179 track.rclTrack.xLeft = 2;
1180 track.rclTrack.xRight = swp.x + swp.cx + 2;
1181 track.rclBoundary = track.rclTrack;
1182 track.rclBoundary.xRight = swpC.cx - 80;
1183 track.ptlMinTrackSize.x = 80;
1184 track.ptlMinTrackSize.y = swpC.cy - 4;
1185 track.ptlMaxTrackSize.x = swpC.cx - 80;
1186 track.ptlMaxTrackSize.y = swpC.cy - 4;
1187 track.fs = TF_RIGHT;
1188 if (WinTrackRect(hwnd, (HPS) 0, &track)) {
1189 TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
1190 PrfWriteProfileData(fmprof,
1191 realappname,
1192 "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
1193 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1194 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1195 }
1196 return (MRESULT) TRUE;
1197 }
1198 }
1199 break;
1200
1201 case WM_MOUSEMOVE:
1202 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1203 if (hwndTree) {
1204
1205 SWP swp;
1206
1207 if (WinQueryWindowPos(hwndTree, &swp)) {
1208 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1209 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
1210 WinSetPointer(HWND_DESKTOP, hptrEW);
1211 else
1212 WinSetPointer(HWND_DESKTOP, hptrArrow);
1213 }
1214 else
1215 WinSetPointer(HWND_DESKTOP, hptrArrow);
1216 }
1217 return (MRESULT) TRUE;
1218
1219 case WM_BUTTON1UP:
1220 case WM_BUTTON2UP:
1221 case WM_BUTTON3UP:
1222 case WM_CHAR:
1223 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1224 break;
1225
1226 case UM_ADVISEFOCUS:
1227 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1228 if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
1229 if ((HWND) mp1 != hwndTree)
1230 pd->hwndLastDir = (HWND) mp1;
1231 pd->hwndCurr = (HWND) mp1;
1232 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1233 }
1234 return 0;
1235
1236 case UM_MAXIMIZE:
1237 if (mp1) {
1238 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1239 if (pd) {
1240 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1241 if (pd->hwndMax != (HWND) mp1) {
1242 pd->hwndMax = (HWND) mp1;
1243 WinSetFocus(HWND_DESKTOP, pd->hwndMax);
1244 }
1245 else
1246 pd->hwndMax = (HWND) 0;
1247 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
1248 }
1249 }
1250 return 0;
1251
1252 case WM_INITMENU:
1253 switch (SHORT1FROMMP(mp1)) {
1254 case IDM_FILESMENU:
1255 case IDM_VIEWSMENU:
1256 case IDM_DETAILSSETUP:
1257 case IDM_COMMANDSMENU:
1258 case IDM_SORTSUBMENU:
1259 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1260 if (pd)
1261 WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
1262 break;
1263 case IDM_CONFIGMENU:
1264 // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
1265 WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
1266 WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
1267 WinCheckMenuItem((HWND) mp2, IDM_CONFIRMDELETE, fConfirmDelete); // 2014-05-17 SHL
1268 WinCheckMenuItem((HWND) mp2, IDM_TOGGLEDRAGDIALOG, fDragndropDlg); // 2014-05-15 SHL
1269 break;
1270 case IDM_TOOLSUBMENU:
1271 // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
1272 WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
1273 WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
1274 WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
1275 break;
1276 case IDM_WINDOWSMENU:
1277 // 2014-05-17 SHL FIXME to use SetToggleChecks maybe
1278 WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
1279 WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
1280 SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
1281 break;
1282 }
1283 break;
1284
1285 case WM_SETFOCUS:
1286 if (mp2)
1287 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1288 break;
1289
1290 case UM_FOCUSME:
1291 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1292 if (pd)
1293 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
1294 return 0;
1295
1296 case UM_RESCAN:
1297 return 0;
1298
1299 case UM_SIZE:
1300 {
1301 SWP swp;
1302
1303 if (WinQueryWindowPos(hwnd, &swp)) {
1304 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1305 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
1306 }
1307 else
1308 return 0;
1309 }
1310 // intentional fallthru
1311 case WM_SIZE:
1312 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1313 if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
1314 if (hwndTree)
1315 WinSetWindowPos(hwndTree,
1316 HWND_TOP,
1317 2,
1318 2,
1319 TreeWidth - 4,
1320 SHORT2FROMMP(mp2) - 4,
1321 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1322 else
1323 TreeWidth = 0;
1324 if (!pd->hwndMax) {
1325 if (fTileBackwards) {
1326 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1327 (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
1328 TreeWidth) + 2,
1329 2,
1330 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1331 SHORT2FROMMP(mp2) - 4,
1332 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1333 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1334 TreeWidth + 2,
1335 2,
1336 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1337 SHORT2FROMMP(mp2) - 4,
1338 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1339 }
1340 else {
1341 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
1342 TreeWidth + 2,
1343 2,
1344 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1345 (SHORT2FROMMP(mp2) / 2) - 4,
1346 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1347 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
1348 TreeWidth + 2,
1349 (SHORT2FROMMP(mp2) / 2) + 2,
1350 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1351 (SHORT2FROMMP(mp2) / 2) - 4,
1352 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1353 }
1354 }
1355 else {
1356
1357 HWND hwndOther;
1358
1359 WinSetWindowPos(pd->hwndMax, HWND_TOP,
1360 TreeWidth + 2,
1361 2,
1362 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1363 SHORT2FROMMP(mp2) - 4,
1364 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1365 hwndOther = (pd->hwndMax == pd->hwndDir1) ?
1366 pd->hwndDir2 : pd->hwndDir1;
1367 WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
1368 }
1369 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1370 }
1371 if (msg == UM_SIZE)
1372 return 0;
1373 break;
1374
1375 case WM_ERASEBACKGROUND:
1376 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
1377 return 0;
1378
1379 case WM_PAINT:
1380 {
1381 HPS hps;
1382 RECTL rcl;
1383
1384 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
1385 if (hps) {
1386 WinQueryWindowRect(hwnd, &rcl);
1387 WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
1388 WinEndPaint(hps);
1389 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
1390 }
1391 }
1392 break;
1393
1394 case UM_COMMAND:
1395 case WM_COMMAND:
1396 return MainWMCommand2(hwnd, msg, mp1, mp2);
1397
1398 case WM_CLOSE:
1399 fAmClosing = TRUE;
1400 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
1401 CloseChildren(hwnd);
1402 PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
1403 fAmQuitting = TRUE; // Let world know quit in progress
1404 DosSleep(1);
1405 return 0; // Suppress WinDefWindowProc WM_QUIT message generation
1406
1407 case UM_CLOSE:
1408 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1409 return 0;
1410
1411 case WM_DESTROY:
1412 hwndMain = (HWND) 0;
1413 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
1414 xfree(pd, pszSrcFile, __LINE__);
1415 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1416 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1417 break;
1418 }
1419 return WinDefWindowProc(hwnd, msg, mp1, mp2);
1420}
1421
1422HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
1423{
1424 HWND hwndFrame, hwndClient;
1425 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1426 FCF_SIZEBORDER | FCF_MINMAX |
1427 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1428
1429 {
1430 INT x;
1431
1432 for (x = 1; x < argc; x++) {
1433 if (*argv[x] == '+' && !argv[x][1])
1434 fLogFile = TRUE;
1435 if (*argv[x] == '-') {
1436 if (argv[x][1])
1437 strcpy(profile, &argv[x][1]);
1438 }
1439 }
1440 }
1441 {
1442 CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
1443 FILESTATUS3 fsa;
1444
1445 if (PrfQueryProfileString(HINI_USERPROFILE,
1446 (CHAR *) FM2Str,
1447 "Home", NULL, inipath, sizeof(inipath))) {
1448 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
1449 if (fsa.attrFile & FILE_DIRECTORY) {
1450 if (DosQueryPathInfo(inipath,
1451 FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
1452 strcpy(fullpath, inipath);
1453 switch_to(fullpath);
1454 }
1455 }
1456 }
1457 }
1458
1459 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1460 WS_VISIBLE,
1461 &FrameFlags,
1462 (CHAR *) WC_MAINWND2,
1463 NULL,
1464 WS_VISIBLE | WS_ANIMATE,
1465 FM3ModHandle, MAIN2_FRAME, &hwndClient);
1466 if (hwndFrame) {
1467 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
1468 if (!WinRestoreWindowPos((CHAR *) FM2Str, "MainWindowPos2", hwndFrame)) {
1469
1470 ULONG fl = SWP_MOVE | SWP_SIZE;
1471 RECTL rcl;
1472 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1473 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1474
1475 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1476 rcl.yBottom += icz;
1477 rcl.yTop -= bsz;
1478 rcl.xLeft += bsz;
1479 rcl.xRight -= bsz;
1480 WinSetWindowPos(hwndFrame,
1481 HWND_TOP,
1482 rcl.xLeft,
1483 rcl.yBottom,
1484 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1485 }
1486 if (fLogFile) {
1487 CHAR *modea = "a+";
1488
1489 LogFileHandle = xfsopen("FM2.LOG", modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
1490 }
1491 if (hwndHelp)
1492 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1493 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1494 }
1495 return hwndFrame;
1496}
1497
1498#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
1499#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
1500#pragma alloc_text(PERSON13,MainWMCommand2)
Note: See TracBrowser for help on using the repository browser.