source: trunk/dll/dircnrs.c@ 593

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

Changes to remove GetPString from window class names

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