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