source: trunk/dll/dircnrs.c@ 796

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

Move #pragma alloc_text to end for OpenWatcom compat

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