source: trunk/dll/dircnrs.c@ 975

Last change on this file since 975 was 972, checked in by John Small, 18 years ago

Ticket 230: Added comments.

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