source: trunk/dll/mainwnd2.c@ 775

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

Minor clean up add comments re recent changes

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