source: trunk/dll/dircnrs.c@ 616

Last change on this file since 616 was 606, checked in by Gregg Young, 19 years ago

Drag drop work around for number of files limitation in PM

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