source: trunk/dll/mainwnd2.c@ 940

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

Minor cleanup, added comments and History for recent changes

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