source: trunk/dll/mainwnd2.c@ 858

Last change on this file since 858 was 843, checked in by Steven Levine, 18 years ago

Revert to standard APIs where large file support not required by ticket #41

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