source: trunk/dll/dircnrs.c@ 897

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

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

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