source: trunk/dll/dircnrs.c@ 768

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

Turn off debug code

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