source: trunk/dll/mainwnd2.c@ 917

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

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

  • 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 917 2008-01-11 21:41:56Z stevenhl $
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
[672]23
[133]24***********************************************************************/
25
[907]26#include <stdlib.h>
27#include <string.h>
28#include <share.h>
29#include <process.h> // _beginthread
30
[2]31#define INCL_DOS
32#define INCL_WIN
33#define INCL_GPI
[841]34#define INCL_LONGLONG
[2]35
36#include "fm3dlg.h"
37#include "fm3str.h"
38#include "tools.h"
[133]39#include "datamin.h"
[907]40#include "comp.h" // COMPARE
41#include "arccnrs.h" // BldQuotedFileName
42#include "errutil.h" // Dos_Error...
43#include "strutil.h" // GetPString
44#include "fm3dll.h"
[2]45
[133]46typedef struct
47{
48 USHORT size;
49 USHORT dummy;
50 HWND hwndDir1;
51 HWND hwndDir2;
52 HWND hwndCurr;
53 HWND hwndLastDir;
54 HWND hwndMax;
[551]55}
56PERSON1DATA;
[2]57
[352]58static PSZ pszSrcFile = __FILE__;
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,
[917]505 HWND_DESKTOP, pszSrcFile, __LINE__,
506 NULL, NULL,
[773]507 "%s %s %s",
[133]508 dircompare,
[773]509 BldQuotedFileName(szPath1, wa.szCurrentPath1),
510 BldQuotedFileName(szPath2, wa.szCurrentPath2));
[133]511 }
[2]512 }
[133]513 }
514 break;
[2]515
[133]516 case IDM_VTREE:
[551]517 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
518 if (hwndTree) {
[133]519 WinShowWindow(hwndTree, FALSE);
[551]520 PostMsg(hwndTree, WM_CLOSE, MPVOID, MPVOID);
521 hwndTree = (HWND) 0;
[133]522 }
[551]523 else {
[2]524
[133]525 ULONG size = sizeof(ULONG);
[2]526
[133]527 hwndTree = StartTreeCnr(hwnd, 3);
528 PrfQueryProfileData(fmprof,
529 realappname,
[551]530 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
[133]531 TreeWidth = max(TreeWidth, 80);
532 }
533 {
[551]534 BOOL dummy = (hwndTree != (HWND) 0);
[2]535
536 PrfWriteProfileData(fmprof,
[133]537 realappname,
[551]538 "FM/4 TreeUp", (PVOID) & dummy, sizeof(dummy));
[133]539 }
[551]540 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]541 break;
[2]542
[133]543 case IDM_TILEBACKWARDS:
[551]544 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
[133]545 fTileBackwards = (fTileBackwards) ? FALSE : TRUE;
546 PrfWriteProfileData(fmprof,
547 FM3Str,
548 "TileBackwards",
[551]549 (PVOID) & fTileBackwards, sizeof(BOOL));
550 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]551 break;
[2]552
[133]553 case IDM_NEXTWINDOW:
554 case IDM_PREVWINDOW:
[299]555 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]556 if (pd) {
[2]557
[133]558 HWND hwndFocus;
559
[551]560 if (hwndTree) {
561 if (pd->hwndMax) {
562 if (hwndTree == pd->hwndCurr)
563 hwndFocus = pd->hwndMax;
[133]564 else
565 hwndFocus = hwndTree;
566 }
[551]567 else {
568 if (hwndTree == pd->hwndCurr)
[133]569 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]570 pd->hwndDir1 : pd->hwndDir2;
571 else if (pd->hwndDir1 == pd->hwndCurr)
[133]572 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]573 pd->hwndDir2 : hwndTree;
[133]574 else
575 hwndFocus = (SHORT1FROMMP(mp1) == IDM_PREVWINDOW) ?
[551]576 hwndTree : pd->hwndDir1;
[133]577 }
[2]578 }
[551]579 else {
580 if (pd->hwndMax)
581 hwndFocus = pd->hwndMax;
[133]582 else
[551]583 hwndFocus = (pd->hwndCurr == pd->hwndDir1) ?
584 pd->hwndDir2 : pd->hwndDir1;
[133]585 }
586 WinSetFocus(HWND_DESKTOP, hwndFocus);
587 }
588 break;
[2]589
[133]590 case IDM_NOTEBOOK:
[917]591 // Indicate fm/2 lite
592 // 10 Jan 08 SHL fixme to have IDM_FM2LITE
[133]593 WinDlgBox(HWND_DESKTOP,
594 hwnd,
[917]595 CfgDlgProc,
596 FM3ModHandle,
597 CFG_FRAME,
598 MPFROMLONG(IDM_LITESETTINGS));
[551]599 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]600 break;
[2]601
[133]602 case IDM_SEEALL:
603 case IDM_GREP:
604 case IDM_COLLECTOR:
605 {
606 HWND hwndC;
607
608 hwndC = StartCollector(HWND_DESKTOP, 4);
[551]609 if (hwndC) {
[133]610 WinSetWindowPos(hwndC,
611 HWND_TOP,
[551]612 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE);
[133]613 if (SHORT1FROMMP(mp1) == IDM_GREP)
614 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
[551]615 WM_COMMAND, MPFROM2SHORT(IDM_GREP, 0), MPVOID);
[133]616 if (SHORT1FROMMP(mp1) == IDM_SEEALL)
617 PostMsg(WinWindowFromID(hwndC, FID_CLIENT),
[551]618 WM_COMMAND, MPFROM2SHORT(IDM_SEEALL, 0), MPVOID);
[2]619 }
[133]620 }
621 break;
[2]622
[133]623 case IDM_EDITCOMMANDS:
624 EditCommands(hwnd);
625 break;
626
627 default:
628 if (SHORT1FROMMP(mp1) >= IDM_SWITCHSTART &&
[551]629 SHORT1FROMMP(mp1) < IDM_SWITCHSTART + 499) {
[133]630 if (SHORT1FROMMP(mp1) - IDM_SWITCHSTART < numswitches)
[551]631 WinSwitchToProgram(switches[SHORT1FROMMP(mp1) - IDM_SWITCHSTART]);
[2]632 break;
[133]633 }
634 else if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
[551]635 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[2]636
[133]637 INT x;
638 HWND hwndCnr;
639
640 if (!cmdloaded)
641 load_commands();
[551]642 hwndCnr = TopWindow(hwnd, (HWND) 0);
643 hwndCnr = (HWND) WinSendMsg(WinWindowFromID(hwndCnr, FID_CLIENT),
644 UM_CONTAINERHWND, MPVOID, MPVOID);
645 if (!hwndCnr) {
646 Runtime_Error2(pszSrcFile, __LINE__, IDS_NOWINDOWTEXT);
[133]647 break;
[2]648 }
[133]649 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
[551]650 if (x >= 0) {
[133]651 x++;
652 RunCommand(hwndCnr, x);
[551]653 if (fUnHilite) {
[2]654
[133]655 PCNRITEM pci;
656 DIRCNRDATA *dcd = NULL;
[2]657
[133]658 if (WinQueryWindowUShort(hwndCnr, QWS_ID) != TREE_CNR)
659 dcd = INSTDATA(hwndCnr);
660 pci = (PCNRITEM) WinSendMsg(hwndCnr,
661 CM_QUERYRECORDEMPHASIS,
662 MPFROMLONG(CMA_FIRST),
663 MPFROMSHORT(CRA_CURSORED));
[672]664 if (pci && (INT) pci != -1 && (pci->rc.flRecordAttr & CRA_SELECTED)) {
665 UnHilite(hwnd,
666 TRUE,
667 dcd ? &dcd->lastselection : NULL,
668 dcd ? dcd->ulItemsToUnHilite : 0);
669 }
[133]670 }
[2]671 }
[133]672 }
673 else if (SHORT1FROMMP(mp1) >= IDM_QUICKTOOLSTART &&
[551]674 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART + 50) {
[133]675 if (!qtloaded)
676 load_quicktools();
[551]677 if (quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]) {
[133]678 if (fToolsChanged)
679 save_tools(NULL);
680 if (!load_tools(quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]))
681 load_tools(NULL);
[551]682 else {
683 strcpy(lasttoolbox,
684 quicktool[SHORT1FROMMP(mp1) - IDM_QUICKTOOLSTART]);
685 PrfWriteProfileString(fmprof, FM3Str, "LastToolBox", lasttoolbox);
[133]686 }
687 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]688 MAIN_TOOLS), TRUE);
[2]689 }
[133]690 }
[551]691 else {
[2]692
[133]693 HWND hwndActive;
[2]694
[551]695 hwndActive = TopWindow(hwnd, (HWND) 0);
[133]696 if (hwndActive)
[551]697 PostMsg(WinWindowFromID(hwndActive, FID_CLIENT), msg, mp1, mp2);
[133]698 }
699 break;
[2]700 }
701 return 0;
702}
703
[551]704static MRESULT EXPENTRY MainWMOnce2(HWND hwnd, ULONG msg, MPARAM mp1,
705 MPARAM mp2)
[133]706{
[2]707 PERSON1DATA *pd;
708
[551]709 switch (msg) {
[133]710 case WM_CREATE:
711 {
712 TID tid;
[2]713
[133]714 WinQueryWindowProcess(hwnd, &mypid, &tid);
715 }
716 hwndMain = hwnd;
717 WinSetWindowUShort(hwnd, QWL_USER + 8, 0);
718 WinSetWindowUShort(hwnd, QWL_USER + 10, 0);
719 WinSetWindowUShort(hwnd, QWL_USER + 12, 0);
720 WinSetWindowUShort(hwnd, QWL_USER + 16, 0);
[551]721 if (_beginthread(MakeMainObjWin, NULL, 245760, MPVOID) == -1) {
722 Runtime_Error(pszSrcFile, __LINE__,
723 GetPString(IDS_COULDNTSTARTTHREADTEXT));
724 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[133]725 return 0;
726 }
727 else
[771]728 DosSleep(32);//05 Aug 07 GKY 64
[2]729
[551]730 pd = xmallocz(sizeof(PERSON1DATA), pszSrcFile, __LINE__);
[133]731 if (!pd)
732 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
[352]733 else {
[551]734 pd->size = sizeof(PERSON1DATA);
735 WinSetWindowPtr(hwnd, QWL_USER + 4, (PVOID) pd);
[133]736 }
737 {
738 SWP swp;
739 PFNWP oldproc;
[2]740
[133]741 /*
742 * create frame children (not client children, frame children)
743 */
[771]744 DosSleep(1);
[133]745 WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
746 oldproc = WinSubclassWindow(WinQueryWindow(hwnd, QW_PARENT),
747 (PFNWP) MainFrameWndProc2);
748 if (oldproc)
[574]749 WinSetWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER, (PVOID) oldproc);
[133]750 CommonCreateMainChildren(hwnd, &swp);
[2]751
[133]752 {
753 HWND hwndMenu;
[2]754
[551]755 hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_MENU);
756 WinSetWindowULong(hwnd, 0, hwndMenu);
757 SetConditionalCascade(hwndMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
758 SetConditionalCascade(hwndMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
[2]759 }
[133]760 }
761 WinSetWindowText(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]762 FID_TITLEBAR), "FM/2 Lite");
763 FixSwitchList(WinQueryWindow(hwnd, QW_PARENT), NULL);
764 SetSysMenu(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_SYSMENU));
[133]765 break;
[2]766
[133]767 case UM_SETUP:
[299]768 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]769 if (pd) {
[2]770
[133]771 CHAR s[CCHMAXPATH];
772 ULONG size;
773 DIRCNRDATA *dcd;
774 HWND hwndC;
775 BOOL dummy = TRUE;
[2]776
[133]777 size = sizeof(BOOL);
778 PrfQueryProfileData(fmprof,
[551]779 realappname, "FM/4 TreeUp", (PVOID) & dummy, &size);
780 if (dummy) {
[133]781 size = sizeof(ULONG);
782 hwndTree = StartTreeCnr(hwnd, 3);
783 PrfQueryProfileData(fmprof,
784 realappname,
[551]785 "FM/4 TreeWidth", (PVOID) & TreeWidth, &size);
[133]786 TreeWidth = max(TreeWidth, 80);
787 }
788 size = sizeof(BOOL);
789 if (PrfQueryProfileData(fmprof,
790 FM3Str,
[551]791 "Toolbar", &dummy, &size) && size && !dummy)
792 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_TOOLBAR, 0), MPVOID);
[2]793
[133]794 size = sizeof(s);
795 *s = 0;
796 if (PrfQueryProfileData(fmprof,
[551]797 realappname, "FM/4 Dir1", s, &size) && *s)
[133]798 MakeValidDir(s);
799 else
800 save_dir(s);
[551]801 pd->hwndLastDir = pd->hwndCurr = pd->hwndDir1 =
802 StartDirCnr(hwnd, s, (HWND) 0, 3);
[133]803 size = sizeof(s);
804 *s = 0;
805 if (PrfQueryProfileData(fmprof,
[551]806 realappname, "FM/4 Dir2", s, &size) && *s)
[133]807 MakeValidDir(s);
808 else
809 save_dir(s);
[551]810 pd->hwndDir2 = StartDirCnr(hwnd, s, (HWND) 0, 3);
811 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
[2]812
[551]813 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
814 if (hwndC) {
[299]815 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]816 if (dcd) {
[133]817 size = sizeof(INT);
818 if (PrfQueryProfileData(fmprof,
819 realappname,
820 "FM/4 Dir1.Sort",
[551]821 (PVOID) & dcd->sortFlags,
822 &size) && size == sizeof(INT)) {
823 if (!dcd->sortFlags)
824 dcd->sortFlags = SORT_PATHNAME;
[133]825 }
826 size = sizeof(MASK);
827 if (PrfQueryProfileData(fmprof,
828 realappname,
829 "FM/4 Dir1.Filter",
[551]830 (PVOID) & dcd->mask, &size) && size) {
831 if (*dcd->mask.szMask)
[133]832 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
[551]833 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
[133]834 }
[551]835 *(dcd->mask.prompt) = 0;
[133]836 size = sizeof(ULONG);
837 if (PrfQueryProfileData(fmprof,
838 realappname,
839 "FM/4 Dir1.View",
[551]840 (PVOID) & dcd->flWindowAttr,
841 &size) && size == sizeof(ULONG)) {
[2]842
[133]843 CNRINFO cnri;
[2]844
[133]845 memset(&cnri, 0, sizeof(CNRINFO));
846 cnri.cb = sizeof(CNRINFO);
847 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
848 CM_QUERYCNRINFO,
[551]849 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
850 cnri.flWindowAttr = dcd->flWindowAttr;
[133]851 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
852 CM_SETCNRINFO,
[551]853 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
[133]854 }
855 }
856 }
857 }
[2]858
[551]859 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
860 if (hwndC) {
[299]861 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]862 if (dcd) {
[133]863 size = sizeof(INT);
864 if (PrfQueryProfileData(fmprof,
865 realappname,
866 "FM/4 Dir2.Sort",
[551]867 (PVOID) & dcd->sortFlags,
868 &size) && size == sizeof(INT)) {
869 if (!dcd->sortFlags)
870 dcd->sortFlags = SORT_PATHNAME;
[133]871 }
872 size = sizeof(MASK);
873 if (PrfQueryProfileData(fmprof,
874 realappname,
875 "FM/4 Dir2.Filter",
[551]876 (PVOID) & dcd->mask, &size) && size) {
877 if (*dcd->mask.szMask)
[133]878 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
[551]879 UM_FILTER, MPFROMP(dcd->mask.szMask), MPVOID);
[133]880 }
[551]881 *(dcd->mask.prompt) = 0;
[133]882 size = sizeof(ULONG);
883 if (PrfQueryProfileData(fmprof,
884 realappname,
885 "FM/4 Dir2.View",
[551]886 (PVOID) & dcd->flWindowAttr,
887 &size) && size == sizeof(ULONG)) {
[2]888
[133]889 CNRINFO cnri;
[2]890
[133]891 memset(&cnri, 0, sizeof(CNRINFO));
892 cnri.cb = sizeof(CNRINFO);
893 if (WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
894 CM_QUERYCNRINFO,
[551]895 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
896 cnri.flWindowAttr = dcd->flWindowAttr;
[133]897 WinSendMsg(WinWindowFromID(hwndC, DIR_CNR),
898 CM_SETCNRINFO,
[551]899 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
[133]900 }
901 }
902 }
[2]903 }
[133]904 }
905 {
906 ULONG which = 0, size = sizeof(ULONG);
907
908 if (PrfQueryProfileData(fmprof,
909 realappname,
910 "FM/4 Max",
911 (PVOID) & which,
[551]912 &size) && size == sizeof(ULONG) && which) {
[133]913 PostMsg(hwnd,
914 UM_MAXIMIZE,
915 MPFROMLONG(((which == 1) ?
[551]916 pd->hwndDir1 : pd->hwndDir2)), MPVOID);
[2]917 }
[133]918 }
[551]919 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]920 if (!hwndTree)
[551]921 PostMsg(hwnd, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
[133]922 load_tools(NULL);
923 BuildTools(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]924 MAIN_TOOLS), TRUE);
[133]925 fRunning = TRUE;
926 return 0;
[2]927
[133]928 case WM_SAVEAPPLICATION:
929 WinStoreWindowPos(FM2Str,
[551]930 "MainWindowPos2", WinQueryWindow(hwnd, QW_PARENT));
[299]931 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]932 if (pd) {
[2]933
[133]934 CHAR s[CCHMAXPATH];
935 HWND hwndC;
936 DIRCNRDATA *dcd;
937 ULONG flWindowAttr;
[2]938
[133]939 *s = 0;
[551]940 WinSendMsg(pd->hwndDir1, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
941 if (*s) {
[133]942 MakeValidDir(s);
[551]943 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir1", s);
[133]944 }
945 *s = 0;
[551]946 WinSendMsg(pd->hwndDir2, UM_CONTAINERDIR, MPFROMP(s), MPVOID);
947 if (*s) {
[133]948 MakeValidDir(s);
[551]949 PrfWriteProfileString(fmprof, realappname, "FM/4 Dir2", s);
[133]950 }
[551]951 flWindowAttr = (pd->hwndMax == pd->hwndDir1) ?
952 1 : (pd->hwndMax == pd->hwndDir2) ? 2 : 0;
[133]953 PrfWriteProfileData(fmprof,
954 realappname,
[551]955 "FM/4 Max", &flWindowAttr, sizeof(flWindowAttr));
956 hwndC = WinWindowFromID(pd->hwndDir1, FID_CLIENT);
957 if (hwndC) {
[299]958 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]959 if (dcd) {
960 flWindowAttr = dcd->flWindowAttr;
961 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
[133]962 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
[551]963 if (dcd->lastattr) {
964 if (dcd->lastattr & CV_TEXT)
[133]965 flWindowAttr |= CV_TEXT;
[551]966 else if (dcd->lastattr & CV_DETAIL)
[133]967 flWindowAttr |= CV_DETAIL;
[551]968 else if (dcd->lastattr & CV_ICON)
[133]969 flWindowAttr |= CV_ICON;
970 else
971 flWindowAttr |= CV_NAME;
972 }
973 else
974 flWindowAttr |= CV_NAME;
975 }
976 PrfWriteProfileData(fmprof,
977 realappname,
978 "FM/4 Dir1.Sort",
[551]979 (PVOID) & dcd->sortFlags, sizeof(INT));
[133]980 PrfWriteProfileData(fmprof,
981 realappname,
982 "FM/4 Dir1.Filter",
[551]983 (PVOID) & dcd->mask, sizeof(MASK));
[133]984 PrfWriteProfileData(fmprof,
985 realappname,
986 "FM/4 Dir1.View",
[551]987 (PVOID) & flWindowAttr, sizeof(ULONG));
[133]988 }
989 }
[2]990
[551]991 hwndC = WinWindowFromID(pd->hwndDir2, FID_CLIENT);
992 if (hwndC) {
[299]993 dcd = WinQueryWindowPtr(WinWindowFromID(hwndC, DIR_CNR), QWL_USER);
[551]994 if (dcd) {
995 flWindowAttr = dcd->flWindowAttr;
996 if (!fLeaveTree && (flWindowAttr & CV_TREE)) {
[133]997 flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
[551]998 if (dcd->lastattr) {
999 if (dcd->lastattr & CV_TEXT)
[133]1000 flWindowAttr |= CV_TEXT;
[551]1001 else if (dcd->lastattr & CV_DETAIL)
[133]1002 flWindowAttr |= CV_DETAIL;
[551]1003 else if (dcd->lastattr & CV_ICON)
[133]1004 flWindowAttr |= CV_ICON;
1005 else
1006 flWindowAttr |= CV_NAME;
1007 }
1008 else
1009 flWindowAttr |= CV_NAME;
1010 }
1011 PrfWriteProfileData(fmprof,
1012 realappname,
1013 "FM/4 Dir2.Sort",
[551]1014 (PVOID) & dcd->sortFlags, sizeof(INT));
[133]1015 PrfWriteProfileData(fmprof,
1016 realappname,
1017 "FM/4 Dir2.Filter",
[551]1018 (PVOID) & dcd->mask, sizeof(MASK));
[133]1019 PrfWriteProfileData(fmprof,
1020 realappname,
1021 "FM/4 Dir2.View",
[551]1022 (PVOID) & flWindowAttr, sizeof(ULONG));
[133]1023 }
[2]1024 }
[133]1025 }
1026 break;
[2]1027 }
[133]1028 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1029}
1030
[133]1031MRESULT EXPENTRY MainWndProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1032{
[2]1033 PERSON1DATA *pd;
1034
[551]1035 switch (msg) {
[133]1036 case WM_SAVEAPPLICATION:
1037 case UM_SETUP:
1038 case WM_CREATE:
1039 return MainWMOnce2(hwnd, msg, mp1, mp2);
[2]1040
[133]1041 case UM_THREADUSE:
1042 case UM_LOADFILE:
[246]1043 case UM_BUILDDRIVEBAR:
[133]1044 return CommonMainWndProc(hwnd, msg, mp1, mp2);
[2]1045
[133]1046 case UM_SETUP2:
[299]1047 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1048 if (pd) {
1049 if (mp1) {
1050 if (pd->hwndDir1 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir1))
1051 BoxWindow(pd->hwndDir1, (HPS) 0, CLR_PALEGRAY);
1052 if (pd->hwndDir2 && (!pd->hwndMax || pd->hwndMax == pd->hwndDir2))
1053 BoxWindow(pd->hwndDir2, (HPS) 0, CLR_PALEGRAY);
[133]1054 if (hwndTree)
[551]1055 BoxWindow(hwndTree, (HPS) 0, CLR_PALEGRAY);
[2]1056 }
[551]1057 else {
[133]1058 if (hwndTree)
1059 BoxWindow(hwndTree,
1060 (HPS) 0,
[551]1061 (pd->hwndCurr == hwndTree) ? CLR_RED : CLR_WHITE);
1062 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir1)
1063 BoxWindow(pd->hwndDir1,
[133]1064 (HPS) 0,
[551]1065 (pd->hwndDir1 == pd->hwndCurr) ?
[133]1066 CLR_RED :
[551]1067 (pd->hwndDir1 == pd->hwndLastDir) ?
1068 CLR_DARKRED : CLR_PALEGRAY);
1069 if (!pd->hwndMax || pd->hwndMax == pd->hwndDir2)
1070 BoxWindow(pd->hwndDir2,
[133]1071 (HPS) 0,
[551]1072 (pd->hwndDir2 == pd->hwndCurr) ?
[133]1073 CLR_RED :
[551]1074 (pd->hwndDir2 == pd->hwndLastDir) ?
1075 CLR_DARKRED : CLR_PALEGRAY);
[133]1076 }
1077 }
1078 return 0;
[2]1079
[133]1080 case WM_BUTTON1DOWN:
1081 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
[551]1082 if (hwndTree) {
[2]1083
[133]1084 SWP swp;
[2]1085
[133]1086 WinQueryWindowPos(hwndTree, &swp);
1087 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
[551]1088 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3) {
[2]1089
[133]1090 SWP swpC;
1091 TRACKINFO track;
[2]1092
[133]1093 WinQueryWindowPos(hwnd, &swpC);
1094 track.cxBorder = 4;
1095 track.cyBorder = 4;
1096 track.cxGrid = 1;
1097 track.cyGrid = 1;
1098 track.cxKeyboard = 8;
1099 track.cyKeyboard = 8;
1100 track.rclTrack.yBottom = 2;
1101 track.rclTrack.yTop = swpC.cy - 4;
1102 track.rclTrack.xLeft = 2;
1103 track.rclTrack.xRight = swp.x + swp.cx + 2;
1104 track.rclBoundary = track.rclTrack;
1105 track.rclBoundary.xRight = swpC.cx - 80;
1106 track.ptlMinTrackSize.x = 80;
1107 track.ptlMinTrackSize.y = swpC.cy - 4;
1108 track.ptlMaxTrackSize.x = swpC.cx - 80;
1109 track.ptlMaxTrackSize.y = swpC.cy - 4;
1110 track.fs = TF_RIGHT;
[551]1111 if (WinTrackRect(hwnd, (HPS) 0, &track)) {
[133]1112 TreeWidth = track.rclTrack.xRight - track.rclTrack.xLeft;
1113 PrfWriteProfileData(fmprof,
1114 realappname,
[551]1115 "FM/4 TreeWidth", &TreeWidth, sizeof(ULONG));
1116 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1117 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[133]1118 }
1119 return (MRESULT) TRUE;
[2]1120 }
[133]1121 }
1122 break;
[2]1123
[133]1124 case WM_MOUSEMOVE:
1125 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
[551]1126 if (hwndTree) {
[2]1127
[133]1128 SWP swp;
[2]1129
[551]1130 if (WinQueryWindowPos(hwndTree, &swp)) {
[133]1131 if (SHORT1FROMMP(mp1) > (swp.x + swp.cx) - 3 &&
1132 SHORT1FROMMP(mp1) < (swp.x + swp.cx) + 3)
1133 WinSetPointer(HWND_DESKTOP, hptrEW);
1134 else
1135 WinSetPointer(HWND_DESKTOP, hptrArrow);
[2]1136 }
[133]1137 else
1138 WinSetPointer(HWND_DESKTOP, hptrArrow);
1139 }
1140 return (MRESULT) TRUE;
[2]1141
[133]1142 case WM_BUTTON1UP:
1143 case WM_BUTTON2UP:
1144 case WM_BUTTON3UP:
1145 case WM_CHAR:
1146 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1147 break;
[2]1148
[133]1149 case UM_ADVISEFOCUS:
[299]1150 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1151 if (mp1 && pd && (HWND) mp1 != pd->hwndCurr) {
1152 if ((HWND) mp1 != hwndTree)
1153 pd->hwndLastDir = (HWND) mp1;
1154 pd->hwndCurr = (HWND) mp1;
1155 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[133]1156 }
1157 return 0;
[2]1158
[133]1159 case UM_MAXIMIZE:
[551]1160 if (mp1) {
[299]1161 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1162 if (pd) {
1163 WinSendMsg(hwnd, UM_SETUP2, MPFROMLONG(1), MPVOID);
1164 if (pd->hwndMax != (HWND) mp1) {
1165 pd->hwndMax = (HWND) mp1;
1166 WinSetFocus(HWND_DESKTOP, pd->hwndMax);
[133]1167 }
1168 else
[551]1169 pd->hwndMax = (HWND) 0;
1170 PostMsg(hwnd, UM_SIZE, MPVOID, MPVOID);
[2]1171 }
[133]1172 }
1173 return 0;
[2]1174
[133]1175 case WM_INITMENU:
[551]1176 switch (SHORT1FROMMP(mp1)) {
[133]1177 case IDM_FILESMENU:
1178 case IDM_VIEWSMENU:
1179 case IDM_DETAILSSETUP:
1180 case IDM_COMMANDSMENU:
1181 case IDM_SORTSUBMENU:
[299]1182 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1183 if (pd)
[551]1184 WinSendMsg(pd->hwndCurr, UM_INITMENU, mp1, mp2);
[2]1185 break;
[133]1186 case IDM_CONFIGMENU:
[551]1187 WinCheckMenuItem((HWND) mp2, IDM_TOOLSUBMENU, fToolbar);
1188 WinCheckMenuItem((HWND) mp2, IDM_AUTOVIEW, fAutoView);
[2]1189 break;
[133]1190 case IDM_TOOLSUBMENU:
[551]1191 WinCheckMenuItem((HWND) mp2, IDM_TOOLBAR, fToolbar);
1192 WinCheckMenuItem((HWND) mp2, IDM_TEXTTOOLS, fTextTools);
1193 WinCheckMenuItem((HWND) mp2, IDM_TOOLTITLES, fToolTitles);
[133]1194 break;
1195 case IDM_WINDOWSMENU:
[551]1196 WinCheckMenuItem((HWND) mp2, IDM_VTREE, (hwndTree != (HWND) 0));
1197 WinCheckMenuItem((HWND) mp2, IDM_TILEBACKWARDS, fTileBackwards);
1198 SetupWinList((HWND) mp2, hwnd, WinQueryWindow(hwnd, QW_PARENT));
[133]1199 break;
1200 }
1201 break;
[2]1202
[133]1203 case WM_SETFOCUS:
1204 if (mp2)
[551]1205 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
[133]1206 break;
[2]1207
[133]1208 case UM_FOCUSME:
[299]1209 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1210 if (pd)
[551]1211 WinSetFocus(HWND_DESKTOP, pd->hwndCurr);
[133]1212 return 0;
[2]1213
[133]1214 case UM_RESCAN:
1215 return 0;
1216
1217 case UM_SIZE:
1218 {
1219 SWP swp;
1220
[551]1221 if (WinQueryWindowPos(hwnd, &swp)) {
[133]1222 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1223 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
[2]1224 }
[133]1225 else
1226 return 0;
1227 }
1228 /* intentional fallthru */
1229 case WM_SIZE:
[299]1230 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[551]1231 if (mp1 && mp2 && pd && pd->hwndDir1 && pd->hwndDir2) {
[133]1232 if (hwndTree)
1233 WinSetWindowPos(hwndTree,
1234 HWND_TOP,
1235 2,
1236 2,
1237 TreeWidth - 4,
1238 SHORT2FROMMP(mp2) - 4,
1239 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1240 else
1241 TreeWidth = 0;
[551]1242 if (!pd->hwndMax) {
1243 if (fTileBackwards) {
1244 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
[133]1245 (((SHORT1FROMMP(mp2) - TreeWidth) / 2) +
1246 TreeWidth) + 2,
1247 2,
1248 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1249 SHORT2FROMMP(mp2) - 4,
1250 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1251 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
[133]1252 TreeWidth + 2,
1253 2,
1254 ((SHORT1FROMMP(mp2) - TreeWidth) / 2) - 4,
1255 SHORT2FROMMP(mp2) - 4,
1256 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1257 }
[551]1258 else {
1259 WinSetWindowPos(pd->hwndDir1, HWND_TOP,
[133]1260 TreeWidth + 2,
1261 2,
1262 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1263 (SHORT2FROMMP(mp2) / 2) - 4,
1264 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1265 WinSetWindowPos(pd->hwndDir2, HWND_TOP,
[133]1266 TreeWidth + 2,
1267 (SHORT2FROMMP(mp2) / 2) + 2,
1268 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1269 (SHORT2FROMMP(mp2) / 2) - 4,
1270 SWP_SHOW | SWP_MOVE | SWP_SIZE);
1271 }
1272 }
[551]1273 else {
[2]1274
[133]1275 HWND hwndOther;
[2]1276
[551]1277 WinSetWindowPos(pd->hwndMax, HWND_TOP,
[133]1278 TreeWidth + 2,
1279 2,
1280 (SHORT1FROMMP(mp2) - TreeWidth) - 4,
1281 SHORT2FROMMP(mp2) - 4,
1282 SWP_SHOW | SWP_MOVE | SWP_SIZE);
[551]1283 hwndOther = (pd->hwndMax == pd->hwndDir1) ?
1284 pd->hwndDir2 : pd->hwndDir1;
[133]1285 WinSetWindowPos(hwndOther, HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDE);
[2]1286 }
[551]1287 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[133]1288 }
1289 if (msg == UM_SIZE)
[2]1290 return 0;
[133]1291 break;
[2]1292
[133]1293 case WM_ERASEBACKGROUND:
[551]1294 WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
[133]1295 return 0;
1296
1297 case WM_PAINT:
1298 {
1299 HPS hps;
1300 RECTL rcl;
1301
[551]1302 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
1303 if (hps) {
[133]1304 WinQueryWindowRect(hwnd, &rcl);
[551]1305 WinFillRect(hps, (PRECTL) & rcl, CLR_PALEGRAY);
[133]1306 WinEndPaint(hps);
[551]1307 WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[2]1308 }
[133]1309 }
1310 break;
[2]1311
[133]1312 case UM_COMMAND:
1313 case WM_COMMAND:
1314 return MainWMCommand2(hwnd, msg, mp1, mp2);
[2]1315
[133]1316 case WM_CLOSE:
1317 fAmClosing = TRUE;
[551]1318 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
[133]1319 CloseChildren(hwnd);
[551]1320 PostMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
[771]1321 DosSleep(1);
[133]1322 return 0;
[2]1323
[133]1324 case UM_CLOSE:
1325 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1326 return 0;
[2]1327
[133]1328 case WM_DESTROY:
[551]1329 hwndMain = (HWND) 0;
[299]1330 pd = WinQueryWindowPtr(hwnd, QWL_USER + 4);
[133]1331 if (pd)
1332 free(pd);
[551]1333 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1334 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
[133]1335 break;
[2]1336 }
[133]1337 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1338}
1339
[133]1340HWND StartFM32(HAB hab, INT argc, CHAR ** argv)
1341{
1342 HWND hwndFrame, hwndClient;
1343 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1344 FCF_SIZEBORDER | FCF_MINMAX |
1345 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1346
1347 {
1348 INT x;
1349
[551]1350 for (x = 1; x < argc; x++) {
[133]1351 if (*argv[x] == '+' && !argv[x][1])
1352 fLogFile = TRUE;
[551]1353 if (*argv[x] == '-') {
[133]1354 if (argv[x][1])
1355 strcpy(profile, &argv[x][1]);
[2]1356 }
1357 }
1358 }
1359 {
[133]1360 CHAR inipath[CCHMAXPATH], fullpath[CCHMAXPATH];
[843]1361 FILESTATUS3 fsa;
[2]1362
[133]1363 if (PrfQueryProfileString(HINI_USERPROFILE,
1364 FM2Str,
[551]1365 "Home", NULL, inipath, sizeof(inipath))) {
[843]1366 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, sizeof(fsa))) {
[551]1367 if (fsa.attrFile & FILE_DIRECTORY) {
[133]1368 if (DosQueryPathInfo(inipath,
[551]1369 FIL_QUERYFULLNAME, fullpath, sizeof(fullpath)))
[133]1370 strcpy(fullpath, inipath);
1371 switch_to(fullpath);
1372 }
[2]1373 }
1374 }
1375 }
1376
1377 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[133]1378 WS_VISIBLE,
1379 &FrameFlags,
[593]1380 WC_MAINWND2,
[133]1381 NULL,
1382 WS_VISIBLE | WS_ANIMATE,
[551]1383 FM3ModHandle, MAIN2_FRAME, &hwndClient);
1384 if (hwndFrame) {
[875]1385 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[551]1386 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos2", hwndFrame)) {
[2]1387
[133]1388 ULONG fl = SWP_MOVE | SWP_SIZE;
[2]1389 RECTL rcl;
[133]1390 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1391 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1392
[133]1393 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1394 rcl.yBottom += icz;
1395 rcl.yTop -= bsz;
1396 rcl.xLeft += bsz;
1397 rcl.xRight -= bsz;
1398 WinSetWindowPos(hwndFrame,
[133]1399 HWND_TOP,
1400 rcl.xLeft,
1401 rcl.yBottom,
[551]1402 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1403 }
[133]1404 if (fLogFile)
1405 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1406 if (hwndHelp)
1407 WinAssociateHelpInstance(hwndHelp, hwndFrame);
[551]1408 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1409 }
1410 return hwndFrame;
1411}
[793]1412
1413#pragma alloc_text(PERSON11,MainFrameWndProc2,MainWndProc2)
1414#pragma alloc_text(PERSON12,StartFM32,MainWMOnce2)
1415#pragma alloc_text(PERSON13,MainWMCommand2)
Note: See TracBrowser for help on using the repository browser.