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