source: trunk/dll/mainwnd2.c@ 827

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

Move #pragma alloc_text to end for OpenWatcom compat

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