source: trunk/dll/dircnrs.c@ 943

Last change on this file since 943 was 930, checked in by John Small, 18 years ago

Some code "cleanup" for ticket 150.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 91.3 KB
RevLine 
[36]1
2/***********************************************************************
3
4 $Id: dircnrs.c 930 2008-01-19 13:54:06Z jbs $
5
6 Directory containers
7
8 Copyright (c) 1993-98 M. Kimes
[907]9 Copyright (c) 2001, 2008 Steven H. Levine
[36]10
[130]11 16 Oct 02 SHL Handle large partitions
12 01 Aug 04 SHL Rework lstrip/rstrip usage
13 23 May 05 SHL Use QWL_USER
[145]14 24 May 05 SHL Rework Win_Error usage
[150]15 25 May 05 SHL Use ULONGLONG and CommaFmtULL
[171]16 26 May 05 SHL More large file formatting updates
[186]17 05 Jun 05 SHL Use QWL_USER
[275]18 10 Nov 05 SHL Comments
[358]19 13 Jul 06 SHL Use Runtime_Error
[369]20 26 Jul 06 SHL Use chop_at_crnl
[449]21 15 Aug 06 SHL Rework warning message text
[552]22 07 Jan 07 GKY Move error strings etc. to string file
[593]23 30 Mar 07 GKY Remove GetPString for window class names
[603]24 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
25 06 Apr 07 GKY Add some error checking in drag/drop
[618]26 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checking.
[672]27 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
[688]28 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
[751]29 02 Aug 07 SHL Sync with CNRITEM mods
[775]30 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[793]31 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[814]32 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
[872]33 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
[917]34 10 Jan 08 SHL Sync with CfgDlgProc mods
[930]35 xx Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
[36]36
37***********************************************************************/
38
[907]39#include <stdlib.h>
40#include <string.h>
41#include <ctype.h>
42#include <limits.h>
43#include <process.h> // _beginthread
44
[2]45#define INCL_DOS
46#define INCL_WIN
47#define INCL_DOSERRORS
[150]48#define INCL_LONGLONG
[2]49
50#include "fm3dlg.h"
51#include "fm3str.h"
52#include "mle.h"
[907]53#include "arccnrs.h" // StartArcCnr
54#include "comp.h" // COMPARE
55#include "filldir.h" // EmptyCnr...
56#include "errutil.h" // Dos_Error...
57#include "strutil.h" // GetPString
58#include "fm3dll.h"
[2]59
60#pragma data_seg(DATA1)
61
[358]62static PSZ pszSrcFile = __FILE__;
[2]63
[551]64MRESULT EXPENTRY DirFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[275]65{
[551]66 return CommonFrameWndProc(DIR_CNR, hwnd, msg, mp1, mp2);
[2]67}
68
[551]69MRESULT EXPENTRY DirTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[275]70{
[551]71 static BOOL emphasized = FALSE;
72 static HWND hwndButtonPopup = (HWND) 0;
73 static USHORT lastid = 0;
74 static ULONG timestamp = ULONG_MAX;
[2]75
[551]76 switch (msg) {
77 case WM_CREATE:
78 return CommonTextProc(hwnd, msg, mp1, mp2);
[2]79
[551]80 case WM_COMMAND:
81 {
82 DIRCNRDATA *dcd;
83 MRESULT mr;
[2]84
[551]85 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
86 QW_PARENT),
87 DIR_CNR), msg, mp1, mp2);
88 if (hwndButtonPopup &&
89 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
90 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
91 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
92 QW_PARENT),
93 DIR_CNR), QWL_USER);
94 if (dcd)
95 SetDetailsSwitches(hwndButtonPopup, dcd);
[2]96 }
[551]97 return mr;
98 }
[2]99
[551]100 case UM_CONTEXTMENU:
101 case WM_CONTEXTMENU:
102 {
103 USHORT id;
[2]104
[551]105 id = WinQueryWindowUShort(hwnd, QWS_ID);
106 switch (id) {
107 case DIR_FOLDERICON:
108 if (fNoFoldMenu) {
109 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
110 DIR_CNR),
111 WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), mp2);
112 break;
113 }
114 /* else intentional fallthru */
115 case DIR_SELECTED:
116 case DIR_VIEW:
117 case DIR_SORT:
118 {
119 POINTL ptl = { 0, 0 };
120 SWP swp;
121 DIRCNRDATA *dcd;
[2]122
[551]123 if (hwndButtonPopup)
124 WinDestroyWindow(hwndButtonPopup);
125 if (id == DIR_SELECTED && msg == WM_CONTEXTMENU)
126 id = DIR_MAX;
127 if (id == lastid) {
[2]128
[551]129 ULONG check;
[2]130
[551]131 DosQuerySysInfo(QSV_MS_COUNT,
132 QSV_MS_COUNT, &check, sizeof(check));
133 if (check < timestamp + 500) {
134 lastid = 0;
135 goto MenuAbort;
136 }
137 }
[907]138 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
139 CopyPresParams(hwndButtonPopup, hwnd);
[551]140 if (hwndButtonPopup) {
141 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
142 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
143 QW_PARENT),
144 DIR_CNR), QWL_USER);
145 if (id == DIR_SORT) { /* don't have sort pathname in dirs */
146 WinSendMsg(hwndButtonPopup,
147 MM_DELETEITEM,
148 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
149 WinSendMsg(hwndButtonPopup,
150 MM_DELETEITEM,
151 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
152 if (dcd)
153 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
154 }
155 else if (id == DIR_VIEW) {
156 if (dcd) {
157 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
158 SetDetailsSwitches(hwndButtonPopup, dcd);
159 }
160 }
161 else if (id == DIR_MAX) {
[2]162
[551]163 int x;
164 BOOL enable;
165 USHORT ids[] = { IDM_SELECTBOTH,
166 IDM_SELECTMORE,
167 IDM_SELECTONE,
168 IDM_SELECTNEWER,
169 IDM_SELECTOLDER,
170 IDM_SELECTBIGGER,
171 IDM_SELECTSMALLER,
172 IDM_DESELECTBOTH,
173 IDM_DESELECTMORE,
174 IDM_DESELECTONE,
175 IDM_DESELECTNEWER,
176 IDM_DESELECTOLDER,
177 IDM_DESELECTBIGGER,
178 IDM_DESELECTSMALLER,
179 0
180 };
[2]181
[551]182 enable = (CountDirCnrs(dcd->hwndParent) > 1);
183 for (x = 0; ids[x]; x++)
184 WinEnableMenuItem(hwndButtonPopup, ids[x], enable);
185 }
186 else if (id == DIR_SELECTED) {
187 if (dcd)
188 WinEnableMenuItem(hwndButtonPopup,
189 IDM_RESELECT, (dcd->lastselection != NULL));
190 }
191 ptl.x = 0;
192 if (WinPopupMenu(HWND_OBJECT,
193 HWND_OBJECT,
194 hwndButtonPopup, -32767, -32767, 0, 0)) {
195 WinQueryWindowPos(hwndButtonPopup, &swp);
196 ptl.y = -(swp.cy + 2);
197 }
198 else {
199 WinQueryWindowPos(hwnd, &swp);
200 ptl.y = swp.cy + 2;
201 }
202 if (WinPopupMenu(hwnd,
203 hwnd,
204 hwndButtonPopup,
205 ptl.x,
206 ptl.y,
207 0,
208 PU_HCONSTRAIN | PU_VCONSTRAIN |
209 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
210 CenterOverWindow(hwndButtonPopup);
211 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
212 }
213 }
214 }
215 break;
216 default:
217 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR),
218 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU), MPVOID);
219 break;
220 }
221 } // case WM_CONTENT_MENU
[275]222
[551]223 MenuAbort:
[275]224
[551]225 if (msg == UM_CONTEXTMENU)
226 return 0;
227 break;
[2]228
[551]229 case WM_MENUEND:
230 if (hwndButtonPopup == (HWND) mp2) {
231 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
232 WinDestroyWindow(hwndButtonPopup);
233 hwndButtonPopup = (HWND) 0;
234 DosQuerySysInfo(QSV_MS_COUNT,
235 QSV_MS_COUNT, &timestamp, sizeof(timestamp));
236 switch (lastid) {
237 case DIR_VIEW:
238 case DIR_SORT:
239 case DIR_FOLDERICON:
240 case DIR_SELECTED:
241 case DIR_MAX:
242 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
243 break;
[2]244 }
[551]245 }
246 break;
[2]247
[551]248 case WM_BUTTON3DOWN:
249 case WM_BUTTON1DOWN:
250 case WM_BUTTON3UP:
251 case WM_BUTTON1UP:
252 {
253 USHORT id;
[2]254
[551]255 id = WinQueryWindowUShort(hwnd, QWS_ID);
256 switch (id) {
257 case DIR_FILTER:
258 case DIR_VIEW:
259 case DIR_SORT:
260 case DIR_SELECTED:
261 case DIR_FOLDERICON:
262 case DIR_MAX:
263 return CommonTextButton(hwnd, msg, mp1, mp2);
[2]264 }
[551]265 }
266 break;
[2]267
[551]268 case WM_BUTTON1DBLCLK:
269 {
270 NOTIFYRECORDENTER nr;
[2]271
[551]272 memset(&nr, 0, sizeof(NOTIFYRECORDENTER));
273 nr.hwndCnr = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), DIR_CNR);
274 WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
275 WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_ENTER), MPFROMP(&nr));
276 }
277 break;
[2]278
[551]279 case WM_MOUSEMOVE:
280 {
281 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
282 char *s = NULL;
[2]283
[551]284 if (fOtherHelp) {
285 if ((!hwndBubble ||
286 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
287 !WinQueryCapture(HWND_DESKTOP)) {
288 switch (id) {
289 case DIR_TOTALS:
290 s = GetPString(IDS_DIRCNRTOTALHELP);
291 break;
292 case DIR_SELECTED:
293 s = GetPString(IDS_DIRCNRSELECTEDHELP);
294 break;
295 case DIR_VIEW:
296 s = GetPString(IDS_DIRCNRVIEWHELP);
297 break;
298 case DIR_SORT:
299 s = GetPString(IDS_DIRCNRSORTHELP);
300 break;
301 case DIR_FILTER:
302 s = GetPString(IDS_DIRCNRFILTERHELP);
303 break;
304 case DIR_MAX:
305 s = GetPString(IDS_DIRCNRMAXHELP);
306 break;
307 case DIR_FOLDERICON:
308 s = GetPString(IDS_DIRCNRFOLDERHELP);
309 break;
310 default:
311 break;
312 }
313 if (s)
314 MakeBubble(hwnd, TRUE, s);
315 else if (hwndBubble)
316 WinDestroyWindow(hwndBubble);
317 }
[2]318 }
[551]319 switch (id) {
320 case DIR_MAX:
321 case DIR_FOLDERICON:
322 case DIR_FILTER:
323 case DIR_SORT:
324 case DIR_VIEW:
325 case DIR_SELECTED:
326 return CommonTextButton(hwnd, msg, mp1, mp2);
327 }
328 }
329 break;
[2]330
[551]331 case WM_CHORD:
332 case WM_BUTTON3CLICK:
333 case WM_BUTTON1CLICK:
334 case UM_CLICKED:
335 case UM_CLICKED3:
336 {
337 USHORT id, cmd = 0;
[2]338
[551]339 id = WinQueryWindowUShort(hwnd, QWS_ID);
340 if (msg == UM_CLICKED || msg == UM_CLICKED3) {
341 switch (id) {
342 case DIR_MAX:
343 cmd = IDM_MAXIMIZE;
344 break;
345 case DIR_VIEW:
346 case DIR_SELECTED:
347 case DIR_SORT:
348 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
349 break;
350 case DIR_FILTER:
351 cmd = IDM_FILTER;
352 break;
353 default:
354 break;
355 }
[2]356 }
[551]357 else if (id == DIR_FOLDERICON) {
358 if ((msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_CTRL)))
359 cmd = IDM_PREVIOUS;
360 else if (msg == WM_BUTTON3CLICK || msg == WM_CHORD)
361 cmd = IDM_RESCAN;
362 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_SHIFT))
363 cmd = IDM_WALKDIR;
364 else if (msg == WM_BUTTON1CLICK && (SHORT2FROMMP(mp2) & KC_ALT))
365 cmd = IDM_WINDOWDLG;
366 else
367 cmd = IDM_PARENT;
368 }
369 if (cmd)
370 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
371 DIR_CNR),
372 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
373 }
374 if (msg == UM_CLICKED || msg == UM_CLICKED3)
375 return 0;
376 break;
[2]377
[551]378 case DM_DROP:
379 case DM_DRAGOVER:
380 case DM_DRAGLEAVE:
381 case DM_DROPHELP:
382 case WM_BEGINDRAG:
383 if (msg == DM_DRAGOVER) {
384 if (!emphasized) {
385 emphasized = TRUE;
386 DrawTargetEmphasis(hwnd, emphasized);
[2]387 }
[551]388 }
389 else if (msg != WM_BEGINDRAG) {
390 if (emphasized) {
391 emphasized = FALSE;
392 DrawTargetEmphasis(hwnd, emphasized);
[2]393 }
[551]394 }
395 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
396 case DIR_FOLDERICON:
397 switch (msg) {
398 case DM_DRAGOVER:
[618]399 if (AcceptOneDrop(hwnd, mp1, mp2))
[551]400 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
[618]401 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
[551]402 case DM_DROPHELP:
403 DropHelp(mp1, mp2, hwnd, GetPString(IDS_DIRCNRFOLDERDROPHELP));
404 return 0;
405 case DM_DROP:
406 {
407 char szFrom[CCHMAXPATH + 2];
[2]408
[551]409 if (emphasized) {
410 emphasized = FALSE;
411 DrawTargetEmphasis(hwnd, emphasized);
412 }
[618]413 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
[551]414 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
415 DIR_CNR),
416 WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0),
417 MPFROMP(szFrom));
418 }
419 return 0;
420 default:
421 return PFNWPStatic(hwnd, msg, mp1, mp2);
422 }
423 case DIR_MAX:
424 if (msg == WM_BEGINDRAG)
425 return PFNWPStatic(hwnd, msg, mp1, mp2);
426 default:
427 {
428 CNRDRAGINFO cnd;
429 USHORT dcmd;
[2]430
[551]431 switch (msg) {
432 case DM_DROP:
433 dcmd = CN_DROP;
434 break;
435 case DM_DRAGOVER:
436 dcmd = CN_DRAGOVER;
437 break;
438 case DM_DRAGLEAVE:
439 dcmd = CN_DRAGLEAVE;
440 break;
441 case DM_DROPHELP:
442 dcmd = CN_DROPHELP;
443 break;
444 case WM_BEGINDRAG:
445 dcmd = CN_INITDRAG;
446 break;
447 }
448 memset(&cnd, 0, sizeof(cnd));
449 cnd.pDragInfo = (PDRAGINFO) mp1;
450 cnd.pRecord = NULL;
451 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
452 WM_CONTROL,
453 MPFROM2SHORT(DIR_CNR, dcmd), MPFROMP(&cnd));
[2]454 }
[551]455 }
[2]456 }
[551]457 return PFNWPStatic(hwnd, msg, mp1, mp2);
[2]458}
459
[551]460MRESULT EXPENTRY DirClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
461 MPARAM mp2)
[275]462{
[551]463 switch (msg) {
464 case UM_CONTAINERDIR:
465 if (mp1) {
[2]466
[551]467 DIRCNRDATA *dcd;
[2]468
[551]469 *(CHAR *) mp1 = 0;
470 dcd = WinQueryWindowPtr(WinWindowFromID(hwnd, DIR_CNR), QWL_USER);
471 if (dcd)
472 strcpy((CHAR *) mp1, dcd->directory);
473 return MRFROMLONG(TRUE);
474 }
475 return 0;
[2]476
[551]477 case UM_CONTAINERHWND:
478 return MRFROMLONG(WinWindowFromID(hwnd, DIR_CNR));
[2]479
[551]480 case UM_VIEWSMENU:
[877]481 return MRFROMLONG(CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP));
[2]482
[551]483 case UM_DRIVECMD:
484 case WM_INITMENU:
485 case UM_FILTER:
486 case UM_INITMENU:
487 case MM_PORTHOLEINIT:
488 case UM_COMMAND:
489 case UM_FILESMENU:
490 case UM_UPDATERECORD:
491 case UM_UPDATERECORDLIST:
492 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
[2]493
[551]494 case WM_PSETFOCUS:
495 case WM_SETFOCUS:
496 if (mp2)
497 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
498 break;
[2]499
[551]500 case UM_FOCUSME:
501 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DIR_CNR));
502 break;
[2]503
[551]504 case WM_PAINT:
505 {
506 HPS hps;
507 RECTL rcl;
[2]508
[551]509 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
510 if (hps) {
511 WinQueryWindowRect(hwnd, &rcl);
512 WinFillRect(hps, &rcl, CLR_PALEGRAY);
513 CommonTextPaint(hwnd, hps);
514 WinEndPaint(hps);
[2]515 }
[551]516 }
517 break;
[2]518
[551]519 case UM_SIZE:
520 case WM_SIZE:
521 if (msg == UM_SIZE) {
[2]522
[551]523 SWP swp;
[2]524
[551]525 WinQueryWindowPos(hwnd, &swp);
526 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
527 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
528 }
529 {
530 USHORT cx, cy, bx;
[2]531
[551]532 cx = SHORT1FROMMP(mp2);
533 cy = SHORT2FROMMP(mp2);
534 WinSetWindowPos(WinWindowFromID(hwnd, DIR_CNR), HWND_TOP,
535 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
536 if (WinWindowFromID(hwnd, DIR_MAX) != (HWND) 0) {
537 WinSetWindowPos(WinWindowFromID(hwnd, DIR_MAX), HWND_TOP,
538 cx - 22,
539 cy - 22, 20, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
540 cx -= 24;
[2]541 }
[551]542 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
543 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
544 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
545 29,
546 cy - 22,
547 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
548 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
549 29 + (cx / 3) + 2,
550 cy - 22,
551 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
552 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
553 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
554 29 + (((cx / 3) + 2) * 2),
555 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
556 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
557 29 + (((cx / 3) + 2) * 2) + bx,
558 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
559 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
560 29 + (((cx / 3) + 2) * 2) + (bx * 2),
561 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
562 }
563 CommonTextPaint(hwnd, (HPS) 0);
564 if (msg == UM_SIZE) {
565 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
566 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
567 return 0;
568 }
569 break;
[2]570
[551]571 case WM_COMMAND:
572 case WM_CONTROL:
573 case WM_CLOSE:
574 return WinSendMsg(WinWindowFromID(hwnd, DIR_CNR), msg, mp1, mp2);
[2]575 }
[551]576 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]577}
578
[551]579MRESULT EXPENTRY DirObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[150]580{
[2]581 DIRCNRDATA *dcd;
582
[551]583 switch (msg) {
584 case WM_CREATE:
585 break;
[2]586
[551]587 case DM_PRINTOBJECT:
588 return MRFROMLONG(DRR_TARGET);
[2]589
[551]590 case DM_DISCARDOBJECT:
591 dcd = INSTDATA(hwnd);
592 if (fFM2Deletes && dcd) {
[2]593
[551]594 LISTINFO *li;
595 CNRDRAGINFO cni;
[2]596
[551]597 cni.pRecord = NULL;
598 cni.pDragInfo = (PDRAGINFO) mp1;
[768]599 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
[551]600 li =
601 DoFileDrop(dcd->hwndCnr, dcd->directory, FALSE, MPVOID,
[907]602 MPFROMP(&cni));
[687]603 CheckPmDrgLimit(cni.pDragInfo);
[551]604 if (li) {
605 li->type = (fDefaultDeletePerm) ? IDM_PERMDELETE : IDM_DELETE;
606 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
607 FreeListInfo(li);
608 else
609 return MRFROMLONG(DRR_SOURCE);
[2]610 }
[551]611 }
612 return MRFROMLONG(DRR_TARGET);
[2]613
[551]614 case UM_UPDATERECORDLIST:
615 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
616 if (dcd && mp1) {
[2]617
[551]618 INT numentries = 0;
619 CHAR **list = (CHAR **) mp1;
[2]620
[551]621 while (list[numentries])
622 numentries++;
623 if (numentries)
624 UpdateCnrList(dcd->hwndCnr, list, numentries, TRUE, dcd);
625 }
626 return 0;
[2]627
[551]628 case UM_SETUP:
629 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
630 if (dcd) {
631 /* set unique id */
632 WinSetWindowUShort(hwnd, QWS_ID, DIROBJ_FRAME + (DIR_FRAME - dcd->id));
633 dcd->hwndObject = hwnd;
634 if (ParentIsDesktop(hwnd, dcd->hwndParent))
[771]635 DosSleep(100); //05 Aug 07 GKY 250
[551]636 }
637 else
638 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
639 return 0;
640
641 case UM_RESCAN2:
642 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
643 if (dcd && dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
644
645 FSALLOCATE fsa;
646 CHAR s[CCHMAXPATH * 2];
647 CHAR tf[64];
648 CHAR tb[64];
649 CHAR szFree[64];
650
651 DosError(FERR_DISABLEHARDERR);
652 if (!DosQueryFSInfo(toupper(*dcd->directory) - '@',
653 FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
654 CommaFmtULL(tb, sizeof(tb),
655 (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit *
656 fsa.cbSector), 'K');
657 sprintf(szFree, " {%s %s}", tb, GetPString(IDS_FREETEXT));
[2]658 }
659 else
[551]660 *szFree = 0;
661 commafmt(tf, sizeof(tf), dcd->totalfiles);
662 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
663 if (!fMoreButtons) {
664 sprintf(s, " [%s / %s]%s%s%s%s %s",
665 tf, tb, szFree,
666 (*dcd->mask.szMask || dcd->mask.antiattr ||
667 dcd->mask.attrFile != ALLATTRS) ? " (" : NullStr,
668 (*dcd->mask.szMask) ? dcd->mask.szMask :
669 (dcd->mask.antiattr ||
670 dcd->mask.attrFile != ALLATTRS) ?
671 GetPString(IDS_ALLTEXT) : NullStr,
672 (*dcd->mask.szMask || dcd->mask.antiattr ||
673 dcd->mask.attrFile != ALLATTRS) ? ")" : NullStr,
674 dcd->directory);
675 }
676 else {
677 sprintf(s, " [%s / %s]%s %s", tf, tb, szFree, dcd->directory);
678 }
679 if (dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent))
680 WinSetWindowText(hwndStatus, s);
681 }
682 return 0;
[2]683
[551]684 case UM_FLESH:
685 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
686 if (dcd) {
[2]687
[551]688 PCNRITEM pci, pciC;
[2]689
[551]690 pci = WinSendMsg(dcd->hwndCnr,
691 CM_QUERYRECORD,
692 MPVOID, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
693 while (pci && (INT) pci != -1) {
694 if (pci->attrFile & FILE_DIRECTORY) {
695 pciC = WinSendMsg(dcd->hwndCnr,
696 CM_QUERYRECORD,
697 MPFROMP(pci),
698 MPFROM2SHORT(CMA_FIRSTCHILD, CMA_ITEMORDER));
699 if (!pciC) {
700 Stubby(dcd->hwndCnr, pci);
[814]701 DosSleep(0); //26 Aug 07 GKY 1
[551]702 }
[171]703 }
[551]704 pci = WinSendMsg(dcd->hwndCnr,
705 CM_QUERYRECORD,
706 MPFROMP(pci), MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
[2]707 }
[551]708 dcd->firsttree = TRUE;
709 }
710 return 0;
[2]711
[551]712 case UM_RESCAN:
713 /*
714 * populate container
715 */
716 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
717 if (dcd) {
718 DosEnterCritSec();
719 if (dcd->stopflag)
720 dcd->stopflag--;
721 if (dcd->stopflag) {
722 DosExitCritSec();
723 return 0;
724 }
725 DosExitCritSec();
726 if (mp1) {
727 strcpy(dcd->previous, dcd->directory);
728 strcpy(dcd->directory, (CHAR *) mp1);
729 }
730 MakeValidDir(dcd->directory);
731 {
732 CHAR s[CCHMAXPATH + 8];
[2]733
[551]734 sprintf(s,
735 "%s%s%s",
736 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
737 "VDir" :
738 NullStr,
739 (ParentIsDesktop(dcd->hwndFrame, (HWND) 0)) ?
740 (!dcd->dontclose) ?
741 " Master: " : ": " : NullStr, dcd->directory);
742 WinSetWindowText(dcd->hwndFrame, s);
743 WinSetWindowText(WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR), s);
[2]744 }
[751]745 RemoveCnrItems(dcd->hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[551]746 AdjustCnrColsForFSType(dcd->hwndCnr, dcd->directory, dcd);
747 dcd->ullTotalBytes = dcd->totalfiles =
748 dcd->selectedfiles = dcd->selectedbytes = 0;
749 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0 / 0k");
750 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
751 if (hwndStatus &&
752 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
753 WinSetWindowText(hwndStatus, GetPString(IDS_SCANNINGTEXT));
754 if (hwndMain)
755 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
756 }
757 if (fSwitchTree && hwndTree) {
758 if (hwndMain) {
759 if (TopWindow(hwndMain, (HWND) 0) == dcd->hwndFrame)
760 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
761 }
762 else
763 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
764 }
765 dcd->firsttree = FALSE;
766 // fixme to check errors
767 FillDirCnr(dcd->hwndCnr, dcd->directory, dcd, &dcd->ullTotalBytes);
768 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
769 if (mp2 && !fLeaveTree && (dcd->flWindowAttr & CV_TREE)) {
[2]770
[551]771 ULONG flWindowAttr = dcd->flWindowAttr;
772 CNRINFO cnri;
[2]773
[551]774 flWindowAttr &=
775 (~(CV_NAME | CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
776 if (dcd->lastattr) {
777 if (dcd->lastattr & CV_TEXT)
778 flWindowAttr |= CV_TEXT;
779 else if (dcd->lastattr & CV_DETAIL)
780 flWindowAttr |= CV_DETAIL;
781 else if (dcd->lastattr & CV_ICON)
782 flWindowAttr |= CV_ICON;
783 else
784 flWindowAttr |= CV_NAME;
785 }
786 else
787 flWindowAttr |= CV_NAME;
788 flWindowAttr |= CV_FLOW;
789 memset(&cnri, 0, sizeof(CNRINFO));
790 cnri.cb = sizeof(CNRINFO);
791 if (WinSendMsg(dcd->hwndCnr, CM_QUERYCNRINFO, MPFROMP(&cnri),
792 MPFROMLONG(sizeof(CNRINFO)))) {
793 dcd->flWindowAttr = cnri.flWindowAttr = flWindowAttr;
794 WinSendMsg(dcd->hwndCnr, CM_SETCNRINFO,
795 MPFROMP(&cnri), MPFROMLONG(CMA_FLWINDOWATTR));
796 SayView(WinWindowFromID(dcd->hwndClient,
797 DIR_VIEW), dcd->flWindowAttr);
798 }
799 }
800 if (dcd->flWindowAttr & CV_TREE)
801 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
802 if (*dcd->previous) {
803 if (strlen(dcd->previous) > strlen(dcd->directory) &&
804 !strnicmp(dcd->directory, dcd->previous,
[787]805 strlen(dcd->directory)))
[907]806 {
[787]807 PCNRITEM pci = FindCnrRecord(dcd->hwndCnr,
[907]808 dcd->previous,
[787]809 NULL, TRUE, FALSE, TRUE);
[551]810 if (pci && (INT) pci != -1) {
[787]811 // make found item current (cursored) item
[551]812 WinSendMsg(dcd->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pci),
813 MPFROM2SHORT(TRUE, CRA_CURSORED));
814 /* make sure that record shows in viewport */
815 ShowCnrRecord(dcd->hwndCnr, (PMINIRECORDCORE) pci);
816 }
817 }
[2]818 }
[551]819 }
820 return 0;
[2]821
[551]822 case UM_COMMAND:
823 if (mp1) {
[2]824
[551]825 LISTINFO *li = (LISTINFO *) mp1;
[2]826
[551]827 switch (li->type) {
828 case IDM_DOITYOURSELF:
829 case IDM_APPENDTOCLIP:
830 case IDM_SAVETOCLIP:
831 case IDM_ARCHIVE:
832 case IDM_ARCHIVEM:
833 case IDM_VIEWTEXT:
834 case IDM_VIEWBINARY:
835 case IDM_VIEWARCHIVE:
836 case IDM_VIEW:
837 case IDM_EDITTEXT:
838 case IDM_EDITBINARY:
839 case IDM_EDIT:
840 case IDM_OBJECT:
841 case IDM_SHADOW:
842 case IDM_SHADOW2:
843 case IDM_PRINT:
844 case IDM_ATTRS:
845 case IDM_DELETE:
846 case IDM_PERMDELETE:
847 case IDM_MCIPLAY:
848 case IDM_UPDATE:
849 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
850 return (MRESULT) TRUE;
851 break;
852 default:
853 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
854 return (MRESULT) TRUE;
[2]855 }
[551]856 }
857 return 0;
[2]858
[551]859 case UM_SELECT:
860 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
861 if (dcd) {
862 switch (SHORT1FROMMP(mp1)) {
863 case IDM_SELECTBOTH:
864 case IDM_SELECTONE:
865 case IDM_SELECTMORE:
866 case IDM_SELECTNEWER:
867 case IDM_SELECTOLDER:
868 case IDM_SELECTBIGGER:
869 case IDM_SELECTSMALLER:
870 case IDM_DESELECTBOTH:
871 case IDM_DESELECTONE:
872 case IDM_DESELECTMORE:
873 case IDM_DESELECTNEWER:
874 case IDM_DESELECTOLDER:
875 case IDM_DESELECTBIGGER:
876 case IDM_DESELECTSMALLER:
877 SpecialSelect2(dcd->hwndParent, SHORT1FROMMP(mp1));
878 break;
879 case IDM_SELECTLIST:
880 {
881 CHAR filename[CCHMAXPATH], *p, *pp;
882 ULONG size;
[2]883
[551]884 strcpy(filename, "*.LST");
885 size = CCHMAXPATH;
886 PrfQueryProfileData(fmprof, appname, "SaveToListName",
887 filename, &size);
888 pp = strrchr(filename, '\\');
889 if (!pp)
890 pp = filename;
891 p = strrchr(pp, '.');
892 if (p && *(p + 1) && p > pp + 1) {
893 if (pp > filename)
894 pp++;
895 *pp = '*';
896 pp++;
897 if (p > pp)
898 memmove(pp, p, strlen(p) + 1);
899 }
900 if (insert_filename(hwnd, filename, FALSE, FALSE))
901 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
902 NULL);
903 }
904 break;
905 case IDM_SELECTALL:
906 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
907 break;
908 case IDM_DESELECTALL:
909 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
910 break;
911 case IDM_SELECTALLFILES:
912 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
913 break;
914 case IDM_DESELECTALLFILES:
915 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
916 break;
917 case IDM_SELECTALLDIRS:
918 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
919 break;
920 case IDM_DESELECTALLDIRS:
921 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
922 break;
923 case IDM_DESELECTMASK:
924 case IDM_SELECTMASK:
925 {
926 MASK mask;
927 PCNRITEM pci = (PCNRITEM) mp2;
[2]928
[551]929 memset(&mask, 0, sizeof(MASK));
930 mask.fNoAttribs = TRUE;
931 mask.fNoDirs = TRUE;
932 mask.fText = TRUE;
933 strcpy(mask.prompt,
934 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
935 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
936 if (pci && (INT) pci != -1)
[730]937 strcpy(mask.szMask, pci->pszFileName);
[551]938 if (WinDlgBox(HWND_DESKTOP,
939 dcd->hwndCnr,
940 PickMaskDlgProc,
941 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
942 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
943 SelectAll(dcd->hwndCnr,
944 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
945 else
946 DeselectAll(dcd->hwndCnr,
947 TRUE, TRUE, mask.szMask, mask.szText, FALSE);
948 }
949 }
950 break;
[2]951
[551]952 case IDM_DESELECTCLIP:
953 case IDM_SELECTCLIP:
954 {
955 CHAR **list;
[2]956
[551]957 list = ListFromClipboard(hwnd);
958 if (list) {
959 SelectList(dcd->hwndCnr, TRUE, FALSE,
960 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
961 NULL, NULL, list);
962 FreeList(list);
963 }
964 }
965 break;
[2]966
[551]967 case IDM_INVERT:
968 InvertAll(dcd->hwndCnr);
969 break;
[2]970 }
[551]971 }
972 return 0;
[2]973
[551]974 case UM_MASSACTION:
975 if (mp1) {
[2]976
[551]977 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
978 if (dcd) {
[2]979
[551]980 WORKER *wk;
[2]981
[551]982 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
983 if (!wk)
984 FreeListInfo((LISTINFO *) mp1);
985 else {
986 wk->size = sizeof(WORKER);
987 wk->hwndCnr = dcd->hwndCnr;
988 wk->hwndParent = dcd->hwndParent;
989 wk->hwndFrame = dcd->hwndFrame;
990 wk->hwndClient = dcd->hwndClient;
991 wk->li = (LISTINFO *) mp1;
992 strcpy(wk->directory, dcd->directory);
993 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
994 Runtime_Error(pszSrcFile, __LINE__,
995 GetPString(IDS_COULDNTSTARTTHREADTEXT));
996 free(wk);
997 FreeListInfo((LISTINFO *) mp1);
998 }
999 }
[2]1000 }
[551]1001 }
1002 return 0;
[2]1003
[551]1004 case UM_ACTION:
1005 if (mp1) {
[2]1006
[551]1007 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1008 if (dcd) {
[2]1009
[551]1010 WORKER *wk;
[2]1011
[551]1012 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
1013 if (!wk)
1014 FreeListInfo((LISTINFO *) mp1);
1015 else {
1016 wk->size = sizeof(WORKER);
1017 wk->hwndCnr = dcd->hwndCnr;
1018 wk->hwndParent = dcd->hwndParent;
1019 wk->hwndFrame = dcd->hwndFrame;
1020 wk->hwndClient = dcd->hwndClient;
1021 wk->li = (LISTINFO *) mp1;
1022 strcpy(wk->directory, dcd->directory);
1023 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
1024 Runtime_Error(pszSrcFile, __LINE__,
1025 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1026 free(wk);
1027 FreeListInfo((LISTINFO *) mp1);
1028 }
1029 }
[2]1030 }
[551]1031 }
1032 return 0;
[2]1033
[551]1034 case WM_CLOSE:
1035 WinDestroyWindow(hwnd);
1036 break;
[2]1037
[551]1038 case WM_DESTROY:
1039 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1040 if (dcd) {
1041 if (dcd->hwndRestore)
1042 WinSetWindowPos(dcd->hwndRestore,
1043 HWND_TOP,
1044 0,
1045 0,
1046 0,
1047 0,
1048 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
1049 FreeList(dcd->lastselection);
1050 free(dcd);
1051 DosPostEventSem(CompactSem);
1052 }
1053 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
1054 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
1055 break;
[2]1056 }
[551]1057 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1058}
1059
[551]1060MRESULT EXPENTRY DirCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[275]1061{
[672]1062 DIRCNRDATA *dcd = INSTDATA(hwnd);
[2]1063
[551]1064 switch (msg) {
1065 case DM_PRINTOBJECT:
1066 return MRFROMLONG(DRR_TARGET);
1067
1068 case DM_DISCARDOBJECT:
1069 if (dcd)
1070 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1071 else
[2]1072 return MRFROMLONG(DRR_TARGET);
1073
[551]1074 case WM_CHAR:
1075 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1076 if (SHORT1FROMMP(mp1) & KC_KEYUP)
1077 return (MRESULT) TRUE;
1078 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
1079 switch (SHORT2FROMMP(mp2)) {
1080 case VK_INSERT:
1081 if ((shiftstate & KC_CTRL) == KC_CTRL)
1082 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_MKDIR, 0), MPVOID);
1083 else if ((shiftstate & KC_ALT) == KC_ALT)
1084 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_CREATE, 0), MPVOID);
1085 break;
1086 case VK_PAGEUP:
1087 if ((shiftstate & KC_CTRL) == KC_CTRL)
1088 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PARENT, 0), MPVOID);
1089 break;
1090 case VK_PAGEDOWN:
1091 if ((shiftstate & KC_CTRL) == KC_CTRL)
1092 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PREVIOUS, 0), MPVOID);
1093 break;
1094 case VK_HOME:
1095 if ((shiftstate & KC_CTRL) == KC_CTRL && dcd) {
[2]1096
[551]1097 CHAR s[CCHMAXPATH], *p;
[2]1098
[551]1099 strcpy(s, dcd->directory);
1100 p = strchr(s, '\\');
1101 if (p) {
1102 p++;
1103 *p = 0;
1104 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(s), MPVOID);
1105 }
1106 }
1107 break;
1108 case VK_DELETE:
1109 if ((shiftstate & KC_CTRL) == KC_CTRL)
1110 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
1111 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
1112 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
1113 else
1114 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
1115 break;
[2]1116 }
[551]1117 }
1118 if (shiftstate || fNoSearch)
1119 break;
1120 if (SHORT1FROMMP(mp1) & KC_CHAR) {
[2]1121
[551]1122 ULONG thistime, len;
1123 SEARCHSTRING srch;
1124 PCNRITEM pci;
[2]1125
[551]1126 if (!dcd)
1127 break;
1128 switch (SHORT1FROMMP(mp2)) {
1129 case '\x1b':
1130 case '\r':
1131 case '\n':
1132 dcd->lasttime = 0;
1133 *dcd->szCommonName = 0;
1134 break;
1135 default:
1136 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1137 if (thistime > dcd->lasttime + 1250)
1138 *dcd->szCommonName = 0;
1139 dcd->lasttime = thistime;
1140 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1141 break;
1142 KbdRetry:
1143 len = strlen(dcd->szCommonName);
1144 if (len >= CCHMAXPATH - 1) {
1145 *dcd->szCommonName = 0;
1146 len = 0;
1147 }
1148 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1149 dcd->szCommonName[len + 1] = 0;
1150 memset(&srch, 0, sizeof(SEARCHSTRING));
1151 srch.cb = (ULONG) sizeof(SEARCHSTRING);
1152 srch.pszSearch = (PSZ) dcd->szCommonName;
1153 srch.fsPrefix = TRUE;
1154 srch.fsCaseSensitive = FALSE;
1155 srch.usView = CV_ICON;
1156 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1157 MPFROMLONG(CMA_FIRST));
1158 if (pci && (INT) pci != -1) {
[2]1159
[551]1160 USHORT attrib = CRA_CURSORED;
[2]1161
[551]1162 /* make found item current item */
1163 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1164 attrib |= CRA_SELECTED;
1165 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1166 MPFROM2SHORT(TRUE, attrib));
1167 /* make sure that record shows in viewport */
1168 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1169 return (MRESULT) TRUE;
1170 }
1171 else {
1172 if (SHORT1FROMMP(mp2) == ' ') {
1173 dcd->szCommonName[len] = 0;
1174 break;
1175 }
1176 *dcd->szCommonName = 0;
1177 dcd->lasttime = 0;
1178 if (len) // retry as first letter if no match
1179 goto KbdRetry;
1180 }
1181 break;
[2]1182 }
[551]1183 }
1184 break;
[2]1185
[551]1186 case WM_MOUSEMOVE:
1187 case WM_BUTTON1UP:
1188 case WM_BUTTON2UP:
1189 case WM_BUTTON3UP:
1190 case WM_CHORD:
1191 shiftstate = (SHORT2FROMMP(mp2) & (KC_ALT | KC_SHIFT | KC_CTRL));
1192 break;
[2]1193
[551]1194 case WM_BUTTON1MOTIONEND:
1195 {
1196 CNRINFO cnri;
[2]1197
[551]1198 memset(&cnri, 0, sizeof(CNRINFO));
1199 cnri.cb = sizeof(CNRINFO);
1200 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1201 MPFROMLONG(sizeof(CNRINFO)))) {
1202 if (cnri.flWindowAttr & CV_DETAIL)
1203 PrfWriteProfileData(fmprof, appname, "CnrSplitBar",
1204 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
[2]1205 }
[551]1206 }
1207 break;
[2]1208
[551]1209 case UM_COMPARE:
1210 if (dcd && mp1 && mp2) {
[2]1211
[551]1212 COMPARE *cmp;
1213 CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
[2]1214
[551]1215 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1216 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1217 if (cmp) {
1218 cmp->size = sizeof(COMPARE);
1219 strcpy(cmp->leftdir, leftdir);
1220 strcpy(cmp->rightdir, rightdir);
1221 cmp->hwndParent = dcd->hwndParent;
1222 cmp->dcd.hwndParent = dcd->hwndParent;
1223 WinDlgBox(HWND_DESKTOP,
1224 HWND_DESKTOP,
1225 CompareDlgProc, FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1226 }
[2]1227 }
[551]1228 }
1229 return 0;
[2]1230
[551]1231 case WM_PRESPARAMCHANGED:
1232 PresParamChanged(hwnd, "DirCnr", mp1, mp2);
1233 break;
[2]1234
[551]1235 case UM_UPDATERECORDLIST:
1236 if (dcd && mp1)
1237 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1238 return 0;
[2]1239
[551]1240 case UM_UPDATERECORD:
1241 if (dcd && mp1) {
[2]1242
[551]1243 CHAR *filename;
[2]1244
[551]1245 filename = mp1;
1246 if (filename)
1247 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1248 }
1249 return 0;
[2]1250
[551]1251 case WM_SETFOCUS:
1252 /*
1253 * put name of our window (directory name) on status line
1254 */
1255 if (dcd && hwndStatus && mp2) {
[2]1256
[551]1257 PCNRITEM pci = NULL;
[2]1258
[551]1259 if (fAutoView && hwndMain) {
1260 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS, MPFROMLONG(CMA_FIRST),
1261 MPFROMSHORT(CRA_CURSORED));
1262 if (pci && (INT) pci != -1 &&
[730]1263 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1264 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]1265 else
1266 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
[2]1267 }
[551]1268 if (*dcd->directory) {
1269 if (hwndMain)
1270 WinSendMsg(hwndMain,
1271 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1272 else
1273 add_udir(FALSE, dcd->directory);
[2]1274 }
[551]1275 if (hwndMain)
1276 PostMsg(hwndMain, UM_ADVISEFOCUS, MPFROMLONG(dcd->hwndFrame), MPVOID);
1277 }
1278 if (mp2) {
1279 LastDir = hwnd;
1280 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1281 if (fSwitchTreeOnFocus && hwndTree && dcd && *dcd->directory)
1282 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory), MPVOID);
1283 }
1284 break;
[2]1285
[551]1286 case UM_SETDIR:
1287 if (dcd && mp1) {
[2]1288
[551]1289 CHAR fullname[CCHMAXPATH];
[2]1290
[551]1291 DosError(FERR_DISABLEHARDERR);
1292 if (!DosQueryPathInfo((CHAR *) mp1,
1293 FIL_QUERYFULLNAME, fullname, sizeof(fullname))) {
1294 if (stricmp(dcd->directory, fullname)) {
1295 strcpy(dcd->previous, dcd->directory);
1296 strcpy(dcd->directory, fullname);
1297 DosEnterCritSec();
1298 dcd->stopflag++;
1299 DosExitCritSec();
1300 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
1301 strcpy(dcd->directory, dcd->previous);
1302 DosEnterCritSec();
1303 dcd->stopflag--;
1304 DosExitCritSec();
1305 }
1306 else if (*dcd->directory) {
1307 if (hwndMain)
1308 WinSendMsg(hwndMain,
1309 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
1310 else
1311 add_udir(FALSE, dcd->directory);
1312 }
1313 }
[2]1314 }
[551]1315 }
1316 break;
[2]1317
[551]1318 case UM_RESCAN:
1319 if (dcd) {
[2]1320
[551]1321 CNRINFO cnri;
1322 CHAR s[CCHMAXPATH * 2], tf[81], tb[81];
1323 PCNRITEM pci;
[2]1324
[551]1325 memset(&cnri, 0, sizeof(CNRINFO));
1326 cnri.cb = sizeof(CNRINFO);
1327 WinSendMsg(hwnd,
1328 CM_QUERYCNRINFO,
1329 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1330 cnri.pszCnrTitle = dcd->directory;
1331 WinSendMsg(hwnd,
1332 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_CNRTITLE));
1333 dcd->totalfiles = cnri.cRecords;
1334 commafmt(tb, sizeof(tb), dcd->totalfiles);
1335 CommaFmtULL(tf, sizeof(tf), dcd->ullTotalBytes, 'K');
1336 sprintf(s, "%s / %s", tb, tf);
1337 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1338 commafmt(tb, sizeof(tb), dcd->selectedfiles);
1339 CommaFmtULL(tf, sizeof(tf), dcd->selectedbytes, 'K');
1340 sprintf(s, "%s / %s", tb, tf);
1341 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1342 if (hwndStatus &&
1343 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1344 PostMsg(dcd->hwndObject, UM_RESCAN2, MPVOID, MPVOID);
1345 if ((fSplitStatus && hwndStatus2) || fMoreButtons) {
1346 pci = WinSendMsg(hwnd,
1347 CM_QUERYRECORDEMPHASIS,
1348 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1349 if (pci && (INT) pci != -1) {
1350 if (fSplitStatus && hwndStatus2) {
1351 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1352 if (!fMoreButtons)
1353 sprintf(s,
1354 " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1355 tb,
1356 pci->date.year,
1357 pci->date.month,
1358 pci->date.day,
1359 pci->time.hours,
1360 pci->time.minutes,
1361 pci->time.seconds,
1362 pci->pszDispAttr, pci->pszFileName);
1363 else {
1364 *tf = 0;
1365 if (pci->cbFile + pci->easize > 1024) {
1366 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1367 }
1368 sprintf(s,
1369 GetPString(IDS_STATUSSIZETEXT),
1370 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1371 }
1372 WinSetWindowText(hwndStatus2, s);
1373 }
1374 else
1375 WinSetWindowText(hwndStatus2, NullStr);
1376 if (fMoreButtons) {
1377 WinSetWindowText(hwndName, pci->pszFileName);
1378 sprintf(s,
1379 "%04u/%02u/%02u %02u:%02u:%02u",
1380 pci->date.year,
1381 pci->date.month,
1382 pci->date.day,
1383 pci->time.hours, pci->time.minutes, pci->time.seconds);
1384 WinSetWindowText(hwndDate, s);
1385 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1386 }
1387 }
1388 else {
1389 WinSetWindowText(hwndStatus2, NullStr);
1390 WinSetWindowText(hwndName, NullStr);
1391 WinSetWindowText(hwndDate, NullStr);
1392 WinSetWindowText(hwndAttr, NullStr);
1393 }
1394 }
[2]1395 }
[551]1396 }
1397 return 0;
[2]1398
[551]1399 case UM_SORTRECORD:
1400 if (dcd) {
[2]1401
[551]1402 CNRINFO cnri;
[2]1403
[551]1404 memset(&cnri, 0, sizeof(CNRINFO));
1405 cnri.cb = sizeof(CNRINFO);
1406 WinSendMsg(hwnd,
1407 CM_QUERYCNRINFO,
1408 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1409 cnri.pSortRecord = (PVOID) SortDirCnr;
1410 WinSendMsg(hwnd,
1411 CM_SETCNRINFO, MPFROMP(&cnri), MPFROMLONG(CMA_PSORTRECORD));
1412 WinSendMsg(hwnd,
1413 CM_SORTRECORD,
1414 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
1415 }
1416 return 0;
[2]1417
[551]1418 case UM_SETUP:
1419 if (dcd) {
1420 if (!dcd->hwndObject) {
1421 /*
1422 * first time through -- set things up
1423 */
[2]1424
[551]1425 CNRINFO cnri;
[2]1426
[551]1427 RestorePresParams(hwnd, "DirCnr");
1428 memset(&cnri, 0, sizeof(CNRINFO));
1429 cnri.cb = sizeof(CNRINFO);
1430 WinSendMsg(hwnd,
1431 CM_QUERYCNRINFO,
1432 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
1433 cnri.cyLineSpacing = 0;
1434 cnri.cxTreeIndent = 12L;
[2]1435
[551]1436 cnri.flWindowAttr &= (~(CV_TREE | CV_ICON | CV_DETAIL | CV_TEXT));
1437 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES | CV_MINI |
1438 CV_FLOW);
1439 cnri.pSortRecord = (PVOID) SortDirCnr;
[2]1440
[551]1441 {
1442 ULONG size = sizeof(ULONG);
[2]1443
[551]1444 PrfQueryProfileData(fmprof,
1445 appname,
1446 "DirflWindowAttr",
1447 (PVOID) & cnri.flWindowAttr, &size);
1448 size = sizeof(MASK);
1449 if (!*dcd->mask.szMask &&
1450 !dcd->mask.attrFile && !dcd->mask.antiattr) {
1451 if (PrfQueryProfileSize(fmprof,
1452 appname, "DirFilter", &size) && size) {
1453 PrfQueryProfileData(fmprof,
1454 appname, "DirFilter", &dcd->mask, &size);
1455 SetMask(dcd->mask.szMask, &dcd->mask);
1456 }
1457 else
1458 dcd->mask.attrFile = (FILE_READONLY | FILE_NORMAL |
1459 FILE_ARCHIVED | FILE_DIRECTORY |
1460 FILE_HIDDEN | FILE_SYSTEM);
1461 }
1462 *(dcd->mask.prompt) = 0;
1463 }
1464 if (dcd->flWindowAttr)
1465 cnri.flWindowAttr = dcd->flWindowAttr;
1466 else
1467 dcd->flWindowAttr = cnri.flWindowAttr;
1468 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH |
1469 CA_TITLEREADONLY | CA_TITLESEPARATOR));
1470 cnri.flWindowAttr |= CV_FLOW;
1471 dcd->flWindowAttr |= CV_FLOW;
1472 if (WinWindowFromID(dcd->hwndFrame, FID_TITLEBAR))
1473 cnri.flWindowAttr &= (~CA_CONTAINERTITLE);
1474 else
1475 cnri.flWindowAttr |= CA_CONTAINERTITLE;
1476 if (!dcd->sortFlags)
1477 dcd->sortFlags = sortFlags;
1478 WinSendMsg(hwnd,
1479 CM_SETCNRINFO,
1480 MPFROMP(&cnri),
1481 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1482 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1483 SetCnrCols(hwnd, FALSE);
1484 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID) dcd) == -1) {
1485 Runtime_Error(pszSrcFile, __LINE__,
1486 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1487 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1488 return 0;
1489 }
1490 else
[771]1491 DosSleep(32); //05 Aug 07 GKY 64
[551]1492 WinEnableMenuItem(DirCnrMenu, IDM_FINDINTREE, (hwndTree != (HWND) 0));
[2]1493 }
[551]1494 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1495 DIR_FILTER), &dcd->mask, FALSE);
1496 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1497 DIR_SORT), dcd->sortFlags, FALSE);
1498 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1499 DIR_VIEW), dcd->flWindowAttr);
1500 }
1501 else {
1502 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[2]1503 return 0;
[551]1504 }
1505 return 0;
[2]1506
[923]1507 case UM_SETUP2:
1508 if (dcd)
1509 {
1510 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1511 }
1512 else {
1513 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1514 return 0;
1515 }
1516 return 0;
1517
[551]1518 case WM_MENUEND:
1519 if (dcd) {
[2]1520
[551]1521 HWND hwndMenu = (HWND) mp2;
[2]1522
[551]1523 if (hwndMenu == DirCnrMenu ||
1524 hwndMenu == FileMenu || hwndMenu == DirMenu) {
1525 MarkAll(hwnd, TRUE, FALSE, TRUE);
1526 if (dcd->cnremphasized) {
1527 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1528 MPFROM2SHORT(FALSE, CRA_SOURCE));
1529 dcd->cnremphasized = FALSE;
1530 }
[2]1531 }
[551]1532 }
1533 break;
[2]1534
[551]1535 case UM_OPENWINDOWFORME:
1536 if (dcd) {
1537 if (mp1 && !IsFile((CHAR *) mp1)) {
1538 OpenDirCnr(hwnd, dcd->hwndParent, dcd->hwndFrame, FALSE, (char *)mp1);
[2]1539 }
[551]1540 else if (mp1 && IsFile(mp1) == 1) {
1541 StartArcCnr(HWND_DESKTOP,
1542 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1543 }
1544 }
1545 return 0;
[2]1546
[551]1547 case MM_PORTHOLEINIT:
1548 if (dcd) {
1549 switch (SHORT1FROMMP(mp1)) {
1550 case 0:
1551 case 1:
1552 {
1553 ULONG wmsg;
[2]1554
[551]1555 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1556 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
1557 wmsg, MPVOID, MPVOID), mp1, mp2);
1558 }
1559 break;
[2]1560 }
[551]1561 }
1562 break;
[2]1563
[551]1564 case UM_INITMENU:
1565 case WM_INITMENU:
1566 if (dcd) {
1567 switch (SHORT1FROMMP(mp1)) {
1568 case IDM_FILESMENU:
[907]1569 CopyPresParams((HWND) mp2, hwndMainMenu);
1570 if (isalpha(*dcd->directory)) {
[551]1571 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE) {
1572 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, FALSE);
1573 WinEnableMenuItem((HWND) mp2, IDM_RENAME, FALSE);
1574 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1575 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, FALSE);
1576 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, FALSE);
1577 WinEnableMenuItem((HWND) mp2, IDM_DELETE, FALSE);
1578 WinEnableMenuItem((HWND) mp2, IDM_EDIT, FALSE);
1579 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, FALSE);
1580 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, FALSE);
1581 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, FALSE);
1582 }
1583 else {
1584 WinEnableMenuItem((HWND) mp2, IDM_MOVEMENU, TRUE);
1585 WinEnableMenuItem((HWND) mp2, IDM_RENAME, TRUE);
1586 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1587 WinEnableMenuItem((HWND) mp2, IDM_UNDELETE, TRUE);
1588 WinEnableMenuItem((HWND) mp2, IDM_DELETESUBMENU, TRUE);
1589 WinEnableMenuItem((HWND) mp2, IDM_DELETE, TRUE);
1590 WinEnableMenuItem((HWND) mp2, IDM_EDIT, TRUE);
1591 WinEnableMenuItem((HWND) mp2, IDM_EDITTEXT, TRUE);
1592 WinEnableMenuItem((HWND) mp2, IDM_EDITBINARY, TRUE);
[907]1593 WinEnableMenuItem((HWND) mp2, IDM_ATTRS, TRUE);
[551]1594 }
1595 }
1596 break;
[2]1597
[551]1598 case IDM_VIEWSMENU:
[907]1599 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
[877]1600 CopyPresParams((HWND) mp2, hwndMainMenu);
[907]1601 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1602 (dcd->lastselection != NULL));
1603 if (isalpha(*dcd->directory)) {
[551]1604 if (driveflags[toupper(*dcd->directory) - 'A'] & DRIVE_NOTWRITEABLE)
1605 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, FALSE);
1606 else
1607 WinEnableMenuItem((HWND) mp2, IDM_MKDIR, TRUE);
1608 }
1609 WinEnableMenuItem((HWND) mp2,
1610 IDM_SELECTCOMPAREMENU,
1611 (CountDirCnrs(dcd->hwndParent) > 1));
1612 break;
[2]1613
[551]1614 case IDM_DETAILSSETUP:
1615 SetDetailsSwitches((HWND) mp2, dcd);
1616 break;
[2]1617
[551]1618 case IDM_COMMANDSMENU:
1619 SetupCommandMenu((HWND) mp2, hwnd);
1620 break;
[2]1621
[551]1622 case IDM_SORTSUBMENU:
1623 SetSortChecks((HWND) mp2, dcd->sortFlags);
1624 break;
[2]1625
[551]1626 case IDM_WINDOWSMENU:
1627 SetupWinList((HWND) mp2,
1628 (hwndMain) ? hwndMain : (HWND) 0, dcd->hwndFrame);
1629 break;
[2]1630 }
[551]1631 dcd->hwndLastMenu = (HWND) mp2;
1632 }
1633 if (msg == WM_INITMENU)
1634 break;
1635 return 0;
[2]1636
[551]1637 case UM_FILTER:
1638 if (dcd) {
[2]1639
[551]1640 PCNRITEM pci;
[2]1641
[551]1642 if (mp1) {
1643 DosEnterCritSec();
1644 SetMask((CHAR *) mp1, &dcd->mask);
1645 DosExitCritSec();
[2]1646 }
[551]1647 dcd->suspendview = 1;
1648 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1649 dcd->suspendview = 0;
1650 if (fAutoView && hwndMain) {
1651 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1652 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1653 if (pci && (INT) pci != -1 &&
[730]1654 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1655 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]1656 else
1657 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1658 }
1659 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1660 }
1661 return 0;
[2]1662
[551]1663 case UM_COMMAND:
1664 if (mp1) {
1665 if (dcd) {
1666 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1667 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1668 FreeListInfo((LISTINFO *) mp1);
1669 }
1670 else
1671 return (MRESULT) TRUE;
[2]1672 }
[551]1673 else
1674 FreeListInfo((LISTINFO *) mp1);
1675 }
1676 return 0;
[2]1677
[551]1678 case UM_NOTIFY:
1679 if (mp2)
1680 Notify((CHAR *) mp2);
1681 return 0;
[2]1682
[551]1683 case UM_DRIVECMD:
1684 if (mp1)
1685 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SWITCH, 0), mp1);
1686 return 0;
[2]1687
[551]1688 case WM_COMMAND:
1689 DosError(FERR_DISABLEHARDERR);
1690 if (dcd) {
1691 switch (SHORT1FROMMP(mp1)) {
1692 case IDM_SETTARGET:
1693 SetTargetDir(hwnd, FALSE);
1694 break;
[2]1695
[551]1696 case IDM_CREATE:
1697 {
1698 STRINGINPARMS sip;
1699 CHAR filename[CCHMAXPATHCOMP];
[2]1700
[551]1701 memset(&sip, 0, sizeof(sip));
1702 sip.help = GetPString(IDS_CREATETEXT);
1703 sip.prompt = GetPString(IDS_CREATEPROMPTTEXT);
1704 sip.inputlen = CCHMAXPATHCOMP - (strlen(dcd->directory) - 1);
1705 strcpy(filename, "NEWFILE.TXT");
1706 sip.ret = filename;
1707 sip.title = GetPString(IDS_CREATETITLETEXT);
1708 if (WinDlgBox(HWND_DESKTOP, hwnd, InputDlgProc, FM3ModHandle,
1709 STR_FRAME, &sip)) {
1710 bstrip(sip.ret);
1711 if (*sip.ret) {
1712 CHAR newfile[CCHMAXPATH];
1713 FILE *fp;
1714 INT test;
1715 PCNRITEM pci;
[2]1716
[551]1717 strcpy(newfile, dcd->directory);
1718 if (newfile[strlen(newfile) - 1] != '\\')
1719 strcat(newfile, "\\");
1720 strcat(newfile, sip.ret);
1721 test = IsFile(newfile);
1722 if (test != 1)
1723 fp = fopen(newfile, "w");
1724 if (test != 1 && !fp) {
1725 saymsg(MB_ENTER,
1726 hwnd,
1727 GetPString(IDS_ERRORTEXT),
1728 GetPString(IDS_CREATEERRORTEXT), newfile);
1729 }
1730 else {
1731 if (fp) {
1732 WinSendMsg(hwnd, UM_UPDATERECORD, MPFROMP(newfile), MPVOID);
1733 fclose(fp);
1734 }
1735 if (*editor) {
[2]1736
[551]1737 CHAR *dummy[2];
[2]1738
[551]1739 dummy[0] = newfile;
1740 dummy[1] = NULL;
1741 ExecOnList(hwnd,
[907]1742 editor, WINDOWED | SEPARATE, NULL, dummy, NULL,
1743 pszSrcFile, __LINE__);
[551]1744 }
1745 else
1746 StartMLEEditor(dcd->hwndParent, 4, newfile, dcd->hwndFrame);
1747 pci = FindCnrRecord(hwnd, newfile, NULL, TRUE, FALSE, TRUE);
1748 if (pci && (INT) pci != -1)
1749 /* make sure that record shows in viewport */
1750 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1751 }
1752 }
1753 }
1754 }
1755 break;
[2]1756
[551]1757 case IDM_CONTEXTMENU:
1758 {
1759 PCNRITEM pci;
[2]1760
[551]1761 pci = (PCNRITEM) CurrentRecord(hwnd);
1762 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(DIR_CNR, CN_CONTEXTMENU),
1763 MPFROMP(pci));
1764 }
1765 break;
[2]1766
[551]1767 case IDM_MAXIMIZE:
1768 PostMsg(hwndMain, UM_MAXIMIZE, MPFROMLONG(dcd->hwndFrame), MPVOID);
1769 break;
[2]1770
[551]1771 case IDM_SHOWALLFILESCNR:
1772 StartSeeAll(HWND_DESKTOP, FALSE, dcd->directory);
1773 break;
[2]1774
[551]1775 case IDM_SHOWALLFILES:
1776 {
1777 PCNRITEM pci;
[2]1778
[551]1779 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1780 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1781 if (pci && (INT) pci != -1) {
[2]1782
[551]1783 static CHAR dirname[CCHMAXPATH];
[2]1784
[730]1785 strcpy(dirname, pci->pszFileName);
[551]1786 MakeValidDir(dirname);
1787 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1788 }
1789 }
1790 break;
[2]1791
[551]1792 case IDM_FINDINTREE:
1793 if (hwndTree)
1794 WinSendMsg(hwndTree, UM_SHOWME, MPFROMP(dcd->directory),
1795 MPFROMLONG(1L));
1796 break;
[2]1797
[551]1798 case IDM_BEGINEDIT:
1799 OpenEdit(hwnd);
1800 break;
[2]1801
[551]1802 case IDM_ENDEDIT:
1803 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1804 break;
[2]1805
[551]1806 case IDM_SHOWSELECT:
1807 QuickPopup(hwnd,
1808 dcd,
[877]1809 CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP), IDM_SELECTSUBMENU);
[551]1810 break;
[2]1811
[551]1812 case IDM_SHOWSORT:
[877]1813 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP),
[551]1814 IDM_SORTSUBMENU);
1815 break;
[2]1816
[551]1817 case IDM_VIEWORARC:
1818 {
1819 SWP swp;
1820 PCNRITEM pci;
[2]1821
[551]1822 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1823 MPFROMLONG(CMA_FIRST),
1824 MPFROMSHORT(CRA_CURSORED));
1825 if (pci && (INT) pci != -1) {
1826 WinQueryWindowPos(dcd->hwndFrame, &swp);
1827 DefaultViewKeys(hwnd,
1828 dcd->hwndFrame,
[730]1829 dcd->hwndParent, &swp, pci->pszFileName);
[551]1830 }
1831 }
1832 break;
[2]1833
[551]1834 case IDM_NOTEBOOK:
1835 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
[917]1836 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_DIRCNRSETTINGS), mp2);
1837 else {
1838 WinDlgBox(HWND_DESKTOP,
1839 hwnd,
1840 CfgDlgProc,
1841 FM3ModHandle,
1842 CFG_FRAME,
1843 MPFROMLONG(IDM_DIRCNRSETTINGS));
1844 }
[551]1845 break;
[2]1846
[551]1847 case IDM_QTREE:
1848 case IDM_TREE:
1849 {
1850 CHAR newpath[CCHMAXPATH];
1851 APIRET rc;
1852 PCNRITEM pci;
[2]1853
[551]1854 if (SHORT1FROMMP(mp1) == IDM_TREE) {
1855 pci = (PCNRITEM) CurrentRecord(hwnd);
1856 if (pci && (INT) pci != -1)
[730]1857 strcpy(newpath, pci->pszFileName);
[551]1858 else
1859 strcpy(newpath, dcd->directory);
1860 }
1861 else
1862 strcpy(newpath, dcd->directory);
1863 MakeValidDir(newpath);
1864 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ObjCnrDlgProc,
1865 FM3ModHandle, QTREE_FRAME, MPFROMP(newpath));
1866 if (rc)
1867 WinSendMsg(hwnd, UM_SETDIR, MPFROMP(newpath), MPVOID);
1868 }
1869 break;
[2]1870
[551]1871 case IDM_RESELECT:
1872 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1873 break;
[2]1874
[551]1875 case IDM_HELP:
1876 if (hwndHelp) {
1877 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1878 PostMsg(dcd->hwndParent, UM_COMMAND, mp1, mp2);
1879 else
1880 WinSendMsg(hwndHelp, HM_HELP_CONTENTS, MPVOID, MPVOID);
1881 }
1882 break;
[2]1883
[551]1884 case IDM_WINDOWDLG:
1885 if (!ParentIsDesktop(dcd->hwndFrame, dcd->hwndParent))
1886 PostMsg(dcd->hwndParent, UM_COMMAND,
1887 MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
1888 break;
[2]1889
[551]1890 case IDM_SORTSMARTNAME:
1891 case IDM_SORTNAME:
1892 case IDM_SORTFILENAME:
1893 case IDM_SORTSIZE:
1894 case IDM_SORTEASIZE:
1895 case IDM_SORTFIRST:
1896 case IDM_SORTLAST:
1897 case IDM_SORTLWDATE:
1898 case IDM_SORTLADATE:
1899 case IDM_SORTCRDATE:
1900 case IDM_SORTSUBJECT:
1901 dcd->sortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1902 case IDM_SORTDIRSFIRST:
1903 case IDM_SORTDIRSLAST:
1904 case IDM_SORTREVERSE:
1905 switch (SHORT1FROMMP(mp1)) {
1906 case IDM_SORTSUBJECT:
1907 dcd->sortFlags |= SORT_SUBJECT;
1908 break;
1909 case IDM_SORTSMARTNAME:
1910 case IDM_SORTFILENAME:
1911 dcd->sortFlags |= SORT_FILENAME;
1912 break;
1913 case IDM_SORTSIZE:
1914 dcd->sortFlags |= SORT_SIZE;
1915 break;
1916 case IDM_SORTEASIZE:
1917 dcd->sortFlags |= SORT_EASIZE;
1918 break;
1919 case IDM_SORTFIRST:
1920 dcd->sortFlags |= SORT_FIRSTEXTENSION;
1921 break;
1922 case IDM_SORTLAST:
1923 dcd->sortFlags |= SORT_LASTEXTENSION;
1924 break;
1925 case IDM_SORTLWDATE:
1926 dcd->sortFlags |= SORT_LWDATE;
1927 break;
1928 case IDM_SORTLADATE:
1929 dcd->sortFlags |= SORT_LADATE;
1930 break;
1931 case IDM_SORTCRDATE:
1932 dcd->sortFlags |= SORT_CRDATE;
1933 break;
1934 case IDM_SORTDIRSFIRST:
1935 if (dcd->sortFlags & SORT_DIRSFIRST)
1936 dcd->sortFlags &= (~SORT_DIRSFIRST);
1937 else {
1938 dcd->sortFlags |= SORT_DIRSFIRST;
1939 dcd->sortFlags &= (~SORT_DIRSLAST);
1940 }
1941 break;
1942 case IDM_SORTDIRSLAST:
1943 if (dcd->sortFlags & SORT_DIRSLAST)
1944 dcd->sortFlags &= (~SORT_DIRSLAST);
1945 else {
1946 dcd->sortFlags |= SORT_DIRSLAST;
1947 dcd->sortFlags &= (~SORT_DIRSFIRST);
1948 }
1949 break;
1950 case IDM_SORTREVERSE:
1951 if (dcd->sortFlags & SORT_REVERSE)
1952 dcd->sortFlags &= (~SORT_REVERSE);
1953 else
1954 dcd->sortFlags |= SORT_REVERSE;
1955 break;
1956 }
1957 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortDirCnr),
1958 MPFROMLONG(dcd->sortFlags));
1959 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1960 DIR_SORT), dcd->sortFlags, FALSE);
1961 break;
[2]1962
[551]1963 case IDM_COLLECT:
1964 if (!Collector) {
[2]1965
[551]1966 HWND hwndC;
1967 SWP swp;
[2]1968
[551]1969 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1970 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1971 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
1972 hwndC = StartCollector((fExternalCollector ||
1973 strcmp(realappname, FM3Str)) ?
1974 HWND_DESKTOP : dcd->hwndParent, 4);
1975 if (hwndC) {
1976 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
1977 (!fExternalCollector && !strcmp(realappname, FM3Str)))
1978 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
1979 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
1980 SWP_SHOW | SWP_ZORDER);
1981 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) && fAutoTile &&
1982 !strcmp(realappname, FM3Str))
1983 TileChildren(dcd->hwndParent, TRUE);
1984 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
[771]1985 DosSleep(100); //05 Aug 07 GKY 250
[551]1986 }
1987 }
1988 else
1989 StartCollector(dcd->hwndParent, 4);
1990 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
1991 break;
[2]1992
[551]1993 case IDM_COLLECTOR:
[771]1994 DosSleep(32); //05 Aug 07 GKY 64
[551]1995 {
1996 CHAR **list;
[2]1997
[551]1998 list = BuildList(hwnd);
1999 if (list) {
2000 if (Collector) {
2001 if (!PostMsg(Collector,
2002 WM_COMMAND,
2003 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list)))
2004 FreeList(list);
2005 else if (fUnHilite)
[672]2006 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2007 }
2008 else
2009 FreeList(list);
2010 }
2011 }
2012 break;
[2]2013
[551]2014 case IDM_UNDELETE:
2015 {
2016 PCNRITEM pci;
2017 CHAR path[CCHMAXPATH];
[2]2018
[551]2019 pci = (PCNRITEM) CurrentRecord(hwnd);
2020 if (pci && (INT) pci != -1) {
[730]2021 strcpy(path, pci->pszFileName);
[551]2022 MakeValidDir(path);
2023 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
2024 UNDEL_FRAME, MPFROMP(path));
2025 }
2026 }
2027 break;
[2]2028
[551]2029 case IDM_UNDELETESPEC:
2030 WinDlgBox(HWND_DESKTOP,
2031 hwnd,
2032 UndeleteDlgProc,
2033 FM3ModHandle, UNDEL_FRAME, MPFROMP(dcd->directory));
2034 break;
[2]2035
[551]2036 case IDM_RESORT:
[930]2037// WinSendMsg(hwnd,
2038// CM_SORTRECORD,
2039// MPFROMP(SortDirCnr),
2040// MPFROMLONG((fSyncUpdates) ? sortFlags : dcd->sortFlags));
[551]2041 WinSendMsg(hwnd,
2042 CM_SORTRECORD,
2043 MPFROMP(SortDirCnr), MPFROMLONG(dcd->sortFlags));
2044 break;
[2]2045
[551]2046 case IDM_FILTER:
2047 {
2048 BOOL empty = FALSE;
2049 PCNRITEM pci;
2050 CHAR *p;
[2]2051
[551]2052 if (!*dcd->mask.szMask) {
2053 empty = TRUE;
2054 pci = (PCNRITEM) CurrentRecord(hwnd);
2055 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
[730]2056 p = strrchr(pci->pszFileName, '\\');
[551]2057 if (p) {
2058 p++;
2059 strcpy(dcd->mask.szMask, p);
2060 }
2061 }
2062 }
2063 *(dcd->mask.prompt) = 0;
[2]2064
[551]2065 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
2066 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask)))
2067 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2068 else if (empty)
2069 *dcd->mask.szMask = 0;
2070 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2071 DIR_FILTER), &dcd->mask, FALSE);
2072 }
2073 break;
[2]2074
[551]2075 case IDM_HIDEALL:
2076 if (fAutoView && hwndMain)
2077 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2078 dcd->suspendview = 1;
2079 HideAll(hwnd);
2080 dcd->suspendview = 0;
2081 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2082 break;
[2]2083
[551]2084 case IDM_SELECTBOTH:
2085 case IDM_SELECTONE:
2086 case IDM_SELECTMORE:
2087 case IDM_SELECTNEWER:
2088 case IDM_SELECTOLDER:
2089 case IDM_SELECTBIGGER:
2090 case IDM_SELECTSMALLER:
2091 case IDM_DESELECTBOTH:
2092 case IDM_DESELECTONE:
2093 case IDM_DESELECTMORE:
2094 case IDM_DESELECTNEWER:
2095 case IDM_DESELECTOLDER:
2096 case IDM_DESELECTBIGGER:
2097 case IDM_DESELECTSMALLER:
2098 if (ParentIsDesktop(hwnd, dcd->hwndParent)) {
2099 Runtime_Error(pszSrcFile, __LINE__, "ParentIsDesktop unexpected");
2100 break;
2101 }
2102 case IDM_SELECTLIST:
2103 case IDM_SELECTALL:
2104 case IDM_DESELECTALL:
2105 case IDM_SELECTALLFILES:
2106 case IDM_DESELECTALLFILES:
2107 case IDM_SELECTALLDIRS:
2108 case IDM_DESELECTALLDIRS:
2109 case IDM_SELECTMASK:
2110 case IDM_DESELECTMASK:
2111 case IDM_INVERT:
2112 case IDM_SELECTCLIP:
2113 case IDM_DESELECTCLIP:
2114 {
2115 PCNRITEM pci;
[2]2116
[551]2117 pci = (PCNRITEM) CurrentRecord(hwnd);
2118 if ((INT) pci == -1)
2119 pci = NULL;
2120 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2121 if (pci) {
2122 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2123 pci->rc.flRecordAttr |= CRA_FILTERED;
2124 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
2125 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2126 break;
2127 }
2128 }
2129 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2130 }
2131 break;
[2]2132
[551]2133 case IDM_RESCAN:
2134 DosEnterCritSec();
2135 dcd->stopflag++;
2136 DosExitCritSec();
2137 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID)) {
2138 DosEnterCritSec();
2139 dcd->stopflag--;
2140 DosExitCritSec();
2141 }
2142 break;
[2]2143
[551]2144 case IDM_SHOWLNAMES:
2145 case IDM_SHOWSUBJECT:
2146 case IDM_SHOWEAS:
2147 case IDM_SHOWSIZE:
2148 case IDM_SHOWICON:
2149 case IDM_SHOWLWDATE:
2150 case IDM_SHOWLWTIME:
2151 case IDM_SHOWLADATE:
2152 case IDM_SHOWLATIME:
2153 case IDM_SHOWCRDATE:
2154 case IDM_SHOWCRTIME:
2155 case IDM_SHOWATTR:
2156 AdjustDetailsSwitches(hwnd,
2157 dcd->hwndLastMenu,
2158 SHORT1FROMMP(mp1),
[923]2159 dcd->directory, NULL, dcd, FALSE);
[551]2160 break;
[2]2161
[551]2162 case IDM_TREEVIEW:
2163 case IDM_ICON:
2164 case IDM_TEXT:
2165 case IDM_DETAILS:
2166 case IDM_NAME:
2167 case IDM_MINIICONS:
2168 case IDM_DETAILSTITLES:
2169 {
2170 CNRINFO cnri;
[2]2171
[551]2172 memset(&cnri, 0, sizeof(CNRINFO));
2173 cnri.cb = sizeof(CNRINFO);
2174 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
2175 MPFROMLONG(sizeof(CNRINFO)));
2176 switch (SHORT1FROMMP(mp1)) {
2177 case IDM_TREEVIEW:
2178 if (!(cnri.flWindowAttr & CV_TREE))
2179 dcd->lastattr = cnri.flWindowAttr;
2180 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2181 CV_DETAIL | CV_NAME | CA_TREELINE));
2182 cnri.flWindowAttr |= CA_TREELINE | CV_TREE | CV_ICON;
2183 if (!dcd->firsttree)
2184 PostMsg(dcd->hwndObject, UM_FLESH, MPVOID, MPVOID);
2185 break;
2186 case IDM_ICON:
2187 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2188 CV_DETAIL | CV_NAME | CA_TREELINE));
2189 cnri.flWindowAttr |= CV_ICON;
2190 break;
2191 case IDM_NAME:
2192 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2193 CV_DETAIL | CV_NAME | CA_TREELINE));
2194 cnri.flWindowAttr |= CV_NAME;
2195 break;
2196 case IDM_TEXT:
2197 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2198 CV_DETAIL | CV_NAME | CA_TREELINE));
2199 cnri.flWindowAttr |= CV_TEXT;
2200 break;
2201 case IDM_DETAILS:
2202 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
2203 CV_DETAIL | CV_NAME | CA_TREELINE));
2204 cnri.flWindowAttr |= CV_DETAIL;
2205 break;
2206 case IDM_MINIICONS:
2207 if (cnri.flWindowAttr & CV_MINI)
2208 cnri.flWindowAttr &= (~CV_MINI);
2209 else
2210 cnri.flWindowAttr |= CV_MINI;
2211 break;
2212 case IDM_DETAILSTITLES:
2213 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
2214 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
2215 else
2216 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
2217 break;
2218 }
2219 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
2220 cnri.flWindowAttr |= CV_FLOW;
2221 dcd->flWindowAttr = cnri.flWindowAttr;
2222 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
2223 MPFROMLONG(CMA_FLWINDOWATTR));
2224 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
2225 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2226 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2227 DIR_VIEW), dcd->flWindowAttr);
2228 }
2229 break;
[2]2230
[551]2231 case IDM_SAVETOLIST:
2232 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
2233 SAV_FRAME, MPFROMP(&hwnd));
2234 break;
[2]2235
[551]2236 case IDM_SIZES:
2237 {
2238 PCNRITEM pci;
2239 CHAR path[CCHMAXPATH];
[2]2240
[551]2241 pci = (PCNRITEM) CurrentRecord(hwnd);
2242 if (pci && (INT) pci != -1)
[730]2243 strcpy(path, pci->pszFileName);
[551]2244 else
2245 strcpy(path, dcd->directory);
2246 MakeValidDir(path);
2247 WinDlgBox(HWND_DESKTOP,
2248 HWND_DESKTOP, DirSizeProc, FM3ModHandle, DSZ_FRAME, path);
2249 }
2250 break;
[2]2251
[551]2252 case IDM_MKDIR:
2253 {
[907]2254 PCNRITEM pci;
2255 BOOL saved;
[2]2256
[907]2257 saved = fSelectedAlways;
2258 fSelectedAlways = FALSE;
2259 pci = (PCNRITEM)CurrentRecord(hwnd);
2260 // 01 Oct 07 SHL Make below selected directory or in current directory
[551]2261 PMMkDir(dcd->hwndParent,
[907]2262 pci && (INT)pci != -1 ? pci->pszFileName : dcd->directory,
2263 FALSE);
2264 fSelectedAlways = saved;
[551]2265 }
2266 break;
[2]2267
[551]2268 case IDM_SWITCH:
2269 if (mp2) {
2270 strcpy(dcd->previous, dcd->directory);
2271 strcpy(dcd->directory, (CHAR *) mp2);
2272 DosEnterCritSec();
2273 dcd->stopflag++;
2274 DosExitCritSec();
2275 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2276 strcpy(dcd->directory, dcd->previous);
2277 DosEnterCritSec();
2278 dcd->stopflag--;
2279 DosExitCritSec();
2280 }
2281 else if (*dcd->directory) {
2282 if (hwndMain)
2283 WinSendMsg(hwndMain,
2284 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2285 else
2286 add_udir(FALSE, dcd->directory);
2287 }
2288 }
2289 break;
[2]2290
[551]2291 case IDM_PARENT:
2292 {
2293 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
[2]2294
[551]2295 strcpy(tempname1, dcd->directory);
2296 if (tempname1[strlen(tempname1) - 1] != '\\')
2297 strcat(tempname1, "\\");
2298 strcat(tempname1, "..");
2299 DosError(FERR_DISABLEHARDERR);
2300 if (!DosQueryPathInfo(tempname1,
2301 FIL_QUERYFULLNAME,
2302 tempname2, sizeof(tempname2))) {
2303 if (stricmp(dcd->directory, tempname2)) {
2304 strcpy(dcd->previous, dcd->directory);
2305 strcpy(dcd->directory, tempname2);
2306 DosEnterCritSec();
2307 dcd->stopflag++;
2308 DosExitCritSec();
2309 if (!PostMsg(dcd->hwndObject,
2310 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2311 strcpy(dcd->directory, dcd->previous);
2312 DosEnterCritSec();
2313 dcd->stopflag--;
2314 DosExitCritSec();
2315 }
2316 else if (*dcd->directory) {
2317 if (hwndMain)
2318 WinSendMsg(hwndMain,
2319 UM_SETUSERLISTNAME,
2320 MPFROMP(dcd->directory), MPVOID);
2321 else
2322 add_udir(FALSE, dcd->directory);
2323 }
2324 }
2325 }
2326 }
2327 break;
[2]2328
[551]2329 case IDM_PREVIOUS:
2330 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
[2]2331
[551]2332 CHAR tempname[CCHMAXPATH];
[2]2333
[551]2334 if (IsValidDir(dcd->previous)) {
2335 strcpy(tempname, dcd->directory);
2336 strcpy(dcd->directory, dcd->previous);
2337 strcpy(dcd->previous, tempname);
2338 DosEnterCritSec();
2339 dcd->stopflag++;
2340 DosExitCritSec();
2341 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2342 strcpy(dcd->directory, dcd->previous);
2343 DosEnterCritSec();
2344 dcd->stopflag--;
2345 DosExitCritSec();
2346 }
2347 else if (*dcd->directory) {
2348 if (hwndMain)
2349 WinSendMsg(hwndMain,
2350 UM_SETUSERLISTNAME,
2351 MPFROMP(dcd->directory), MPVOID);
2352 else
2353 add_udir(FALSE, dcd->directory);
2354 }
2355 }
2356 else
2357 *dcd->previous = 0;
2358 }
2359 break;
[2]2360
[551]2361 case IDM_WALKDIR:
2362 {
2363 CHAR newdir[CCHMAXPATH];
[2]2364
[551]2365 strcpy(newdir, dcd->directory);
2366 if (!WinDlgBox(HWND_DESKTOP,
2367 dcd->hwndParent,
2368 WalkAllDlgProc,
2369 FM3ModHandle,
2370 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2371 break;
2372 if (stricmp(newdir, dcd->directory)) {
2373 strcpy(dcd->previous, dcd->directory);
2374 strcpy(dcd->directory, newdir);
2375 DosEnterCritSec();
2376 dcd->stopflag++;
2377 DosExitCritSec();
2378 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2379 strcpy(dcd->directory, dcd->previous);
2380 DosEnterCritSec();
2381 dcd->stopflag--;
2382 DosExitCritSec();
2383 }
2384 else if (*dcd->directory) {
2385 if (hwndMain)
2386 WinSendMsg(hwndMain,
2387 UM_SETUSERLISTNAME,
2388 MPFROMP(dcd->directory), MPVOID);
2389 else
2390 add_udir(FALSE, dcd->directory);
2391 }
2392 }
2393 }
2394 break;
[2]2395
[551]2396 case IDM_OPENICONME:
2397 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2398 break;
2399 case IDM_OPENDETAILSME:
2400 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2401 break;
2402 case IDM_OPENTREEME:
2403 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2404 break;
2405 case IDM_OPENSETTINGSME:
2406 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2407 break;
[2]2408
[551]2409 case IDM_DOITYOURSELF:
2410 case IDM_UPDATE:
2411 case IDM_OPENWINDOW:
2412 case IDM_OPENSETTINGS:
2413 case IDM_OPENDEFAULT:
2414 case IDM_OPENICON:
2415 case IDM_OPENDETAILS:
2416 case IDM_OPENTREE:
2417 case IDM_OBJECT:
2418 case IDM_SHADOW:
2419 case IDM_SHADOW2:
2420 case IDM_DELETE:
2421 case IDM_PERMDELETE:
2422 case IDM_PRINT:
2423 case IDM_ATTRS:
2424 case IDM_INFO:
2425 case IDM_COPY:
2426 case IDM_MOVE:
2427 case IDM_WPSMOVE:
2428 case IDM_WPSCOPY:
2429 case IDM_WILDCOPY:
2430 case IDM_WILDMOVE:
2431 case IDM_RENAME:
2432 case IDM_COMPARE:
2433 case IDM_EAS:
2434 case IDM_SUBJECT:
2435 case IDM_VIEW:
2436 case IDM_VIEWTEXT:
2437 case IDM_VIEWBINARY:
2438 case IDM_VIEWARCHIVE:
2439 case IDM_EDIT:
2440 case IDM_EDITTEXT:
2441 case IDM_EDITBINARY:
2442 case IDM_SAVETOCLIP:
2443 case IDM_APPENDTOCLIP:
2444 case IDM_ARCHIVE:
2445 case IDM_ARCHIVEM:
2446 case IDM_EXTRACT:
2447 case IDM_MCIPLAY:
2448 case IDM_COLLECTFROMFILE:
2449 case IDM_UUDECODE:
2450 case IDM_MERGE:
2451 {
2452 LISTINFO *li;
2453 ULONG action = UM_ACTION;
[2]2454
[551]2455 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2456 if (li) {
2457 li->type = SHORT1FROMMP(mp1);
2458 li->hwnd = hwnd;
2459 li->list = BuildList(hwnd);
2460 switch (SHORT1FROMMP(mp1)) {
2461 case IDM_WILDMOVE:
2462 case IDM_WILDCOPY:
2463 case IDM_MOVE:
2464 case IDM_COPY:
2465 case IDM_WPSMOVE:
2466 case IDM_WPSCOPY:
2467 break;
2468 default:
2469 strcpy(li->targetpath, dcd->directory);
2470 break;
2471 }
2472 if (li->list) {
2473 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2474 if (!Collector) {
[2]2475
[551]2476 HWND hwndC;
2477 SWP swp;
[2]2478
[551]2479 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2480 !fAutoTile &&
2481 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2482 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2483 hwndC = StartCollector((fExternalCollector ||
2484 strcmp(realappname, FM3Str)) ?
2485 HWND_DESKTOP : dcd->hwndParent, 4);
2486 if (hwndC) {
2487 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2488 !fAutoTile && (!fExternalCollector &&
2489 !strcmp(realappname, FM3Str)))
2490 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2491 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2492 SWP_SHOW | SWP_ZORDER);
2493 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2494 fAutoTile && !strcmp(realappname, FM3Str))
2495 TileChildren(dcd->hwndParent, TRUE);
2496 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2497 SWP_ACTIVATE);
[771]2498 DosSleep(100); //05 Aug 07 GKY 250
[551]2499 }
2500 }
2501 else
2502 StartCollector(dcd->hwndParent, 4);
2503 }
2504 switch (SHORT1FROMMP(mp1)) {
2505 case IDM_APPENDTOCLIP:
2506 case IDM_SAVETOCLIP:
2507 case IDM_ARCHIVE:
2508 case IDM_ARCHIVEM:
2509 case IDM_DELETE:
2510 case IDM_PERMDELETE:
2511 case IDM_ATTRS:
2512 case IDM_PRINT:
2513 case IDM_SHADOW:
2514 case IDM_SHADOW2:
2515 case IDM_OBJECT:
2516 case IDM_VIEW:
2517 case IDM_VIEWTEXT:
2518 case IDM_VIEWBINARY:
2519 case IDM_EDIT:
2520 case IDM_EDITTEXT:
2521 case IDM_EDITBINARY:
2522 case IDM_MCIPLAY:
2523 case IDM_UPDATE:
2524 case IDM_DOITYOURSELF:
2525 case IDM_INFO:
2526 case IDM_EAS:
2527 action = UM_MASSACTION;
2528 break;
2529 }
2530 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2531 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2532 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2533 *li->targetpath = 0;
2534 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2535 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2536 FreeListInfo(li);
2537 }
2538 else if (fUnHilite)
[672]2539 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2540 }
2541 else
2542 free(li);
2543 }
2544 }
2545 break;
[2]2546
[551]2547 case IDM_DRIVESMENU:
2548 if (!hwndMain)
2549 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2550 break;
[2]2551
[551]2552 default:
2553 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2554 return 0;
2555 else {
2556 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2557 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[2]2558
[551]2559 register INT x;
[2]2560
[551]2561 if (!cmdloaded)
2562 load_commands();
2563 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2564 if (x >= 0) {
2565 x++;
2566 RunCommand(hwnd, x);
2567 if (fUnHilite)
[672]2568 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2569 }
2570 }
2571 }
2572 break;
[2]2573 }
[551]2574 }
2575 return 0;
[2]2576
[551]2577 case UM_FIXCNRMLE:
2578 case UM_FIXEDITNAME:
2579 return CommonCnrProc(hwnd, msg, mp1, mp2);
[2]2580
[551]2581 case UM_FILESMENU:
2582 {
2583 PCNRITEM pci;
2584 HWND menuHwnd = (HWND) 0;
[2]2585
[551]2586 pci = (PCNRITEM) CurrentRecord(hwnd);
2587 if (pci && (INT) pci != -1) {
2588 if (pci->attrFile & FILE_DIRECTORY) {
[875]2589 menuHwnd = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
[930]2590// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
[551]2591 }
2592 else
[875]2593 menuHwnd = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
[2]2594 }
[551]2595 return MRFROMLONG(menuHwnd);
2596 }
[2]2597
[551]2598 case WM_CONTROL:
2599 DosError(FERR_DISABLEHARDERR);
2600 if (dcd) {
2601 switch (SHORT2FROMMP(mp1)) {
2602 case CN_COLLAPSETREE:
2603 case CN_EXPANDTREE:
2604 {
2605 PCNRITEM pci = (PCNRITEM) mp2;
[2]2606
[551]2607 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
[730]2608 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
[551]2609 struct
[275]2610 {
[551]2611 ULONG serial;
2612 CHAR volumelength;
2613 CHAR volumelabel[CCHMAXPATH];
2614 }
2615 volser;
2616 APIRET rc;
[2]2617
[551]2618 memset(&volser, 0, sizeof(volser));
2619 DosError(FERR_DISABLEHARDERR);
[907]2620 // fixme?
[730]2621 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
[551]2622 FSIL_VOLSER, &volser, sizeof(volser));
2623 if (rc) {
2624 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[552]2625 GetPString(IDS_CANTFINDDIRTEXT),
[730]2626 pci->pszFileName);
[552]2627 DosBeep(250,100);
[730]2628 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
[551]2629 UnFlesh(hwnd, pci);
2630 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2631 }
2632 else {
2633 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2634 !volser.serial ||
[907]2635 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2636 volser.serial)
2637 UnFlesh(hwnd, pci);
2638 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2639 (!volser.serial ||
[730]2640 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2641 volser.serial)) {
2642 if (Flesh(hwnd, pci) &&
2643 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2644 !dcd->suspendview && fTopDir)
2645 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2646 }
[730]2647 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
[551]2648 }
2649 }
2650 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2651 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2652 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2653 }
2654 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2655 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2656 }
2657 }
2658 break;
[2]2659
2660/*
[618]2661 case CN_PICKUP:
2662 return PickUp(hwnd,dcd->hwndObject,mp2);
[2]2663*/
2664
[551]2665 case CN_CONTEXTMENU:
2666 {
2667 PCNRITEM pci = (PCNRITEM) mp2;
[2]2668
[551]2669 if (pci) {
2670 WinSendMsg(hwnd,
2671 CM_SETRECORDEMPHASIS,
2672 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
[907]2673 MarkAll(hwnd, FALSE, FALSE, TRUE);
2674 if (pci->attrFile & FILE_DIRECTORY)
[875]2675 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &DirMenu, DIR_POPUP);
[551]2676 else
[875]2677 dcd->hwndLastMenu = CheckMenu(hwndMainMenu, &FileMenu, FILE_POPUP);
[551]2678 }
2679 else {
[877]2680 dcd->hwndLastMenu = CheckMenu(hwnd, &DirCnrMenu, DIRCNR_POPUP);
[551]2681 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2682 WinSendMsg(hwnd,
2683 CM_SETRECORDEMPHASIS,
2684 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2685 dcd->cnremphasized = TRUE;
2686 }
2687 }
2688 if (dcd->hwndLastMenu) {
2689 if (dcd->hwndLastMenu == DirCnrMenu) {
2690 if (dcd->flWindowAttr & CV_MINI)
2691 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2692 }
2693 if (dcd->hwndLastMenu == DirMenu)
2694 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2695 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2696 if (dcd->cnremphasized) {
2697 WinSendMsg(hwnd,
2698 CM_SETRECORDEMPHASIS,
2699 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2700 dcd->cnremphasized = TRUE;
2701 }
2702 MarkAll(hwnd, TRUE, FALSE, TRUE);
2703 }
2704 }
2705 }
2706 break;
[2]2707
[551]2708 case CN_DROPHELP:
2709 if (mp2) {
[2]2710
[551]2711 PDRAGINFO pDInfo;
2712 PCNRITEM pci;
2713 ULONG numitems;
2714 USHORT usOperation;
[2]2715
[551]2716 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2717 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2718 if (!DrgAccessDraginfo(pDInfo)) {
2719 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2720 GetPString(IDS_DROPERRORTEXT));
2721 }
[618]2722 else {
2723 numitems = DrgQueryDragitemCount(pDInfo);
2724 usOperation = pDInfo->usOperation;
2725 FreeDragInfoData(hwnd, pDInfo);
2726 saymsg(MB_ENTER | MB_ICONASTERISK,
2727 hwnd,
2728 GetPString(IDS_DROPHELPHDRTEXT),
2729 GetPString(IDS_DROPHELPTEXT),
2730 numitems,
2731 &"s"[numitems == 1L],
2732 pci ? NullStr : GetPString(IDS_NOTEXT),
2733 pci ? NullStr : " ",
[730]2734 pci ? pci->pszFileName : NullStr,
[618]2735 pci ? " " : NullStr,
2736 GetPString((usOperation == DO_COPY) ?
2737 IDS_COPYTEXT :
2738 (usOperation == DO_LINK) ?
2739 IDS_LINKTEXT : IDS_MOVETEXT));
2740 }
[551]2741 }
2742 return 0;
[2]2743
[551]2744 case CN_DRAGLEAVE:
2745 return 0;
[2]2746
[551]2747 case CN_DRAGAFTER:
2748 case CN_DRAGOVER:
2749 if (mp2) {
[2]2750
[618]2751 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2752 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
[551]2753 PCNRITEM pci;
2754 USHORT uso;
[2]2755
[551]2756 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2757 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[907]2758 if (!DrgAccessDraginfo(pDInfo)) {
2759 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2760 "DrgAccessDraginfo");
[618]2761 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
[907]2762 }
2763 if (*dcd->directory &&
[687]2764 (driveflags[toupper(*dcd->directory) - 'A'] &
2765 DRIVE_NOTWRITEABLE)) {
[551]2766 DrgFreeDraginfo(pDInfo);
2767 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
[618]2768 DO_LINK); /* (compare) only */
[551]2769 }
2770 if (pci) {
2771 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2772 DrgFreeDraginfo(pDInfo);
2773 return (MRFROM2SHORT(DOR_NODROP, 0));
2774 }
2775 uso = pDInfo->usOperation;
2776 if (uso == DO_DEFAULT)
[618]2777 uso = fCopyDefault ? DO_COPY : DO_MOVE;
[551]2778 if (!(pci->attrFile & FILE_DIRECTORY)) {
2779 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2780 DrgFreeDraginfo(pDInfo);
2781 return MRFROM2SHORT(DOR_NODROP, 0);
2782 }
2783 if (uso != DO_LINK &&
[730]2784 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2785 DRIVE_NOTWRITEABLE)) {
[2]2786
[551]2787 ARC_TYPE *info = NULL;
[2]2788
[551]2789 if (!fQuickArcFind &&
[730]2790 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2791 DRIVE_SLOW))
[730]2792 info = find_type(pci->pszFileName, NULL);
[551]2793 else
[730]2794 info = quick_find_type(pci->pszFileName, NULL);
[551]2795 if (!info || ((uso == DO_MOVE && !info->move) ||
2796 (uso == DO_COPY && !info->create))) {
2797 DrgFreeDraginfo(pDInfo);
2798 return MRFROM2SHORT(DOR_NODROP, 0);
2799 }
2800 }
2801 }
2802 }
[275]2803
[551]2804 /* Access DRAGITEM index to DRAGITEM
2805 * Check valid rendering mechanisms and data
2806 */
2807 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2808 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2809 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2810 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2811 DrgFreeDraginfo(pDInfo);
2812 if (driveflags[toupper(*dcd->directory) - 'A'] &
2813 DRIVE_NOTWRITEABLE)
2814 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2815 if (toupper(*dcd->directory) < 'C')
2816 return MRFROM2SHORT(DOR_DROP, DO_COPY);
[618]2817 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
[551]2818 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2819 }
[618]2820 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[551]2821 }
[618]2822 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
[2]2823
[551]2824 case CN_INITDRAG:
2825 {
2826 BOOL wasemphasized = FALSE;
2827 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2828 PCNRITEM pci;
[2]2829
[551]2830 if (pcd) {
2831 pci = (PCNRITEM) pcd->pRecord;
2832 if (pci) {
2833 if ((INT) pci == -1)
2834 pci = NULL;
2835 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2836 wasemphasized = TRUE;
2837 }
2838 else if (!*dcd->directory) {
2839 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2840 break;
2841 }
2842 else if (IsRoot(dcd->directory)) {
[618]2843 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2844 GetPString(IDS_CANTDRAGROOTDIR));
[551]2845 break;
2846 }
2847 if (hwndStatus2) {
2848 if (pci)
2849 WinSetWindowText(hwndStatus2,
2850 GetPString(IDS_DRAGFILEOBJTEXT));
2851 else
2852 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2853 }
2854 if (DoFileDrag(hwnd,
2855 dcd->hwndObject,
2856 mp2,
2857 NULL,
[618]2858 pci ? NULL : dcd->directory,
2859 pci ? TRUE : FALSE)) {
[672]2860 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2861 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[618]2862 }
[551]2863 }
2864 if (hwndStatus2) {
2865 WinSetFocus(HWND_DESKTOP, hwnd);
2866 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2867 }
2868 }
2869 }
2870 return 0;
[2]2871
[551]2872 case CN_DROP:
2873 if (mp2) {
[2]2874
[551]2875 LISTINFO *li;
2876 ULONG action = UM_ACTION;
[2]2877
[907]2878 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
2879 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2880 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
[551]2881 if (li) {
2882 if (li->list && li->list[0] && IsRoot(li->list[0]))
2883 li->type = DO_LINK;
2884 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
[2]2885
[551]2886 CHECKLIST cl;
[2]2887
[551]2888 memset(&cl, 0, sizeof(cl));
2889 cl.size = sizeof(cl);
2890 cl.flags = li->type;
2891 cl.list = li->list;
2892 cl.cmd = li->type;
2893 cl.prompt = li->targetpath;
2894 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2895 DropListProc, FM3ModHandle,
[618]2896 DND_FRAME, MPFROMP(&cl));
2897 if (li->type == DID_ERROR)
2898 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2899 "Drag & Drop Dialog");
2900 if (!li->type) {
[551]2901 FreeListInfo(li);
2902 return 0;
2903 }
2904 li->list = cl.list;
[618]2905 if (!li->list || !li->list[0]) {
[551]2906 FreeListInfo(li);
2907 return 0;
2908 }
2909 }
2910 switch (li->type) {
2911 case DND_LAUNCH:
2912 strcat(li->targetpath, " %a");
2913 ExecOnList(dcd->hwndParent, li->targetpath,
[907]2914 PROMPT | WINDOWED, NULL, li->list, NULL,
2915 pszSrcFile, __LINE__);
[551]2916 FreeList(li->list);
2917 li->list = NULL;
2918 break;
2919 case DO_LINK:
2920 if (fLinkSetsIcon) {
2921 li->type = IDM_SETICON;
2922 action = UM_MASSACTION;
2923 }
2924 else
2925 li->type = IDM_COMPARE;
2926 break;
2927 case DND_EXTRACT:
2928 if (*li->targetpath && !IsFile(li->targetpath))
2929 li->type = IDM_EXTRACT;
2930 break;
2931 case DND_MOVE:
2932 li->type = IDM_MOVE;
2933 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2934 action = UM_MASSACTION;
2935 li->type = IDM_ARCHIVEM;
2936 }
2937 break;
2938 case DND_WILDMOVE:
2939 li->type = IDM_WILDMOVE;
2940 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2941 action = UM_MASSACTION;
2942 li->type = IDM_ARCHIVEM;
2943 }
2944 break;
2945 case DND_OBJECT:
2946 li->type = IDM_OBJECT;
2947 action = UM_MASSACTION;
2948 break;
2949 case DND_SHADOW:
2950 li->type = IDM_SHADOW;
2951 action = UM_MASSACTION;
2952 break;
2953 case DND_COMPARE:
2954 li->type = IDM_COMPARE;
2955 break;
2956 case DND_SETICON:
2957 action = UM_MASSACTION;
2958 li->type = IDM_SETICON;
2959 break;
2960 case DND_COPY:
2961 li->type = IDM_COPY;
2962 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2963 action = UM_MASSACTION;
2964 li->type = IDM_ARCHIVE;
2965 }
2966 break;
2967 case DND_WILDCOPY:
2968 li->type = IDM_WILDCOPY;
2969 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2970 action = UM_MASSACTION;
2971 li->type = IDM_ARCHIVE;
2972 }
2973 break;
2974 default:
2975 if (*li->arcname && li->info) {
2976 action = UM_MASSACTION;
2977 li->type =
2978 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2979 }
2980 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2981 action = UM_MASSACTION;
2982 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2983 }
2984 else
2985 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2986 break;
2987 }
2988 if (!li->list || !li->list[0])
2989 FreeListInfo(li);
2990 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2991 FreeListInfo(li);
2992 else {
[2]2993
[551]2994 USHORT usop = 0;
[2]2995
[551]2996 switch (li->type) {
2997 case IDM_COPY:
2998 case IDM_WILDCOPY:
2999 usop = DO_COPY;
3000 break;
3001 case IDM_MOVE:
3002 case IDM_WILDMOVE:
3003 case IDM_ARCHIVEM:
3004 usop = DO_MOVE;
3005 break;
3006 }
3007 if (usop)
3008 return MRFROM2SHORT(DOR_DROP, usop);
3009 }
3010 }
3011 }
3012 return 0;
[2]3013
[551]3014 case CN_ENDEDIT:
3015 case CN_BEGINEDIT:
3016 {
3017 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3018 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]3019
[551]3020 if (pfi || pci) {
[2]3021
[551]3022 MRESULT mre;
[2]3023
[551]3024 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3025 if (mre != (MRESULT) - 1)
3026 return mre;
3027 }
3028 else if (!pfi && !pci)
3029 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3030 }
3031 return 0;
[2]3032
[551]3033 case CN_REALLOCPSZ:
3034 {
3035 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3036 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3037 HWND hwndMLE;
3038 static CHAR szData[CCHMAXPATH];
[689]3039 CHAR testname[CCHMAXPATH];
[2]3040
[551]3041 if (!pci && !pfi) {
3042 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3043 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3044 chop_at_crnl(szData);
3045 bstrip(szData);
3046 if (*szData) {
3047 if (!DosQueryPathInfo(szData,
3048 FIL_QUERYFULLNAME,
3049 testname, sizeof(testname))) {
3050 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3051 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3052 }
3053 }
3054 }
3055 }
3056 else {
[2]3057
[551]3058 MRESULT mre;
[2]3059
[551]3060 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3061 if (mre != (MRESULT) - 1)
3062 return mre;
3063 }
3064 }
3065 return 0;
[2]3066
[551]3067 case CN_EMPHASIS:
3068 if (!mp2)
3069 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3070 else {
3071 PNOTIFYRECORDEMPHASIS pre = mp2;
3072 PCNRITEM pci;
3073 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
[2]3074
[762]3075 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
[551]3076 if (!pci) {
3077 if (hwndStatus2)
3078 WinSetWindowText(hwndStatus2, NullStr);
3079 if (fMoreButtons) {
3080 WinSetWindowText(hwndName, NullStr);
3081 WinSetWindowText(hwndDate, NullStr);
3082 WinSetWindowText(hwndAttr, NullStr);
3083 }
3084 if (hwndMain)
3085 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3086 break;
3087 }
3088 if (pre->fEmphasisMask & CRA_SELECTED) {
3089 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3090 dcd->selectedbytes += (pci->cbFile + pci->easize);
3091 dcd->selectedfiles++;
3092 }
3093 else if (dcd->selectedfiles) {
3094 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3095 dcd->selectedfiles--;
3096 }
3097 if (!dcd->suspendview) {
3098 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3099 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3100 sprintf(s, "%s / %s", tf, tb);
3101 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3102 }
3103 }
3104 if (!dcd->suspendview && hwndMain &&
3105 (pre->fEmphasisMask & CRA_CURSORED) &&
3106 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3107 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
[730]3108 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
[551]3109 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3110 else
3111 WinSendMsg(hwndMain,
[730]3112 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]3113 }
3114 if (!dcd->suspendview &&
3115 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3116 if (pre->fEmphasisMask & CRA_CURSORED) {
3117 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3118 if (fSplitStatus && hwndStatus2) {
3119 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3120 if (!fMoreButtons) {
3121 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3122 tb, pci->date.year,
3123 pci->date.month, pci->date.day, pci->time.hours,
3124 pci->time.minutes, pci->time.seconds,
3125 pci->pszDispAttr, pci->pszFileName);
3126 }
3127 else {
3128 *tf = 0;
3129 if (pci->cbFile + pci->easize > 1024) {
3130 CommaFmtULL(tf, sizeof(tf),
3131 pci->cbFile + pci->easize, 'K');
3132 }
3133 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3134 tb,
3135 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3136 }
3137 WinSetWindowText(hwndStatus2, s);
3138 }
3139 if (fMoreButtons) {
3140 WinSetWindowText(hwndName, pci->pszFileName);
3141 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3142 pci->date.year, pci->date.month,
3143 pci->date.day, pci->time.hours, pci->time.minutes,
3144 pci->time.seconds);
3145 WinSetWindowText(hwndDate, s);
3146 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3147 }
3148 }
3149 }
3150 }
3151 }
3152 break;
[2]3153
[551]3154 case CN_ENTER:
3155 if (mp2) {
[2]3156
[551]3157 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
[847]3158 FILEFINDBUF3 ffb;
[551]3159 HDIR hDir = HDIR_CREATE;
[761]3160 ULONG nm = 1;
[551]3161 APIRET status = 0;
[2]3162
[551]3163 SetShiftState();
3164 if (pci) {
3165 if (pci->rc.flRecordAttr & CRA_INUSE)
3166 break;
3167 DosError(FERR_DISABLEHARDERR);
[847]3168 status = DosFindFirst(pci->pszFileName,
[838]3169 &hDir,
3170 FILE_NORMAL | FILE_DIRECTORY |
3171 FILE_ARCHIVED | FILE_READONLY |
3172 FILE_HIDDEN | FILE_SYSTEM,
[847]3173 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
[551]3174 priority_bumped();
3175 if (!status) {
3176 DosFindClose(hDir);
3177 if (ffb.attrFile & FILE_DIRECTORY) {
3178 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3179 PostMsg(hwnd,
3180 WM_COMMAND,
3181 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3182 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3183 (KC_CTRL | KC_SHIFT))
[730]3184 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
[551]3185 else if (shiftstate & KC_CTRL)
[730]3186 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
[551]3187 else if (shiftstate & KC_SHIFT) {
[2]3188
[551]3189 HWND hwndDir;
[2]3190
[551]3191 hwndDir = OpenDirCnr((HWND) 0,
3192 dcd->hwndParent,
3193 dcd->hwndFrame,
[730]3194 FALSE, pci->pszFileName);
[551]3195 if (hwndDir) {
3196 if (fMinOnOpen)
3197 WinSetWindowPos(dcd->hwndFrame,
3198 HWND_BOTTOM,
3199 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3200 if (fAutoTile)
3201 TileChildren(dcd->hwndParent, TRUE);
3202 WinSetWindowPos(hwndDir,
3203 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3204 }
3205 }
3206 else {
3207 strcpy(dcd->previous, dcd->directory);
[730]3208 strcpy(dcd->directory, pci->pszFileName);
[551]3209 DosEnterCritSec();
3210 dcd->stopflag++;
3211 DosExitCritSec();
3212 if (!PostMsg(dcd->hwndObject,
[841]3213 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
[551]3214 DosEnterCritSec();
3215 dcd->stopflag--;
3216 DosExitCritSec();
3217 }
3218 else if (*dcd->directory) {
3219 if (hwndMain)
3220 WinSendMsg(hwndMain,
3221 UM_SETUSERLISTNAME,
3222 MPFROMP(dcd->directory), MPVOID);
3223 else
3224 add_udir(FALSE, dcd->directory);
3225 }
3226 }
3227 }
3228 else {
[2]3229
[551]3230 SWP swp;
[2]3231
[551]3232 WinQueryWindowPos(dcd->hwndFrame, &swp);
3233 WinSendMsg(hwnd,
3234 CM_SETRECORDEMPHASIS,
3235 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3236 DefaultViewKeys(hwnd,
3237 dcd->hwndFrame,
[730]3238 dcd->hwndParent, &swp, pci->pszFileName);
[551]3239 WinSendMsg(hwnd,
3240 CM_SETRECORDEMPHASIS,
3241 MPFROMP(pci),
3242 MPFROM2SHORT(FALSE,
3243 CRA_INUSE |
3244 ((fUnHilite) ? CRA_SELECTED : 0)));
3245 }
3246 }
3247 else {
3248 if (!*dcd->directory || IsValidDir(dcd->directory)) {
[730]3249 NotifyError(pci->pszFileName, status);
[751]3250 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[551]3251 if (hwndStatus)
3252 WinSetWindowText(hwndStatus,
3253 GetPString(IDS_RESCANSUGGESTEDTEXT));
3254 }
3255 else {
3256 DosEnterCritSec();
3257 dcd->stopflag++;
3258 DosExitCritSec();
3259 if (!PostMsg(dcd->hwndObject,
3260 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3261 DosEnterCritSec();
3262 dcd->stopflag--;
3263 DosExitCritSec();
3264 }
3265 else if (*dcd->directory) {
3266 if (hwndMain)
3267 WinSendMsg(hwndMain,
3268 UM_SETUSERLISTNAME,
3269 MPFROMP(dcd->directory), MPVOID);
3270 else
3271 add_udir(FALSE, dcd->directory);
3272 }
3273 }
3274 }
3275 }
3276 else if (*dcd->directory)
3277 OpenObject(dcd->directory, Default, hwnd);
[787]3278 } // CN_ENTER
[551]3279 break;
[787]3280 } // switch mp1
[551]3281 break;
[787]3282 } // if dcd
[551]3283 return 0;
[2]3284
[551]3285 case UM_LOADFILE:
3286 if (dcd && mp2) {
[2]3287
[787]3288 HWND ret = StartMLEEditor(dcd->hwndParent,
[907]3289 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
[551]3290 if (mp2)
[787]3291 free((CHAR *)mp2);
[551]3292 return MRFROMLONG(ret);
3293 }
3294 return 0;
[2]3295
[551]3296 case WM_SAVEAPPLICATION:
3297 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
[2]3298
[551]3299 SWP swp;
[2]3300
[551]3301 WinQueryWindowPos(dcd->hwndFrame, &swp);
3302 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3303 PrfWriteProfileData(fmprof,
3304 appname, "VDirSizePos", &swp, sizeof(swp));
3305 }
3306 break;
[2]3307
[551]3308 case WM_CLOSE:
3309 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3310 if (LastDir == hwnd)
3311 LastDir = (HWND) 0;
3312 if (dcd) {
3313 dcd->stopflag++;
3314 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3315 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3316 if (!dcd->hwndObject ||
3317 !PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID)) {
3318 if (dcd->hwndObject)
3319 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3320 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3321 if (dcd->hwndRestore)
3322 WinSetWindowPos(dcd->hwndRestore,
3323 HWND_TOP,
3324 0,
3325 0,
3326 0,
3327 0,
3328 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3329 FreeList(dcd->lastselection);
3330 free(dcd);
3331 DosPostEventSem(CompactSem);
[2]3332 }
[551]3333 }
3334 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3335 QW_PARENT));
3336 return 0;
[2]3337
[551]3338 case WM_DESTROY:
3339 if (DirMenu)
3340 WinDestroyWindow(DirMenu);
3341 if (DirCnrMenu)
3342 WinDestroyWindow(DirCnrMenu);
3343 if (FileMenu)
3344 WinDestroyWindow(FileMenu);
3345 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3346 EmptyCnr(hwnd);
3347 break;
[2]3348 }
[705]3349 if (dcd && dcd->oldproc){
3350 return dcd->oldproc(hwnd, msg, mp1, mp2);
3351 }
3352 else
3353 return PFNWPCnr(hwnd, msg, mp1, mp2);
[2]3354}
3355
[551]3356HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3357 ULONG flags)
[275]3358{
[2]3359 /* bitmapped flags:
3360 * 0x00000001 = don't close app when window closes
3361 * 0x00000002 = no frame controls
3362 */
3363
[551]3364 HWND hwndFrame = (HWND) 0, hwndClient;
3365 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3366 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3367 USHORT id;
[2]3368 static USHORT idinc = 0;
[551]3369 DIRCNRDATA *dcd;
3370 static BOOL first = FALSE;
[2]3371
[551]3372 if (flags & 2)
[2]3373 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
[551]3374 FCF_MINMAX | FCF_ICON));
3375 if (!idinc)
[2]3376 idinc = (rand() % 100);
[551]3377 if (!hwndParent)
[2]3378 hwndParent = HWND_DESKTOP;
[551]3379 if (ParentIsDesktop(hwndParent, hwndParent))
[2]3380 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
[551]3381 if (!hwndMain && !first) {
3382 if (DirCnrMenu) {
[2]3383
3384 MENUITEM mi;
3385
[551]3386 memset(&mi, 0, sizeof(mi));
[2]3387 WinSendMsg(DirCnrMenu,
[551]3388 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
[2]3389 mi.iPosition = MIT_END;
3390 mi.afStyle = MIS_TEXT;
3391 mi.id = IDM_DRIVESMENU;
3392 WinSendMsg(DirCnrMenu,
[551]3393 MM_INSERTITEM,
3394 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
[2]3395 }
3396 first = TRUE;
3397 }
[551]3398 if (directory) {
[2]3399 hwndFrame = WinCreateStdWindow(hwndParent,
[551]3400 WS_VISIBLE,
3401 &FrameFlags,
[593]3402 WC_DIRCONTAINER,
[551]3403 NULL,
3404 WS_VISIBLE | fwsAnimate,
3405 FM3ModHandle, DIR_FRAME, &hwndClient);
3406 if (hwndFrame && hwndClient) {
[2]3407 id = DIR_FRAME + idinc++;
[551]3408 if (idinc > 99)
3409 idinc = 0;
3410 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3411 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
[358]3412 if (!dcd) {
[551]3413 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3414 hwndFrame = (HWND) 0;
[358]3415 }
3416 else {
[551]3417 dcd->size = sizeof(DIRCNRDATA);
3418 dcd->id = id;
3419 dcd->type = DIR_FRAME;
3420 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3421 dcd->hwndFrame = hwndFrame;
3422 dcd->hwndClient = hwndClient;
3423 dcd->hwndRestore = hwndRestore;
3424 dcd->dontclose = ((flags & 1) != 0);
[930]3425 dcd->detailslongname = detailslongname;
3426 dcd->detailssubject = detailssubject;
3427 dcd->detailsea = detailsea;
3428 dcd->detailssize = detailssize;
3429 dcd->detailsicon = detailsicon;
3430 dcd->detailsattr = detailsattr;
3431 dcd->detailscrdate = detailscrdate;
3432 dcd->detailscrtime = detailscrtime;
3433 dcd->detailslwdate = detailslwdate;
3434 dcd->detailslwtime = detailslwtime;
3435 dcd->detailsladate = detailsladate;
3436 dcd->detailslatime = detailslatime;
[551]3437 strcpy(dcd->directory, directory);
3438 add_udir(FALSE, directory);
3439 {
3440 PFNWP oldproc;
[2]3441
[551]3442 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3443 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
[377]3444 }
[551]3445 dcd->hwndCnr = WinCreateWindow(hwndClient,
3446 WC_CONTAINER,
3447 NULL,
3448 CCS_AUTOPOSITION | CCS_MINIICONS |
3449 CCS_MINIRECORDCORE | ulCnrType |
3450 WS_VISIBLE,
3451 0,
3452 0,
3453 0,
3454 0,
3455 hwndClient,
3456 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3457 if (!dcd->hwndCnr) {
3458 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3459 IDS_WINCREATEWINDOW);
3460 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3461 free(dcd);
3462 hwndFrame = (HWND) 0;
3463 }
[377]3464 else {
[551]3465 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3466 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3467 (PFNWP) DirCnrWndProc);
3468 {
3469 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3470 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3471 };
[2]3472
[551]3473 if (!(flags & 2))
3474 ids[6] = 0;
3475 CommonCreateTextChildren(dcd->hwndClient,
[593]3476 WC_DIRSTATUS, ids);
[551]3477 }
3478 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3479 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3480 if (FrameFlags & FCF_TASKLIST) {
[2]3481
[551]3482 SWP swp, swpD;
3483 ULONG size = sizeof(swp);
3484 LONG cxScreen, cyScreen;
[2]3485
[551]3486 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3487 if (PrfQueryProfileData(fmprof,
3488 appname, "VDirSizePos", &swpD, &size)) {
3489 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3490 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3491 if (swp.x + swpD.cx > cxScreen)
3492 swp.x = cxScreen - swpD.cx;
3493 if (swp.y + swpD.cy > cyScreen)
3494 swp.y = cyScreen - swpD.cy;
3495 swp.cx = swpD.cx;
3496 swp.cy = swpD.cy;
3497 }
3498 WinSetWindowPos(hwndFrame,
3499 HWND_TOP,
3500 swp.x,
3501 swp.y,
3502 swp.cx,
3503 swp.cy,
3504 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3505 SWP_ACTIVATE);
3506 }
3507 }
[2]3508 }
3509 }
3510 }
3511 return hwndFrame;
3512}
[793]3513
3514#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3515#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3516#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.