source: trunk/dll/dircnrs.c@ 971

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

Ticket 230: Fix/improve code related to various state or presparam values
stored in the INI file.

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