source: trunk/dll/dircnrs.c@ 672

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

Use dcd->ulItemsToUnHilite
Sync UnHilite calls with arg mods

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