source: trunk/dll/dircnrs.c@ 787

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

Rework UM_FILLSETUPLIST IDM_SAVEDIRCNRSTATE and ..._setups() logic for ticket# 109 and #31
Add GetMSecTimer()
Use GetMSecTimer in DbgMsg
Tweak notebook.ipf scanning page
Move more #pragma alloc_text statements to end of files for OpenWatcom
Delete obsoletes
Revert ExpandAll() ShowTreeRec() DosSleeps to 0 - DosSleep(1) was slowing down inner loops
Drop afFilesToGet - use FilesToGet directly
Optimze ShowTreeRec() collapse logic - was really slow

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