source: trunk/dll/dircnrs.c@ 1012

Last change on this file since 1012 was 1012, checked in by Gregg Young, 17 years ago

Fixed crash on directory container close with fortify enabled; fixed memory leak in assoc.c;added a fortify scope to correspond to the loading and unloading of fm3.dll

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