source: trunk/dll/mainwnd2.c@ 888

Last change on this file since 888 was 888, checked in by Gregg Young, 18 years ago

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

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