[70] | 1 | /***********************************************************************
|
---|
| 2 |
|
---|
| 3 | $Id: misc.c 1395 2009-02-08 01:48:16Z gyoung $
|
---|
| 4 |
|
---|
[406] | 5 | Misc GUI support functions
|
---|
[70] | 6 |
|
---|
| 7 | Copyright (c) 1993-98 M. Kimes
|
---|
[1394] | 8 | Copyright (c) 2003, 2009 Steven H. Levine
|
---|
[70] | 9 |
|
---|
[161] | 10 | 11 Jun 03 SHL Add JFS and FAT32 support
|
---|
| 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 12 | 01 Aug 04 SHL LoadLibPath: avoid buffer overflow
|
---|
[198] | 13 | 07 Jun 05 SHL Drop obsoletes
|
---|
[231] | 14 | 24 Jul 05 SHL Beautify
|
---|
[245] | 15 | 24 Jul 05 SHL Correct longname display option
|
---|
[350] | 16 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[369] | 17 | 26 Jul 06 SHL Use chop_at_crnl
|
---|
[397] | 18 | 27 Jul 06 SHL Comments, apply indent
|
---|
[406] | 19 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
[451] | 20 | 16 Aug 06 SHL Comments
|
---|
[468] | 21 | 31 Aug 06 SHL disable_menuitem: rework args to match name - sheesh
|
---|
[526] | 22 | 10 Oct 06 GKY Add NDFS32 support
|
---|
[552] | 23 | 18 Feb 07 GKY More drive type and drive icon support
|
---|
[688] | 24 | 10 Jun 07 GKY Add IsFm2Window as part of work around PM drag limit
|
---|
[730] | 25 | 05 Jul 07 GKY Fix menu removals for WORKPLACE_PROCESS=YES
|
---|
[737] | 26 | 23 Jul 07 SHL Sync with CNRITEM updates (ticket#24)
|
---|
[751] | 27 | 31 Jul 07 SHL Clean up and report errors (ticket#24)
|
---|
[756] | 28 | 03 Aug 07 GKY Direct editting fixed (ticket#24)
|
---|
[773] | 29 | 06 Aug 07 SHL Use BldQuotedFileName
|
---|
[775] | 30 | 06 Aug 07 GKY Increase Subject EA to 1024
|
---|
| 31 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[787] | 32 | 14 Aug 07 SHL Delete obsoletes
|
---|
| 33 | 14 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[827] | 34 | 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
|
---|
[860] | 35 | 05 Nov 07 GKY Use commafmtULL to display file sizes for large file support
|
---|
[872] | 36 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
[921] | 37 | 12 Jan 08 SHL Document SetConditionalCascade
|
---|
[940] | 38 | 13 Jan 08 GKY Get Subjectwidth/Subjectleft working in the collector.
|
---|
[998] | 39 | 19 Jan 08 JBS Ticket 150: fix/improve save and restore of dir cnr state at FM/2 close/reopen
|
---|
[940] | 40 | 21 Jan 08 GKY Stop reallocating NullStr by direct editing of empty subject and longname strings.
|
---|
[985] | 41 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[998] | 42 | 08 Mar 08 JBS Ticket 230: Replace prefixless INI keys for default directory containers with
|
---|
[1394] | 43 | keys using a "DirCnr." prefix
|
---|
[1026] | 44 | 19 Jun 08 JBS Ticket 239: Fix LoadDetailsSwitches so INI file is read correctly and details
|
---|
[1394] | 45 | switches are set correctly.
|
---|
[1065] | 46 | 11 Jul 08 JBS Ticket 230: Simplified code and eliminated some local variables by incorporating
|
---|
[1394] | 47 | all the details view settings (both the global variables and those in the
|
---|
| 48 | DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
|
---|
[1077] | 49 | 17 Jul 08 SHL Add GetTidForWindow for Fortify support
|
---|
[1084] | 50 | 20 Jul 08 GKY Add save/append filename to clipboard.
|
---|
[1394] | 51 | Change menu wording to make these easier to find
|
---|
[1112] | 52 | 23 Aug 08 GKY Add CheckDriveSpaceAvail To pre check drive space to prevent failures
|
---|
[1358] | 53 | 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
|
---|
[1360] | 54 | 28 Dec 08 GKY Check for LVM.EXE and remove Refresh removable media menu item as appropriate
|
---|
[1395] | 55 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
---|
[70] | 56 |
|
---|
| 57 | ***********************************************************************/
|
---|
| 58 |
|
---|
[907] | 59 | #include <stdlib.h>
|
---|
| 60 | #include <string.h>
|
---|
| 61 | #include <ctype.h>
|
---|
| 62 | #include <share.h>
|
---|
[1159] | 63 | #include <malloc.h> // _heapmin
|
---|
[907] | 64 |
|
---|
[2] | 65 | #define INCL_DOS
|
---|
| 66 | #define INCL_WIN
|
---|
| 67 | #define INCL_GPI
|
---|
[841] | 68 | #define INCL_LONGLONG
|
---|
[2] | 69 |
|
---|
[1182] | 70 | #include "fm3dll.h"
|
---|
[1225] | 71 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
| 72 | #include "misc.h"
|
---|
[1210] | 73 | #include "killproc.h" // Data declaration(s)
|
---|
| 74 | #include "comp.h" // Data declaration(s)
|
---|
| 75 | #include "treecnr.h" // Data declaration(s)
|
---|
| 76 | #include "mainwnd.h" // Data declaration(s)
|
---|
| 77 | #include "init.h" // Data declaration(s)
|
---|
| 78 | #include "dircnrs.h" // Data declaration(s)
|
---|
| 79 | #include "newview.h" // Data declarations
|
---|
| 80 | #include "collect.h" // data declaration(s)
|
---|
| 81 | #include "notebook.h" // data declaration(s)
|
---|
| 82 | #include "arccnrs.h"
|
---|
[2] | 83 | #include "fm3dlg.h"
|
---|
| 84 | #include "fm3str.h"
|
---|
[1159] | 85 | #include "pathutil.h" // BldQuotedFileName
|
---|
| 86 | #include "errutil.h" // Dos_Error...
|
---|
| 87 | #include "strutil.h" // GetPString
|
---|
| 88 | #include "command.h" // LINKCMDS
|
---|
| 89 | #include "cmdline.h" // CmdLineDlgProc
|
---|
| 90 | #include "defview.h" // QuickView
|
---|
| 91 | #include "copyf.h" // WriteLongName
|
---|
| 92 | #include "strips.h" // chop_at_crnl
|
---|
[1182] | 93 | #include "valid.h" // CheckDrive
|
---|
| 94 | #include "presparm.h" // CopyPresParams
|
---|
| 95 | #include "systemf.h" // ExecOnList
|
---|
| 96 | #include "viewer.h" // StartMLEEditor
|
---|
| 97 | #include "subj.h" // Subject
|
---|
| 98 | #include "wrappers.h" // xDosSetPathInfo
|
---|
| 99 | #include "commafmt.h" // CommaFmtULL
|
---|
[1159] | 100 | #include "fortify.h"
|
---|
[1354] | 101 | #include "info.h" // driveflags
|
---|
[2] | 102 |
|
---|
[1225] | 103 | #define CONTAINER_COLUMNS 13 /* Number of columns in details view */
|
---|
| 104 | #define MS_POPUP 0x00000010L
|
---|
| 105 |
|
---|
[1210] | 106 | // Data definitions
|
---|
| 107 | #pragma data_seg(GLOBAL1)
|
---|
| 108 | HWND CollectorDirMenu;
|
---|
| 109 | HWND CollectorFileMenu;
|
---|
| 110 | HWND DirMenu;
|
---|
| 111 | HWND FileMenu;
|
---|
| 112 | HWND TreeMenu;
|
---|
| 113 | BOOL fDefaultDeletePerm;
|
---|
| 114 | BOOL fWorkPlace;
|
---|
| 115 |
|
---|
| 116 | #pragma data_seg(GLOBAL4)
|
---|
| 117 | ULONG numswitches;
|
---|
| 118 | HSWITCH switches[499];
|
---|
| 119 |
|
---|
[2] | 120 | #pragma data_seg(DATA1)
|
---|
[350] | 121 | static PSZ pszSrcFile = __FILE__;
|
---|
| 122 |
|
---|
[2] | 123 | #ifndef BEGIN_LIBPATH
|
---|
[1159] | 124 | #define BEGIN_LIBPATH 1
|
---|
[2] | 125 | #endif
|
---|
[231] | 126 |
|
---|
[2] | 127 | #ifndef END_LIBPATH
|
---|
[1159] | 128 | #define END_LIBPATH 2
|
---|
[2] | 129 | #endif
|
---|
[231] | 130 |
|
---|
[2] | 131 | #ifndef ORD_DOS32QUERYEXTLIBPATH
|
---|
[231] | 132 | #define ORD_DOS32QUERYEXTLIBPATH 874
|
---|
[2] | 133 | #endif
|
---|
| 134 |
|
---|
[687] | 135 | BOOL IsFm2Window(HWND hwnd, BOOL chkTid)
|
---|
| 136 | {
|
---|
| 137 | PIB *ppib;
|
---|
| 138 | TIB *ptib;
|
---|
[751] | 139 | BOOL yes;
|
---|
| 140 | APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
|
---|
[687] | 141 |
|
---|
[733] | 142 | if (rc) {
|
---|
[687] | 143 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1394] | 144 | "DosGetInfoBlocks");
|
---|
[751] | 145 | yes = FALSE;
|
---|
[733] | 146 | }
|
---|
[687] | 147 | else {
|
---|
| 148 | PID pid;
|
---|
| 149 | TID tid;
|
---|
| 150 |
|
---|
[751] | 151 | // Check window owned by FM2 process
|
---|
| 152 | // Check say same thread too, if requested
|
---|
| 153 | // OK for window to be dead - just return FALSE
|
---|
| 154 | yes = WinQueryWindowProcess(hwnd, &pid, &tid) &&
|
---|
[1394] | 155 | pid == ppib->pib_ulpid &&
|
---|
| 156 | (!chkTid || tid == ptib->tib_ptib2->tib2_ultid);
|
---|
[687] | 157 | }
|
---|
[751] | 158 | return yes;
|
---|
[687] | 159 | }
|
---|
| 160 |
|
---|
[1077] | 161 | #ifdef FORTIFY
|
---|
| 162 |
|
---|
| 163 | /**
|
---|
[1078] | 164 | * Return thread ordinal for fm/2 window
|
---|
[1077] | 165 | * window must exist and must be created by fm/2
|
---|
| 166 | * @param hwnd is window handle
|
---|
[1078] | 167 | * @returns thread ordinal or -1 if error
|
---|
[1077] | 168 | */
|
---|
| 169 |
|
---|
| 170 | INT GetTidForWindow(HWND hwnd)
|
---|
| 171 | {
|
---|
| 172 | PIB *ppib;
|
---|
| 173 | TIB *ptib;
|
---|
[1078] | 174 | LONG ordinal = -1;
|
---|
[1077] | 175 | APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
|
---|
| 176 |
|
---|
| 177 | if (rc) {
|
---|
| 178 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1394] | 179 | "DosGetInfoBlocks");
|
---|
[1077] | 180 | }
|
---|
| 181 | else {
|
---|
| 182 | PID pid;
|
---|
| 183 | TID tid;
|
---|
| 184 | if (!WinQueryWindowProcess(hwnd, &pid, &tid))
|
---|
[1394] | 185 | Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for %X", hwnd);
|
---|
[1077] | 186 | else if (pid != ppib->pib_ulpid)
|
---|
[1394] | 187 | Runtime_Error(pszSrcFile, __LINE__, "hwnd %X not created by fm/2", hwnd);
|
---|
[1077] | 188 | else
|
---|
[1394] | 189 | ordinal = ptib->tib_ptib2->tib2_ultid;
|
---|
[1077] | 190 | }
|
---|
[1078] | 191 | return ordinal;
|
---|
[1077] | 192 | }
|
---|
| 193 |
|
---|
[1078] | 194 | /**
|
---|
| 195 | * Return thread ordinal for current thread
|
---|
| 196 | * @returns thread ordinal or -1 if error
|
---|
| 197 | */
|
---|
| 198 |
|
---|
| 199 | INT GetTidForThread(VOID)
|
---|
| 200 | {
|
---|
| 201 | PIB *ppib;
|
---|
| 202 | TIB *ptib;
|
---|
| 203 | LONG ordinal = -1;
|
---|
| 204 | APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
|
---|
| 205 |
|
---|
| 206 | if (rc) {
|
---|
| 207 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1394] | 208 | "DosGetInfoBlocks");
|
---|
[1078] | 209 | }
|
---|
| 210 | else
|
---|
| 211 | ordinal = ptib->tib_ptib2->tib2_ultid;
|
---|
| 212 |
|
---|
| 213 | return ordinal;
|
---|
| 214 | }
|
---|
| 215 |
|
---|
[1077] | 216 | #endif // FORTIFY
|
---|
| 217 |
|
---|
[231] | 218 | VOID SetShiftState(VOID)
|
---|
| 219 | {
|
---|
[397] | 220 | shiftstate = 0;
|
---|
| 221 | if (WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
|
---|
| 222 | shiftstate |= KC_CTRL;
|
---|
| 223 | if (WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
|
---|
| 224 | shiftstate |= KC_SHIFT;
|
---|
| 225 | if (WinGetKeyState(HWND_DESKTOP, VK_ALT) & 0x8000)
|
---|
| 226 | shiftstate |= KC_ALT;
|
---|
[2] | 227 | }
|
---|
| 228 |
|
---|
[231] | 229 | void EmphasizeButton(HWND hwnd, BOOL on)
|
---|
| 230 | {
|
---|
[397] | 231 | HPS hps = DrgGetPS(hwnd);
|
---|
[2] | 232 |
|
---|
[397] | 233 | // fixme to complain?
|
---|
| 234 | if (hps) {
|
---|
| 235 | POINTL ptl;
|
---|
| 236 | SWP swp;
|
---|
[2] | 237 |
|
---|
[397] | 238 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 239 | ptl.x = 1;
|
---|
| 240 | ptl.y = 1;
|
---|
| 241 | GpiMove(hps, &ptl);
|
---|
[787] | 242 | GpiSetColor(hps, on ? CLR_BLACK : CLR_PALEGRAY);
|
---|
[397] | 243 | ptl.x = swp.cx - 2;
|
---|
| 244 | ptl.y = swp.cy - 2;
|
---|
| 245 | GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
|
---|
| 246 | DrgReleasePS(hps);
|
---|
[551] | 247 | if (remove) //fixme always true
|
---|
[397] | 248 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
| 249 | }
|
---|
[2] | 250 | }
|
---|
| 251 |
|
---|
[231] | 252 | void DrawTargetEmphasis(HWND hwnd, BOOL on)
|
---|
| 253 | {
|
---|
[397] | 254 | HPS hps = DrgGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
[551] | 255 |
|
---|
[397] | 256 | if (hps) {
|
---|
[787] | 257 | BoxWindow(hwnd, hps, on ? CLR_BLACK : CLR_PALEGRAY);
|
---|
[397] | 258 | DrgReleasePS(hps);
|
---|
| 259 | }
|
---|
[2] | 260 | }
|
---|
| 261 |
|
---|
[231] | 262 | void BoxWindow(HWND hwnd, HPS hps, LONG color)
|
---|
| 263 | {
|
---|
[397] | 264 | POINTL ptl;
|
---|
| 265 | SWP swp;
|
---|
| 266 | BOOL releaseme = FALSE;
|
---|
[2] | 267 |
|
---|
[397] | 268 | if (!hps) {
|
---|
| 269 | hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 270 | releaseme = TRUE;
|
---|
| 271 | }
|
---|
| 272 | if (hps && WinQueryWindowPos(hwnd, &swp)) {
|
---|
| 273 | ptl.x = swp.x - 2;
|
---|
| 274 | ptl.y = swp.y - 2;
|
---|
| 275 | GpiMove(hps, &ptl);
|
---|
| 276 | GpiSetColor(hps, color);
|
---|
| 277 | ptl.x = swp.x + swp.cx + 1;
|
---|
| 278 | ptl.y = swp.y + swp.cy + 1;
|
---|
| 279 | GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
|
---|
| 280 | }
|
---|
| 281 | if (releaseme && hps)
|
---|
| 282 | WinReleasePS(hps);
|
---|
[2] | 283 | }
|
---|
| 284 |
|
---|
[231] | 285 | void PaintSTextWindow(HWND hwnd, HPS hps)
|
---|
| 286 | {
|
---|
[397] | 287 | /*
|
---|
| 288 | * paint a text window such that the rightmost part of the text is
|
---|
| 289 | * always visible even if the text length exceeds the length of the
|
---|
| 290 | * window -- otherwise, paint the window so that it is left-justified
|
---|
| 291 | * and vertically centered.
|
---|
| 292 | */
|
---|
[2] | 293 |
|
---|
[397] | 294 | char *s = NULL;
|
---|
| 295 | long len;
|
---|
| 296 | POINTL aptl[TXTBOX_COUNT], ptl;
|
---|
| 297 | RECTL rcl;
|
---|
| 298 | char *p;
|
---|
| 299 | BOOL releaseme = FALSE;
|
---|
[2] | 300 |
|
---|
[397] | 301 | if (!hps) {
|
---|
| 302 | releaseme = TRUE;
|
---|
| 303 | hps = WinGetPS(hwnd);
|
---|
| 304 | }
|
---|
| 305 | if (hps) {
|
---|
| 306 | WinQueryWindowRect(hwnd, &rcl);
|
---|
| 307 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
| 308 | len = WinQueryWindowTextLength(hwnd);
|
---|
| 309 | if (len)
|
---|
| 310 | s = xmalloc(len + 1, pszSrcFile, __LINE__);
|
---|
| 311 | if (s) {
|
---|
| 312 | *s = 0;
|
---|
| 313 | WinQueryWindowText(hwnd, CCHMAXPATH, s);
|
---|
| 314 | if (*s) {
|
---|
[1394] | 315 | rcl.xRight -= 3;
|
---|
| 316 | p = s;
|
---|
| 317 | GpiQueryTextBox(hps, 3, "...", TXTBOX_COUNT, aptl);
|
---|
| 318 | len = aptl[TXTBOX_TOPRIGHT].x;
|
---|
| 319 | do {
|
---|
| 320 | GpiQueryTextBox(hps, strlen(p), p, TXTBOX_COUNT, aptl);
|
---|
| 321 | if (aptl[TXTBOX_TOPRIGHT].x > (rcl.xRight - (p != s ? len : 0)))
|
---|
| 322 | p++;
|
---|
| 323 | else
|
---|
| 324 | break;
|
---|
| 325 | }
|
---|
| 326 | while (*p);
|
---|
| 327 | if (*p) {
|
---|
| 328 | GpiSetMix(hps, FM_OVERPAINT);
|
---|
| 329 | GpiSetColor(hps, CLR_BLACK);
|
---|
| 330 | ptl.x = 3;
|
---|
| 331 | ptl.y = ((rcl.yTop / 2) -
|
---|
| 332 | ((aptl[TXTBOX_TOPRIGHT].y +
|
---|
| 333 | aptl[TXTBOX_BOTTOMLEFT].y) / 2));
|
---|
| 334 | GpiMove(hps, &ptl);
|
---|
| 335 | if (p != s)
|
---|
| 336 | GpiCharString(hps, 3, "...");
|
---|
| 337 | GpiCharString(hps, strlen(p), p);
|
---|
| 338 | }
|
---|
[397] | 339 | }
|
---|
[1039] | 340 | free(s);
|
---|
[231] | 341 | }
|
---|
[397] | 342 | if (releaseme)
|
---|
| 343 | WinReleasePS(hps);
|
---|
| 344 | }
|
---|
[2] | 345 | }
|
---|
| 346 |
|
---|
[231] | 347 | VOID PaintRecessedWindow(HWND hwnd, HPS hps, BOOL outtie, BOOL dbl)
|
---|
| 348 | {
|
---|
[397] | 349 | /*
|
---|
| 350 | * paint a recessed box around the window
|
---|
| 351 | * two pixels width required around window for painting...
|
---|
| 352 | */
|
---|
| 353 | BOOL releaseme = FALSE;
|
---|
[2] | 354 |
|
---|
[397] | 355 | if (!hps) {
|
---|
| 356 | hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 357 | releaseme = TRUE;
|
---|
| 358 | }
|
---|
| 359 | if (hps) {
|
---|
[2] | 360 |
|
---|
[397] | 361 | POINTL ptl;
|
---|
| 362 | SWP swp;
|
---|
[2] | 363 |
|
---|
[397] | 364 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 365 | ptl.x = swp.x - 1;
|
---|
| 366 | ptl.y = swp.y - 1;
|
---|
| 367 | GpiMove(hps, &ptl);
|
---|
| 368 | if (!outtie)
|
---|
| 369 | GpiSetColor(hps, CLR_WHITE);
|
---|
| 370 | else
|
---|
| 371 | GpiSetColor(hps, CLR_DARKGRAY);
|
---|
| 372 | ptl.x = swp.x + swp.cx;
|
---|
| 373 | GpiLine(hps, &ptl);
|
---|
| 374 | ptl.y = swp.y + swp.cy;
|
---|
| 375 | GpiLine(hps, &ptl);
|
---|
| 376 | if (dbl) {
|
---|
| 377 | ptl.x = swp.x - 2;
|
---|
| 378 | ptl.y = swp.y - 2;
|
---|
| 379 | GpiMove(hps, &ptl);
|
---|
| 380 | ptl.x = swp.x + swp.cx + 1;
|
---|
| 381 | GpiLine(hps, &ptl);
|
---|
| 382 | ptl.y = swp.y + swp.cy + 1;
|
---|
| 383 | GpiLine(hps, &ptl);
|
---|
[2] | 384 | }
|
---|
[397] | 385 | if (!outtie)
|
---|
| 386 | GpiSetColor(hps, CLR_DARKGRAY);
|
---|
| 387 | else
|
---|
| 388 | GpiSetColor(hps, CLR_WHITE);
|
---|
| 389 | if (dbl) {
|
---|
| 390 | ptl.x = swp.x - 2;
|
---|
| 391 | GpiLine(hps, &ptl);
|
---|
| 392 | ptl.y = swp.y - 2;
|
---|
| 393 | GpiLine(hps, &ptl);
|
---|
| 394 | ptl.x = swp.x + swp.cx;
|
---|
| 395 | ptl.y = swp.y + swp.cy;
|
---|
| 396 | GpiMove(hps, &ptl);
|
---|
| 397 | }
|
---|
| 398 | ptl.x = swp.x - 1;
|
---|
| 399 | GpiLine(hps, &ptl);
|
---|
| 400 | ptl.y = swp.y - 1;
|
---|
| 401 | GpiLine(hps, &ptl);
|
---|
| 402 | GpiSetColor(hps, CLR_PALEGRAY);
|
---|
| 403 | ptl.x = swp.x - (2 + (dbl != FALSE));
|
---|
| 404 | ptl.y = swp.y - (2 + (dbl != FALSE));
|
---|
| 405 | GpiMove(hps, &ptl);
|
---|
| 406 | ptl.x = swp.x + swp.cx + (1 + (dbl != FALSE));
|
---|
| 407 | GpiLine(hps, &ptl);
|
---|
| 408 | ptl.y = swp.y + swp.cy + (1 + (dbl != FALSE));
|
---|
| 409 | GpiLine(hps, &ptl);
|
---|
| 410 | ptl.x = swp.x - (2 + (dbl != FALSE));
|
---|
| 411 | GpiLine(hps, &ptl);
|
---|
| 412 | ptl.y = swp.y - (2 + (dbl != FALSE));
|
---|
| 413 | GpiLine(hps, &ptl);
|
---|
| 414 | if (releaseme)
|
---|
| 415 | WinReleasePS(hps);
|
---|
| 416 | }
|
---|
[2] | 417 | }
|
---|
| 418 |
|
---|
[1394] | 419 | BOOL AdjustCnrColVis(HWND hwndCnr, PCSZ title, BOOL visible, BOOL toggle)
|
---|
[231] | 420 | {
|
---|
[551] | 421 | PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
|
---|
[1394] | 422 | CM_QUERYDETAILFIELDINFO,
|
---|
| 423 | MPVOID, MPFROMSHORT(CMA_FIRST));
|
---|
[551] | 424 |
|
---|
[397] | 425 | while (pfi) {
|
---|
| 426 | if (!strcmp(pfi->pTitleData, title)) {
|
---|
| 427 | if (toggle) {
|
---|
[1394] | 428 | if (pfi->flData & CFA_INVISIBLE)
|
---|
| 429 | pfi->flData &= (~CFA_INVISIBLE);
|
---|
| 430 | else
|
---|
| 431 | pfi->flData |= CFA_INVISIBLE;
|
---|
| 432 | return !(pfi->flData & CFA_INVISIBLE);
|
---|
[397] | 433 | }
|
---|
| 434 | else {
|
---|
[1394] | 435 | if (visible)
|
---|
| 436 | pfi->flData &= (~CFA_INVISIBLE);
|
---|
| 437 | else
|
---|
| 438 | pfi->flData |= CFA_INVISIBLE;
|
---|
[397] | 439 | }
|
---|
| 440 | return TRUE;
|
---|
[2] | 441 | }
|
---|
[397] | 442 | pfi = pfi->pNextFieldInfo;
|
---|
| 443 | }
|
---|
| 444 | return FALSE;
|
---|
[2] | 445 | }
|
---|
| 446 |
|
---|
[1394] | 447 | BOOL AdjustCnrColRO(HWND hwndCnr, PCSZ title, BOOL readonly, BOOL toggle)
|
---|
[70] | 448 | {
|
---|
[551] | 449 | PFIELDINFO pfi = (PFIELDINFO) WinSendMsg(hwndCnr,
|
---|
[1394] | 450 | CM_QUERYDETAILFIELDINFO,
|
---|
| 451 | MPVOID, MPFROMSHORT(CMA_FIRST));
|
---|
[551] | 452 |
|
---|
[397] | 453 | while (pfi) {
|
---|
| 454 | if (!strcmp(pfi->pTitleData, title)) {
|
---|
| 455 | if (toggle) {
|
---|
[1394] | 456 | if (pfi->flData & CFA_FIREADONLY)
|
---|
| 457 | pfi->flData &= (~CFA_FIREADONLY);
|
---|
| 458 | else
|
---|
| 459 | pfi->flData |= CFA_FIREADONLY;
|
---|
| 460 | return (pfi->flData & CFA_FIREADONLY);
|
---|
[397] | 461 | }
|
---|
| 462 | else {
|
---|
[1394] | 463 | if (!readonly)
|
---|
| 464 | pfi->flData &= (~CFA_FIREADONLY);
|
---|
| 465 | else
|
---|
| 466 | pfi->flData |= CFA_FIREADONLY;
|
---|
[397] | 467 | }
|
---|
| 468 | return TRUE;
|
---|
[2] | 469 | }
|
---|
[397] | 470 | pfi = pfi->pNextFieldInfo;
|
---|
| 471 | }
|
---|
| 472 | return FALSE;
|
---|
[2] | 473 | }
|
---|
| 474 |
|
---|
[1394] | 475 | VOID AdjustCnrColsForFSType(HWND hwndCnr, PCSZ directory, DETAILS_SETTINGS * pds)
|
---|
[231] | 476 | {
|
---|
[397] | 477 | CHAR FileSystem[CCHMAXPATH];
|
---|
| 478 | INT x;
|
---|
| 479 | BOOL hasCreateDT;
|
---|
| 480 | BOOL hasAccessDT;
|
---|
| 481 | BOOL hasLongNames;
|
---|
[2] | 482 |
|
---|
[397] | 483 | if (!directory || !*directory)
|
---|
| 484 | return;
|
---|
| 485 | x = CheckDrive(toupper(*directory), FileSystem, NULL);
|
---|
| 486 | if (x != -1) {
|
---|
| 487 | if (!stricmp(FileSystem, HPFS) ||
|
---|
[1394] | 488 | !stricmp(FileSystem, JFS) ||
|
---|
| 489 | !stricmp(FileSystem, FAT32) ||
|
---|
| 490 | !stricmp(FileSystem, RAMFS) ||
|
---|
| 491 | !stricmp(FileSystem, NDFS32) ||
|
---|
| 492 | !stricmp(FileSystem, NTFS) ||
|
---|
| 493 | !stricmp(FileSystem, HPFS386)) {
|
---|
[397] | 494 | hasCreateDT = TRUE;
|
---|
| 495 | hasAccessDT = TRUE;
|
---|
| 496 | hasLongNames = TRUE;
|
---|
[2] | 497 | }
|
---|
[552] | 498 | else if (!strcmp(FileSystem, CDFS) || !strcmp(FileSystem, ISOFS)) {
|
---|
[397] | 499 | hasCreateDT = TRUE;
|
---|
| 500 | hasAccessDT = FALSE;
|
---|
| 501 | hasLongNames = FALSE;
|
---|
[2] | 502 | }
|
---|
[397] | 503 | else {
|
---|
| 504 | // Assume FAT
|
---|
| 505 | hasCreateDT = FALSE;
|
---|
| 506 | hasAccessDT = FALSE;
|
---|
| 507 | hasLongNames = FALSE;
|
---|
| 508 | }
|
---|
| 509 | }
|
---|
| 510 | else {
|
---|
| 511 | // Assume FAT
|
---|
| 512 | hasCreateDT = FALSE;
|
---|
| 513 | hasAccessDT = FALSE;
|
---|
| 514 | hasLongNames = FALSE;
|
---|
| 515 | }
|
---|
[787] | 516 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 517 | GetPString(IDS_LADATE),
|
---|
| 518 | pds->detailsladate ? hasAccessDT : FALSE,
|
---|
| 519 | FALSE);
|
---|
[787] | 520 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 521 | GetPString(IDS_LATIME),
|
---|
| 522 | pds->detailslatime ? hasAccessDT : FALSE,
|
---|
| 523 | FALSE);
|
---|
[787] | 524 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 525 | GetPString(IDS_CRDATE),
|
---|
| 526 | pds->detailscrdate ? hasCreateDT : FALSE,
|
---|
| 527 | FALSE);
|
---|
[787] | 528 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 529 | GetPString(IDS_CRTIME),
|
---|
| 530 | pds->detailscrtime ? hasCreateDT : FALSE,
|
---|
| 531 | FALSE);
|
---|
[787] | 532 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 533 | GetPString(IDS_LNAME),
|
---|
| 534 | pds->detailslongname ? hasLongNames : FALSE,
|
---|
| 535 | FALSE);
|
---|
[397] | 536 | WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
|
---|
[2] | 537 | }
|
---|
| 538 |
|
---|
[1394] | 539 | VOID AdjustCnrColsForPref(HWND hwndCnr, PCSZ directory, DETAILS_SETTINGS * pds,
|
---|
| 540 | BOOL compare)
|
---|
[231] | 541 | {
|
---|
[2] | 542 |
|
---|
[751] | 543 | AdjustCnrColVis(hwndCnr,
|
---|
[1394] | 544 | compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ),
|
---|
| 545 | pds->detailssubject,
|
---|
| 546 | FALSE);
|
---|
[751] | 547 |
|
---|
[1065] | 548 | AdjustCnrColVis(hwndCnr, GetPString(IDS_ATTR), pds->detailsattr, FALSE);
|
---|
| 549 | AdjustCnrColVis(hwndCnr, GetPString(IDS_ICON), pds->detailsicon, FALSE);
|
---|
| 550 | AdjustCnrColVis(hwndCnr, GetPString(IDS_LWDATE), pds->detailslwdate, FALSE);
|
---|
| 551 | AdjustCnrColVis(hwndCnr, GetPString(IDS_LWTIME), pds->detailslwtime, FALSE);
|
---|
| 552 | AdjustCnrColVis(hwndCnr, GetPString(IDS_EA), pds->detailsea, FALSE);
|
---|
| 553 | AdjustCnrColVis(hwndCnr, GetPString(IDS_SIZE), pds->detailssize, FALSE);
|
---|
[751] | 554 |
|
---|
[397] | 555 | if (!directory) {
|
---|
[1065] | 556 | AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), pds->detailsladate, FALSE);
|
---|
| 557 | AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), pds->detailslatime, FALSE);
|
---|
| 558 | AdjustCnrColVis(hwndCnr, GetPString(IDS_CRDATE), pds->detailscrdate, FALSE);
|
---|
| 559 | AdjustCnrColVis(hwndCnr, GetPString(IDS_CRTIME), pds->detailscrtime, FALSE);
|
---|
| 560 | AdjustCnrColVis(hwndCnr, GetPString(IDS_LNAME), pds->detailslongname, FALSE);
|
---|
[397] | 561 | WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
|
---|
| 562 | }
|
---|
| 563 | else
|
---|
[1065] | 564 | AdjustCnrColsForFSType(hwndCnr, directory, pds);
|
---|
[2] | 565 | }
|
---|
| 566 |
|
---|
[751] | 567 | BOOL SetCnrCols(HWND hwndCnr, BOOL isCompCnr)
|
---|
[231] | 568 | {
|
---|
[397] | 569 | BOOL fSuccess = TRUE;
|
---|
| 570 | PFIELDINFO pfi, pfiLastLeftCol, pfiIconCol;
|
---|
[2] | 571 |
|
---|
[397] | 572 | // Allocate storage for container column data
|
---|
[2] | 573 |
|
---|
[397] | 574 | pfi = WinSendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO,
|
---|
[1394] | 575 | MPFROMLONG(CONTAINER_COLUMNS), NULL);
|
---|
[2] | 576 |
|
---|
[751] | 577 | if (!pfi) {
|
---|
| 578 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCDETAILFIELDINFO");
|
---|
| 579 | fSuccess = FALSE;
|
---|
| 580 | }
|
---|
| 581 | else {
|
---|
[2] | 582 |
|
---|
[397] | 583 | PFIELDINFO pfiFirst;
|
---|
| 584 | FIELDINFOINSERT fii;
|
---|
[2] | 585 |
|
---|
[397] | 586 | // Store original value of pfi so we won't lose it when it changes.
|
---|
| 587 | // This will be needed on the CM_INSERTDETAILFIELDINFO message.
|
---|
[2] | 588 |
|
---|
[397] | 589 | pfiFirst = pfi;
|
---|
[2] | 590 |
|
---|
[397] | 591 | // Fill in column information for the icon column
|
---|
[2] | 592 |
|
---|
[397] | 593 | pfi->flData = CFA_BITMAPORICON | CFA_CENTER | CFA_FIREADONLY;
|
---|
| 594 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
[1394] | 595 | pfi->pTitleData = (PSZ)GetPString(IDS_ICON);
|
---|
[397] | 596 | pfi->offStruct = FIELDOFFSET(MINIRECORDCORE, hptrIcon);
|
---|
[2] | 597 |
|
---|
[397] | 598 | pfiIconCol = pfi;
|
---|
[2] | 599 |
|
---|
[397] | 600 | // Fill in column information for the file name. Note that we are
|
---|
[737] | 601 | // using the pszDisplayName variable rather than pszFileName. We do this
|
---|
| 602 | // because the container does not always display the full path file name.
|
---|
[2] | 603 |
|
---|
[397] | 604 | pfi = pfi->pNextFieldInfo;
|
---|
[856] | 605 |
|
---|
[397] | 606 | pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
|
---|
[792] | 607 | pfi->flTitle = CFA_LEFT;
|
---|
[1394] | 608 | pfi->pTitleData = (PSZ)GetPString(IDS_FILENAME);
|
---|
[737] | 609 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszDisplayName);
|
---|
[2] | 610 |
|
---|
[397] | 611 | // Fill in column information for the longname.
|
---|
[2] | 612 |
|
---|
[397] | 613 | pfi = pfi->pNextFieldInfo;
|
---|
| 614 | pfi->flData = CFA_STRING | CFA_LEFT;
|
---|
[792] | 615 | pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
|
---|
[1394] | 616 | pfi->pTitleData = (PSZ)GetPString(IDS_LNAME);
|
---|
[762] | 617 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszLongName);
|
---|
[2] | 618 |
|
---|
[397] | 619 | // Fill in column info for subjects
|
---|
[2] | 620 |
|
---|
[1065] | 621 | if (dsDirCnrDefault.fSubjectInLeftPane) {
|
---|
[796] | 622 | pfi = pfi->pNextFieldInfo;
|
---|
| 623 | pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
|
---|
| 624 | if (isCompCnr)
|
---|
[1394] | 625 | pfi->flData |= CFA_FIREADONLY;
|
---|
[796] | 626 | pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
|
---|
[1394] | 627 | pfi->pTitleData = isCompCnr ? (PSZ)GetPString(IDS_STATUS) :
|
---|
| 628 | (PSZ)GetPString(IDS_SUBJ);
|
---|
[796] | 629 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
|
---|
[1065] | 630 | pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth;
|
---|
[2] | 631 |
|
---|
[796] | 632 | // Store the current pfi value as that will be used to indicate the
|
---|
| 633 | // last column in the lefthand container window (we have a splitbar)
|
---|
[792] | 634 |
|
---|
[796] | 635 | pfiLastLeftCol = pfi;
|
---|
| 636 | }
|
---|
| 637 | else {
|
---|
| 638 | // Store the current pfi value as that will be used to indicate the
|
---|
| 639 | // last column in the lefthand container window (we have a splitbar)
|
---|
[792] | 640 |
|
---|
[796] | 641 | pfiLastLeftCol = pfi;
|
---|
| 642 | pfi = pfi->pNextFieldInfo;
|
---|
| 643 | pfi->flData = CFA_STRING | CFA_LEFT | CFA_SEPARATOR;
|
---|
| 644 | if (isCompCnr)
|
---|
[1394] | 645 | pfi->flData |= CFA_FIREADONLY;
|
---|
[796] | 646 | pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY;
|
---|
[1394] | 647 | pfi->pTitleData = isCompCnr ? (PSZ)GetPString(IDS_STATUS) :
|
---|
| 648 | (PSZ)GetPString(IDS_SUBJ);
|
---|
[796] | 649 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject);
|
---|
[1065] | 650 | pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth;
|
---|
[796] | 651 | }
|
---|
| 652 |
|
---|
[397] | 653 | // Fill in column information for the file size
|
---|
[2] | 654 |
|
---|
| 655 |
|
---|
[859] | 656 | pfi = pfi->pNextFieldInfo;
|
---|
| 657 | pfi->flData = CFA_STRING | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 658 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 659 | pfi->pTitleData = (PSZ)GetPString(IDS_SIZE);
|
---|
[859] | 660 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszFmtFileSize);
|
---|
| 661 |
|
---|
| 662 |
|
---|
[397] | 663 | // Fill in the column information for the file's ea size
|
---|
[2] | 664 |
|
---|
[397] | 665 | pfi = pfi->pNextFieldInfo;
|
---|
| 666 | pfi->flData = CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 667 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 668 | pfi->pTitleData = (PSZ)GetPString(IDS_EA);
|
---|
[397] | 669 | pfi->offStruct = FIELDOFFSET(CNRITEM, easize);
|
---|
[2] | 670 |
|
---|
[397] | 671 | // Fill in the column information for the file attribute
|
---|
[2] | 672 |
|
---|
[397] | 673 | pfi = pfi->pNextFieldInfo;
|
---|
| 674 | pfi->flData = CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 675 | pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
|
---|
[1394] | 676 | pfi->pTitleData = (PSZ)GetPString(IDS_ATTR);
|
---|
[397] | 677 | pfi->offStruct = FIELDOFFSET(CNRITEM, pszDispAttr);
|
---|
[2] | 678 |
|
---|
[397] | 679 | // Fill in column information for last write file date
|
---|
[2] | 680 |
|
---|
[397] | 681 | pfi = pfi->pNextFieldInfo;
|
---|
| 682 | pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 683 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 684 | pfi->pTitleData = (PSZ)GetPString(IDS_LWDATE);
|
---|
[397] | 685 | pfi->offStruct = FIELDOFFSET(CNRITEM, date);
|
---|
[2] | 686 |
|
---|
[397] | 687 | // Fill in column information for the last write file time
|
---|
[2] | 688 |
|
---|
[397] | 689 | pfi = pfi->pNextFieldInfo;
|
---|
| 690 | pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 691 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 692 | pfi->pTitleData = (PSZ)GetPString(IDS_LWTIME);
|
---|
[397] | 693 | pfi->offStruct = FIELDOFFSET(CNRITEM, time);
|
---|
[2] | 694 |
|
---|
[397] | 695 | // Fill in column information for last access file date
|
---|
[2] | 696 |
|
---|
[397] | 697 | pfi = pfi->pNextFieldInfo;
|
---|
| 698 | pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 699 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 700 | pfi->pTitleData = (PSZ)GetPString(IDS_LADATE);
|
---|
[397] | 701 | pfi->offStruct = FIELDOFFSET(CNRITEM, ladate);
|
---|
[2] | 702 |
|
---|
[397] | 703 | // Fill in column information for the last access file time
|
---|
[2] | 704 |
|
---|
[397] | 705 | pfi = pfi->pNextFieldInfo;
|
---|
| 706 | pfi->flData = CFA_TIME | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
|
---|
| 707 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 708 | pfi->pTitleData = (PSZ)GetPString(IDS_LATIME);
|
---|
[397] | 709 | pfi->offStruct = FIELDOFFSET(CNRITEM, latime);
|
---|
[2] | 710 |
|
---|
[397] | 711 | // Fill in column information for create file date
|
---|
[2] | 712 |
|
---|
[397] | 713 | pfi = pfi->pNextFieldInfo;
|
---|
| 714 | pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 715 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 716 | pfi->pTitleData = (PSZ)GetPString(IDS_CRDATE);
|
---|
[397] | 717 | pfi->offStruct = FIELDOFFSET(CNRITEM, crdate);
|
---|
[2] | 718 |
|
---|
[397] | 719 | // Fill in column information for the create file time
|
---|
[2] | 720 |
|
---|
[397] | 721 | pfi = pfi->pNextFieldInfo;
|
---|
| 722 | pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
|
---|
| 723 | pfi->flTitle = CFA_CENTER;
|
---|
[1394] | 724 | pfi->pTitleData = (PSZ)GetPString(IDS_CRTIME);
|
---|
[397] | 725 | pfi->offStruct = FIELDOFFSET(CNRITEM, crtime);
|
---|
[2] | 726 |
|
---|
[397] | 727 | // Use the CM_INSERTDETAILFIELDINFO message to tell the container
|
---|
| 728 | // all the column information it needs to function properly. Place
|
---|
| 729 | // this column info first in the column list and update the display
|
---|
| 730 | // after they are inserted (fInvalidateFieldInfo = TRUE)
|
---|
[2] | 731 |
|
---|
[397] | 732 | (void)memset(&fii, 0, sizeof(FIELDINFOINSERT));
|
---|
[2] | 733 |
|
---|
[397] | 734 | fii.cb = sizeof(FIELDINFOINSERT);
|
---|
| 735 | fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
|
---|
| 736 | fii.cFieldInfoInsert = (SHORT) CONTAINER_COLUMNS;
|
---|
| 737 | fii.fInvalidateFieldInfo = TRUE;
|
---|
[2] | 738 |
|
---|
[397] | 739 | if (!WinSendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO, MPFROMP(pfiFirst),
|
---|
[1394] | 740 | MPFROMP(&fii))) {
|
---|
[751] | 741 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_INSERTDETAILFIELDINFO");
|
---|
[397] | 742 | fSuccess = FALSE;
|
---|
[751] | 743 | }
|
---|
[397] | 744 | }
|
---|
[2] | 745 |
|
---|
[397] | 746 | if (fSuccess) {
|
---|
[2] | 747 |
|
---|
[397] | 748 | CNRINFO cnri;
|
---|
| 749 | ULONG size;
|
---|
[2] | 750 |
|
---|
[397] | 751 | // Tell the container about the splitbar and where it goes
|
---|
[2] | 752 |
|
---|
[397] | 753 | cnri.cb = sizeof(CNRINFO);
|
---|
| 754 | cnri.pFieldInfoLast = pfiLastLeftCol;
|
---|
| 755 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
|
---|
| 756 | cnri.pFieldInfoObject = pfiIconCol;
|
---|
| 757 | size = sizeof(LONG);
|
---|
| 758 | PrfQueryProfileData(fmprof,
|
---|
[1394] | 759 | appname, "CnrSplitBar", &cnri.xVertSplitbar, &size);
|
---|
[397] | 760 | if (cnri.xVertSplitbar <= 0)
|
---|
| 761 | cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
|
---|
| 762 | if (!WinSendMsg(hwndCnr, CM_SETCNRINFO, MPFROMP(&cnri),
|
---|
[1394] | 763 | MPFROMLONG(CMA_PFIELDINFOLAST | CMA_PFIELDINFOOBJECT |
|
---|
| 764 | CMA_XVERTSPLITBAR))) {
|
---|
[751] | 765 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_SETCNRINFO");
|
---|
[397] | 766 | fSuccess = FALSE;
|
---|
[751] | 767 | }
|
---|
[397] | 768 | }
|
---|
[2] | 769 |
|
---|
[397] | 770 | return fSuccess;
|
---|
[2] | 771 | }
|
---|
| 772 |
|
---|
[231] | 773 | MRESULT CnrDirectEdit(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[161] | 774 | {
|
---|
[397] | 775 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 776 | case CN_BEGINEDIT:
|
---|
| 777 | if (mp2) {
|
---|
| 778 | PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
|
---|
| 779 | PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
|
---|
[2] | 780 |
|
---|
[397] | 781 | if (pci &&
|
---|
[1394] | 782 | (INT) pci != -1 &&
|
---|
| 783 | !IsRoot(pci->pszFileName) &&
|
---|
| 784 | !(pci->flags & RECFLAGS_ENV) && !(pci->flags & RECFLAGS_UNDERENV)) {
|
---|
| 785 | if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName)) {
|
---|
| 786 | PostMsg(hwnd, UM_FIXEDITNAME, MPFROMP(pci->pszFileName), MPVOID);
|
---|
| 787 | }
|
---|
| 788 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject))
|
---|
| 789 | PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(1048), MPVOID);
|
---|
| 790 | else
|
---|
| 791 | PostMsg(hwnd, UM_FIXCNRMLE, MPFROMLONG(CCHMAXPATH), MPVOID);
|
---|
[397] | 792 | }
|
---|
| 793 | else
|
---|
[1394] | 794 | PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
|
---|
[397] | 795 | }
|
---|
| 796 | break;
|
---|
[2] | 797 |
|
---|
[397] | 798 | case CN_REALLOCPSZ:
|
---|
| 799 | if (mp2) {
|
---|
| 800 | PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
|
---|
| 801 | PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
|
---|
[689] | 802 | CHAR szData[CCHMAXPATH], testname[CCHMAXPATH];
|
---|
[397] | 803 | HWND hwndMLE = WinWindowFromID(hwnd, CID_MLE);
|
---|
[1354] | 804 | BOOL fResetVerify = FALSE;
|
---|
[2] | 805 |
|
---|
[730] | 806 | if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
|
---|
[1394] | 807 | if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszSubject)) {
|
---|
[2] | 808 |
|
---|
[1394] | 809 | APIRET rc;
|
---|
| 810 | EAOP2 eaop;
|
---|
| 811 | PFEA2LIST pfealist = NULL;
|
---|
| 812 | CHAR szSubject[1048];
|
---|
| 813 | ULONG ealen;
|
---|
| 814 | USHORT len;
|
---|
| 815 | CHAR *eaval;
|
---|
| 816 | LONG retlen;
|
---|
| 817 | PSZ psz;
|
---|
[2] | 818 |
|
---|
[1394] | 819 | retlen = WinQueryWindowText(hwndMLE, sizeof(szSubject), szSubject);
|
---|
| 820 | szSubject[retlen + 1] = 0;
|
---|
| 821 | bstrip(szSubject);
|
---|
| 822 | if (pci->pszSubject != NullStr) {
|
---|
| 823 | if (retlen == 0) {
|
---|
| 824 | psz = pci->pszSubject;
|
---|
| 825 | pci->pszSubject = NullStr;
|
---|
| 826 | xfree(psz, pszSrcFile, __LINE__);
|
---|
| 827 | }
|
---|
| 828 | else
|
---|
| 829 | pci->pszSubject = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__);
|
---|
| 830 | }
|
---|
| 831 | else {
|
---|
| 832 | pci->pszSubject = xmalloc(retlen + 1, pszSrcFile, __LINE__);
|
---|
| 833 | if (!pci->pszSubject)
|
---|
| 834 | return FALSE;
|
---|
| 835 | }
|
---|
| 836 | len = strlen(szSubject);
|
---|
| 837 | if (len)
|
---|
| 838 | ealen = sizeof(FEA2LIST) + 9 + len + 4;
|
---|
| 839 | else
|
---|
| 840 | ealen = sizeof(FEALIST) + 9;
|
---|
| 841 | rc = DosAllocMem((PPVOID) & pfealist, ealen + 64,
|
---|
| 842 | OBJ_TILE | PAG_COMMIT | PAG_READ | PAG_WRITE);
|
---|
| 843 | if (rc)
|
---|
| 844 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile,
|
---|
| 845 | __LINE__, GetPString(IDS_OUTOFMEMORY));
|
---|
| 846 | else {
|
---|
| 847 | memset(pfealist, 0, ealen + 1);
|
---|
| 848 | pfealist->cbList = ealen;
|
---|
| 849 | pfealist->list[0].oNextEntryOffset = 0;
|
---|
| 850 | pfealist->list[0].fEA = 0;
|
---|
| 851 | pfealist->list[0].cbName = 8;
|
---|
| 852 | strcpy(pfealist->list[0].szName, SUBJECT);
|
---|
| 853 | if (len) {
|
---|
| 854 | eaval = pfealist->list[0].szName + 9;
|
---|
| 855 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
| 856 | eaval += sizeof(USHORT);
|
---|
| 857 | *(USHORT *) eaval = (USHORT) len;
|
---|
| 858 | eaval += sizeof(USHORT);
|
---|
| 859 | memcpy(eaval, szSubject, len);
|
---|
| 860 | pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
|
---|
| 861 | }
|
---|
| 862 | else
|
---|
| 863 | pfealist->list[0].cbValue = 0;
|
---|
| 864 | eaop.fpGEA2List = (PGEA2LIST) 0;
|
---|
| 865 | eaop.fpFEA2List = pfealist;
|
---|
| 866 | eaop.oError = 0;
|
---|
| 867 | rc = xDosSetPathInfo(pci->pszFileName, FIL_QUERYEASIZE,
|
---|
| 868 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
| 869 | DosFreeMem(pfealist);
|
---|
| 870 | if (rc)
|
---|
| 871 | return FALSE;
|
---|
| 872 | }
|
---|
| 873 | return (MRESULT) TRUE;
|
---|
| 874 | }
|
---|
| 875 | else if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszLongName)) {
|
---|
[2] | 876 |
|
---|
[1394] | 877 | CHAR longname[CCHMAXPATHCOMP];
|
---|
| 878 | LONG retlen;
|
---|
| 879 | PSZ psz;
|
---|
[2] | 880 |
|
---|
[1394] | 881 | *longname = 0;
|
---|
| 882 | retlen = WinQueryWindowText(hwndMLE, sizeof(longname), longname);
|
---|
| 883 | longname[retlen + 1] = 0;
|
---|
| 884 | chop_at_crnl(longname);
|
---|
| 885 | bstrip(longname);
|
---|
| 886 | WinSetWindowText(hwndMLE, longname);
|
---|
| 887 | if (pci->pszLongName != NullStr) {
|
---|
| 888 | if (retlen == 0) {
|
---|
| 889 | psz = pci->pszLongName;
|
---|
| 890 | pci->pszLongName = NullStr;
|
---|
| 891 | xfree(psz, pszSrcFile, __LINE__);
|
---|
| 892 | }
|
---|
| 893 | else
|
---|
| 894 | pci->pszLongName = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__);
|
---|
| 895 | }
|
---|
| 896 | else {
|
---|
| 897 | pci->pszLongName = xmalloc(retlen + 1, pszSrcFile, __LINE__);
|
---|
| 898 | if (!pci->pszLongName)
|
---|
| 899 | return FALSE;
|
---|
| 900 | }
|
---|
| 901 | return (MRESULT) WriteLongName(pci->pszFileName, longname);
|
---|
| 902 | }
|
---|
| 903 | else {
|
---|
| 904 | WinQueryWindowText(hwndMLE, sizeof(szData), szData);
|
---|
| 905 | if (strchr(szData, '?') ||
|
---|
| 906 | strchr(szData, '*') || IsRoot(pci->pszFileName))
|
---|
| 907 | return (MRESULT) FALSE;
|
---|
| 908 | /* If the text changed, rename the file system object. */
|
---|
| 909 | chop_at_crnl(szData);
|
---|
| 910 | bstrip(szData);
|
---|
| 911 | if (!IsFullName(szData))
|
---|
| 912 | Runtime_Error(pszSrcFile, __LINE__, "bad name");
|
---|
| 913 | else {
|
---|
| 914 | if (DosQueryPathInfo(szData,
|
---|
| 915 | FIL_QUERYFULLNAME,
|
---|
| 916 | testname, sizeof(testname)))
|
---|
| 917 | return FALSE;
|
---|
| 918 | if (DosQueryPathInfo(pci->pszFileName,
|
---|
| 919 | FIL_QUERYFULLNAME,
|
---|
| 920 | szData,
|
---|
| 921 | sizeof(szData)))
|
---|
| 922 | {
|
---|
| 923 | pci->pszFileName = xrealloc(pci->pszFileName, sizeof(szData), pszSrcFile, __LINE__);
|
---|
| 924 | strcpy(szData, pci->pszFileName);
|
---|
| 925 | }
|
---|
| 926 | WinSetWindowText(hwndMLE, szData);
|
---|
| 927 | if (strcmp(szData, testname)) {
|
---|
[1395] | 928 | if (stricmp(szData, testname) && IsFile(testname) != -1) {
|
---|
| 929 | if (!fAlertBeepOff)
|
---|
| 930 | DosBeep(50, 100); /* exists; disallow */
|
---|
[1394] | 931 | return (MRESULT) FALSE;
|
---|
| 932 | }
|
---|
| 933 | if (fVerify && (driveflags[toupper(*szData) - 'A'] & DRIVE_WRITEVERIFYOFF ||
|
---|
| 934 | driveflags[toupper(*testname) - 'A'] & DRIVE_WRITEVERIFYOFF)) {
|
---|
| 935 | DosSetVerify(FALSE);
|
---|
| 936 | fResetVerify = TRUE;
|
---|
| 937 | }
|
---|
| 938 | if (docopyf(MOVE, szData, "%s", testname))
|
---|
| 939 | Runtime_Error(pszSrcFile, __LINE__, "docopyf");
|
---|
| 940 | else {
|
---|
| 941 | CHAR *filename;
|
---|
[2] | 942 |
|
---|
[1394] | 943 | filename = xstrdup(testname, pszSrcFile, __LINE__);
|
---|
| 944 | if (filename) {
|
---|
| 945 | if (!PostMsg(hwnd,
|
---|
| 946 | UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
|
---|
| 947 | free(filename);
|
---|
| 948 | }
|
---|
| 949 | if (stricmp(testname, pci->pszFileName)) {
|
---|
| 950 | PostMsg(hwnd, UM_FIXEDITNAME, MPFROMLONG(-1), MPFROMP(pci));
|
---|
| 951 | filename = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
|
---|
| 952 | if (filename) {
|
---|
| 953 | if (!PostMsg(hwnd,
|
---|
| 954 | UM_FIXEDITNAME, MPVOID, MPFROMP(filename)))
|
---|
| 955 | free(filename);
|
---|
| 956 | }
|
---|
| 957 | }
|
---|
| 958 | }
|
---|
| 959 | if (fResetVerify) {
|
---|
| 960 | DosSetVerify(fVerify);
|
---|
| 961 | fResetVerify = FALSE;
|
---|
| 962 | }
|
---|
| 963 | }
|
---|
| 964 | }
|
---|
| 965 | }
|
---|
[397] | 966 | }
|
---|
| 967 | }
|
---|
| 968 | return FALSE;
|
---|
[2] | 969 |
|
---|
[397] | 970 | case CN_ENDEDIT:
|
---|
| 971 | if (mp2) {
|
---|
| 972 | PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
|
---|
| 973 | PCNRITEM pci = (PCNRITEM) ((PCNREDITDATA) mp2)->pRecord;
|
---|
[2] | 974 |
|
---|
[730] | 975 | if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
|
---|
[1394] | 976 | WinSendMsg(hwnd,
|
---|
| 977 | CM_INVALIDATERECORD,
|
---|
| 978 | MPFROMP(&pci),
|
---|
| 979 | MPFROM2SHORT(1, CMA_ERASE | CMA_TEXTCHANGED));
|
---|
| 980 | if (pfi && pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
|
---|
| 981 | PostMsg(hwnd, UM_SORTRECORD, MPVOID, MPVOID);
|
---|
[397] | 982 | }
|
---|
| 983 | else {
|
---|
[1394] | 984 | USHORT cmd = 0;
|
---|
[2] | 985 |
|
---|
[1394] | 986 | if (!pfi || pfi->offStruct == FIELDOFFSET(CNRITEM, pszDisplayName))
|
---|
| 987 | cmd = IDM_SORTSMARTNAME;
|
---|
| 988 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, cbFile))
|
---|
| 989 | cmd = IDM_SORTSIZE;
|
---|
| 990 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, easize))
|
---|
| 991 | cmd = IDM_SORTEASIZE;
|
---|
| 992 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, date))
|
---|
| 993 | cmd = IDM_SORTLWDATE;
|
---|
| 994 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, time))
|
---|
| 995 | cmd = IDM_SORTLWDATE;
|
---|
| 996 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, ladate))
|
---|
| 997 | cmd = IDM_SORTLADATE;
|
---|
| 998 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, latime))
|
---|
| 999 | cmd = IDM_SORTLADATE;
|
---|
| 1000 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crdate))
|
---|
| 1001 | cmd = IDM_SORTCRDATE;
|
---|
| 1002 | else if (pfi->offStruct == FIELDOFFSET(CNRITEM, crtime))
|
---|
| 1003 | cmd = IDM_SORTCRDATE;
|
---|
| 1004 | if (cmd)
|
---|
| 1005 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
[397] | 1006 | }
|
---|
[231] | 1007 | }
|
---|
[397] | 1008 | break;
|
---|
| 1009 | }
|
---|
| 1010 | return (MRESULT) - 1;
|
---|
[2] | 1011 | }
|
---|
| 1012 |
|
---|
[231] | 1013 | BOOL SetMenuCheck(HWND hwndMenu, USHORT id, BOOL * bool, BOOL toggle,
|
---|
[1394] | 1014 | PCSZ savename)
|
---|
[231] | 1015 | {
|
---|
[397] | 1016 | if (toggle) {
|
---|
[787] | 1017 | *bool = *bool ? FALSE : TRUE;
|
---|
[397] | 1018 | if (savename && *savename)
|
---|
| 1019 | PrfWriteProfileData(fmprof, appname, savename, bool, sizeof(BOOL));
|
---|
| 1020 | }
|
---|
| 1021 | WinSendMsg(hwndMenu, MM_SETITEMATTR,
|
---|
[1394] | 1022 | MPFROM2SHORT(id, 1),
|
---|
| 1023 | MPFROM2SHORT(MIA_CHECKED, (*bool ? MIA_CHECKED : 0)));
|
---|
[397] | 1024 | return *bool;
|
---|
[2] | 1025 | }
|
---|
| 1026 |
|
---|
[468] | 1027 | //== disable_menuitem() disable or enable_menuitem ==
|
---|
| 1028 |
|
---|
| 1029 | VOID disable_menuitem(HWND hwndMenu, USHORT id, BOOL disable)
|
---|
[231] | 1030 | {
|
---|
[397] | 1031 | WinSendMsg(hwndMenu, MM_SETITEMATTR,
|
---|
[1394] | 1032 | MPFROM2SHORT(id, TRUE),
|
---|
| 1033 | MPFROM2SHORT(MIA_DISABLED, (disable ? MIA_DISABLED : 0)));
|
---|
[2] | 1034 | }
|
---|
| 1035 |
|
---|
[451] | 1036 | //== ViewHelp() invoke view.exe, return TRUE if OK ==
|
---|
| 1037 |
|
---|
[1394] | 1038 | BOOL ViewHelp(PCSZ filename)
|
---|
[231] | 1039 | {
|
---|
[397] | 1040 | CHAR s[CCHMAXPATH + 81];
|
---|
[891] | 1041 | CHAR szQuotedFileName[CCHMAXPATH];
|
---|
[397] | 1042 | FILE *fp;
|
---|
| 1043 | INT ret = -1;
|
---|
[2] | 1044 |
|
---|
[397] | 1045 | fp = _fsopen(filename, "rb", SH_DENYNO);
|
---|
| 1046 | if (fp) {
|
---|
| 1047 | *s = 0;
|
---|
| 1048 | fread(s, 1, 3, fp);
|
---|
| 1049 | if (*s != 'H' || s[1] != 'S' || s[2] != 'P') {
|
---|
| 1050 | fclose(fp);
|
---|
| 1051 | return FALSE;
|
---|
[2] | 1052 | }
|
---|
[397] | 1053 | fclose(fp);
|
---|
[888] | 1054 | ret = runemf2(SEPARATE | WINDOWED, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1394] | 1055 | NULL, NULL,
|
---|
| 1056 | "VIEW.EXE \"%s\"",
|
---|
| 1057 | BldQuotedFileName(szQuotedFileName, filename));
|
---|
[397] | 1058 | }
|
---|
[2] | 1059 |
|
---|
[397] | 1060 | return (ret != -1);
|
---|
[2] | 1061 | }
|
---|
| 1062 |
|
---|
[451] | 1063 | //== ExecFile() run file, return 1 if OK 0 if skipped -1 if can't run ==
|
---|
| 1064 |
|
---|
[1394] | 1065 | INT ExecFile(HWND hwnd, PCSZ filename)
|
---|
[231] | 1066 | {
|
---|
[397] | 1067 | EXECARGS ex;
|
---|
[989] | 1068 | CHAR path[CCHMAXPATH], *p;
|
---|
| 1069 | PSZ pszCmdLine;
|
---|
[397] | 1070 | APIRET ret;
|
---|
| 1071 | static INT lastflags = 0;
|
---|
[2] | 1072 |
|
---|
[397] | 1073 | strcpy(path, filename);
|
---|
| 1074 | p = strrchr(path, '\\');
|
---|
| 1075 | if (!p)
|
---|
| 1076 | p = strrchr(path, ':');
|
---|
| 1077 | if (p) {
|
---|
| 1078 | if (*p == ':') {
|
---|
| 1079 | p++;
|
---|
| 1080 | *p = '\\';
|
---|
| 1081 | p++;
|
---|
[2] | 1082 | }
|
---|
[397] | 1083 | *p = 0;
|
---|
| 1084 | }
|
---|
| 1085 | else
|
---|
| 1086 | *path = 0;
|
---|
[989] | 1087 | pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
| 1088 | if (pszCmdLine) {
|
---|
| 1089 | BldQuotedFileName(pszCmdLine, filename);
|
---|
| 1090 | memset(&ex, 0, sizeof(ex));
|
---|
| 1091 | ex.flags = lastflags;
|
---|
| 1092 | ex.commandline = pszCmdLine;
|
---|
| 1093 | *ex.path = 0;
|
---|
| 1094 | *ex.environment = 0;
|
---|
| 1095 | ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
|
---|
[1394] | 1096 | EXEC_FRAME, &ex);
|
---|
[989] | 1097 | if (ret == 1) {
|
---|
| 1098 | lastflags = ex.flags;
|
---|
| 1099 | return runemf2(ex.flags, hwnd, pszSrcFile, __LINE__, path,
|
---|
[1394] | 1100 | *ex.environment ? ex.environment : NULL,
|
---|
| 1101 | "%s", pszCmdLine) != -1;
|
---|
[989] | 1102 | }
|
---|
| 1103 | else if (ret != 0)
|
---|
| 1104 | return -1;
|
---|
[1039] | 1105 | free(pszCmdLine);
|
---|
[397] | 1106 | }
|
---|
| 1107 | return 0;
|
---|
[2] | 1108 | }
|
---|
| 1109 |
|
---|
[1065] | 1110 | VOID SetDetailsSwitches(HWND hwnd, DETAILS_SETTINGS * pds)
|
---|
[231] | 1111 | {
|
---|
[1065] | 1112 | WinCheckMenuItem(hwnd, IDM_SHOWLNAMES, pds->detailslongname);
|
---|
| 1113 | WinCheckMenuItem(hwnd, IDM_SHOWSUBJECT, pds->detailssubject);
|
---|
| 1114 | WinCheckMenuItem(hwnd, IDM_SHOWEAS, pds->detailsea);
|
---|
| 1115 | WinCheckMenuItem(hwnd, IDM_SHOWSIZE, pds->detailssize);
|
---|
| 1116 | WinCheckMenuItem(hwnd, IDM_SHOWICON, pds->detailsicon);
|
---|
| 1117 | WinCheckMenuItem(hwnd, IDM_SHOWLWDATE, pds->detailslwdate);
|
---|
| 1118 | WinCheckMenuItem(hwnd, IDM_SHOWLWTIME, pds->detailslwtime);
|
---|
| 1119 | WinCheckMenuItem(hwnd, IDM_SHOWLADATE, pds->detailsladate);
|
---|
| 1120 | WinCheckMenuItem(hwnd, IDM_SHOWLATIME, pds->detailslatime);
|
---|
| 1121 | WinCheckMenuItem(hwnd, IDM_SHOWCRDATE, pds->detailscrdate);
|
---|
| 1122 | WinCheckMenuItem(hwnd, IDM_SHOWCRTIME, pds->detailscrtime);
|
---|
| 1123 | WinCheckMenuItem(hwnd, IDM_SHOWATTR, pds->detailsattr);
|
---|
[2] | 1124 | }
|
---|
| 1125 |
|
---|
[231] | 1126 | VOID AdjustDetailsSwitches(HWND hwnd, HWND hwndMenu, USHORT cmd,
|
---|
[1394] | 1127 | PCSZ directory, PCSZ keyroot,
|
---|
| 1128 | DETAILS_SETTINGS * pds, BOOL compare)
|
---|
[231] | 1129 | {
|
---|
[397] | 1130 | BOOL *bool = NULL;
|
---|
[2] | 1131 |
|
---|
[397] | 1132 | switch (cmd) {
|
---|
| 1133 | case IDM_SHOWLNAMES:
|
---|
[1065] | 1134 | bool = &pds->detailslongname;
|
---|
[397] | 1135 | break;
|
---|
| 1136 | case IDM_SHOWSUBJECT:
|
---|
[1065] | 1137 | bool = &pds->detailssubject;
|
---|
[397] | 1138 | break;
|
---|
| 1139 | case IDM_SHOWEAS:
|
---|
[1065] | 1140 | bool = &pds->detailsea;
|
---|
[397] | 1141 | break;
|
---|
| 1142 | case IDM_SHOWSIZE:
|
---|
[1065] | 1143 | bool = &pds->detailssize;
|
---|
[397] | 1144 | break;
|
---|
| 1145 | case IDM_SHOWICON:
|
---|
[1065] | 1146 | bool = &pds->detailsicon;
|
---|
[397] | 1147 | break;
|
---|
| 1148 | case IDM_SHOWLWDATE:
|
---|
[1065] | 1149 | bool = &pds->detailslwdate;
|
---|
[397] | 1150 | break;
|
---|
| 1151 | case IDM_SHOWLWTIME:
|
---|
[1065] | 1152 | bool = &pds->detailslwtime;
|
---|
[397] | 1153 | break;
|
---|
| 1154 | case IDM_SHOWLADATE:
|
---|
[1065] | 1155 | bool = &pds->detailsladate;
|
---|
[397] | 1156 | break;
|
---|
| 1157 | case IDM_SHOWLATIME:
|
---|
[1065] | 1158 | bool = &pds->detailslatime;
|
---|
[397] | 1159 | break;
|
---|
| 1160 | case IDM_SHOWCRDATE:
|
---|
[1065] | 1161 | bool = &pds->detailscrdate;
|
---|
[397] | 1162 | break;
|
---|
| 1163 | case IDM_SHOWCRTIME:
|
---|
[1065] | 1164 | bool = &pds->detailscrtime;
|
---|
[397] | 1165 | break;
|
---|
| 1166 | case IDM_SHOWATTR:
|
---|
[1065] | 1167 | bool = &pds->detailsattr;
|
---|
[397] | 1168 | break;
|
---|
| 1169 | default:
|
---|
[231] | 1170 | if (hwndMenu)
|
---|
[1065] | 1171 | SetDetailsSwitches(hwndMenu, pds);
|
---|
[397] | 1172 | return;
|
---|
| 1173 | }
|
---|
| 1174 | if (bool)
|
---|
[787] | 1175 | *bool = *bool ? FALSE : TRUE;
|
---|
[397] | 1176 | if (hwnd)
|
---|
[1065] | 1177 | AdjustCnrColsForPref(hwnd, directory, pds, compare);
|
---|
[397] | 1178 | if (hwndMenu)
|
---|
[1065] | 1179 | SetDetailsSwitches(hwndMenu, pds);
|
---|
[2] | 1180 | }
|
---|
| 1181 |
|
---|
[921] | 1182 | /**
|
---|
| 1183 | * Set default menu item to invoke for top level conditional cascade menu
|
---|
| 1184 | * @param def is default menu id (i.e. IDM_...)
|
---|
| 1185 | */
|
---|
| 1186 |
|
---|
[231] | 1187 | VOID SetConditionalCascade(HWND hwndMenu, USHORT id, USHORT def)
|
---|
| 1188 | {
|
---|
[397] | 1189 | MENUITEM mi;
|
---|
[2] | 1190 |
|
---|
[397] | 1191 | mi.iPosition = MIT_END;
|
---|
[921] | 1192 | mi.hItem = 0;
|
---|
| 1193 | mi.hwndSubMenu = (HWND)0;
|
---|
[397] | 1194 | mi.afAttribute = 0;
|
---|
| 1195 | mi.afStyle = MIS_TEXT;
|
---|
[921] | 1196 | if (WinSendMsg(hwndMenu,
|
---|
[1394] | 1197 | MM_QUERYITEM,
|
---|
| 1198 | MPFROM2SHORT(id, TRUE),
|
---|
| 1199 | MPFROMP(&mi)))
|
---|
[921] | 1200 | {
|
---|
[397] | 1201 | WinSetWindowBits(mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
|
---|
[1394] | 1202 | MS_CONDITIONALCASCADE);
|
---|
[397] | 1203 | WinSendMsg(mi.hwndSubMenu, MM_SETDEFAULTITEMID, MPFROMSHORT(def), MPVOID);
|
---|
| 1204 | WinCheckMenuItem(mi.hwndSubMenu, def, TRUE);
|
---|
| 1205 | }
|
---|
[2] | 1206 | }
|
---|
| 1207 |
|
---|
[231] | 1208 | VOID SetSortChecks(HWND hwndMenu, INT sortflags)
|
---|
| 1209 | {
|
---|
[397] | 1210 | WinCheckMenuItem(hwndMenu, IDM_SORTNONE, FALSE);
|
---|
| 1211 | WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, FALSE);
|
---|
| 1212 | WinCheckMenuItem(hwndMenu, IDM_SORTLAST, FALSE);
|
---|
| 1213 | WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, FALSE);
|
---|
| 1214 | WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, FALSE);
|
---|
| 1215 | WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, FALSE);
|
---|
| 1216 | WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, FALSE);
|
---|
| 1217 | WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, FALSE);
|
---|
| 1218 | WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, FALSE);
|
---|
| 1219 | WinCheckMenuItem(hwndMenu, IDM_SORTNAME, FALSE);
|
---|
| 1220 | WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, FALSE);
|
---|
| 1221 | WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, FALSE);
|
---|
| 1222 | WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, FALSE);
|
---|
| 1223 | WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, FALSE);
|
---|
| 1224 | if (sortflags & SORT_FIRSTEXTENSION)
|
---|
| 1225 | WinCheckMenuItem(hwndMenu, IDM_SORTFIRST, TRUE);
|
---|
| 1226 | else if (sortflags & SORT_LASTEXTENSION)
|
---|
| 1227 | WinCheckMenuItem(hwndMenu, IDM_SORTLAST, TRUE);
|
---|
| 1228 | else if (sortflags & SORT_SIZE)
|
---|
| 1229 | WinCheckMenuItem(hwndMenu, IDM_SORTSIZE, TRUE);
|
---|
| 1230 | else if (sortflags & SORT_EASIZE)
|
---|
| 1231 | WinCheckMenuItem(hwndMenu, IDM_SORTEASIZE, TRUE);
|
---|
| 1232 | else if (sortflags & SORT_LWDATE)
|
---|
| 1233 | WinCheckMenuItem(hwndMenu, IDM_SORTLWDATE, TRUE);
|
---|
| 1234 | else if (sortflags & SORT_LADATE)
|
---|
| 1235 | WinCheckMenuItem(hwndMenu, IDM_SORTLADATE, TRUE);
|
---|
| 1236 | else if (sortflags & SORT_CRDATE)
|
---|
| 1237 | WinCheckMenuItem(hwndMenu, IDM_SORTCRDATE, TRUE);
|
---|
| 1238 | else if (sortflags & SORT_FILENAME)
|
---|
| 1239 | WinCheckMenuItem(hwndMenu, IDM_SORTFILENAME, TRUE);
|
---|
| 1240 | else if (sortflags & SORT_NOSORT)
|
---|
| 1241 | WinCheckMenuItem(hwndMenu, IDM_SORTNONE, TRUE);
|
---|
| 1242 | else if (sortflags & SORT_SUBJECT)
|
---|
| 1243 | WinCheckMenuItem(hwndMenu, IDM_SORTSUBJECT, TRUE);
|
---|
| 1244 | else
|
---|
| 1245 | WinCheckMenuItem(hwndMenu, IDM_SORTNAME, TRUE);
|
---|
| 1246 | if (sortflags & SORT_DIRSFIRST)
|
---|
| 1247 | WinCheckMenuItem(hwndMenu, IDM_SORTDIRSFIRST, TRUE);
|
---|
| 1248 | else if (sortflags & SORT_DIRSLAST)
|
---|
| 1249 | WinCheckMenuItem(hwndMenu, IDM_SORTDIRSLAST, TRUE);
|
---|
| 1250 | if (sortflags & SORT_REVERSE)
|
---|
| 1251 | WinCheckMenuItem(hwndMenu, IDM_SORTREVERSE, TRUE);
|
---|
[2] | 1252 | }
|
---|
| 1253 |
|
---|
[231] | 1254 | VOID FcloseFile(FILE * fp)
|
---|
| 1255 | {
|
---|
[397] | 1256 | /* for use by apps that don't use the DLLs runtime library */
|
---|
| 1257 | fclose(fp);
|
---|
[2] | 1258 | }
|
---|
| 1259 |
|
---|
[231] | 1260 | VOID SetupCommandMenu(HWND hwndMenu, HWND hwndCnr)
|
---|
| 1261 | {
|
---|
[397] | 1262 | MENUITEM mi, mit;
|
---|
| 1263 | INT x;
|
---|
| 1264 | SHORT numitems;
|
---|
| 1265 | LINKCMDS *info;
|
---|
[2] | 1266 |
|
---|
[397] | 1267 | if (!cmdloaded)
|
---|
| 1268 | load_commands();
|
---|
| 1269 | mi.iPosition = MIT_END;
|
---|
| 1270 | mi.hwndSubMenu = (HWND) 0;
|
---|
| 1271 | mi.hItem = 0L;
|
---|
| 1272 | mi.afAttribute = 0;
|
---|
| 1273 | mi.afStyle = MIS_TEXT;
|
---|
| 1274 | memset(&mit, 0, sizeof(MENUITEM));
|
---|
| 1275 | if (WinQueryWindowUShort(hwndMenu, QWS_ID) == IDM_COMMANDSMENU)
|
---|
| 1276 | mit.hwndSubMenu = hwndMenu;
|
---|
| 1277 | else
|
---|
| 1278 | WinSendMsg(hwndMenu, MM_QUERYITEM,
|
---|
[1394] | 1279 | MPFROM2SHORT(IDM_COMMANDSMENU, TRUE), MPFROMP(&mit));
|
---|
[397] | 1280 | if (mit.hwndSubMenu) {
|
---|
| 1281 | numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_QUERYITEMCOUNT,
|
---|
[1394] | 1282 | MPVOID, MPVOID);
|
---|
[397] | 1283 | WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, MPFROMSHORT(-1), MPVOID);
|
---|
| 1284 | for (x = 0; x < numitems; x++)
|
---|
| 1285 | WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
|
---|
[1394] | 1286 | MPFROMSHORT((SHORT) (x + IDM_COMMANDSTART)), MPVOID);
|
---|
[397] | 1287 | if (hwndCnr && cmdhead) {
|
---|
| 1288 | x = 0;
|
---|
| 1289 | info = cmdhead;
|
---|
| 1290 | while (info) {
|
---|
[2] | 1291 |
|
---|
[1394] | 1292 | CHAR s[CCHMAXPATH + 24];
|
---|
[2] | 1293 |
|
---|
[1394] | 1294 | sprintf(s,
|
---|
| 1295 | "%s%s%s",
|
---|
| 1296 | info->title,
|
---|
| 1297 | x < 20 ? "\tCtrl + " : NullStr,
|
---|
| 1298 | x < 20 && x > 9 ? "Shift + " : NullStr);
|
---|
| 1299 | if (x < 20)
|
---|
| 1300 | sprintf(&s[strlen(s)], "%d",
|
---|
| 1301 | ((x % 10) + 1) == 10 ? 0 : (x % 10) + 1);
|
---|
| 1302 | mi.id = IDM_COMMANDSTART + x;
|
---|
| 1303 | mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
|
---|
| 1304 | (info->flags & PROMPT ? MIA_FRAMED : 0);
|
---|
| 1305 | mi.afStyle = MIS_TEXT;
|
---|
| 1306 | if (!(x % 24) && x && info->next)
|
---|
| 1307 | mi.afStyle |= MIS_BREAK;
|
---|
| 1308 | WinSendMsg(mit.hwndSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s));
|
---|
| 1309 | x++;
|
---|
| 1310 | info = info->next;
|
---|
[397] | 1311 | }
|
---|
[2] | 1312 | }
|
---|
[397] | 1313 | }
|
---|
[2] | 1314 | }
|
---|
| 1315 |
|
---|
[1394] | 1316 | VOID LoadDetailsSwitches(PCSZ keyroot, DETAILS_SETTINGS * pds)
|
---|
[231] | 1317 | {
|
---|
[397] | 1318 | ULONG size;
|
---|
| 1319 | CHAR s[CCHMAXPATH], *eos = s;
|
---|
[2] | 1320 |
|
---|
[997] | 1321 | strcpy(s, keyroot);
|
---|
| 1322 | strcat(s, ".");
|
---|
| 1323 | eos = &s[strlen(s)];
|
---|
[1065] | 1324 | strcpy(eos, "DetailsLongname");
|
---|
| 1325 | pds->detailslongname = dsDirCnrDefault.detailslongname;
|
---|
[397] | 1326 | size = sizeof(BOOL);
|
---|
[1065] | 1327 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslongname, &size);
|
---|
[1030] | 1328 | strcpy(eos, "DetailsSubject");
|
---|
[1065] | 1329 | pds->detailssubject = dsDirCnrDefault.detailssubject;
|
---|
[397] | 1330 | size = sizeof(BOOL);
|
---|
[1065] | 1331 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssubject, &size);
|
---|
[1030] | 1332 | strcpy(eos, "DetailsEA");
|
---|
[1065] | 1333 | pds->detailsea = dsDirCnrDefault.detailsea;
|
---|
[397] | 1334 | size = sizeof(BOOL);
|
---|
[1065] | 1335 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsea, &size);
|
---|
[1030] | 1336 | strcpy(eos, "DetailsSize");
|
---|
[1065] | 1337 | pds->detailssize = dsDirCnrDefault.detailssize;
|
---|
[397] | 1338 | size = sizeof(BOOL);
|
---|
[1065] | 1339 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailssize, &size);
|
---|
[1030] | 1340 | strcpy(eos, "DetailsIcon");
|
---|
[1065] | 1341 | pds->detailsicon = dsDirCnrDefault.detailsicon;
|
---|
[397] | 1342 | size = sizeof(BOOL);
|
---|
[1065] | 1343 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsicon, &size);
|
---|
[1030] | 1344 | strcpy(eos, "DetailsAttr");
|
---|
[1065] | 1345 | pds->detailsattr = dsDirCnrDefault.detailsattr;
|
---|
[397] | 1346 | size = sizeof(BOOL);
|
---|
[1065] | 1347 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsattr, &size);
|
---|
[1030] | 1348 | strcpy(eos, "DetailsCRDate");
|
---|
[1065] | 1349 | pds->detailscrdate = dsDirCnrDefault.detailscrdate;
|
---|
[397] | 1350 | size = sizeof(BOOL);
|
---|
[1065] | 1351 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrdate, &size);
|
---|
[1030] | 1352 | strcpy(eos, "DetailsCRTime");
|
---|
[1065] | 1353 | pds->detailscrtime = dsDirCnrDefault.detailscrtime;
|
---|
[397] | 1354 | size = sizeof(BOOL);
|
---|
[1065] | 1355 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailscrtime, &size);
|
---|
[1030] | 1356 | strcpy(eos, "DetailsLWDate");
|
---|
[1065] | 1357 | pds->detailslwdate = dsDirCnrDefault.detailslwdate;
|
---|
[397] | 1358 | size = sizeof(BOOL);
|
---|
[1065] | 1359 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwdate, &size);
|
---|
[1030] | 1360 | strcpy(eos, "DetailsLWTime");
|
---|
[1065] | 1361 | pds->detailslwtime = dsDirCnrDefault.detailslwtime;
|
---|
[397] | 1362 | size = sizeof(BOOL);
|
---|
[1065] | 1363 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslwtime, &size);
|
---|
[1030] | 1364 | strcpy(eos, "DetailsLADate");
|
---|
[1065] | 1365 | pds->detailsladate = dsDirCnrDefault.detailsladate;
|
---|
[397] | 1366 | size = sizeof(BOOL);
|
---|
[1065] | 1367 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailsladate, &size);
|
---|
[1030] | 1368 | strcpy(eos, "DetailsLATime");
|
---|
[1065] | 1369 | pds->detailslatime = dsDirCnrDefault.detailslatime;
|
---|
[397] | 1370 | size = sizeof(BOOL);
|
---|
[1065] | 1371 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->detailslatime, &size);
|
---|
[1030] | 1372 | strcpy(eos, "SubjectInLeftPane");
|
---|
[1065] | 1373 | pds->fSubjectInLeftPane = dsDirCnrDefault.fSubjectInLeftPane;
|
---|
[922] | 1374 | size = sizeof(BOOL);
|
---|
[1065] | 1375 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectInLeftPane, &size);
|
---|
[1030] | 1376 | strcpy(eos, "SubjectLengthMax");
|
---|
[1065] | 1377 | pds->fSubjectLengthMax = dsDirCnrDefault.fSubjectLengthMax;
|
---|
[922] | 1378 | size = sizeof(BOOL);
|
---|
[1065] | 1379 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->fSubjectLengthMax, &size);
|
---|
| 1380 | if (pds->fSubjectLengthMax)
|
---|
| 1381 | pds->SubjectDisplayWidth = 0;
|
---|
[922] | 1382 | else {
|
---|
[1065] | 1383 | strcpy(eos, "SubjectDisplayWidth");
|
---|
| 1384 | pds->SubjectDisplayWidth = dsDirCnrDefault.SubjectDisplayWidth;
|
---|
| 1385 | size = sizeof(ULONG);
|
---|
| 1386 | PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->SubjectDisplayWidth, &size);
|
---|
| 1387 | if (pds->SubjectDisplayWidth < 50)
|
---|
| 1388 | pds->SubjectDisplayWidth = 0;
|
---|
| 1389 | else if (pds->SubjectDisplayWidth > 1000)
|
---|
| 1390 | pds->SubjectDisplayWidth = 1000;
|
---|
[922] | 1391 | }
|
---|
[2] | 1392 | }
|
---|
| 1393 |
|
---|
[231] | 1394 | HWND FindDirCnr(HWND hwndParent)
|
---|
| 1395 | {
|
---|
[397] | 1396 | HWND found, hwndDir = (HWND) 0;
|
---|
| 1397 | HENUM henum;
|
---|
[2] | 1398 |
|
---|
[397] | 1399 | henum = WinBeginEnumWindows(hwndParent);
|
---|
| 1400 | while ((found = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 1401 | hwndDir = WinWindowFromID(found, FID_CLIENT);
|
---|
| 1402 | if (hwndDir) {
|
---|
| 1403 | hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
|
---|
| 1404 | if (hwndDir)
|
---|
[1394] | 1405 | break;
|
---|
[397] | 1406 | hwndDir = (HWND) 0;
|
---|
[2] | 1407 | }
|
---|
[397] | 1408 | }
|
---|
| 1409 | WinEndEnumWindows(henum);
|
---|
[2] | 1410 |
|
---|
[397] | 1411 | return hwndDir;
|
---|
[2] | 1412 | }
|
---|
| 1413 |
|
---|
[231] | 1414 | VOID HeapThread(VOID * dummy)
|
---|
| 1415 | {
|
---|
[397] | 1416 | ULONG postcount;
|
---|
| 1417 | APIRET rc;
|
---|
[2] | 1418 |
|
---|
[397] | 1419 | rc = DosCreateEventSem(NULL, &CompactSem, 0L, FALSE);
|
---|
| 1420 | if (rc)
|
---|
| 1421 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1394] | 1422 | "DosCreateEventSem");
|
---|
[397] | 1423 | else {
|
---|
| 1424 | priority_normal();
|
---|
| 1425 | for (;;) {
|
---|
| 1426 | if (DosWaitEventSem(CompactSem, SEM_INDEFINITE_WAIT))
|
---|
[1394] | 1427 | break;
|
---|
[397] | 1428 | _heapmin();
|
---|
| 1429 | DosResetEventSem(CompactSem, &postcount);
|
---|
[2] | 1430 | }
|
---|
[397] | 1431 | }
|
---|
[2] | 1432 | }
|
---|
| 1433 |
|
---|
[1394] | 1434 | VOID FixSwitchList(HWND hwnd, PCSZ text)
|
---|
[231] | 1435 | {
|
---|
[397] | 1436 | HSWITCH hswitch;
|
---|
| 1437 | SWCNTRL swctl;
|
---|
[2] | 1438 |
|
---|
[397] | 1439 | hswitch = WinQuerySwitchHandle(hwnd, 0);
|
---|
| 1440 | if (hswitch) {
|
---|
| 1441 | if (!WinQuerySwitchEntry(hswitch, &swctl)) {
|
---|
| 1442 | strcpy(swctl.szSwtitle, "FM/2");
|
---|
| 1443 | WinChangeSwitchEntry(hswitch, &swctl);
|
---|
[2] | 1444 | }
|
---|
[397] | 1445 | }
|
---|
[2] | 1446 | }
|
---|
| 1447 |
|
---|
[231] | 1448 | VOID QuickPopup(HWND hwnd, DIRCNRDATA * dcd, HWND hwndMenu, USHORT id)
|
---|
| 1449 | {
|
---|
[397] | 1450 | dcd->hwndLastMenu = hwndMenu;
|
---|
| 1451 | if (dcd->hwndLastMenu && !dcd->cnremphasized) {
|
---|
| 1452 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
[1394] | 1453 | MPFROM2SHORT(TRUE, CRA_SOURCE));
|
---|
[397] | 1454 | dcd->cnremphasized = TRUE;
|
---|
| 1455 | }
|
---|
| 1456 | if (dcd->flWindowAttr & CV_MINI)
|
---|
| 1457 | WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
|
---|
| 1458 | if (!WinPopupMenu(hwnd, hwnd, dcd->hwndLastMenu,
|
---|
[1394] | 1459 | 8, 8, 0,
|
---|
| 1460 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
| 1461 | PU_KEYBOARD | PU_MOUSEBUTTON1)) {
|
---|
[397] | 1462 | if (dcd->cnremphasized) {
|
---|
| 1463 | WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
|
---|
[1394] | 1464 | MPFROM2SHORT(FALSE, CRA_SOURCE));
|
---|
[397] | 1465 | dcd->cnremphasized = FALSE;
|
---|
[2] | 1466 | }
|
---|
[397] | 1467 | }
|
---|
| 1468 | else
|
---|
| 1469 | WinSendMsg(dcd->hwndLastMenu, MM_SELECTITEM,
|
---|
[1394] | 1470 | MPFROM2SHORT(id, TRUE), MPFROM2SHORT(0, FALSE));
|
---|
[2] | 1471 | }
|
---|
| 1472 |
|
---|
[231] | 1473 | PMINIRECORDCORE CurrentRecord(HWND hwndCnr)
|
---|
| 1474 | {
|
---|
[787] | 1475 | SHORT attrib = fSelectedAlways ? CRA_SELECTED : CRA_CURSORED;
|
---|
[397] | 1476 | PMINIRECORDCORE pmi;
|
---|
[2] | 1477 |
|
---|
[397] | 1478 | for (;;) {
|
---|
| 1479 | pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS,
|
---|
[1394] | 1480 | MPFROMLONG(CMA_FIRST),
|
---|
| 1481 | MPFROMSHORT(attrib));
|
---|
[930] | 1482 | if ((!pmi || (INT) pmi == -1) && attrib == CRA_SELECTED) /* punt */
|
---|
[397] | 1483 | attrib = CRA_CURSORED;
|
---|
| 1484 | else
|
---|
| 1485 | break;
|
---|
| 1486 | }
|
---|
[787] | 1487 | return ((INT)pmi == -1) ? NULL : pmi;
|
---|
[2] | 1488 | }
|
---|
| 1489 |
|
---|
[231] | 1490 | BOOL PostMsg(HWND h, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1491 | {
|
---|
[397] | 1492 | BOOL rc = WinPostMsg(h, msg, mp1, mp2);
|
---|
[2] | 1493 |
|
---|
[397] | 1494 | if (!rc) {
|
---|
[2] | 1495 |
|
---|
[882] | 1496 | // If window owned by some other process or some other thread?
|
---|
| 1497 | if (!IsFm2Window(h, 1)) {
|
---|
| 1498 | QMSG qmsg;
|
---|
| 1499 | for (;;) {
|
---|
[1394] | 1500 | DosSleep(1);
|
---|
| 1501 | rc = WinPostMsg(h, msg, mp1, mp2);
|
---|
| 1502 | if (rc)
|
---|
| 1503 | break; // OK
|
---|
| 1504 | if (!WinIsWindow((HAB) 0, h))
|
---|
| 1505 | break; // Window gone
|
---|
| 1506 | if (WinPeekMsg((HAB) 0, &qmsg, (HWND) 0, 0, 0, PM_NOREMOVE))
|
---|
| 1507 | break; // Queue has message(s)
|
---|
[1159] | 1508 | } // for
|
---|
[2] | 1509 | }
|
---|
[882] | 1510 | }
|
---|
[397] | 1511 | return rc;
|
---|
[2] | 1512 | }
|
---|
| 1513 |
|
---|
[231] | 1514 | VOID OpenEdit(HWND hwnd)
|
---|
| 1515 | {
|
---|
[397] | 1516 | CNREDITDATA ced;
|
---|
| 1517 | PCNRITEM pci;
|
---|
| 1518 | PFIELDINFO pfi;
|
---|
[2] | 1519 |
|
---|
[397] | 1520 | pci = (PCNRITEM) WinSendMsg(hwnd,
|
---|
[1394] | 1521 | CM_QUERYRECORDEMPHASIS,
|
---|
| 1522 | MPFROMLONG(CMA_FIRST),
|
---|
| 1523 | MPFROMSHORT(CRA_CURSORED));
|
---|
[397] | 1524 | if (pci && (INT) pci != -1) {
|
---|
| 1525 | memset(&ced, 0, sizeof(ced));
|
---|
| 1526 | ced.cb = sizeof(ced);
|
---|
| 1527 | ced.hwndCnr = hwnd;
|
---|
| 1528 | ced.id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
| 1529 | ced.pRecord = (PRECORDCORE) pci;
|
---|
| 1530 | pfi = (PFIELDINFO) WinSendMsg(hwnd,
|
---|
[1394] | 1531 | CM_QUERYDETAILFIELDINFO,
|
---|
| 1532 | MPVOID, MPFROMSHORT(CMA_FIRST));
|
---|
[397] | 1533 | if (!pfi)
|
---|
| 1534 | WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
|
---|
| 1535 | else {
|
---|
| 1536 | while (pfi && (INT) pfi != -1 &&
|
---|
[1394] | 1537 | pfi->offStruct != FIELDOFFSET(CNRITEM, pszFileName))
|
---|
| 1538 | pfi = (PFIELDINFO) WinSendMsg(hwnd,
|
---|
| 1539 | CM_QUERYDETAILFIELDINFO,
|
---|
| 1540 | MPFROMP(pfi), MPFROMSHORT(CMA_NEXT));
|
---|
[397] | 1541 | if (pfi && (INT) pfi != -1) {
|
---|
[1394] | 1542 | ced.pFieldInfo = pfi;
|
---|
| 1543 | {
|
---|
| 1544 | CNRINFO cnri;
|
---|
[2] | 1545 |
|
---|
[1394] | 1546 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
| 1547 | cnri.cb = sizeof(CNRINFO);
|
---|
| 1548 | WinSendMsg(hwnd,
|
---|
| 1549 | CM_QUERYCNRINFO,
|
---|
| 1550 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
| 1551 | if (cnri.flWindowAttr & CV_DETAIL)
|
---|
| 1552 | ced.id = CID_LEFTDVWND;
|
---|
| 1553 | }
|
---|
| 1554 | WinSendMsg(hwnd, CM_OPENEDIT, MPFROMP(&ced), MPVOID);
|
---|
[397] | 1555 | }
|
---|
[2] | 1556 | }
|
---|
[397] | 1557 | }
|
---|
[2] | 1558 | }
|
---|
| 1559 |
|
---|
| 1560 | #ifdef NEVER
|
---|
[1394] | 1561 | VOID QuickView(HWND hwnd, PCSZ filename)
|
---|
[231] | 1562 | {
|
---|
[397] | 1563 | if (filename && IsFile(filename) == 1) {
|
---|
| 1564 | if (TestBinary(filename) && *binview) {
|
---|
[2] | 1565 |
|
---|
[397] | 1566 | CHAR *list[2];
|
---|
[2] | 1567 |
|
---|
[397] | 1568 | list[0] = filename;
|
---|
| 1569 | list[1] = NULL;
|
---|
[888] | 1570 | ExecOnList(hwnd, binview, WINDOWED | SEPARATE, NULL, list, NULL,
|
---|
[1394] | 1571 | pszSrcFile, __LINE__);
|
---|
[397] | 1572 | return;
|
---|
| 1573 | }
|
---|
| 1574 | else if (*viewer) {
|
---|
[2] | 1575 |
|
---|
[397] | 1576 | CHAR *list[2];
|
---|
[2] | 1577 |
|
---|
[397] | 1578 | list[0] = filename;
|
---|
| 1579 | list[1] = NULL;
|
---|
[787] | 1580 | ExecOnList(hwnd, viewer,
|
---|
[1394] | 1581 | WINDOWED | SEPARATE | (fViewChild ? CHILD : 0),
|
---|
| 1582 | NULL, list, NULL, pszSrcFile, __LINE__);
|
---|
[397] | 1583 | return;
|
---|
[2] | 1584 | }
|
---|
[397] | 1585 | StartMLEEditor(HWND_DESKTOP, 5, filename, (HWND) 0);
|
---|
| 1586 | }
|
---|
[2] | 1587 | }
|
---|
| 1588 |
|
---|
[231] | 1589 | VOID QuickEdit(HWND hwnd, CHAR * filename)
|
---|
| 1590 | {
|
---|
[397] | 1591 | if (filename && IsFile(filename) == 1) {
|
---|
| 1592 | if (TestBinary(filename) && *bined) {
|
---|
[2] | 1593 |
|
---|
[397] | 1594 | CHAR *list[2];
|
---|
[2] | 1595 |
|
---|
[397] | 1596 | list[0] = filename;
|
---|
| 1597 | list[1] = NULL;
|
---|
[888] | 1598 | ExecOnList(hwnd, bined, WINDOWED | SEPARATE, NULL, list, NULL,
|
---|
[1394] | 1599 | pszSrcFile, __LINE__);
|
---|
[397] | 1600 | return;
|
---|
| 1601 | }
|
---|
| 1602 | else if (*editor) {
|
---|
[2] | 1603 |
|
---|
[397] | 1604 | CHAR *list[2];
|
---|
[2] | 1605 |
|
---|
[397] | 1606 | list[0] = filename;
|
---|
| 1607 | list[1] = NULL;
|
---|
[888] | 1608 | ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, list, NULL,
|
---|
[1394] | 1609 | pszSrcFile, __LINE__);
|
---|
[397] | 1610 | return;
|
---|
[2] | 1611 | }
|
---|
[397] | 1612 | StartMLEEditor(HWND_DESKTOP, 4, filename, (HWND) 0);
|
---|
| 1613 | }
|
---|
[2] | 1614 | }
|
---|
| 1615 | #endif
|
---|
| 1616 |
|
---|
[231] | 1617 | VOID PortholeInit(HWND hwndNew, MPARAM mp1, MPARAM mp2)
|
---|
| 1618 | {
|
---|
[397] | 1619 | static HWND DefMenu = (HWND) 0;
|
---|
| 1620 | HWND hwndMenu = (HWND) mp2;
|
---|
[2] | 1621 |
|
---|
[397] | 1622 | {
|
---|
| 1623 | ULONG style;
|
---|
| 1624 |
|
---|
| 1625 | style = WinQueryWindowULong(hwndMenu, QWL_STYLE);
|
---|
| 1626 | if (!(style & MS_ACTIONBAR))
|
---|
| 1627 | return;
|
---|
| 1628 | }
|
---|
| 1629 |
|
---|
| 1630 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1631 | case 0:
|
---|
[231] | 1632 | {
|
---|
[397] | 1633 | HWND hwndNow;
|
---|
| 1634 | MENUITEM mi;
|
---|
| 1635 | ULONG ulStyle;
|
---|
[2] | 1636 |
|
---|
[397] | 1637 | memset(&mi, 0, sizeof(mi));
|
---|
| 1638 | mi.iPosition = MIT_END;
|
---|
| 1639 | mi.afStyle = MIS_TEXT;
|
---|
| 1640 | WinSendMsg(hwndMenu, MM_QUERYITEM,
|
---|
[1394] | 1641 | MPFROM2SHORT(IDM_FILESMENU, TRUE), MPFROMP(&mi));
|
---|
[397] | 1642 | if (!DefMenu)
|
---|
[1394] | 1643 | DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
|
---|
[397] | 1644 | hwndNow = mi.hwndSubMenu;
|
---|
| 1645 | mi.hwndSubMenu = hwndNew;
|
---|
| 1646 | if (!mi.hwndSubMenu)
|
---|
[1394] | 1647 | mi.hwndSubMenu = DefMenu;
|
---|
[397] | 1648 | WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
|
---|
| 1649 | WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
|
---|
| 1650 | WinSetOwner(mi.hwndSubMenu, hwndMenu);
|
---|
| 1651 | WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
|
---|
| 1652 | WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1653 | mi.afStyle = MIS_SUBMENU;
|
---|
| 1654 | ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
|
---|
| 1655 | ulStyle &= -WS_SAVEBITS;
|
---|
| 1656 | ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
|
---|
| 1657 | WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
|
---|
| 1658 | WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
|
---|
[231] | 1659 | }
|
---|
[397] | 1660 | break;
|
---|
[2] | 1661 |
|
---|
[397] | 1662 | case 1:
|
---|
[231] | 1663 | {
|
---|
[397] | 1664 | HWND hwndNow;
|
---|
| 1665 | MENUITEM mi;
|
---|
| 1666 | ULONG ulStyle;
|
---|
[2] | 1667 |
|
---|
[397] | 1668 | memset(&mi, 0, sizeof(mi));
|
---|
| 1669 | mi.iPosition = MIT_END;
|
---|
| 1670 | mi.afStyle = MIS_TEXT;
|
---|
| 1671 | WinSendMsg(hwndMenu, MM_QUERYITEM,
|
---|
[1394] | 1672 | MPFROM2SHORT(IDM_VIEWSMENU, TRUE), MPFROMP(&mi));
|
---|
[397] | 1673 | if (!DefMenu)
|
---|
[1394] | 1674 | DefMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, DEFMENU);
|
---|
[397] | 1675 | hwndNow = mi.hwndSubMenu;
|
---|
| 1676 | mi.hwndSubMenu = hwndNew;
|
---|
| 1677 | if (!mi.hwndSubMenu)
|
---|
[1394] | 1678 | mi.hwndSubMenu = DefMenu;
|
---|
[397] | 1679 | WinSetParent(hwndNow, WinQueryObjectWindow(HWND_DESKTOP), FALSE);
|
---|
| 1680 | WinSetOwner(hwndNow, WinQueryObjectWindow(HWND_DESKTOP));
|
---|
| 1681 | WinSetOwner(mi.hwndSubMenu, hwndMenu);
|
---|
| 1682 | WinSetParent(mi.hwndSubMenu, hwndMenu, FALSE);
|
---|
| 1683 | WinSetWindowUShort(mi.hwndSubMenu, QWS_ID, IDM_VIEWSMENU);
|
---|
| 1684 | mi.afStyle = MIS_SUBMENU;
|
---|
| 1685 | ulStyle = WinQueryWindowULong(mi.hwndSubMenu, QWL_STYLE);
|
---|
| 1686 | ulStyle &= -WS_SAVEBITS;
|
---|
| 1687 | ulStyle |= MS_POPUP | WS_CLIPSIBLINGS | WS_SAVEBITS;
|
---|
| 1688 | WinSetWindowULong(mi.hwndSubMenu, QWL_STYLE, ulStyle);
|
---|
| 1689 | WinSendMsg(hwndMenu, MM_SETITEM, MPFROM2SHORT(0, TRUE), MPFROMP(&mi));
|
---|
[231] | 1690 | }
|
---|
[397] | 1691 | break;
|
---|
| 1692 | }
|
---|
[2] | 1693 | }
|
---|
| 1694 |
|
---|
[872] | 1695 | HWND CheckMenu(HWND hwnd, HWND * hwndMenu, USHORT id)
|
---|
[231] | 1696 | {
|
---|
[397] | 1697 | /* load and adjust menus as required */
|
---|
| 1698 | if (!*hwndMenu || !WinIsWindow((HAB) 0, *hwndMenu)) {
|
---|
| 1699 | *hwndMenu = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
---|
[877] | 1700 | CopyPresParams(*hwndMenu, hwnd);
|
---|
[397] | 1701 | if (hwndMenu == &DirMenu) {
|
---|
| 1702 | WinSetWindowUShort(DirMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1703 | SetConditionalCascade(DirMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
|
---|
| 1704 | SetConditionalCascade(DirMenu, IDM_COPYMENU, IDM_COPY);
|
---|
| 1705 | SetConditionalCascade(DirMenu, IDM_MOVEMENU, IDM_MOVE);
|
---|
| 1706 | SetConditionalCascade(DirMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
|
---|
| 1707 | SetConditionalCascade(DirMenu, IDM_VIEWSUBMENU, IDM_INFO);
|
---|
| 1708 | SetConditionalCascade(DirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
|
---|
| 1709 | SetConditionalCascade(DirMenu, IDM_DELETESUBMENU,
|
---|
[1394] | 1710 | fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
|
---|
[397] | 1711 | SetConditionalCascade(DirMenu, IDM_MISCSUBMENU, IDM_SIZES);
|
---|
| 1712 | SetConditionalCascade(DirMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
|
---|
| 1713 | if (fWorkPlace) {
|
---|
[1394] | 1714 | WinSendMsg(DirMenu, MM_DELETEITEM,
|
---|
| 1715 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
| 1716 | WinSendMsg(DirMenu, MM_DELETEITEM,
|
---|
| 1717 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1718 | }
|
---|
[2] | 1719 | }
|
---|
[397] | 1720 | else if (hwndMenu == &TreeMenu) {
|
---|
| 1721 | WinSetWindowUShort(TreeMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1722 | SetConditionalCascade(TreeMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
|
---|
| 1723 | SetConditionalCascade(TreeMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
|
---|
| 1724 | SetConditionalCascade(TreeMenu, IDM_EDITSUBMENU, IDM_ATTRS);
|
---|
| 1725 | SetConditionalCascade(TreeMenu, IDM_EXPANDSUBMENU, IDM_EXPAND);
|
---|
| 1726 | SetConditionalCascade(TreeMenu, IDM_MISCSUBMENU, IDM_SIZES);
|
---|
| 1727 | SetConditionalCascade(TreeMenu, IDM_OPENSUBMENU, IDM_OPENWINDOW);
|
---|
| 1728 | if (fWorkPlace) {
|
---|
[1394] | 1729 | WinSendMsg(TreeMenu, MM_DELETEITEM,
|
---|
| 1730 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
| 1731 | WinSendMsg(TreeMenu, MM_DELETEITEM,
|
---|
| 1732 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1733 | }
|
---|
[1360] | 1734 | if (!fLVM)
|
---|
[1394] | 1735 | WinSendMsg(TreeMenu, MM_DELETEITEM,
|
---|
| 1736 | MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
|
---|
[397] | 1737 | }
|
---|
| 1738 | else if (hwndMenu == &ArcMenu) {
|
---|
| 1739 | WinSetWindowUShort(ArcMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1740 | SetConditionalCascade(ArcMenu, IDM_EXTRACTSUBMENU, IDM_EXTRACT);
|
---|
| 1741 | SetConditionalCascade(ArcMenu, IDM_EDITSUBMENU, IDM_EDIT);
|
---|
| 1742 | SetConditionalCascade(ArcMenu, IDM_VIEWSUBMENU, IDM_VIEW);
|
---|
| 1743 | if (fWorkPlace)
|
---|
[1394] | 1744 | WinSendMsg(ArcMenu, MM_DELETEITEM,
|
---|
| 1745 | MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
|
---|
[397] | 1746 | }
|
---|
| 1747 | else if (hwndMenu == &FileMenu) {
|
---|
| 1748 | WinSetWindowUShort(FileMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1749 | SetConditionalCascade(FileMenu, IDM_COMMANDSMENU, IDM_DOITYOURSELF);
|
---|
| 1750 | SetConditionalCascade(FileMenu, IDM_COPYMENU, IDM_COPY);
|
---|
| 1751 | SetConditionalCascade(FileMenu, IDM_MOVEMENU, IDM_MOVE);
|
---|
| 1752 | SetConditionalCascade(FileMenu, IDM_SAVESUBMENU, IDM_SAVETOCLIP);
|
---|
| 1753 | SetConditionalCascade(FileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
|
---|
| 1754 | SetConditionalCascade(FileMenu, IDM_EDITSUBMENU, IDM_EDIT);
|
---|
| 1755 | SetConditionalCascade(FileMenu, IDM_COLLECTMENU, IDM_COLLECT);
|
---|
| 1756 | SetConditionalCascade(FileMenu, IDM_DELETESUBMENU,
|
---|
[1394] | 1757 | fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
|
---|
[397] | 1758 | SetConditionalCascade(FileMenu, IDM_OPENSUBMENU, IDM_OPENDEFAULT);
|
---|
| 1759 | SetConditionalCascade(FileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
|
---|
| 1760 | if (fWorkPlace) {
|
---|
[1394] | 1761 | WinSendMsg(FileMenu, MM_DELETEITEM,
|
---|
| 1762 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
| 1763 | WinSendMsg(FileMenu, MM_DELETEITEM,
|
---|
| 1764 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1765 | }
|
---|
[1360] | 1766 | if (!fLVM)
|
---|
[1394] | 1767 | WinSendMsg(FileMenu, MM_DELETEITEM,
|
---|
| 1768 | MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
|
---|
[397] | 1769 | }
|
---|
| 1770 | else if (hwndMenu == &DirCnrMenu) {
|
---|
| 1771 | WinSetWindowUShort(DirCnrMenu, QWS_ID, IDM_VIEWSMENU);
|
---|
| 1772 | SetConditionalCascade(DirCnrMenu, IDM_MISCSUBMENU, IDM_SIZES);
|
---|
| 1773 | SetConditionalCascade(DirCnrMenu, IDM_OPENSUBMENU, IDM_OPENSETTINGSME);
|
---|
| 1774 | if (fWorkPlace)
|
---|
[1394] | 1775 | WinSendMsg(DirCnrMenu, MM_DELETEITEM,
|
---|
| 1776 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1777 | }
|
---|
[489] | 1778 | else if (hwndMenu == &TreeCnrMenu) {
|
---|
[397] | 1779 | WinSetWindowUShort(TreeCnrMenu, QWS_ID, IDM_VIEWSMENU);
|
---|
[1360] | 1780 | if (!fLVM)
|
---|
[1394] | 1781 | WinSendMsg(TreeCnrMenu, MM_DELETEITEM,
|
---|
| 1782 | MPFROM2SHORT(IDM_REFRESHREMOVABLES, TRUE), MPVOID);
|
---|
[468] | 1783 | }
|
---|
[397] | 1784 | else if (hwndMenu == &ArcCnrMenu) {
|
---|
| 1785 | WinSetWindowUShort(ArcCnrMenu, QWS_ID, IDM_VIEWSMENU);
|
---|
| 1786 | SetConditionalCascade(ArcCnrMenu, IDM_EXTRACTSUBMENU, IDM_ARCEXTRACT);
|
---|
| 1787 | if (fWorkPlace)
|
---|
[1394] | 1788 | WinSendMsg(ArcCnrMenu, MM_DELETEITEM,
|
---|
| 1789 | MPFROM2SHORT(IDM_FOLDERAFTEREXTRACT, TRUE), MPVOID);
|
---|
[397] | 1790 | }
|
---|
| 1791 | else if (hwndMenu == &CollectorCnrMenu) {
|
---|
| 1792 | WinSetWindowUShort(CollectorCnrMenu, QWS_ID, IDM_VIEWSMENU);
|
---|
| 1793 | SetConditionalCascade(CollectorCnrMenu, IDM_COLLECTMENU,
|
---|
[1394] | 1794 | IDM_COLLECTFROMCLIP);
|
---|
[397] | 1795 | }
|
---|
| 1796 | else if (hwndMenu == &CollectorFileMenu) {
|
---|
| 1797 | WinSetWindowUShort(CollectorFileMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1798 | SetConditionalCascade(CollectorFileMenu, IDM_COMMANDSMENU,
|
---|
[1394] | 1799 | IDM_DOITYOURSELF);
|
---|
[397] | 1800 | SetConditionalCascade(CollectorFileMenu, IDM_COPYMENU, IDM_COPY);
|
---|
| 1801 | SetConditionalCascade(CollectorFileMenu, IDM_MOVEMENU, IDM_MOVE);
|
---|
| 1802 | SetConditionalCascade(CollectorFileMenu, IDM_SAVESUBMENU,
|
---|
[1394] | 1803 | IDM_SAVETOCLIP);
|
---|
[397] | 1804 | SetConditionalCascade(CollectorFileMenu, IDM_VIEWSUBMENU, IDM_VIEW);
|
---|
| 1805 | SetConditionalCascade(CollectorFileMenu, IDM_EDITSUBMENU, IDM_EDIT);
|
---|
| 1806 | SetConditionalCascade(CollectorFileMenu, IDM_DELETESUBMENU,
|
---|
[1394] | 1807 | fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
|
---|
[397] | 1808 | SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU,
|
---|
[1394] | 1809 | IDM_OPENDEFAULT);
|
---|
[397] | 1810 | SetConditionalCascade(CollectorFileMenu, IDM_OBJECTSUBMENU, IDM_SHADOW);
|
---|
| 1811 | if (fWorkPlace) {
|
---|
[1394] | 1812 | WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
|
---|
| 1813 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
| 1814 | WinSendMsg(CollectorFileMenu, MM_DELETEITEM,
|
---|
| 1815 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1816 | }
|
---|
| 1817 | }
|
---|
| 1818 | else if (hwndMenu == &CollectorDirMenu) {
|
---|
| 1819 | WinSetWindowUShort(CollectorDirMenu, QWS_ID, IDM_FILESMENU);
|
---|
| 1820 | SetConditionalCascade(CollectorDirMenu, IDM_COMMANDSMENU,
|
---|
[1394] | 1821 | IDM_DOITYOURSELF);
|
---|
[397] | 1822 | SetConditionalCascade(CollectorDirMenu, IDM_COPYMENU, IDM_COPY);
|
---|
| 1823 | SetConditionalCascade(CollectorDirMenu, IDM_MOVEMENU, IDM_MOVE);
|
---|
| 1824 | SetConditionalCascade(CollectorDirMenu, IDM_SAVESUBMENU,
|
---|
[1394] | 1825 | IDM_SAVETOCLIP);
|
---|
[397] | 1826 | SetConditionalCascade(CollectorDirMenu, IDM_VIEWSUBMENU, IDM_INFO);
|
---|
| 1827 | SetConditionalCascade(CollectorDirMenu, IDM_EDITSUBMENU, IDM_ATTRS);
|
---|
| 1828 | SetConditionalCascade(CollectorDirMenu, IDM_DELETESUBMENU,
|
---|
[1394] | 1829 | fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE);
|
---|
[397] | 1830 | SetConditionalCascade(CollectorDirMenu, IDM_MISCSUBMENU, IDM_SIZES);
|
---|
| 1831 | SetConditionalCascade(CollectorDirMenu, IDM_OPENSUBMENU,
|
---|
[1394] | 1832 | IDM_OPENWINDOW);
|
---|
[397] | 1833 | if (fWorkPlace) {
|
---|
[1394] | 1834 | WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
|
---|
| 1835 | MPFROM2SHORT(IDM_OPENSUBMENU, TRUE), MPVOID);
|
---|
| 1836 | WinSendMsg(CollectorDirMenu, MM_DELETEITEM,
|
---|
| 1837 | MPFROM2SHORT(IDM_OBJECTSUBMENU, TRUE), MPVOID);
|
---|
[397] | 1838 | }
|
---|
| 1839 | }
|
---|
| 1840 | else if (hwndMenu == &MainPopupMenu) {
|
---|
| 1841 | WinSetWindowUShort(MainPopupMenu, QWS_ID, IDM_MAINPOPUP);
|
---|
| 1842 | SetConditionalCascade(MainPopupMenu, IDM_TOOLSUBMENU, IDM_TOOLBAR);
|
---|
| 1843 | SetConditionalCascade(MainPopupMenu, IDM_AUTOVIEWSUBMENU, IDM_AUTOVIEW);
|
---|
| 1844 | }
|
---|
| 1845 | }
|
---|
[877] | 1846 | CopyPresParams(*hwndMenu, hwnd);
|
---|
[397] | 1847 | return *hwndMenu;
|
---|
[2] | 1848 | }
|
---|
| 1849 |
|
---|
[1394] | 1850 | SHORT AddToListboxBottom(HWND hwnd, PCSZ str)
|
---|
[231] | 1851 | {
|
---|
[397] | 1852 | SHORT ln;
|
---|
[2] | 1853 |
|
---|
[397] | 1854 | ln = (SHORT) WinSendMsg(hwnd, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
|
---|
[1394] | 1855 | MPFROMP(str));
|
---|
[397] | 1856 | if (ln)
|
---|
| 1857 | WinSendMsg(hwnd, LM_SELECTITEM, MPFROM2SHORT(ln, 0), MPVOID);
|
---|
| 1858 | return ln;
|
---|
[2] | 1859 | }
|
---|
| 1860 |
|
---|
[231] | 1861 | VOID SetSysMenu(HWND hwndSysMenu)
|
---|
| 1862 | {
|
---|
[397] | 1863 | CHAR s[128], *p;
|
---|
[2] | 1864 |
|
---|
[397] | 1865 | if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
|
---|
[1394] | 1866 | MPFROM2SHORT(SC_RESTORE, 128), MPFROMP(s))) {
|
---|
[397] | 1867 | p = strchr(s, '\t');
|
---|
| 1868 | if (p) {
|
---|
| 1869 | p++;
|
---|
| 1870 | strcpy(p, "Ctrl+Alt+F5");
|
---|
| 1871 | WinSetMenuItemText(hwndSysMenu, SC_RESTORE, s);
|
---|
[2] | 1872 | }
|
---|
[397] | 1873 | }
|
---|
| 1874 | if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
|
---|
[1394] | 1875 | MPFROM2SHORT(SC_CLOSE, 128), MPFROMP(s))) {
|
---|
[397] | 1876 | p = strchr(s, '\t');
|
---|
| 1877 | if (p) {
|
---|
| 1878 | p++;
|
---|
| 1879 | strcpy(p, "Ctrl+Alt+F4");
|
---|
| 1880 | WinSetMenuItemText(hwndSysMenu, SC_CLOSE, s);
|
---|
[2] | 1881 | }
|
---|
[397] | 1882 | }
|
---|
| 1883 | if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
|
---|
[1394] | 1884 | MPFROM2SHORT(SC_MOVE, 128), MPFROMP(s))) {
|
---|
[397] | 1885 | p = strchr(s, '\t');
|
---|
| 1886 | if (p) {
|
---|
| 1887 | p++;
|
---|
| 1888 | strcpy(p, "Ctrl+Alt+F7");
|
---|
| 1889 | WinSetMenuItemText(hwndSysMenu, SC_MOVE, s);
|
---|
[2] | 1890 | }
|
---|
[397] | 1891 | }
|
---|
| 1892 | if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
|
---|
[1394] | 1893 | MPFROM2SHORT(SC_SIZE, 128), MPFROMP(s))) {
|
---|
[397] | 1894 | p = strchr(s, '\t');
|
---|
| 1895 | if (p) {
|
---|
| 1896 | p++;
|
---|
| 1897 | strcpy(p, "Ctrl+Alt+F8");
|
---|
| 1898 | WinSetMenuItemText(hwndSysMenu, SC_SIZE, s);
|
---|
[2] | 1899 | }
|
---|
[397] | 1900 | }
|
---|
| 1901 | if (WinSendMsg(hwndSysMenu, MM_QUERYITEMTEXT,
|
---|
[1394] | 1902 | MPFROM2SHORT(SC_MINIMIZE, 128), MPFROMP(s))) {
|
---|
[397] | 1903 | p = strchr(s, '\t');
|
---|
| 1904 | if (p) {
|
---|
| 1905 | p++;
|
---|
| 1906 | strcpy(p, "Ctrl+Alt+F9");
|
---|
| 1907 | WinSetMenuItemText(hwndSysMenu, SC_MINIMIZE, s);
|
---|
[2] | 1908 | }
|
---|
[397] | 1909 | }
|
---|
| 1910 | if (WinSendMsg(hwndSysMenu,
|
---|
[1394] | 1911 | MM_QUERYITEMTEXT,
|
---|
| 1912 | MPFROM2SHORT(SC_MAXIMIZE, 128), MPFROMP(s))) {
|
---|
[397] | 1913 | p = strchr(s, '\t');
|
---|
| 1914 | if (p) {
|
---|
| 1915 | p++;
|
---|
| 1916 | strcpy(p, "Ctrl+Alt+F10");
|
---|
| 1917 | WinSetMenuItemText(hwndSysMenu, SC_MAXIMIZE, s);
|
---|
[2] | 1918 | }
|
---|
[397] | 1919 | }
|
---|
| 1920 | if (WinSendMsg(hwndSysMenu,
|
---|
[1394] | 1921 | MM_QUERYITEMTEXT, MPFROM2SHORT(SC_HIDE, 128), MPFROMP(s))) {
|
---|
[397] | 1922 | p = strchr(s, '\t');
|
---|
| 1923 | if (p) {
|
---|
| 1924 | p++;
|
---|
| 1925 | strcpy(p, "Ctrl+Alt+F11");
|
---|
| 1926 | WinSetMenuItemText(hwndSysMenu, SC_HIDE, s);
|
---|
[2] | 1927 | }
|
---|
[397] | 1928 | }
|
---|
[2] | 1929 | }
|
---|
| 1930 |
|
---|
[1394] | 1931 | VOID LoadLibPath(PSZ str, LONG len)
|
---|
[231] | 1932 | {
|
---|
[397] | 1933 | ULONG ver[2];
|
---|
| 1934 | CHAR configsys[] = "C:\\CONFIG.SYS";
|
---|
| 1935 | static CHAR var[8192], beg[16384], end[16384];
|
---|
| 1936 | BOOL warp;
|
---|
| 1937 | FILE *fp;
|
---|
| 1938 | PFN DQELIBPATH = NULL;
|
---|
| 1939 | HMODULE hmod;
|
---|
[2] | 1940 |
|
---|
[397] | 1941 | if (str && len) {
|
---|
| 1942 | *str = 0;
|
---|
| 1943 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
[1394] | 1944 | QSV_BOOT_DRIVE, (PVOID) ver, (ULONG) sizeof(ULONG)))
|
---|
[397] | 1945 | ver[0] = 3L;
|
---|
| 1946 | *configsys = (CHAR) ver[0] + '@';
|
---|
| 1947 | if (!DosQuerySysInfo(QSV_VERSION_MAJOR,
|
---|
[1394] | 1948 | QSV_VERSION_MINOR,
|
---|
| 1949 | (PVOID) ver, (ULONG) sizeof(ver)) && ver[1] >= 30)
|
---|
[397] | 1950 | warp = TRUE;
|
---|
| 1951 | *var = *beg = *end = 0;
|
---|
| 1952 | if (warp) {
|
---|
| 1953 | if (!DosLoadModule(var, sizeof(var), "DOSCALL1.DLL", &hmod)) {
|
---|
[1394] | 1954 | if (!DosQueryProcAddr(hmod,
|
---|
| 1955 | ORD_DOS32QUERYEXTLIBPATH,
|
---|
| 1956 | NULL, (PFN *) & DQELIBPATH)) {
|
---|
| 1957 | DQELIBPATH(beg, BEGIN_LIBPATH);
|
---|
| 1958 | DQELIBPATH(end, END_LIBPATH);
|
---|
| 1959 | }
|
---|
| 1960 | DosFreeModule(hmod);
|
---|
[397] | 1961 | }
|
---|
| 1962 | *var = 0;
|
---|
| 1963 | }
|
---|
| 1964 | fp = xfopen(configsys, "r", pszSrcFile, __LINE__);
|
---|
| 1965 | if (fp) {
|
---|
| 1966 | while (!feof(fp)) {
|
---|
[1394] | 1967 | if (!xfgets_bstripcr(var, sizeof(var), fp, pszSrcFile, __LINE__))
|
---|
| 1968 | break;
|
---|
| 1969 | if (!strnicmp(var, "LIBPATH=", 8)) {
|
---|
| 1970 | memmove(var, var + 8, strlen(var + 8) + 1);
|
---|
| 1971 | lstrip(var);
|
---|
| 1972 | break;
|
---|
| 1973 | }
|
---|
[397] | 1974 | }
|
---|
| 1975 | fclose(fp);
|
---|
[2] | 1976 | }
|
---|
[397] | 1977 | strncpy(str, beg, len);
|
---|
| 1978 | strncat(str, var, len - strlen(str));
|
---|
| 1979 | strncat(str, end, len - strlen(str));
|
---|
| 1980 | str[len - 1] = 0;
|
---|
| 1981 | }
|
---|
[2] | 1982 | }
|
---|
| 1983 |
|
---|
[231] | 1984 | void SetViewMenu(HWND hwndMenu, ULONG flWindowAttr)
|
---|
| 1985 | {
|
---|
[397] | 1986 | WinCheckMenuItem(hwndMenu, IDM_MINIICONS, ((flWindowAttr & CV_MINI)));
|
---|
| 1987 | WinCheckMenuItem(hwndMenu, IDM_TEXT, ((flWindowAttr & CV_TEXT)));
|
---|
| 1988 | WinCheckMenuItem(hwndMenu, IDM_ICON, ((flWindowAttr & CV_ICON) &&
|
---|
[1394] | 1989 | !(flWindowAttr & CV_TREE)));
|
---|
[397] | 1990 | WinCheckMenuItem(hwndMenu, IDM_TREEVIEW, ((flWindowAttr & CV_TREE)));
|
---|
| 1991 | WinCheckMenuItem(hwndMenu, IDM_DETAILS, ((flWindowAttr & CV_DETAIL)));
|
---|
| 1992 | WinCheckMenuItem(hwndMenu, IDM_NAME, ((flWindowAttr & CV_NAME)));
|
---|
[2] | 1993 | }
|
---|
| 1994 |
|
---|
[231] | 1995 | void SaySort(HWND hwnd, INT sortflags, BOOL archive)
|
---|
| 1996 | {
|
---|
[397] | 1997 | char *s = NULL;
|
---|
[2] | 1998 |
|
---|
[397] | 1999 | s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
| 2000 | if (s) {
|
---|
| 2001 | sprintf(s, "S:%s%s",
|
---|
[1394] | 2002 | sortflags & SORT_REVERSE ? "^" : NullStr,
|
---|
| 2003 | (sortflags & SORT_FIRSTEXTENSION) ?
|
---|
| 2004 | GetPString(IDS_FIRSTX) : (sortflags & SORT_LASTEXTENSION) ?
|
---|
| 2005 | GetPString(IDS_LASTX) : (sortflags & SORT_SIZE) ?
|
---|
| 2006 | "Size" : (sortflags & SORT_EASIZE) ?
|
---|
| 2007 | (archive == 0) ?
|
---|
| 2008 | GetPString(IDS_EASIZE) : GetPString(IDS_CSIZE) :
|
---|
| 2009 | (sortflags & SORT_LWDATE) ?
|
---|
| 2010 | (archive == 0) ?
|
---|
| 2011 | GetPString(IDS_LWDATE) : GetPString(IDS_DATE) :
|
---|
| 2012 | (sortflags & SORT_LADATE) ?
|
---|
| 2013 | GetPString(IDS_LADATE) : (sortflags & SORT_CRDATE) ?
|
---|
| 2014 | GetPString(IDS_CRDATE) :
|
---|
| 2015 | (sortflags & SORT_PATHNAME) ?
|
---|
| 2016 | GetPString(IDS_PATH) : (sortflags & SORT_NOSORT) ?
|
---|
| 2017 | GetPString(IDS_NONE) : (sortflags & SORT_SUBJECT) ?
|
---|
| 2018 | GetPString(IDS_SUBJ) : GetPString(IDS_NAME));
|
---|
[397] | 2019 | WinSetWindowText(hwnd, s);
|
---|
[1039] | 2020 | free(s);
|
---|
[397] | 2021 | }
|
---|
[2] | 2022 | }
|
---|
| 2023 |
|
---|
[231] | 2024 | void SayView(HWND hwnd, ULONG flWindowAttr)
|
---|
| 2025 | {
|
---|
[397] | 2026 | char *s = NULL;
|
---|
[2] | 2027 |
|
---|
[397] | 2028 | s = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
| 2029 | if (s) {
|
---|
| 2030 | sprintf(s, "V:%s%s",
|
---|
[1394] | 2031 | (flWindowAttr & CV_TREE) ? GetPString(IDS_TREE) :
|
---|
| 2032 | (flWindowAttr & CV_NAME) ? GetPString(IDS_NAME) :
|
---|
| 2033 | (flWindowAttr & CV_DETAIL) ? GetPString(IDS_DETAIL) :
|
---|
| 2034 | (flWindowAttr & CV_TEXT) ? GetPString(IDS_TEXT) :
|
---|
| 2035 | GetPString(IDS_ICON),
|
---|
| 2036 | ((flWindowAttr & CV_MINI) &&
|
---|
| 2037 | !(flWindowAttr & CV_TEXT)) ? GetPString(IDS_MINI) : NullStr);
|
---|
[397] | 2038 | WinSetWindowText(hwnd, s);
|
---|
[1039] | 2039 | free(s);
|
---|
[397] | 2040 | }
|
---|
[2] | 2041 | }
|
---|
| 2042 |
|
---|
[231] | 2043 | void SayFilter(HWND hwnd, MASK * mask, BOOL archive)
|
---|
| 2044 | {
|
---|
[397] | 2045 | char *s = NULL;
|
---|
[2] | 2046 |
|
---|
[397] | 2047 | s = xmalloc(CCHMAXPATH * 2, pszSrcFile, __LINE__);
|
---|
| 2048 | if (s) {
|
---|
| 2049 | sprintf(s, "F:%s%s",
|
---|
[1394] | 2050 | mask->szMask,
|
---|
| 2051 | (!archive && (mask->attrFile != ALLATTRS ||
|
---|
| 2052 | mask->antiattr != 0)) ? " " : NullStr,
|
---|
| 2053 | (!archive && (mask->attrFile != ALLATTRS ||
|
---|
| 2054 | mask->antiattr !=
|
---|
| 2055 | 0)) ? GetPString(IDS_ATTRTEXT) : NullStr);
|
---|
[397] | 2056 | if (!s[2])
|
---|
| 2057 | sprintf(s, "F:%s", GetPString(IDS_ALLTEXT));
|
---|
| 2058 | WinSetWindowText(hwnd, s);
|
---|
[1039] | 2059 | free(s);
|
---|
[397] | 2060 | }
|
---|
[2] | 2061 | }
|
---|
| 2062 |
|
---|
[231] | 2063 | char *GetCmdSpec(BOOL dos)
|
---|
| 2064 | {
|
---|
[397] | 2065 | char *cmspec;
|
---|
[2] | 2066 |
|
---|
[397] | 2067 | if (!dos) {
|
---|
| 2068 | cmspec = getenv("OS2_SHELL");
|
---|
| 2069 | if (!cmspec)
|
---|
| 2070 | cmspec = getenv("COMSPEC");
|
---|
| 2071 | if (!cmspec)
|
---|
| 2072 | cmspec = "CMD.EXE";
|
---|
| 2073 | }
|
---|
| 2074 | else {
|
---|
| 2075 | cmspec = getenv("DOS_SHELL");
|
---|
| 2076 | if (!cmspec)
|
---|
| 2077 | cmspec = "COMMAND.COM";
|
---|
| 2078 | }
|
---|
| 2079 | return cmspec;
|
---|
[2] | 2080 | }
|
---|
| 2081 |
|
---|
[231] | 2082 | void Broadcast(HAB hab, HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 2083 | {
|
---|
[397] | 2084 | if (hwndMain)
|
---|
| 2085 | WinBroadcastMsg(hwndMain, msg, mp1, mp2, BMSG_SEND | BMSG_FRAMEONLY);
|
---|
| 2086 | if (hwnd &&
|
---|
| 2087 | hwnd != HWND_DESKTOP &&
|
---|
| 2088 | hwnd != hwndMain &&
|
---|
| 2089 | hwnd != WinQueryDesktopWindow(hab, NULLHANDLE) &&
|
---|
| 2090 | WinIsWindow(hab, hwnd) && (!hwndMain || !WinIsChild(hwnd, hwndMain)))
|
---|
| 2091 | WinSendMsg(hwnd, msg, mp1, mp2);
|
---|
[2] | 2092 | }
|
---|
| 2093 |
|
---|
[231] | 2094 | void SetupWinList(HWND hwndMenu, HWND hwndTop, HWND hwndFrame)
|
---|
| 2095 | {
|
---|
[397] | 2096 | /*
|
---|
| 2097 | * add switchlist entries to end of pulldown menu
|
---|
| 2098 | */
|
---|
[2] | 2099 |
|
---|
[397] | 2100 | SHORT sItemCount, x = 0, y = 0;
|
---|
| 2101 | MENUITEM mi;
|
---|
[2] | 2102 |
|
---|
[397] | 2103 | sItemCount = (SHORT) WinSendMsg(hwndMenu,
|
---|
[1394] | 2104 | MM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[2] | 2105 |
|
---|
[397] | 2106 | /* clean out old additions */
|
---|
| 2107 | while ((SHORT) WinSendMsg(hwndMenu,
|
---|
[1394] | 2108 | MM_DELETEITEM,
|
---|
| 2109 | MPFROM2SHORT(IDM_SWITCHSTART + x++,
|
---|
| 2110 | TRUE), MPVOID) < sItemCount)
|
---|
[397] | 2111 | sItemCount--;
|
---|
| 2112 | x = 0;
|
---|
| 2113 | while ((SHORT) WinSendMsg(hwndMenu,
|
---|
[1394] | 2114 | MM_DELETEITEM,
|
---|
| 2115 | MPFROM2SHORT(IDM_WINDOWSTART + x++,
|
---|
| 2116 | TRUE), MPVOID) < sItemCount)
|
---|
[397] | 2117 | sItemCount--;
|
---|
[2] | 2118 |
|
---|
[397] | 2119 | x = 0;
|
---|
| 2120 | if (hwndTop) {
|
---|
[2] | 2121 |
|
---|
[397] | 2122 | char wtext[CCHMAXPATH + 8];
|
---|
| 2123 | HENUM henum;
|
---|
| 2124 | HWND hwndChild;
|
---|
[2] | 2125 |
|
---|
[397] | 2126 | /* add children of the main FM/2 client */
|
---|
| 2127 | henum = WinBeginEnumWindows(hwndTop);
|
---|
| 2128 | memset(&mi, 0, sizeof(mi));
|
---|
| 2129 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 2130 | if (WinQueryWindowUShort(hwndChild, QWS_ID) && hwndChild != hwndFrame) {
|
---|
[1394] | 2131 | *wtext = 0;
|
---|
| 2132 | WinQueryWindowText(hwndChild, CCHMAXPATH + 8, wtext);
|
---|
| 2133 | if (*wtext) {
|
---|
| 2134 | wtext[CCHMAXPATH + 7] = 0;
|
---|
| 2135 | mi.afStyle = MIS_TEXT;
|
---|
| 2136 | if (!((x + sItemCount) % 28))
|
---|
| 2137 | mi.afStyle |= MIS_BREAK;
|
---|
| 2138 | mi.id = IDM_WINDOWSTART + x;
|
---|
| 2139 | mi.iPosition = MIT_END;
|
---|
| 2140 | if ((SHORT) WinSendMsg(hwndMenu,
|
---|
| 2141 | MM_INSERTITEM,
|
---|
| 2142 | MPFROMP(&mi), MPFROMP(wtext)) >= 0)
|
---|
| 2143 | x++;
|
---|
| 2144 | }
|
---|
[397] | 2145 | }
|
---|
[2] | 2146 | }
|
---|
[397] | 2147 | WinEndEnumWindows(henum);
|
---|
| 2148 | }
|
---|
[2] | 2149 |
|
---|
[397] | 2150 | /* add external FM/2 windows */
|
---|
| 2151 | {
|
---|
| 2152 | PSWBLOCK pswb;
|
---|
| 2153 | ULONG ulSize, ulcEntries;
|
---|
| 2154 | HWND hwndTopFrame;
|
---|
| 2155 | register INT i;
|
---|
[2] | 2156 |
|
---|
[787] | 2157 | hwndTopFrame = hwndTop ? WinQueryWindow(hwndTop, QW_PARENT) : (HWND)0;
|
---|
[397] | 2158 | /* Get the switch list information */
|
---|
| 2159 | x = 0;
|
---|
| 2160 | ulcEntries = WinQuerySwitchList(0, NULL, 0);
|
---|
| 2161 | ulSize = sizeof(SWBLOCK) + sizeof(HSWITCH) + (ulcEntries + 4L) *
|
---|
| 2162 | (LONG) sizeof(SWENTRY);
|
---|
| 2163 | /* Allocate memory for list */
|
---|
| 2164 | pswb = xmalloc(ulSize, pszSrcFile, __LINE__);
|
---|
| 2165 | if (pswb) {
|
---|
| 2166 | /* Put the info in the list */
|
---|
| 2167 | ulcEntries = WinQuerySwitchList(0, pswb, ulSize - sizeof(SWENTRY));
|
---|
| 2168 | /* do the dirty deed */
|
---|
| 2169 | memset(&mi, 0, sizeof(mi));
|
---|
| 2170 | for (i = 0; i < pswb->cswentry; i++) {
|
---|
[1394] | 2171 | if (pswb->aswentry[i].swctl.uchVisibility == SWL_VISIBLE &&
|
---|
| 2172 | pswb->aswentry[i].swctl.fbJump == SWL_JUMPABLE &&
|
---|
| 2173 | (pswb->aswentry[i].swctl.idProcess != mypid ||
|
---|
| 2174 | !hwndFrame ||
|
---|
| 2175 | pswb->aswentry[i].swctl.hwnd != hwndFrame) &&
|
---|
| 2176 | (pswb->aswentry[i].swctl.idProcess != mypid ||
|
---|
| 2177 | !hwndTopFrame ||
|
---|
| 2178 | pswb->aswentry[i].swctl.hwnd != hwndTopFrame ||
|
---|
| 2179 | !WinIsChild(hwndFrame, hwndTop))) {
|
---|
| 2180 | if (!strnicmp(pswb->aswentry[i].swctl.szSwtitle, "AV/2", 4)
|
---|
| 2181 | || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "File Manager/2")
|
---|
| 2182 | || !stricmp(pswb->aswentry[i].swctl.szSwtitle, "Collector")
|
---|
| 2183 | || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VTree", 5)
|
---|
| 2184 | || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, "VDir", 4)
|
---|
| 2185 | || !strnicmp(pswb->aswentry[i].swctl.szSwtitle, FM2Str, 4)) {
|
---|
| 2186 | mi.afStyle = MIS_TEXT;
|
---|
| 2187 | if (x && !(x % 28))
|
---|
| 2188 | mi.afStyle |= MIS_BREAK;
|
---|
| 2189 | mi.id = IDM_SWITCHSTART + y;
|
---|
| 2190 | mi.iPosition = MIT_END;
|
---|
| 2191 | switches[y] = pswb->aswentry[i].hswitch;
|
---|
| 2192 | if ((SHORT) WinSendMsg(hwndMenu,
|
---|
| 2193 | MM_INSERTITEM,
|
---|
| 2194 | MPFROMP(&mi),
|
---|
| 2195 | MPFROMP(pswb->aswentry[i].
|
---|
| 2196 | swctl.szSwtitle)) >= 0) {
|
---|
| 2197 | y++;
|
---|
| 2198 | x++;
|
---|
| 2199 | }
|
---|
| 2200 | }
|
---|
| 2201 | }
|
---|
[397] | 2202 | }
|
---|
| 2203 | numswitches = y;
|
---|
[1039] | 2204 | free(pswb);
|
---|
[397] | 2205 | DosPostEventSem(CompactSem);
|
---|
[2] | 2206 | }
|
---|
[397] | 2207 | }
|
---|
[2] | 2208 | }
|
---|
| 2209 |
|
---|
[231] | 2210 | BOOL SwitchCommand(HWND hwndMenu, USHORT cmd)
|
---|
| 2211 | {
|
---|
[397] | 2212 | BOOL ret = FALSE;
|
---|
[2] | 2213 |
|
---|
[397] | 2214 | if (hwndMain && hwndMenu && cmd >= IDM_WINDOWSTART && cmd < IDM_SWITCHSTART) {
|
---|
| 2215 | /*
|
---|
| 2216 | * select a child window (of client)
|
---|
| 2217 | */
|
---|
[2] | 2218 |
|
---|
[397] | 2219 | MENUITEM mi;
|
---|
| 2220 | HWND hwndSubMenu = (HWND) 0, hwndChild;
|
---|
| 2221 | CHAR s[CCHMAXPATH + 8];
|
---|
[2] | 2222 |
|
---|
[397] | 2223 | if (WinQueryWindowUShort(hwndMenu, QWS_ID) != IDM_WINDOWSMENU) {
|
---|
| 2224 | memset(&mi, 0, sizeof(mi));
|
---|
| 2225 | mi.iPosition = MIT_END;
|
---|
| 2226 | mi.afStyle = MIS_TEXT;
|
---|
| 2227 | if (WinSendMsg(hwndMenu,
|
---|
[1394] | 2228 | MM_QUERYITEM,
|
---|
| 2229 | MPFROM2SHORT(IDM_WINDOWSMENU, TRUE), MPFROMP(&mi)))
|
---|
| 2230 | hwndSubMenu = mi.hwndSubMenu;
|
---|
[397] | 2231 | }
|
---|
| 2232 | else
|
---|
| 2233 | hwndSubMenu = hwndMenu;
|
---|
| 2234 | if (hwndSubMenu) {
|
---|
| 2235 | *s = 0;
|
---|
| 2236 | if (WinSendMsg(hwndSubMenu,
|
---|
[1394] | 2237 | MM_QUERYITEMTEXT,
|
---|
| 2238 | MPFROM2SHORT(cmd, CCHMAXPATH + 8), MPFROMP(s)) && *s) {
|
---|
[2] | 2239 |
|
---|
[1394] | 2240 | HENUM henum;
|
---|
| 2241 | CHAR checkText[CCHMAXPATH + 8];
|
---|
| 2242 | SWP swp;
|
---|
[2] | 2243 |
|
---|
[1394] | 2244 | s[CCHMAXPATH + 7] = 0;
|
---|
| 2245 | henum = WinBeginEnumWindows(hwndMain);
|
---|
| 2246 | while ((hwndChild = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 2247 | if (WinQueryWindowUShort(hwndChild, QWS_ID)) {
|
---|
| 2248 | *checkText = 0;
|
---|
| 2249 | WinQueryWindowText(hwndChild, CCHMAXPATH + 8, checkText);
|
---|
| 2250 | checkText[CCHMAXPATH + 7] = 0;
|
---|
| 2251 | if (!stricmp(checkText, s)) {
|
---|
| 2252 | if (WinQueryWindowPos(hwndChild, &swp)) {
|
---|
| 2253 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
|
---|
| 2254 | WinSetWindowPos(hwndChild,
|
---|
| 2255 | HWND_TOP,
|
---|
| 2256 | 0, 0, 0, 0, SWP_RESTORE | SWP_ZORDER);
|
---|
| 2257 | }
|
---|
| 2258 | WinSetActiveWindow(HWND_DESKTOP, hwndChild);
|
---|
| 2259 | ret = TRUE;
|
---|
| 2260 | break;
|
---|
| 2261 | }
|
---|
| 2262 | }
|
---|
| 2263 | }
|
---|
| 2264 | WinEndEnumWindows(henum);
|
---|
[397] | 2265 | }
|
---|
[2] | 2266 | }
|
---|
[397] | 2267 | }
|
---|
| 2268 | else if (cmd >= IDM_SWITCHSTART && cmd < IDM_SWITCHSTART + 499) {
|
---|
| 2269 | if (cmd - IDM_SWITCHSTART < numswitches) {
|
---|
| 2270 | WinSwitchToProgram(switches[cmd - IDM_SWITCHSTART]);
|
---|
| 2271 | ret = TRUE;
|
---|
[2] | 2272 | }
|
---|
[397] | 2273 | }
|
---|
[2] | 2274 |
|
---|
[397] | 2275 | return ret;
|
---|
[2] | 2276 | }
|
---|
[787] | 2277 |
|
---|
[1112] | 2278 | /** CheckDriveSpaceAvail
|
---|
| 2279 | * Take space needed and checks that drive has at least 1000 bits in excess of the required space.
|
---|
| 2280 | * Returns 0 if sufficient space is available; 1 if the drive is full & 2 on abort of operation
|
---|
| 2281 | * when the drive would have less than ullFreeSpaceWhenComplete remaining or has insufficient space.
|
---|
| 2282 | */
|
---|
| 2283 |
|
---|
[1394] | 2284 | INT CheckDriveSpaceAvail(PCSZ pTargetPath, ULONGLONG ullSpaceNeeded,
|
---|
| 2285 | ULONGLONG ullFreeSpaceWhenComplete)
|
---|
[1112] | 2286 | {
|
---|
| 2287 | FSALLOCATE fsa;
|
---|
| 2288 | ULONGLONG ullFreeQty;
|
---|
| 2289 | APIRET ret;
|
---|
| 2290 |
|
---|
| 2291 | DosQueryFSInfo(toupper(*pTargetPath) - 'A' + 1, FSIL_ALLOC, &fsa, sizeof(FSALLOCATE));
|
---|
| 2292 | ullFreeQty = (ULONGLONG) fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
|
---|
| 2293 | if (ullFreeQty > ullSpaceNeeded + ullFreeSpaceWhenComplete)
|
---|
| 2294 | return 0;
|
---|
| 2295 | else if (ullFreeQty < ullSpaceNeeded + 1024) {
|
---|
| 2296 | CHAR szKB[20];
|
---|
| 2297 |
|
---|
[1120] | 2298 | CommaFmtULL(szKB, sizeof(szKB),
|
---|
[1394] | 2299 | ullFreeQty - ullSpaceNeeded, ' ');
|
---|
[1112] | 2300 | if (ullFreeSpaceWhenComplete == 0) {
|
---|
| 2301 | saymsg(MB_OK,
|
---|
[1394] | 2302 | HWND_DESKTOP,
|
---|
| 2303 | NullStr,
|
---|
| 2304 | GetPString(IDS_DRIVESPACELIMITEDTMPSAVE),
|
---|
| 2305 | pTargetPath);
|
---|
[1112] | 2306 | return 0;
|
---|
| 2307 | }
|
---|
| 2308 | else {
|
---|
[1118] | 2309 | if (ullFreeQty > ullSpaceNeeded) {
|
---|
[1394] | 2310 | ret = saymsg(MB_YESNO,
|
---|
| 2311 | HWND_DESKTOP,
|
---|
| 2312 | NullStr,
|
---|
| 2313 | GetPString(IDS_DRIVESPACELIMITED),
|
---|
| 2314 | pTargetPath,
|
---|
| 2315 | szKB);
|
---|
| 2316 | if (ret == MBID_YES)
|
---|
| 2317 | return 0;
|
---|
| 2318 | else
|
---|
| 2319 | return 2;
|
---|
[1112] | 2320 | }
|
---|
| 2321 | else {
|
---|
[1394] | 2322 | saymsg(MB_OK,
|
---|
| 2323 | HWND_DESKTOP,
|
---|
| 2324 | NullStr,
|
---|
| 2325 | GetPString(IDS_DRIVESPACEEXCEEDED),
|
---|
| 2326 | pTargetPath);
|
---|
| 2327 | return 2;
|
---|
[1112] | 2328 | }
|
---|
| 2329 | }
|
---|
| 2330 | }
|
---|
| 2331 | else
|
---|
| 2332 | return 1;
|
---|
| 2333 | }
|
---|
| 2334 |
|
---|
[787] | 2335 | #pragma alloc_text(MAINWND5,SetSysMenu)
|
---|
| 2336 | #pragma alloc_text(MISC1,BoxWindow,PaintRecessedWindow,PostMsg,PaintSTextWindow,IsFm2Window)
|
---|
| 2337 | #pragma alloc_text(MISC1,FixSwitchList,FindDirCnr,CurrentRecord,SetShiftState,AddToListboxBottom)
|
---|
[1112] | 2338 | #pragma alloc_text(MISC1,CheckDriveSpaceAvail)
|
---|
[1077] | 2339 |
|
---|
| 2340 | #ifdef FORTIFY
|
---|
| 2341 | #pragma alloc_text(MISC1,GetTidForWindow)
|
---|
| 2342 | #endif // FORTIFY
|
---|
| 2343 |
|
---|
[787] | 2344 | #pragma alloc_text(CNR_MISC1,AdjustCnrColVis,AdjustCnrColsForFSType)
|
---|
| 2345 | #pragma alloc_text(CNR_MISC1,AdjustCnrColsForPref,SetCnrCols)
|
---|
| 2346 | #pragma alloc_text(CNR_MISC2,CnrDirectEdit,OpenEdit)
|
---|
| 2347 | #pragma alloc_text(MISC2,SetMenuCheck,disable_menuitem,SetSortChecks)
|
---|
| 2348 | #pragma alloc_text(MISC2,SetDetailsSwitches,SetViewMenu)
|
---|
| 2349 | #pragma alloc_text(MISC3,SetupCommandMenu,AdjustDetailsSwitches)
|
---|
| 2350 | #pragma alloc_text(MISC3,ViewHelp,GetCmdSpec)
|
---|
| 2351 | #pragma alloc_text(MISC3,ExecFile,SetConditionalCascade,LoadDetailsSwitches)
|
---|
| 2352 | #pragma alloc_text(MISC4,PortholeInit,CheckMenu,Broadcast,SetupWinList,SwitchCommand)
|
---|
| 2353 | #pragma alloc_text(MISC6,DrawTargetEmphasis,EmphasizeButton)
|
---|
| 2354 | #pragma alloc_text(MISC_LIBPATH,LoadLibPath)
|
---|
| 2355 | #pragma alloc_text(MISC_SAY,SayView,SaySort,SayFilter)
|
---|
| 2356 |
|
---|