source: trunk/dll/dircnrs.c@ 841

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

This implements large file support; The wrappers to allow WARP3 compatibility are not done so this will not run on Warp3or Warp 4 pre fixpack 12(?)

  • 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 841 2007-09-23 16:27:51Z 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 {
[835]2232 // PCNRITEM pci;
[2]2233
[835]2234 // pci = (PCNRITEM) CurrentRecord(hwnd);
[551]2235 PMMkDir(dcd->hwndParent,
[835]2236 (dcd->directory), FALSE);
[551]2237 }
2238 break;
[2]2239
[551]2240 case IDM_SWITCH:
2241 if (mp2) {
2242 strcpy(dcd->previous, dcd->directory);
2243 strcpy(dcd->directory, (CHAR *) mp2);
2244 DosEnterCritSec();
2245 dcd->stopflag++;
2246 DosExitCritSec();
2247 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2248 strcpy(dcd->directory, dcd->previous);
2249 DosEnterCritSec();
2250 dcd->stopflag--;
2251 DosExitCritSec();
2252 }
2253 else if (*dcd->directory) {
2254 if (hwndMain)
2255 WinSendMsg(hwndMain,
2256 UM_SETUSERLISTNAME, MPFROMP(dcd->directory), MPVOID);
2257 else
2258 add_udir(FALSE, dcd->directory);
2259 }
2260 }
2261 break;
[2]2262
[551]2263 case IDM_PARENT:
2264 {
2265 CHAR tempname1[CCHMAXPATH], tempname2[CCHMAXPATH];
[2]2266
[551]2267 strcpy(tempname1, dcd->directory);
2268 if (tempname1[strlen(tempname1) - 1] != '\\')
2269 strcat(tempname1, "\\");
2270 strcat(tempname1, "..");
2271 DosError(FERR_DISABLEHARDERR);
2272 if (!DosQueryPathInfo(tempname1,
2273 FIL_QUERYFULLNAME,
2274 tempname2, sizeof(tempname2))) {
2275 if (stricmp(dcd->directory, tempname2)) {
2276 strcpy(dcd->previous, dcd->directory);
2277 strcpy(dcd->directory, tempname2);
2278 DosEnterCritSec();
2279 dcd->stopflag++;
2280 DosExitCritSec();
2281 if (!PostMsg(dcd->hwndObject,
2282 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2283 strcpy(dcd->directory, dcd->previous);
2284 DosEnterCritSec();
2285 dcd->stopflag--;
2286 DosExitCritSec();
2287 }
2288 else if (*dcd->directory) {
2289 if (hwndMain)
2290 WinSendMsg(hwndMain,
2291 UM_SETUSERLISTNAME,
2292 MPFROMP(dcd->directory), MPVOID);
2293 else
2294 add_udir(FALSE, dcd->directory);
2295 }
2296 }
2297 }
2298 }
2299 break;
[2]2300
[551]2301 case IDM_PREVIOUS:
2302 if (*dcd->previous && stricmp(dcd->directory, dcd->previous)) {
[2]2303
[551]2304 CHAR tempname[CCHMAXPATH];
[2]2305
[551]2306 if (IsValidDir(dcd->previous)) {
2307 strcpy(tempname, dcd->directory);
2308 strcpy(dcd->directory, dcd->previous);
2309 strcpy(dcd->previous, tempname);
2310 DosEnterCritSec();
2311 dcd->stopflag++;
2312 DosExitCritSec();
2313 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2314 strcpy(dcd->directory, dcd->previous);
2315 DosEnterCritSec();
2316 dcd->stopflag--;
2317 DosExitCritSec();
2318 }
2319 else if (*dcd->directory) {
2320 if (hwndMain)
2321 WinSendMsg(hwndMain,
2322 UM_SETUSERLISTNAME,
2323 MPFROMP(dcd->directory), MPVOID);
2324 else
2325 add_udir(FALSE, dcd->directory);
2326 }
2327 }
2328 else
2329 *dcd->previous = 0;
2330 }
2331 break;
[2]2332
[551]2333 case IDM_WALKDIR:
2334 {
2335 CHAR newdir[CCHMAXPATH];
[2]2336
[551]2337 strcpy(newdir, dcd->directory);
2338 if (!WinDlgBox(HWND_DESKTOP,
2339 dcd->hwndParent,
2340 WalkAllDlgProc,
2341 FM3ModHandle,
2342 WALK_FRAME, MPFROMP(newdir)) || !*newdir)
2343 break;
2344 if (stricmp(newdir, dcd->directory)) {
2345 strcpy(dcd->previous, dcd->directory);
2346 strcpy(dcd->directory, newdir);
2347 DosEnterCritSec();
2348 dcd->stopflag++;
2349 DosExitCritSec();
2350 if (!PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
2351 strcpy(dcd->directory, dcd->previous);
2352 DosEnterCritSec();
2353 dcd->stopflag--;
2354 DosExitCritSec();
2355 }
2356 else if (*dcd->directory) {
2357 if (hwndMain)
2358 WinSendMsg(hwndMain,
2359 UM_SETUSERLISTNAME,
2360 MPFROMP(dcd->directory), MPVOID);
2361 else
2362 add_udir(FALSE, dcd->directory);
2363 }
2364 }
2365 }
2366 break;
[2]2367
[551]2368 case IDM_OPENICONME:
2369 OpenObject(dcd->directory, "ICON", dcd->hwndFrame);
2370 break;
2371 case IDM_OPENDETAILSME:
2372 OpenObject(dcd->directory, "DETAILS", dcd->hwndFrame);
2373 break;
2374 case IDM_OPENTREEME:
2375 OpenObject(dcd->directory, "TREE", dcd->hwndFrame);
2376 break;
2377 case IDM_OPENSETTINGSME:
2378 OpenObject(dcd->directory, Settings, dcd->hwndFrame);
2379 break;
[2]2380
[551]2381 case IDM_DOITYOURSELF:
2382 case IDM_UPDATE:
2383 case IDM_OPENWINDOW:
2384 case IDM_OPENSETTINGS:
2385 case IDM_OPENDEFAULT:
2386 case IDM_OPENICON:
2387 case IDM_OPENDETAILS:
2388 case IDM_OPENTREE:
2389 case IDM_OBJECT:
2390 case IDM_SHADOW:
2391 case IDM_SHADOW2:
2392 case IDM_DELETE:
2393 case IDM_PERMDELETE:
2394 case IDM_PRINT:
2395 case IDM_ATTRS:
2396 case IDM_INFO:
2397 case IDM_COPY:
2398 case IDM_MOVE:
2399 case IDM_WPSMOVE:
2400 case IDM_WPSCOPY:
2401 case IDM_WILDCOPY:
2402 case IDM_WILDMOVE:
2403 case IDM_RENAME:
2404 case IDM_COMPARE:
2405 case IDM_EAS:
2406 case IDM_SUBJECT:
2407 case IDM_VIEW:
2408 case IDM_VIEWTEXT:
2409 case IDM_VIEWBINARY:
2410 case IDM_VIEWARCHIVE:
2411 case IDM_EDIT:
2412 case IDM_EDITTEXT:
2413 case IDM_EDITBINARY:
2414 case IDM_SAVETOCLIP:
2415 case IDM_APPENDTOCLIP:
2416 case IDM_ARCHIVE:
2417 case IDM_ARCHIVEM:
2418 case IDM_EXTRACT:
2419 case IDM_MCIPLAY:
2420 case IDM_COLLECTFROMFILE:
2421 case IDM_UUDECODE:
2422 case IDM_MERGE:
2423 {
2424 LISTINFO *li;
2425 ULONG action = UM_ACTION;
[2]2426
[551]2427 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2428 if (li) {
2429 li->type = SHORT1FROMMP(mp1);
2430 li->hwnd = hwnd;
2431 li->list = BuildList(hwnd);
2432 switch (SHORT1FROMMP(mp1)) {
2433 case IDM_WILDMOVE:
2434 case IDM_WILDCOPY:
2435 case IDM_MOVE:
2436 case IDM_COPY:
2437 case IDM_WPSMOVE:
2438 case IDM_WPSCOPY:
2439 break;
2440 default:
2441 strcpy(li->targetpath, dcd->directory);
2442 break;
2443 }
2444 if (li->list) {
2445 if (SHORT1FROMMP(mp1) == IDM_COLLECTFROMFILE) {
2446 if (!Collector) {
[2]2447
[551]2448 HWND hwndC;
2449 SWP swp;
[2]2450
[551]2451 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2452 !fAutoTile &&
2453 (!fExternalCollector && !strcmp(realappname, FM3Str)))
2454 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
2455 hwndC = StartCollector((fExternalCollector ||
2456 strcmp(realappname, FM3Str)) ?
2457 HWND_DESKTOP : dcd->hwndParent, 4);
2458 if (hwndC) {
2459 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2460 !fAutoTile && (!fExternalCollector &&
2461 !strcmp(realappname, FM3Str)))
2462 WinSetWindowPos(hwndC, HWND_TOP, swp.x, swp.y,
2463 swp.cx, swp.cy, SWP_MOVE | SWP_SIZE |
2464 SWP_SHOW | SWP_ZORDER);
2465 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
2466 fAutoTile && !strcmp(realappname, FM3Str))
2467 TileChildren(dcd->hwndParent, TRUE);
2468 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0,
2469 SWP_ACTIVATE);
[771]2470 DosSleep(100); //05 Aug 07 GKY 250
[551]2471 }
2472 }
2473 else
2474 StartCollector(dcd->hwndParent, 4);
2475 }
2476 switch (SHORT1FROMMP(mp1)) {
2477 case IDM_APPENDTOCLIP:
2478 case IDM_SAVETOCLIP:
2479 case IDM_ARCHIVE:
2480 case IDM_ARCHIVEM:
2481 case IDM_DELETE:
2482 case IDM_PERMDELETE:
2483 case IDM_ATTRS:
2484 case IDM_PRINT:
2485 case IDM_SHADOW:
2486 case IDM_SHADOW2:
2487 case IDM_OBJECT:
2488 case IDM_VIEW:
2489 case IDM_VIEWTEXT:
2490 case IDM_VIEWBINARY:
2491 case IDM_EDIT:
2492 case IDM_EDITTEXT:
2493 case IDM_EDITBINARY:
2494 case IDM_MCIPLAY:
2495 case IDM_UPDATE:
2496 case IDM_DOITYOURSELF:
2497 case IDM_INFO:
2498 case IDM_EAS:
2499 action = UM_MASSACTION;
2500 break;
2501 }
2502 if (SHORT1FROMMP(mp1) == IDM_OBJECT ||
2503 SHORT1FROMMP(mp1) == IDM_SHADOW ||
2504 SHORT1FROMMP(mp1) == IDM_SHADOW2)
2505 *li->targetpath = 0;
2506 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2507 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2508 FreeListInfo(li);
2509 }
2510 else if (fUnHilite)
[672]2511 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2512 }
2513 else
2514 free(li);
2515 }
2516 }
2517 break;
[2]2518
[551]2519 case IDM_DRIVESMENU:
2520 if (!hwndMain)
2521 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_WALKDIR, 0), MPVOID);
2522 break;
[2]2523
[551]2524 default:
2525 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2526 return 0;
2527 else {
2528 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2529 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
[2]2530
[551]2531 register INT x;
[2]2532
[551]2533 if (!cmdloaded)
2534 load_commands();
2535 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2536 if (x >= 0) {
2537 x++;
2538 RunCommand(hwnd, x);
2539 if (fUnHilite)
[672]2540 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]2541 }
2542 }
2543 }
2544 break;
[2]2545 }
[551]2546 }
2547 return 0;
[2]2548
[551]2549 case UM_FIXCNRMLE:
2550 case UM_FIXEDITNAME:
2551 return CommonCnrProc(hwnd, msg, mp1, mp2);
[2]2552
[551]2553 case UM_FILESMENU:
2554 {
2555 PCNRITEM pci;
2556 HWND menuHwnd = (HWND) 0;
[2]2557
[551]2558 pci = (PCNRITEM) CurrentRecord(hwnd);
2559 if (pci && (INT) pci != -1) {
2560 if (pci->attrFile & FILE_DIRECTORY) {
2561 menuHwnd = CheckMenu(&DirMenu, DIR_POPUP);
[2]2562// WinEnableMenuItem(DirMenu,IDM_TREE,TRUE);
[551]2563 }
2564 else
2565 menuHwnd = CheckMenu(&FileMenu, FILE_POPUP);
[2]2566 }
[551]2567 return MRFROMLONG(menuHwnd);
2568 }
[2]2569
[551]2570 case WM_CONTROL:
2571 DosError(FERR_DISABLEHARDERR);
2572 if (dcd) {
2573 switch (SHORT2FROMMP(mp1)) {
2574 case CN_COLLAPSETREE:
2575 case CN_EXPANDTREE:
2576 {
2577 PCNRITEM pci = (PCNRITEM) mp2;
[2]2578
[551]2579 if (pci && (INT) pci != -1 && !(pci->flags & RECFLAGS_ENV)) {
[730]2580 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_REMOVABLE) {
[551]2581 struct
[275]2582 {
[551]2583 ULONG serial;
2584 CHAR volumelength;
2585 CHAR volumelabel[CCHMAXPATH];
2586 }
2587 volser;
2588 APIRET rc;
[2]2589
[551]2590 memset(&volser, 0, sizeof(volser));
2591 DosError(FERR_DISABLEHARDERR);
2592 // fixme
[730]2593 rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@',
[551]2594 FSIL_VOLSER, &volser, sizeof(volser));
2595 if (rc) {
2596 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[552]2597 GetPString(IDS_CANTFINDDIRTEXT),
[730]2598 pci->pszFileName);
[552]2599 DosBeep(250,100);
[730]2600 driveserial[toupper(*pci->pszFileName) - 'A'] = -1;
[551]2601 UnFlesh(hwnd, pci);
2602 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2603 }
2604 else {
2605 if (SHORT2FROMMP(mp1) == CN_COLLAPSETREE &&
2606 !volser.serial ||
[730]2607 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2608 volser.serial)
2609 UnFlesh(hwnd, pci);
2610 if (SHORT2FROMMP(mp1) != CN_COLLAPSETREE ||
2611 (!volser.serial ||
[730]2612 driveserial[toupper(*pci->pszFileName) - 'A'] !=
[551]2613 volser.serial)) {
2614 if (Flesh(hwnd, pci) &&
2615 SHORT2FROMMP(mp1) == CN_EXPANDTREE &&
2616 !dcd->suspendview && fTopDir)
2617 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2618 }
[730]2619 driveserial[toupper(*pci->pszFileName) - 'A'] = volser.serial;
[551]2620 }
2621 }
2622 else if (SHORT2FROMMP(mp1) == CN_EXPANDTREE) {
2623 if (Flesh(hwnd, pci) && !dcd->suspendview && fTopDir)
2624 PostMsg(hwnd, UM_TOPDIR, MPFROMP(pci), MPVOID);
2625 }
2626 if (SHORT2FROMMP(mp1) == CN_EXPANDTREE && !dcd->suspendview)
2627 WinSendMsg(hwnd, UM_FILTER, MPVOID, MPVOID);
2628 }
2629 }
2630 break;
[2]2631
2632/*
[618]2633 case CN_PICKUP:
2634 return PickUp(hwnd,dcd->hwndObject,mp2);
[2]2635*/
2636
[551]2637 case CN_CONTEXTMENU:
2638 {
2639 PCNRITEM pci = (PCNRITEM) mp2;
[2]2640
[551]2641 if (pci) {
2642 WinSendMsg(hwnd,
2643 CM_SETRECORDEMPHASIS,
2644 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_CURSORED));
2645 MarkAll(hwnd, FALSE, FALSE, TRUE);
2646 if (pci->attrFile & FILE_DIRECTORY)
2647 dcd->hwndLastMenu = CheckMenu(&DirMenu, DIR_POPUP);
2648 else
2649 dcd->hwndLastMenu = CheckMenu(&FileMenu, FILE_POPUP);
2650 }
2651 else {
2652 dcd->hwndLastMenu = CheckMenu(&DirCnrMenu, DIRCNR_POPUP);
2653 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2654 WinSendMsg(hwnd,
2655 CM_SETRECORDEMPHASIS,
2656 MPVOID, MPFROM2SHORT(TRUE, CRA_SOURCE));
2657 dcd->cnremphasized = TRUE;
2658 }
2659 }
2660 if (dcd->hwndLastMenu) {
2661 if (dcd->hwndLastMenu == DirCnrMenu) {
2662 if (dcd->flWindowAttr & CV_MINI)
2663 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2664 }
2665 if (dcd->hwndLastMenu == DirMenu)
2666 WinEnableMenuItem(DirMenu, IDM_TREE, TRUE);
2667 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2668 if (dcd->cnremphasized) {
2669 WinSendMsg(hwnd,
2670 CM_SETRECORDEMPHASIS,
2671 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2672 dcd->cnremphasized = TRUE;
2673 }
2674 MarkAll(hwnd, TRUE, FALSE, TRUE);
2675 }
2676 }
2677 }
2678 break;
[2]2679
[551]2680 case CN_DROPHELP:
2681 if (mp2) {
[2]2682
[551]2683 PDRAGINFO pDInfo;
2684 PCNRITEM pci;
2685 ULONG numitems;
2686 USHORT usOperation;
[2]2687
[551]2688 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2689 pDInfo = (PDRAGINFO) ((PCNRDRAGINFO) mp2)->pDragInfo;
2690 if (!DrgAccessDraginfo(pDInfo)) {
2691 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2692 GetPString(IDS_DROPERRORTEXT));
2693 }
[618]2694 else {
2695 numitems = DrgQueryDragitemCount(pDInfo);
2696 usOperation = pDInfo->usOperation;
2697 FreeDragInfoData(hwnd, pDInfo);
2698 saymsg(MB_ENTER | MB_ICONASTERISK,
2699 hwnd,
2700 GetPString(IDS_DROPHELPHDRTEXT),
2701 GetPString(IDS_DROPHELPTEXT),
2702 numitems,
2703 &"s"[numitems == 1L],
2704 pci ? NullStr : GetPString(IDS_NOTEXT),
2705 pci ? NullStr : " ",
[730]2706 pci ? pci->pszFileName : NullStr,
[618]2707 pci ? " " : NullStr,
2708 GetPString((usOperation == DO_COPY) ?
2709 IDS_COPYTEXT :
2710 (usOperation == DO_LINK) ?
2711 IDS_LINKTEXT : IDS_MOVETEXT));
2712 }
[551]2713 }
2714 return 0;
[2]2715
[551]2716 case CN_DRAGLEAVE:
2717 return 0;
[2]2718
[551]2719 case CN_DRAGAFTER:
2720 case CN_DRAGOVER:
2721 if (mp2) {
[2]2722
[618]2723 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2724 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
[551]2725 PCNRITEM pci;
2726 USHORT uso;
[2]2727
[551]2728 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2729 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[618]2730 if (!DrgAccessDraginfo(pDInfo)) {
2731 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
2732 "DrgAccessDraginfo");
2733 return (MRFROM2SHORT(DOR_NEVERDROP, 0));
2734 }
[687]2735 if (*dcd->directory &&
2736 (driveflags[toupper(*dcd->directory) - 'A'] &
2737 DRIVE_NOTWRITEABLE)) {
[551]2738 DrgFreeDraginfo(pDInfo);
2739 return MRFROM2SHORT(DOR_DROP, /* Return okay to link */
[618]2740 DO_LINK); /* (compare) only */
[551]2741 }
2742 if (pci) {
2743 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2744 DrgFreeDraginfo(pDInfo);
2745 return (MRFROM2SHORT(DOR_NODROP, 0));
2746 }
2747 uso = pDInfo->usOperation;
2748 if (uso == DO_DEFAULT)
[618]2749 uso = fCopyDefault ? DO_COPY : DO_MOVE;
[551]2750 if (!(pci->attrFile & FILE_DIRECTORY)) {
2751 if (uso != DO_LINK && uso != DO_COPY && uso != DO_MOVE) {
2752 DrgFreeDraginfo(pDInfo);
2753 return MRFROM2SHORT(DOR_NODROP, 0);
2754 }
2755 if (uso != DO_LINK &&
[730]2756 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2757 DRIVE_NOTWRITEABLE)) {
[2]2758
[551]2759 ARC_TYPE *info = NULL;
[2]2760
[551]2761 if (!fQuickArcFind &&
[730]2762 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
[551]2763 DRIVE_SLOW))
[730]2764 info = find_type(pci->pszFileName, NULL);
[551]2765 else
[730]2766 info = quick_find_type(pci->pszFileName, NULL);
[551]2767 if (!info || ((uso == DO_MOVE && !info->move) ||
2768 (uso == DO_COPY && !info->create))) {
2769 DrgFreeDraginfo(pDInfo);
2770 return MRFROM2SHORT(DOR_NODROP, 0);
2771 }
2772 }
2773 }
2774 }
[275]2775
[551]2776 /* Access DRAGITEM index to DRAGITEM
2777 * Check valid rendering mechanisms and data
2778 */
2779 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
2780 if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL) ||
2781 ((!pci || (pci->attrFile & FILE_DIRECTORY)) &&
2782 DrgVerifyRMF(pDItem, DRM_FM2ARCMEMBER, DRF_FM2ARCHIVE))) {
2783 DrgFreeDraginfo(pDInfo);
2784 if (driveflags[toupper(*dcd->directory) - 'A'] &
2785 DRIVE_NOTWRITEABLE)
2786 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2787 if (toupper(*dcd->directory) < 'C')
2788 return MRFROM2SHORT(DOR_DROP, DO_COPY);
[618]2789 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
[551]2790 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2791 }
[618]2792 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[551]2793 }
[618]2794 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
[2]2795
[551]2796 case CN_INITDRAG:
2797 {
2798 BOOL wasemphasized = FALSE;
2799 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2800 PCNRITEM pci;
[2]2801
[551]2802 if (pcd) {
2803 pci = (PCNRITEM) pcd->pRecord;
2804 if (pci) {
2805 if ((INT) pci == -1)
2806 pci = NULL;
2807 else if (pci->rc.flRecordAttr & CRA_SELECTED)
2808 wasemphasized = TRUE;
2809 }
2810 else if (!*dcd->directory) {
2811 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2812 break;
2813 }
2814 else if (IsRoot(dcd->directory)) {
[618]2815 saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
2816 GetPString(IDS_CANTDRAGROOTDIR));
[551]2817 break;
2818 }
2819 if (hwndStatus2) {
2820 if (pci)
2821 WinSetWindowText(hwndStatus2,
2822 GetPString(IDS_DRAGFILEOBJTEXT));
2823 else
2824 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGDIRTEXT));
2825 }
2826 if (DoFileDrag(hwnd,
2827 dcd->hwndObject,
2828 mp2,
2829 NULL,
[618]2830 pci ? NULL : dcd->directory,
2831 pci ? TRUE : FALSE)) {
[672]2832 if ((pci && fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite) {
2833 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[618]2834 }
[551]2835 }
2836 if (hwndStatus2) {
2837 WinSetFocus(HWND_DESKTOP, hwnd);
2838 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2839 }
2840 }
2841 }
2842 return 0;
[2]2843
[551]2844 case CN_DROP:
2845 if (mp2) {
[2]2846
[551]2847 LISTINFO *li;
2848 ULONG action = UM_ACTION;
[2]2849
[768]2850 // DbgMsg(pszSrcFile, __LINE__, "calling DoFileDrop");
[687]2851 li = DoFileDrop(hwnd, dcd->directory, TRUE, mp1, mp2);
2852 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
[551]2853 if (li) {
2854 if (li->list && li->list[0] && IsRoot(li->list[0]))
2855 li->type = DO_LINK;
2856 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
[2]2857
[551]2858 CHECKLIST cl;
[2]2859
[551]2860 memset(&cl, 0, sizeof(cl));
2861 cl.size = sizeof(cl);
2862 cl.flags = li->type;
2863 cl.list = li->list;
2864 cl.cmd = li->type;
2865 cl.prompt = li->targetpath;
2866 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2867 DropListProc, FM3ModHandle,
[618]2868 DND_FRAME, MPFROMP(&cl));
2869 if (li->type == DID_ERROR)
2870 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2871 "Drag & Drop Dialog");
2872 if (!li->type) {
[551]2873 FreeListInfo(li);
2874 return 0;
2875 }
2876 li->list = cl.list;
[618]2877 if (!li->list || !li->list[0]) {
[551]2878 FreeListInfo(li);
2879 return 0;
2880 }
2881 }
2882 switch (li->type) {
2883 case DND_LAUNCH:
2884 strcat(li->targetpath, " %a");
2885 ExecOnList(dcd->hwndParent, li->targetpath,
2886 PROMPT | WINDOWED, NULL, li->list, NULL);
2887 FreeList(li->list);
2888 li->list = NULL;
2889 break;
2890 case DO_LINK:
2891 if (fLinkSetsIcon) {
2892 li->type = IDM_SETICON;
2893 action = UM_MASSACTION;
2894 }
2895 else
2896 li->type = IDM_COMPARE;
2897 break;
2898 case DND_EXTRACT:
2899 if (*li->targetpath && !IsFile(li->targetpath))
2900 li->type = IDM_EXTRACT;
2901 break;
2902 case DND_MOVE:
2903 li->type = IDM_MOVE;
2904 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2905 action = UM_MASSACTION;
2906 li->type = IDM_ARCHIVEM;
2907 }
2908 break;
2909 case DND_WILDMOVE:
2910 li->type = IDM_WILDMOVE;
2911 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2912 action = UM_MASSACTION;
2913 li->type = IDM_ARCHIVEM;
2914 }
2915 break;
2916 case DND_OBJECT:
2917 li->type = IDM_OBJECT;
2918 action = UM_MASSACTION;
2919 break;
2920 case DND_SHADOW:
2921 li->type = IDM_SHADOW;
2922 action = UM_MASSACTION;
2923 break;
2924 case DND_COMPARE:
2925 li->type = IDM_COMPARE;
2926 break;
2927 case DND_SETICON:
2928 action = UM_MASSACTION;
2929 li->type = IDM_SETICON;
2930 break;
2931 case DND_COPY:
2932 li->type = IDM_COPY;
2933 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2934 action = UM_MASSACTION;
2935 li->type = IDM_ARCHIVE;
2936 }
2937 break;
2938 case DND_WILDCOPY:
2939 li->type = IDM_WILDCOPY;
2940 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2941 action = UM_MASSACTION;
2942 li->type = IDM_ARCHIVE;
2943 }
2944 break;
2945 default:
2946 if (*li->arcname && li->info) {
2947 action = UM_MASSACTION;
2948 li->type =
2949 (li->type == DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2950 }
2951 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2952 action = UM_MASSACTION;
2953 li->type = (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2954 }
2955 else
2956 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2957 break;
2958 }
2959 if (!li->list || !li->list[0])
2960 FreeListInfo(li);
2961 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2962 FreeListInfo(li);
2963 else {
[2]2964
[551]2965 USHORT usop = 0;
[2]2966
[551]2967 switch (li->type) {
2968 case IDM_COPY:
2969 case IDM_WILDCOPY:
2970 usop = DO_COPY;
2971 break;
2972 case IDM_MOVE:
2973 case IDM_WILDMOVE:
2974 case IDM_ARCHIVEM:
2975 usop = DO_MOVE;
2976 break;
2977 }
2978 if (usop)
2979 return MRFROM2SHORT(DOR_DROP, usop);
2980 }
2981 }
2982 }
2983 return 0;
[2]2984
[551]2985 case CN_ENDEDIT:
2986 case CN_BEGINEDIT:
2987 {
2988 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
2989 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
[2]2990
[551]2991 if (pfi || pci) {
[2]2992
[551]2993 MRESULT mre;
[2]2994
[551]2995 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2996 if (mre != (MRESULT) - 1)
2997 return mre;
2998 }
2999 else if (!pfi && !pci)
3000 PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
3001 }
3002 return 0;
[2]3003
[551]3004 case CN_REALLOCPSZ:
3005 {
3006 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3007 PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
3008 HWND hwndMLE;
3009 static CHAR szData[CCHMAXPATH];
[689]3010 CHAR testname[CCHMAXPATH];
[2]3011
[551]3012 if (!pci && !pfi) {
3013 hwndMLE = WinWindowFromID(hwnd, CID_MLE);
3014 WinQueryWindowText(hwndMLE, sizeof(szData), szData);
3015 chop_at_crnl(szData);
3016 bstrip(szData);
3017 if (*szData) {
3018 if (!DosQueryPathInfo(szData,
3019 FIL_QUERYFULLNAME,
3020 testname, sizeof(testname))) {
3021 if (!SetDir(dcd->hwndParent, hwnd, testname, 1)) {
3022 PostMsg(hwnd, UM_SETDIR, MPFROMP(testname), MPVOID);
3023 }
3024 }
3025 }
3026 }
3027 else {
[2]3028
[551]3029 MRESULT mre;
[2]3030
[551]3031 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
3032 if (mre != (MRESULT) - 1)
3033 return mre;
3034 }
3035 }
3036 return 0;
[2]3037
[551]3038 case CN_EMPHASIS:
3039 if (!mp2)
3040 Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL");
3041 else {
3042 PNOTIFYRECORDEMPHASIS pre = mp2;
3043 PCNRITEM pci;
3044 CHAR s[CCHMAXPATHCOMP + 91], tb[81], tf[81];
[2]3045
[762]3046 pci = (PCNRITEM) (pre ? pre->pRecord : NULL);
[551]3047 if (!pci) {
3048 if (hwndStatus2)
3049 WinSetWindowText(hwndStatus2, NullStr);
3050 if (fMoreButtons) {
3051 WinSetWindowText(hwndName, NullStr);
3052 WinSetWindowText(hwndDate, NullStr);
3053 WinSetWindowText(hwndAttr, NullStr);
3054 }
3055 if (hwndMain)
3056 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3057 break;
3058 }
3059 if (pre->fEmphasisMask & CRA_SELECTED) {
3060 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3061 dcd->selectedbytes += (pci->cbFile + pci->easize);
3062 dcd->selectedfiles++;
3063 }
3064 else if (dcd->selectedfiles) {
3065 dcd->selectedbytes -= (pci->cbFile + pci->easize);
3066 dcd->selectedfiles--;
3067 }
3068 if (!dcd->suspendview) {
3069 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3070 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
3071 sprintf(s, "%s / %s", tf, tb);
3072 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3073 }
3074 }
3075 if (!dcd->suspendview && hwndMain &&
3076 (pre->fEmphasisMask & CRA_CURSORED) &&
3077 (pci->rc.flRecordAttr & CRA_CURSORED) &&
3078 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
[730]3079 if (driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)
[551]3080 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
3081 else
3082 WinSendMsg(hwndMain,
[730]3083 UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
[551]3084 }
3085 if (!dcd->suspendview &&
3086 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
3087 if (pre->fEmphasisMask & CRA_CURSORED) {
3088 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3089 if (fSplitStatus && hwndStatus2) {
3090 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
3091 if (!fMoreButtons) {
3092 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
3093 tb, pci->date.year,
3094 pci->date.month, pci->date.day, pci->time.hours,
3095 pci->time.minutes, pci->time.seconds,
3096 pci->pszDispAttr, pci->pszFileName);
3097 }
3098 else {
3099 *tf = 0;
3100 if (pci->cbFile + pci->easize > 1024) {
3101 CommaFmtULL(tf, sizeof(tf),
3102 pci->cbFile + pci->easize, 'K');
3103 }
3104 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
3105 tb,
3106 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
3107 }
3108 WinSetWindowText(hwndStatus2, s);
3109 }
3110 if (fMoreButtons) {
3111 WinSetWindowText(hwndName, pci->pszFileName);
3112 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
3113 pci->date.year, pci->date.month,
3114 pci->date.day, pci->time.hours, pci->time.minutes,
3115 pci->time.seconds);
3116 WinSetWindowText(hwndDate, s);
3117 WinSetWindowText(hwndAttr, pci->pszDispAttr);
3118 }
3119 }
3120 }
3121 }
3122 }
3123 break;
[2]3124
[551]3125 case CN_ENTER:
3126 if (mp2) {
[2]3127
[551]3128 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
[841]3129 FILEFINDBUF3L ffb;
[551]3130 HDIR hDir = HDIR_CREATE;
[761]3131 ULONG nm = 1;
[551]3132 APIRET status = 0;
[2]3133
[551]3134 SetShiftState();
3135 if (pci) {
3136 if (pci->rc.flRecordAttr & CRA_INUSE)
3137 break;
3138 DosError(FERR_DISABLEHARDERR);
[838]3139 status = xDosFindFirst(pci->pszFileName,
3140 &hDir,
3141 FILE_NORMAL | FILE_DIRECTORY |
3142 FILE_ARCHIVED | FILE_READONLY |
3143 FILE_HIDDEN | FILE_SYSTEM,
[841]3144 &ffb, sizeof(ffb), &nm, FIL_STANDARDL);
[551]3145 priority_bumped();
3146 if (!status) {
3147 DosFindClose(hDir);
3148 if (ffb.attrFile & FILE_DIRECTORY) {
3149 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
3150 PostMsg(hwnd,
3151 WM_COMMAND,
3152 MPFROM2SHORT(IDM_SHOWALLFILES, 0), MPVOID);
3153 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
3154 (KC_CTRL | KC_SHIFT))
[730]3155 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
[551]3156 else if (shiftstate & KC_CTRL)
[730]3157 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
[551]3158 else if (shiftstate & KC_SHIFT) {
[2]3159
[551]3160 HWND hwndDir;
[2]3161
[551]3162 hwndDir = OpenDirCnr((HWND) 0,
3163 dcd->hwndParent,
3164 dcd->hwndFrame,
[730]3165 FALSE, pci->pszFileName);
[551]3166 if (hwndDir) {
3167 if (fMinOnOpen)
3168 WinSetWindowPos(dcd->hwndFrame,
3169 HWND_BOTTOM,
3170 0, 0, 0, 0, SWP_MINIMIZE | SWP_ZORDER);
3171 if (fAutoTile)
3172 TileChildren(dcd->hwndParent, TRUE);
3173 WinSetWindowPos(hwndDir,
3174 HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
3175 }
3176 }
3177 else {
3178 strcpy(dcd->previous, dcd->directory);
[730]3179 strcpy(dcd->directory, pci->pszFileName);
[551]3180 DosEnterCritSec();
3181 dcd->stopflag++;
3182 DosExitCritSec();
3183 if (!PostMsg(dcd->hwndObject,
[841]3184 UM_RESCAN, MPVOID, MPFROMLONG(1))) {
[551]3185 DosEnterCritSec();
3186 dcd->stopflag--;
3187 DosExitCritSec();
3188 }
3189 else if (*dcd->directory) {
3190 if (hwndMain)
3191 WinSendMsg(hwndMain,
3192 UM_SETUSERLISTNAME,
3193 MPFROMP(dcd->directory), MPVOID);
3194 else
3195 add_udir(FALSE, dcd->directory);
3196 }
3197 }
3198 }
3199 else {
[2]3200
[551]3201 SWP swp;
[2]3202
[551]3203 WinQueryWindowPos(dcd->hwndFrame, &swp);
3204 WinSendMsg(hwnd,
3205 CM_SETRECORDEMPHASIS,
3206 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
3207 DefaultViewKeys(hwnd,
3208 dcd->hwndFrame,
[730]3209 dcd->hwndParent, &swp, pci->pszFileName);
[551]3210 WinSendMsg(hwnd,
3211 CM_SETRECORDEMPHASIS,
3212 MPFROMP(pci),
3213 MPFROM2SHORT(FALSE,
3214 CRA_INUSE |
3215 ((fUnHilite) ? CRA_SELECTED : 0)));
3216 }
3217 }
3218 else {
3219 if (!*dcd->directory || IsValidDir(dcd->directory)) {
[730]3220 NotifyError(pci->pszFileName, status);
[751]3221 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[551]3222 if (hwndStatus)
3223 WinSetWindowText(hwndStatus,
3224 GetPString(IDS_RESCANSUGGESTEDTEXT));
3225 }
3226 else {
3227 DosEnterCritSec();
3228 dcd->stopflag++;
3229 DosExitCritSec();
3230 if (!PostMsg(dcd->hwndObject,
3231 UM_RESCAN, MPVOID, MPFROMLONG(1L))) {
3232 DosEnterCritSec();
3233 dcd->stopflag--;
3234 DosExitCritSec();
3235 }
3236 else if (*dcd->directory) {
3237 if (hwndMain)
3238 WinSendMsg(hwndMain,
3239 UM_SETUSERLISTNAME,
3240 MPFROMP(dcd->directory), MPVOID);
3241 else
3242 add_udir(FALSE, dcd->directory);
3243 }
3244 }
3245 }
3246 }
3247 else if (*dcd->directory)
3248 OpenObject(dcd->directory, Default, hwnd);
[787]3249 } // CN_ENTER
[551]3250 break;
[787]3251 } // switch mp1
[551]3252 break;
[787]3253 } // if dcd
[551]3254 return 0;
[2]3255
[551]3256 case UM_LOADFILE:
3257 if (dcd && mp2) {
[2]3258
[787]3259 HWND ret = StartMLEEditor(dcd->hwndParent,
3260 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
[551]3261 if (mp2)
[787]3262 free((CHAR *)mp2);
[551]3263 return MRFROMLONG(ret);
3264 }
3265 return 0;
[2]3266
[551]3267 case WM_SAVEAPPLICATION:
3268 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
[2]3269
[551]3270 SWP swp;
[2]3271
[551]3272 WinQueryWindowPos(dcd->hwndFrame, &swp);
3273 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3274 PrfWriteProfileData(fmprof,
3275 appname, "VDirSizePos", &swp, sizeof(swp));
3276 }
3277 break;
[2]3278
[551]3279 case WM_CLOSE:
3280 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3281 if (LastDir == hwnd)
3282 LastDir = (HWND) 0;
3283 if (dcd) {
3284 dcd->stopflag++;
3285 if (!dcd->dontclose && ParentIsDesktop(dcd->hwndFrame, (HWND) 0))
3286 PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
3287 if (!dcd->hwndObject ||
3288 !PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID)) {
3289 if (dcd->hwndObject)
3290 WinSetWindowPtr(dcd->hwndObject, QWL_USER, NULL);
3291 WinSetWindowPtr(hwnd, QWL_USER, NULL);
3292 if (dcd->hwndRestore)
3293 WinSetWindowPos(dcd->hwndRestore,
3294 HWND_TOP,
3295 0,
3296 0,
3297 0,
3298 0,
3299 SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
3300 FreeList(dcd->lastselection);
3301 free(dcd);
3302 DosPostEventSem(CompactSem);
[2]3303 }
[551]3304 }
3305 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3306 QW_PARENT));
3307 return 0;
[2]3308
[551]3309 case WM_DESTROY:
3310 if (DirMenu)
3311 WinDestroyWindow(DirMenu);
3312 if (DirCnrMenu)
3313 WinDestroyWindow(DirCnrMenu);
3314 if (FileMenu)
3315 WinDestroyWindow(FileMenu);
3316 DirMenu = DirCnrMenu = FileMenu = (HWND) 0;
3317 EmptyCnr(hwnd);
3318 break;
[2]3319 }
[705]3320 if (dcd && dcd->oldproc){
3321 return dcd->oldproc(hwnd, msg, mp1, mp2);
3322 }
3323 else
3324 return PFNWPCnr(hwnd, msg, mp1, mp2);
[2]3325}
3326
[551]3327HWND StartDirCnr(HWND hwndParent, CHAR * directory, HWND hwndRestore,
3328 ULONG flags)
[275]3329{
[2]3330 /* bitmapped flags:
3331 * 0x00000001 = don't close app when window closes
3332 * 0x00000002 = no frame controls
3333 */
3334
[551]3335 HWND hwndFrame = (HWND) 0, hwndClient;
3336 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3337 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3338 USHORT id;
[2]3339 static USHORT idinc = 0;
[551]3340 DIRCNRDATA *dcd;
3341 static BOOL first = FALSE;
[2]3342
[551]3343 if (flags & 2)
[2]3344 FrameFlags &= (~(FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
[551]3345 FCF_MINMAX | FCF_ICON));
3346 if (!idinc)
[2]3347 idinc = (rand() % 100);
[551]3348 if (!hwndParent)
[2]3349 hwndParent = HWND_DESKTOP;
[551]3350 if (ParentIsDesktop(hwndParent, hwndParent))
[2]3351 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
[551]3352 if (!hwndMain && !first) {
3353 if (DirCnrMenu) {
[2]3354
3355 MENUITEM mi;
3356
[551]3357 memset(&mi, 0, sizeof(mi));
[2]3358 WinSendMsg(DirCnrMenu,
[551]3359 MM_DELETEITEM, MPFROM2SHORT(IDM_DRIVESMENU, FALSE), MPVOID);
[2]3360 mi.iPosition = MIT_END;
3361 mi.afStyle = MIS_TEXT;
3362 mi.id = IDM_DRIVESMENU;
3363 WinSendMsg(DirCnrMenu,
[551]3364 MM_INSERTITEM,
3365 MPFROMP(&mi), MPFROMP(GetPString(IDS_DRIVESMENUTEXT)));
[2]3366 }
3367 first = TRUE;
3368 }
[551]3369 if (directory) {
[2]3370 hwndFrame = WinCreateStdWindow(hwndParent,
[551]3371 WS_VISIBLE,
3372 &FrameFlags,
[593]3373 WC_DIRCONTAINER,
[551]3374 NULL,
3375 WS_VISIBLE | fwsAnimate,
3376 FM3ModHandle, DIR_FRAME, &hwndClient);
3377 if (hwndFrame && hwndClient) {
[2]3378 id = DIR_FRAME + idinc++;
[551]3379 if (idinc > 99)
3380 idinc = 0;
3381 WinSetWindowUShort(hwndFrame, QWS_ID, id);
3382 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
[358]3383 if (!dcd) {
[551]3384 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3385 hwndFrame = (HWND) 0;
[358]3386 }
3387 else {
[551]3388 dcd->size = sizeof(DIRCNRDATA);
3389 dcd->id = id;
3390 dcd->type = DIR_FRAME;
3391 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
3392 dcd->hwndFrame = hwndFrame;
3393 dcd->hwndClient = hwndClient;
3394 dcd->hwndRestore = hwndRestore;
3395 dcd->dontclose = ((flags & 1) != 0);
3396 strcpy(dcd->directory, directory);
3397 add_udir(FALSE, directory);
3398 {
3399 PFNWP oldproc;
[2]3400
[551]3401 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) DirFrameWndProc);
3402 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
[377]3403 }
[551]3404 dcd->hwndCnr = WinCreateWindow(hwndClient,
3405 WC_CONTAINER,
3406 NULL,
3407 CCS_AUTOPOSITION | CCS_MINIICONS |
3408 CCS_MINIRECORDCORE | ulCnrType |
3409 WS_VISIBLE,
3410 0,
3411 0,
3412 0,
3413 0,
3414 hwndClient,
3415 HWND_TOP, (ULONG) DIR_CNR, NULL, NULL);
3416 if (!dcd->hwndCnr) {
3417 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3418 IDS_WINCREATEWINDOW);
3419 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3420 free(dcd);
3421 hwndFrame = (HWND) 0;
3422 }
[377]3423 else {
[551]3424 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3425 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3426 (PFNWP) DirCnrWndProc);
3427 {
3428 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3429 DIR_FILTER, DIR_FOLDERICON, DIR_MAX, 0
3430 };
[2]3431
[551]3432 if (!(flags & 2))
3433 ids[6] = 0;
3434 CommonCreateTextChildren(dcd->hwndClient,
[593]3435 WC_DIRSTATUS, ids);
[551]3436 }
3437 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3438 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
3439 if (FrameFlags & FCF_TASKLIST) {
[2]3440
[551]3441 SWP swp, swpD;
3442 ULONG size = sizeof(swp);
3443 LONG cxScreen, cyScreen;
[2]3444
[551]3445 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3446 if (PrfQueryProfileData(fmprof,
3447 appname, "VDirSizePos", &swpD, &size)) {
3448 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3449 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3450 if (swp.x + swpD.cx > cxScreen)
3451 swp.x = cxScreen - swpD.cx;
3452 if (swp.y + swpD.cy > cyScreen)
3453 swp.y = cyScreen - swpD.cy;
3454 swp.cx = swpD.cx;
3455 swp.cy = swpD.cy;
3456 }
3457 WinSetWindowPos(hwndFrame,
3458 HWND_TOP,
3459 swp.x,
3460 swp.y,
3461 swp.cx,
3462 swp.cy,
3463 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3464 SWP_ACTIVATE);
3465 }
3466 }
[2]3467 }
3468 }
3469 }
3470 return hwndFrame;
3471}
[793]3472
3473#pragma alloc_text(DIRCNRS,DirCnrWndProc,DirObjWndProc,DirClientWndProc)
3474#pragma alloc_text(DIRCNRS,DirTextProc,DirFrameWndProc)
3475#pragma alloc_text(STARTUP,StartDirCnr)
Note: See TracBrowser for help on using the repository browser.