source: trunk/dll/dircnrs.c@ 827

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

DosSleep(1) in loops changed to (0) to enhance performance

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