source: trunk/dll/dircnrs.c@ 917

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

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

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