[123] | 1 |
|
---|
[506] | 2 | /**************************************************************************************
|
---|
[123] | 3 |
|
---|
| 4 | $Id: assoc.c 927 2008-01-17 02:22:03Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
[907] | 7 | Copyright (c) 2004, 2008 Steven H.Levine
|
---|
[123] | 8 |
|
---|
[290] | 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
[342] | 10 | 14 Jul 06 SHL Use Runtime_Error
|
---|
[405] | 11 | 29 Jul 06 SHL Use xfgets, xfgets_bstripcr
|
---|
[506] | 12 | 10 Sep 06 GKY Add Move to last, Okay adds if new, Replace Current in Listbox Dialog
|
---|
[529] | 13 | 19 Oct 06 GKY Rework replace logic
|
---|
[618] | 14 | 18 Feb 07 GKY Move error messages etc to string file
|
---|
| 15 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
[793] | 16 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[920] | 17 | 06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
|
---|
[123] | 18 |
|
---|
[506] | 19 | **************************************************************************************/
|
---|
[123] | 20 |
|
---|
[907] | 21 | #include <stdlib.h>
|
---|
| 22 | #include <string.h>
|
---|
| 23 | #include <share.h>
|
---|
| 24 |
|
---|
[2] | 25 | #define INCL_DOS
|
---|
| 26 | #define INCL_WIN
|
---|
[506] | 27 | #define INCL_PM
|
---|
| 28 | #define INCL_WINHOOKS
|
---|
[907] | 29 | #define INCL_LONGLONG // dircnrs.h
|
---|
[2] | 30 |
|
---|
| 31 | #include "fm3dlg.h"
|
---|
| 32 | #include "fm3str.h"
|
---|
[907] | 33 | #include "pathutil.h" // BldQuotedFileName
|
---|
| 34 | #include "errutil.h" // Dos_Error...
|
---|
| 35 | #include "strutil.h" // GetPString
|
---|
| 36 | #include "fm3dll.h"
|
---|
[2] | 37 |
|
---|
| 38 | #pragma data_seg(DATA1)
|
---|
| 39 |
|
---|
[551] | 40 | typedef struct
|
---|
| 41 | {
|
---|
| 42 | CHAR mask[CCHMAXPATH];
|
---|
[918] | 43 | CHAR cl[MAXCOMLINESTRG];
|
---|
[551] | 44 | CHAR sig[CCHMAXPATH];
|
---|
| 45 | LONG offset;
|
---|
[2] | 46 | ULONG flags;
|
---|
[551] | 47 | }
|
---|
| 48 | ASSOC;
|
---|
[2] | 49 |
|
---|
[551] | 50 | typedef struct LINKASSOC
|
---|
| 51 | {
|
---|
| 52 | CHAR *mask;
|
---|
| 53 | CHAR *cl;
|
---|
| 54 | CHAR *sig;
|
---|
| 55 | LONG offset;
|
---|
| 56 | ULONG flags;
|
---|
[2] | 57 | struct LINKASSOC *prev;
|
---|
| 58 | struct LINKASSOC *next;
|
---|
[551] | 59 | }
|
---|
| 60 | LINKASSOC;
|
---|
[2] | 61 |
|
---|
[551] | 62 | static LINKASSOC *asshead = NULL, *asstail = NULL;
|
---|
| 63 | static BOOL assloaded = FALSE, replace = FALSE;
|
---|
[506] | 64 |
|
---|
[342] | 65 | static PSZ pszSrcFile = __FILE__;
|
---|
| 66 |
|
---|
[551] | 67 | MRESULT EXPENTRY AssocTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[342] | 68 | {
|
---|
[551] | 69 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 70 | static BOOL emphasized = FALSE;
|
---|
| 71 |
|
---|
[551] | 72 | switch (msg) {
|
---|
| 73 | case DM_DRAGOVER:
|
---|
| 74 | if (!emphasized) {
|
---|
| 75 | emphasized = TRUE;
|
---|
| 76 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 77 | }
|
---|
[618] | 78 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
[551] | 79 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
| 80 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
[2] | 81 |
|
---|
[551] | 82 | case DM_DRAGLEAVE:
|
---|
| 83 | if (emphasized) {
|
---|
| 84 | emphasized = FALSE;
|
---|
| 85 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 86 | }
|
---|
| 87 | break;
|
---|
[2] | 88 |
|
---|
[551] | 89 | case DM_DROPHELP:
|
---|
| 90 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_ASSOCDROPHELPTEXT));
|
---|
| 91 | return 0;
|
---|
[2] | 92 |
|
---|
[551] | 93 | case DM_DROP:
|
---|
| 94 | {
|
---|
| 95 | char szFrom[CCHMAXPATH + 5];
|
---|
[2] | 96 |
|
---|
[551] | 97 | if (emphasized) {
|
---|
| 98 | emphasized = FALSE;
|
---|
| 99 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 100 | }
|
---|
[618] | 101 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) {
|
---|
[551] | 102 | strcat(szFrom, " %a");
|
---|
| 103 | WinSetWindowText(hwnd, szFrom);
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 | return 0;
|
---|
[2] | 107 | }
|
---|
[551] | 108 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
| 109 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 110 | }
|
---|
| 111 |
|
---|
[551] | 112 | VOID free_associations(VOID)
|
---|
[342] | 113 | {
|
---|
[551] | 114 | LINKASSOC *info, *next;
|
---|
[2] | 115 |
|
---|
| 116 | info = asshead;
|
---|
[551] | 117 | while (info) {
|
---|
[2] | 118 | next = info->next;
|
---|
| 119 | free(info->mask);
|
---|
| 120 | free(info->cl);
|
---|
[551] | 121 | if (info->sig)
|
---|
[2] | 122 | free(info->sig);
|
---|
| 123 | free(info);
|
---|
| 124 | info = next;
|
---|
| 125 | }
|
---|
| 126 | asshead = asstail = NULL;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[551] | 129 | VOID load_associations(VOID)
|
---|
[342] | 130 | {
|
---|
[551] | 131 | FILE *fp;
|
---|
[2] | 132 | LINKASSOC *info;
|
---|
[551] | 133 | CHAR cl[1024];
|
---|
| 134 | CHAR mask[CCHMAXPATH + 24];
|
---|
| 135 | CHAR sig[CCHMAXPATH + 24];
|
---|
| 136 | CHAR offset[72];
|
---|
| 137 | CHAR flags[72];
|
---|
[2] | 138 |
|
---|
[551] | 139 | if (asshead)
|
---|
[2] | 140 | free_associations();
|
---|
| 141 | assloaded = TRUE;
|
---|
| 142 | save_dir2(mask);
|
---|
[551] | 143 | if (mask[strlen(mask) - 1] != '\\')
|
---|
| 144 | strcat(mask, "\\");
|
---|
| 145 | strcat(mask, "ASSOC.DAT");
|
---|
| 146 | fp = _fsopen(mask, "r", SH_DENYWR);
|
---|
[342] | 147 | if (fp) {
|
---|
[551] | 148 | while (!feof(fp)) {
|
---|
| 149 | if (!xfgets(mask, sizeof(mask), fp, pszSrcFile, __LINE__)) // fixme why +24?
|
---|
| 150 | break;
|
---|
[2] | 151 | mask[CCHMAXPATH] = 0;
|
---|
[123] | 152 | bstripcr(mask);
|
---|
[551] | 153 | if (!*mask || *mask == ';')
|
---|
| 154 | continue;
|
---|
| 155 | if (!xfgets(cl, sizeof(cl), fp, pszSrcFile, __LINE__) ||
|
---|
| 156 | !xfgets(sig, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__) ||
|
---|
| 157 | !xfgets(offset, sizeof(offset), fp, pszSrcFile, __LINE__) ||
|
---|
| 158 | !xfgets(flags, sizeof(flags), fp, pszSrcFile, __LINE__))
|
---|
| 159 | break; /* error! */
|
---|
[2] | 160 | cl[1000] = 0;
|
---|
[405] | 161 | bstripcr(cl);
|
---|
[2] | 162 | sig[CCHMAXPATH] = 0;
|
---|
[405] | 163 | bstripcr(sig);
|
---|
[2] | 164 | offset[34] = 0;
|
---|
[405] | 165 | bstripcr(offset);
|
---|
[2] | 166 | flags[34] = 0;
|
---|
[123] | 167 | bstripcr(flags);
|
---|
[405] | 168 | if (!*cl)
|
---|
[551] | 169 | continue;
|
---|
| 170 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
[342] | 171 | if (info) {
|
---|
[551] | 172 | info->cl = xstrdup(cl, pszSrcFile, __LINE__);
|
---|
| 173 | info->mask = xstrdup(mask, pszSrcFile, __LINE__);
|
---|
| 174 | if (*sig)
|
---|
| 175 | info->sig = xstrdup(sig, pszSrcFile, __LINE__);
|
---|
| 176 | info->offset = atol(offset);
|
---|
| 177 | info->flags = atol(flags);
|
---|
| 178 | if (!info->cl || !info->mask) {
|
---|
| 179 | if (info->cl)
|
---|
| 180 | free(info->cl);
|
---|
| 181 | if (info->mask)
|
---|
| 182 | free(info->mask);
|
---|
| 183 | free(info);
|
---|
| 184 | break;
|
---|
| 185 | }
|
---|
| 186 | if (!asshead)
|
---|
| 187 | asshead = info;
|
---|
| 188 | else {
|
---|
| 189 | asstail->next = info;
|
---|
| 190 | info->prev = asstail;
|
---|
| 191 | }
|
---|
| 192 | asstail = info;
|
---|
[2] | 193 | }
|
---|
| 194 | }
|
---|
| 195 | fclose(fp);
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
| 198 |
|
---|
[551] | 199 | VOID save_associations(VOID)
|
---|
[342] | 200 | {
|
---|
[2] | 201 | LINKASSOC *info;
|
---|
[551] | 202 | FILE *fp;
|
---|
| 203 | CHAR s[CCHMAXPATH + 14];
|
---|
[2] | 204 |
|
---|
[551] | 205 | if (!assloaded || !asshead)
|
---|
[2] | 206 | return;
|
---|
| 207 | info = asshead;
|
---|
| 208 | #ifdef NEVER
|
---|
[551] | 209 | while (info) {
|
---|
[2] | 210 | next = info->next;
|
---|
[551] | 211 | if (!strcmp("*", info->mask)) {
|
---|
| 212 | if (info != asshead) { /* already top record */
|
---|
| 213 | if (info->prev)
|
---|
| 214 | (info->prev)->next = info->next;
|
---|
| 215 | if (info->next)
|
---|
| 216 | (info->next)->prev = info->prev;
|
---|
| 217 | if (info == asstail)
|
---|
| 218 | asstail = info->prev;
|
---|
| 219 | info->next = asshead->next;
|
---|
| 220 | info->prev = NULL;
|
---|
| 221 | asshead = info;
|
---|
[2] | 222 | }
|
---|
| 223 | }
|
---|
| 224 | info = next;
|
---|
| 225 | }
|
---|
| 226 | #endif
|
---|
| 227 | save_dir2(s);
|
---|
[551] | 228 | if (s[strlen(s) - 1] != '\\')
|
---|
| 229 | strcat(s, "\\");
|
---|
| 230 | strcat(s, "ASSOC.DAT");
|
---|
| 231 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
---|
[342] | 232 | if (fp) {
|
---|
[551] | 233 | fputs(GetPString(IDS_ASSOCFILETEXT), fp);
|
---|
[2] | 234 | info = asshead;
|
---|
[551] | 235 | while (info) {
|
---|
[2] | 236 | fprintf(fp,
|
---|
[551] | 237 | ";\n%0.*s\n%0.1000s\n%0.*s\n%lu\n%lu\n",
|
---|
| 238 | CCHMAXPATH,
|
---|
| 239 | info->mask,
|
---|
| 240 | info->cl,
|
---|
| 241 | CCHMAXPATH,
|
---|
| 242 | (info->sig) ? info->sig : NullStr, info->offset, info->flags);
|
---|
[2] | 243 | info = info->next;
|
---|
| 244 | }
|
---|
| 245 | fclose(fp);
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 |
|
---|
[551] | 249 | LINKASSOC *add_association(ASSOC * addme)
|
---|
[342] | 250 | {
|
---|
[2] | 251 | LINKASSOC *info;
|
---|
| 252 |
|
---|
[551] | 253 | if (addme && *addme->cl && *addme->mask) {
|
---|
[2] | 254 | info = asshead;
|
---|
[551] | 255 | while (info) {
|
---|
| 256 | if ((!replace) && (!stricmp(info->mask, addme->mask) &&
|
---|
| 257 | ((!info->sig && !*addme->sig) || (!replace) &&
|
---|
| 258 | (info->sig && !strcmp(addme->sig, info->sig)))))
|
---|
| 259 | return NULL;
|
---|
[2] | 260 | info = info->next;
|
---|
| 261 | }
|
---|
[551] | 262 | if (!info) {
|
---|
| 263 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
| 264 | if (info) {
|
---|
| 265 | info->cl = xstrdup(addme->cl, pszSrcFile, __LINE__);
|
---|
| 266 | info->mask = xstrdup(addme->mask, pszSrcFile, __LINE__);
|
---|
| 267 | if (*addme->sig)
|
---|
| 268 | info->sig = xstrdup(addme->sig, pszSrcFile, __LINE__);
|
---|
| 269 | if (addme->offset)
|
---|
| 270 | info->offset = addme->offset;
|
---|
| 271 | if (addme->flags)
|
---|
| 272 | info->flags = addme->flags;
|
---|
| 273 | if (!info->cl || !info->mask) {
|
---|
| 274 | if (info->cl)
|
---|
| 275 | free(info->cl);
|
---|
| 276 | if (info->mask)
|
---|
| 277 | free(info->mask);
|
---|
| 278 | free(info);
|
---|
| 279 | }
|
---|
| 280 | else {
|
---|
| 281 | if (!asshead) /* only item in list */
|
---|
| 282 | asshead = asstail = info;
|
---|
| 283 | else {
|
---|
| 284 | if (asstail) { /* place at tail */
|
---|
| 285 | asstail->next = info;
|
---|
| 286 | info->prev = asstail;
|
---|
| 287 | }
|
---|
| 288 | asstail = info;
|
---|
| 289 | }
|
---|
| 290 | return info;
|
---|
| 291 | }
|
---|
[2] | 292 | }
|
---|
| 293 | }
|
---|
| 294 | }
|
---|
| 295 | return NULL;
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[551] | 298 | BOOL kill_association(ASSOC * killme)
|
---|
[342] | 299 | {
|
---|
[2] | 300 | LINKASSOC *info;
|
---|
| 301 |
|
---|
[551] | 302 | if (killme && *killme->mask) {
|
---|
[2] | 303 | info = asshead;
|
---|
[551] | 304 | while (info) {
|
---|
| 305 | if (!stricmp(info->mask, killme->mask) &&
|
---|
| 306 | info->offset == killme->offset &&
|
---|
| 307 | (((!info->sig || !*info->sig) && !*killme->sig) ||
|
---|
| 308 | (info->sig && !strcmp(killme->sig, info->sig)))) {
|
---|
| 309 | if (info == asshead) {
|
---|
| 310 | asshead = info->next;
|
---|
| 311 | if (info == asstail)
|
---|
| 312 | asstail = info->prev;
|
---|
| 313 | }
|
---|
| 314 | else {
|
---|
| 315 | if (info->next)
|
---|
| 316 | (info->next)->prev = info->prev;
|
---|
| 317 | if (info->prev)
|
---|
| 318 | (info->prev)->next = info->next;
|
---|
| 319 | if (info == asstail)
|
---|
| 320 | asstail = info->prev;
|
---|
| 321 | }
|
---|
| 322 | free(info->cl);
|
---|
| 323 | free(info->mask);
|
---|
| 324 | if (info->sig)
|
---|
| 325 | free(info->sig);
|
---|
| 326 | free(info);
|
---|
| 327 | return TRUE;
|
---|
[2] | 328 | }
|
---|
| 329 | info = info->next;
|
---|
| 330 | }
|
---|
| 331 | }
|
---|
| 332 | return FALSE;
|
---|
| 333 | }
|
---|
| 334 |
|
---|
[551] | 335 | INT ExecAssociation(HWND hwnd, CHAR * datafile)
|
---|
[342] | 336 | {
|
---|
[551] | 337 | CHAR *file, sig[CCHMAXPATH], sigl[CCHMAXPATH], mask[CCHMAXPATH], *p;
|
---|
| 338 | FILE *fp;
|
---|
| 339 | BOOL didmatch, exclude;
|
---|
| 340 | ULONG offset;
|
---|
[2] | 341 | LINKASSOC *info;
|
---|
| 342 |
|
---|
[551] | 343 | if (!assloaded)
|
---|
[2] | 344 | load_associations();
|
---|
[551] | 345 | if (!asshead)
|
---|
[2] | 346 | return -1;
|
---|
[551] | 347 | if (!datafile || !*datafile)
|
---|
[2] | 348 | return -1;
|
---|
[551] | 349 | file = strrchr(datafile, '\\');
|
---|
| 350 | if (!file)
|
---|
| 351 | file = strrchr(datafile, ':');
|
---|
| 352 | if (file)
|
---|
[2] | 353 | file++;
|
---|
| 354 | else
|
---|
| 355 | file = datafile;
|
---|
| 356 | info = asshead;
|
---|
[551] | 357 | while (info) {
|
---|
| 358 | strcpy(mask, info->mask);
|
---|
| 359 | p = strtok(mask, ";");
|
---|
| 360 | while (p) {
|
---|
| 361 | if (*p == '/') {
|
---|
| 362 | p++;
|
---|
| 363 | exclude = TRUE;
|
---|
[2] | 364 | }
|
---|
| 365 | else
|
---|
[834] | 366 | exclude = FALSE;
|
---|
[832] | 367 | didmatch = wildcard((strchr(p, '\\') ||
|
---|
| 368 | strchr(p, ':')) ? datafile : file, p, FALSE);
|
---|
[551] | 369 | if (exclude && didmatch)
|
---|
| 370 | didmatch = FALSE;
|
---|
| 371 | if (didmatch) {
|
---|
| 372 | if (info->sig && *info->sig) {
|
---|
| 373 | strcpy(sigl, info->sig);
|
---|
| 374 | literal(sigl);
|
---|
| 375 | fp = _fsopen(datafile, "rb", SH_DENYNO);
|
---|
| 376 | if (fp) {
|
---|
| 377 | if (info->offset < 0L) {
|
---|
| 378 | fseek(fp, 0L, SEEK_END);
|
---|
| 379 | offset = ftell(fp) + info->offset;
|
---|
| 380 | }
|
---|
| 381 | else
|
---|
| 382 | offset = info->offset;
|
---|
| 383 | fseek(fp, offset, SEEK_SET);
|
---|
| 384 | if (fread(sig,
|
---|
| 385 | 1,
|
---|
| 386 | strlen(sigl),
|
---|
| 387 | fp) != strlen(sigl) || strncmp(sigl, sig, strlen(sigl)))
|
---|
| 388 | didmatch = FALSE;
|
---|
| 389 | fclose(fp);
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
[2] | 392 | }
|
---|
[551] | 393 | if (didmatch) { /* got a match; do it... */
|
---|
[2] | 394 |
|
---|
[551] | 395 | CHAR *list[2];
|
---|
| 396 | INT flags, rc;
|
---|
| 397 | BOOL dieafter = FALSE;
|
---|
[2] | 398 |
|
---|
[551] | 399 | if (fAmAV2) {
|
---|
| 400 | if (stristr(info->cl, "AV2.EXE") ||
|
---|
| 401 | stristr(info->cl, "AV2.CMD") || stristr(info->cl, "<>"))
|
---|
| 402 | return -1;
|
---|
| 403 | }
|
---|
| 404 | if (!strcmp(info->cl, "<>")) {
|
---|
| 405 | OpenObject(datafile, Default, hwnd);
|
---|
| 406 | return 0;
|
---|
| 407 | }
|
---|
| 408 | list[0] = datafile;
|
---|
| 409 | list[1] = NULL;
|
---|
| 410 | flags = info->flags;
|
---|
| 411 | if (!(flags & FULLSCREEN))
|
---|
| 412 | flags |= WINDOWED;
|
---|
| 413 | if (flags & KEEP)
|
---|
| 414 | flags |= SEPARATEKEEP;
|
---|
| 415 | else
|
---|
| 416 | flags |= SEPARATE;
|
---|
| 417 | flags &= (~KEEP);
|
---|
| 418 | if (flags & DIEAFTER)
|
---|
| 419 | dieafter = TRUE;
|
---|
| 420 | flags &= (~DIEAFTER);
|
---|
| 421 | rc = ExecOnList(hwnd,
|
---|
| 422 | info->cl,
|
---|
| 423 | flags,
|
---|
[888] | 424 | NULL, list, GetPString(IDS_EXECASSOCTITLETEXT),
|
---|
| 425 | pszSrcFile, __LINE__);
|
---|
[551] | 426 | if (rc != -1 && dieafter)
|
---|
| 427 | PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
| 428 | return rc;
|
---|
[2] | 429 | }
|
---|
[551] | 430 | p = strtok(0, ";");
|
---|
[2] | 431 | }
|
---|
| 432 | info = info->next;
|
---|
| 433 | }
|
---|
| 434 | return -1;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
[551] | 437 | MRESULT EXPENTRY AssocDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[342] | 438 | {
|
---|
[2] | 439 | LINKASSOC *info;
|
---|
[551] | 440 | SHORT x, y;
|
---|
[2] | 441 |
|
---|
[551] | 442 | switch (msg) {
|
---|
| 443 | case WM_INITDLG:
|
---|
| 444 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 445 | WinSendDlgItemMsg(hwnd, ASS_MASK, EM_SETTEXTLIMIT,
|
---|
| 446 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 447 | WinSendDlgItemMsg(hwnd, ASS_CL, EM_SETTEXTLIMIT,
|
---|
| 448 | MPFROM2SHORT(1000, 0), MPVOID);
|
---|
| 449 | WinSendDlgItemMsg(hwnd, ASS_SIG, EM_SETTEXTLIMIT,
|
---|
| 450 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 451 | WinSendDlgItemMsg(hwnd, ASS_OFFSET, EM_SETTEXTLIMIT,
|
---|
| 452 | MPFROM2SHORT(34, 0), MPVOID);
|
---|
| 453 | WinSetDlgItemText(hwnd, ASS_MASK, NullStr);
|
---|
| 454 | WinSetDlgItemText(hwnd, ASS_CL, NullStr);
|
---|
| 455 | WinSetDlgItemText(hwnd, ASS_SIG, NullStr);
|
---|
| 456 | WinSetDlgItemText(hwnd, ASS_OFFSET, "0");
|
---|
| 457 | WinCheckButton(hwnd, ASS_DEFAULT, TRUE);
|
---|
| 458 | WinCheckButton(hwnd, ASS_PROMPT, FALSE);
|
---|
| 459 | WinCheckButton(hwnd, ASS_KEEP, FALSE);
|
---|
| 460 | WinCheckButton(hwnd, ASS_DIEAFTER, FALSE);
|
---|
| 461 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
| 462 | {
|
---|
| 463 | PFNWP oldproc;
|
---|
[2] | 464 |
|
---|
[551] | 465 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, ASS_CL),
|
---|
| 466 | (PFNWP) AssocTextProc);
|
---|
| 467 | if (oldproc)
|
---|
| 468 | WinSetWindowPtr(WinWindowFromID(hwnd, ASS_CL), QWL_USER,
|
---|
| 469 | (PVOID) oldproc);
|
---|
| 470 | }
|
---|
| 471 | break;
|
---|
[2] | 472 |
|
---|
[551] | 473 | case UM_UNDO:
|
---|
| 474 | {
|
---|
| 475 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
[2] | 476 |
|
---|
[551] | 477 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 478 | info = asshead;
|
---|
| 479 | while (info) {
|
---|
| 480 | sprintf(s,
|
---|
| 481 | "%-12s \x1a %-24s %s%s%s",
|
---|
| 482 | info->mask,
|
---|
| 483 | info->cl,
|
---|
| 484 | (info->sig && *info->sig) ?
|
---|
| 485 | "[" : NullStr,
|
---|
| 486 | (info->sig && *info->sig) ? info->sig : NullStr,
|
---|
| 487 | (info->sig && *info->sig) ? "]" : NullStr);
|
---|
| 488 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 489 | ASS_LISTBOX,
|
---|
| 490 | LM_INSERTITEM,
|
---|
| 491 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 492 | if (x >= 0)
|
---|
| 493 | WinSendDlgItemMsg(hwnd,
|
---|
| 494 | ASS_LISTBOX,
|
---|
| 495 | LM_SETITEMHANDLE, MPFROMSHORT(x), MPFROMP(info));
|
---|
| 496 | info = info->next;
|
---|
[2] | 497 | }
|
---|
[551] | 498 | WinSendDlgItemMsg(hwnd,
|
---|
| 499 | ASS_LISTBOX,
|
---|
| 500 | LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
| 501 | }
|
---|
| 502 | return 0;
|
---|
[2] | 503 |
|
---|
[551] | 504 | case WM_CONTROL:
|
---|
| 505 | if (SHORT1FROMMP(mp1) == ASS_LISTBOX) {
|
---|
| 506 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 507 | case LN_ENTER:
|
---|
| 508 | case LN_SELECT:
|
---|
| 509 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 510 | ASS_LISTBOX,
|
---|
| 511 | LM_QUERYSELECTION,
|
---|
| 512 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 513 | if (x >= 0) {
|
---|
[2] | 514 |
|
---|
[551] | 515 | CHAR s[36];
|
---|
[2] | 516 |
|
---|
[551] | 517 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd,
|
---|
| 518 | ASS_LISTBOX,
|
---|
| 519 | LM_QUERYITEMHANDLE,
|
---|
| 520 | MPFROMSHORT(x), MPVOID);
|
---|
| 521 | if (!info) {
|
---|
| 522 | Runtime_Error(pszSrcFile, __LINE__, "Query item handle failed");
|
---|
| 523 | break;
|
---|
| 524 | }
|
---|
| 525 | WinSetDlgItemText(hwnd, ASS_MASK, info->mask);
|
---|
| 526 | WinSetDlgItemText(hwnd, ASS_CL, info->cl);
|
---|
| 527 | WinSetDlgItemText(hwnd, ASS_SIG,
|
---|
| 528 | (info->sig && *info->sig) ? info->sig : NullStr);
|
---|
| 529 | sprintf(s, "%ld", info->offset);
|
---|
| 530 | WinSetDlgItemText(hwnd, ASS_OFFSET, s);
|
---|
| 531 | if (!(info->flags & 1023))
|
---|
| 532 | WinCheckButton(hwnd, ASS_DEFAULT, TRUE);
|
---|
| 533 | else {
|
---|
| 534 | if (info->flags & FULLSCREEN)
|
---|
| 535 | WinCheckButton(hwnd, ASS_FULLSCREEN, TRUE);
|
---|
| 536 | else if (info->flags & MINIMIZED)
|
---|
| 537 | WinCheckButton(hwnd, ASS_MINIMIZED, TRUE);
|
---|
| 538 | else if (info->flags & MAXIMIZED)
|
---|
| 539 | WinCheckButton(hwnd, ASS_MAXIMIZED, TRUE);
|
---|
| 540 | else if (info->flags & INVISIBLE)
|
---|
| 541 | WinCheckButton(hwnd, ASS_INVISIBLE, TRUE);
|
---|
| 542 | }
|
---|
| 543 | WinCheckButton(hwnd, ASS_KEEP, ((info->flags & KEEP) != 0));
|
---|
| 544 | WinCheckButton(hwnd, ASS_DIEAFTER, ((info->flags & DIEAFTER) != 0));
|
---|
| 545 | WinCheckButton(hwnd, ASS_PROMPT, ((info->flags & PROMPT) != 0));
|
---|
| 546 | {
|
---|
| 547 | CHAR env[1002];
|
---|
| 548 | ULONG size;
|
---|
[2] | 549 |
|
---|
[551] | 550 | *env = 0;
|
---|
| 551 | size = sizeof(env) - 1;
|
---|
| 552 | if (PrfQueryProfileData(fmprof,
|
---|
| 553 | FM3Str, info->cl, env, &size) && *env)
|
---|
| 554 | WinSetDlgItemText(hwnd, ASS_ENVIRON, env);
|
---|
| 555 | else
|
---|
| 556 | WinSetDlgItemText(hwnd, ASS_ENVIRON, NullStr);
|
---|
| 557 | }
|
---|
| 558 | }
|
---|
| 559 | break;
|
---|
[2] | 560 | }
|
---|
[551] | 561 | }
|
---|
| 562 | return 0;
|
---|
[2] | 563 |
|
---|
[551] | 564 | case WM_COMMAND:
|
---|
| 565 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 566 | case ASS_TOP:
|
---|
| 567 | x = (SHORT) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
| 568 | LM_QUERYSELECTION,
|
---|
| 569 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 570 | if (x >= 0) {
|
---|
| 571 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
| 572 | LM_QUERYITEMHANDLE,
|
---|
| 573 | MPFROMSHORT(x), MPVOID);
|
---|
| 574 | if (info) {
|
---|
| 575 | if (info != asshead) {
|
---|
| 576 | if (info->prev)
|
---|
| 577 | info->prev->next = info->next;
|
---|
| 578 | if (info->next)
|
---|
| 579 | info->next->prev = info->prev;
|
---|
| 580 | if (info == asstail)
|
---|
| 581 | asstail = info->prev;
|
---|
| 582 | info->prev = NULL;
|
---|
| 583 | info->next = asshead;
|
---|
| 584 | asshead->prev = info;
|
---|
| 585 | asshead = info;
|
---|
| 586 | WinSendMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
| 587 | }
|
---|
| 588 | }
|
---|
| 589 | }
|
---|
| 590 | break;
|
---|
[2] | 591 |
|
---|
[551] | 592 | case ASS_BOTTOM:
|
---|
| 593 | x = (SHORT) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
| 594 | LM_QUERYSELECTION,
|
---|
| 595 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 596 | if (x >= 0) {
|
---|
| 597 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
| 598 | LM_QUERYITEMHANDLE,
|
---|
| 599 | MPFROMSHORT(x), MPVOID);
|
---|
| 600 | if (info) {
|
---|
| 601 | if (info != asstail) {
|
---|
| 602 | if (info->next)
|
---|
| 603 | info->next->prev = info->prev;
|
---|
| 604 | if (info->prev)
|
---|
| 605 | info->prev->next = info->next;
|
---|
| 606 | if (info == asshead)
|
---|
| 607 | asshead = info->next;
|
---|
| 608 | info->next = NULL;
|
---|
| 609 | info->prev = asstail;
|
---|
| 610 | asstail->next = info;
|
---|
| 611 | asstail = info;
|
---|
| 612 | WinSendMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
| 613 | }
|
---|
| 614 | }
|
---|
| 615 | }
|
---|
| 616 | break;
|
---|
| 617 | case ASS_FIND:
|
---|
| 618 | {
|
---|
[888] | 619 | CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
|
---|
[2] | 620 |
|
---|
[551] | 621 | *filename = 0;
|
---|
[888] | 622 | if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
|
---|
| 623 | BldQuotedFileName(szfilename, filename);
|
---|
| 624 | strcat(szfilename, " %a");
|
---|
| 625 | WinSetDlgItemText(hwnd, ASS_CL, szfilename);
|
---|
[551] | 626 | }
|
---|
| 627 | }
|
---|
| 628 | break;
|
---|
[2] | 629 |
|
---|
[551] | 630 | case DID_OK:
|
---|
| 631 | {
|
---|
| 632 | ASSOC temp;
|
---|
[918] | 633 | CHAR dummy[34];
|
---|
[920] | 634 | PSZ pszWorkBuf;
|
---|
[918] | 635 | replace = FALSE;
|
---|
[506] | 636 |
|
---|
[551] | 637 | {
|
---|
| 638 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 639 | ASS_LISTBOX,
|
---|
| 640 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
| 641 | if (x == LIT_NONE)
|
---|
| 642 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 643 | ASS_LISTBOX,
|
---|
| 644 | LM_SELECTITEM,
|
---|
| 645 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
[918] | 646 | }
|
---|
[920] | 647 | pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
|
---|
[551] | 648 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 649 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
[909] | 650 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
[920] | 651 | NormalizeCmdLine(pszWorkBuf, temp.cl);
|
---|
| 652 | memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
[927] | 653 | xfree(pszWorkBuf);
|
---|
[551] | 654 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 655 | rstrip(temp.sig);
|
---|
| 656 | if (*temp.sig) {
|
---|
| 657 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 658 | temp.offset = atol(dummy);
|
---|
| 659 | }
|
---|
| 660 | bstrip(temp.mask);
|
---|
| 661 | bstrip(temp.cl);
|
---|
| 662 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 663 | temp.flags = 0;
|
---|
| 664 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 665 | temp.flags = FULLSCREEN;
|
---|
| 666 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 667 | temp.flags = MINIMIZED;
|
---|
| 668 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 669 | temp.flags = MAXIMIZED;
|
---|
| 670 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 671 | temp.flags = INVISIBLE;
|
---|
| 672 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 673 | temp.flags |= KEEP;
|
---|
| 674 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 675 | temp.flags |= DIEAFTER;
|
---|
| 676 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
[909] | 677 | temp.flags |= PROMPT;
|
---|
| 678 | if (fCancelAction){
|
---|
| 679 | fCancelAction = FALSE;
|
---|
| 680 | break;
|
---|
| 681 | }
|
---|
| 682 | else
|
---|
[551] | 683 | info = add_association(&temp);
|
---|
| 684 | if (!info)
|
---|
| 685 | WinDismissDlg(hwnd, 1); /* Runtime_Error(pszSrcFile, __LINE__, "add_association"); */
|
---|
| 686 | else {
|
---|
[506] | 687 |
|
---|
[551] | 688 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
[2] | 689 |
|
---|
[551] | 690 | *s = 0;
|
---|
| 691 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 692 | bstripcr(s);
|
---|
| 693 | if (*s)
|
---|
| 694 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 695 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 696 | temp.cl, (*temp.sig) ?
|
---|
| 697 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 698 | (*temp.sig) ? "]" : NullStr);
|
---|
| 699 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 700 | ASS_LISTBOX,
|
---|
| 701 | LM_INSERTITEM,
|
---|
| 702 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 703 | if (x >= 0) {
|
---|
| 704 | WinSendDlgItemMsg(hwnd,
|
---|
| 705 | ASS_LISTBOX,
|
---|
| 706 | LM_SETITEMHANDLE,
|
---|
| 707 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 708 | WinSendDlgItemMsg(hwnd,
|
---|
| 709 | ASS_LISTBOX,
|
---|
| 710 | LM_SELECTITEM,
|
---|
| 711 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 712 | }
|
---|
| 713 | save_associations();
|
---|
| 714 | }
|
---|
| 715 | }
|
---|
| 716 | WinDismissDlg(hwnd, 1);
|
---|
| 717 | break;
|
---|
[2] | 718 |
|
---|
[551] | 719 | case DID_CANCEL:
|
---|
| 720 | WinDismissDlg(hwnd, 0);
|
---|
| 721 | break;
|
---|
[2] | 722 |
|
---|
[551] | 723 | case IDM_HELP:
|
---|
| 724 | if (hwndHelp)
|
---|
| 725 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 726 | MPFROM2SHORT(HELP_ASSOC, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 727 | break;
|
---|
[2] | 728 |
|
---|
[551] | 729 | case ASS_ADD:
|
---|
| 730 | {
|
---|
| 731 | ASSOC temp;
|
---|
[918] | 732 | CHAR dummy[34];
|
---|
[920] | 733 | PSZ pszWorkBuf;
|
---|
[551] | 734 | replace = FALSE;
|
---|
[2] | 735 |
|
---|
[920] | 736 | pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
|
---|
[551] | 737 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 738 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
[909] | 739 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
[920] | 740 | NormalizeCmdLine(pszWorkBuf, temp.cl);
|
---|
| 741 | memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
[927] | 742 | xfree(pszWorkBuf);
|
---|
[551] | 743 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 744 | rstrip(temp.sig);
|
---|
| 745 | if (*temp.sig) {
|
---|
| 746 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 747 | temp.offset = atol(dummy);
|
---|
| 748 | }
|
---|
| 749 | bstrip(temp.mask);
|
---|
| 750 | bstrip(temp.cl);
|
---|
| 751 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 752 | temp.flags = 0;
|
---|
| 753 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 754 | temp.flags = FULLSCREEN;
|
---|
| 755 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 756 | temp.flags = MINIMIZED;
|
---|
| 757 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 758 | temp.flags = MAXIMIZED;
|
---|
| 759 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 760 | temp.flags = INVISIBLE;
|
---|
| 761 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 762 | temp.flags |= KEEP;
|
---|
| 763 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 764 | temp.flags |= DIEAFTER;
|
---|
| 765 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
[909] | 766 | temp.flags |= PROMPT;
|
---|
| 767 | if (fCancelAction){
|
---|
| 768 | fCancelAction = FALSE;
|
---|
| 769 | break;
|
---|
| 770 | }
|
---|
| 771 | else
|
---|
| 772 | info = add_association(&temp);
|
---|
[551] | 773 | //Add will fail if mask is not changed
|
---|
| 774 | if (info) {
|
---|
[2] | 775 |
|
---|
[551] | 776 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
[2] | 777 |
|
---|
[551] | 778 | *s = 0;
|
---|
| 779 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 780 | bstripcr(s);
|
---|
| 781 | if (*s)
|
---|
| 782 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 783 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 784 | temp.cl, (*temp.sig) ?
|
---|
| 785 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 786 | (*temp.sig) ? "]" : NullStr);
|
---|
| 787 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 788 | ASS_LISTBOX,
|
---|
| 789 | LM_INSERTITEM,
|
---|
| 790 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 791 | if (x >= 0) {
|
---|
| 792 | WinSendDlgItemMsg(hwnd,
|
---|
| 793 | ASS_LISTBOX,
|
---|
| 794 | LM_SETITEMHANDLE,
|
---|
| 795 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 796 | WinSendDlgItemMsg(hwnd,
|
---|
| 797 | ASS_LISTBOX,
|
---|
| 798 | LM_SELECTITEM,
|
---|
| 799 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 800 | }
|
---|
| 801 | save_associations();
|
---|
| 802 | }
|
---|
| 803 | }
|
---|
| 804 | break;
|
---|
[506] | 805 |
|
---|
[551] | 806 | case ASS_DELETE:
|
---|
| 807 | {
|
---|
| 808 | ASSOC temp;
|
---|
| 809 | CHAR dummy[34];
|
---|
[506] | 810 |
|
---|
[551] | 811 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 812 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 813 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 814 | rstrip(temp.sig);
|
---|
| 815 | if (*temp.sig) {
|
---|
| 816 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 817 | temp.offset = atol(dummy);
|
---|
| 818 | }
|
---|
| 819 | bstrip(temp.mask);
|
---|
| 820 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
[552] | 821 | if (kill_association(&temp))
|
---|
| 822 | /* Runtime_Error(pszSrcFile, __LINE__, "kill_association");
|
---|
| 823 | else */{
|
---|
[551] | 824 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 825 | ASS_LISTBOX,
|
---|
| 826 | LM_QUERYSELECTION,
|
---|
| 827 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 828 | if (x >= 0) {
|
---|
| 829 | WinSendDlgItemMsg(hwnd,
|
---|
| 830 | ASS_LISTBOX,
|
---|
| 831 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
| 832 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
| 833 | MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
|
---|
| 834 | }
|
---|
| 835 | save_associations();
|
---|
| 836 | }
|
---|
| 837 | }
|
---|
| 838 | break;
|
---|
| 839 | case ASS_REPLACE:
|
---|
[506] | 840 |
|
---|
[551] | 841 | {
|
---|
| 842 | ASSOC temp;
|
---|
[918] | 843 | CHAR dummy[34];
|
---|
[920] | 844 | PSZ pszWorkBuf;
|
---|
[551] | 845 | replace = TRUE;
|
---|
[506] | 846 |
|
---|
[551] | 847 | y = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 848 | ASS_LISTBOX,
|
---|
| 849 | LM_QUERYSELECTION,
|
---|
[918] | 850 | MPFROMSHORT(LIT_CURSOR), MPVOID);
|
---|
[920] | 851 | pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
|
---|
[551] | 852 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 853 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
[909] | 854 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
[920] | 855 | NormalizeCmdLine(pszWorkBuf, temp.cl);
|
---|
| 856 | memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
[927] | 857 | xfree(pszWorkBuf);
|
---|
[551] | 858 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 859 | rstrip(temp.sig);
|
---|
| 860 | if (*temp.sig) {
|
---|
| 861 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 862 | temp.offset = atol(dummy);
|
---|
| 863 | }
|
---|
| 864 | bstrip(temp.mask);
|
---|
| 865 | bstrip(temp.cl);
|
---|
| 866 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 867 | temp.flags = 0;
|
---|
| 868 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 869 | temp.flags = FULLSCREEN;
|
---|
| 870 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 871 | temp.flags = MINIMIZED;
|
---|
| 872 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 873 | temp.flags = MAXIMIZED;
|
---|
| 874 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 875 | temp.flags = INVISIBLE;
|
---|
| 876 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 877 | temp.flags |= KEEP;
|
---|
| 878 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 879 | temp.flags |= DIEAFTER;
|
---|
| 880 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
[909] | 881 | temp.flags |= PROMPT;
|
---|
| 882 | if (fCancelAction){
|
---|
| 883 | fCancelAction = FALSE;
|
---|
| 884 | break;
|
---|
| 885 | }
|
---|
| 886 | else
|
---|
| 887 | info = add_association(&temp);
|
---|
[551] | 888 | //Add will fail if mask is not changed
|
---|
| 889 | if (info) {
|
---|
[529] | 890 |
|
---|
[551] | 891 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
| 892 |
|
---|
| 893 | *s = 0;
|
---|
| 894 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 895 | bstripcr(s);
|
---|
| 896 | if (*s)
|
---|
| 897 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 898 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 899 | temp.cl, (*temp.sig) ?
|
---|
| 900 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 901 | (*temp.sig) ? "]" : NullStr);
|
---|
| 902 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 903 | ASS_LISTBOX,
|
---|
| 904 | LM_INSERTITEM,
|
---|
| 905 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 906 | if (x >= 0) {
|
---|
| 907 | WinSendDlgItemMsg(hwnd,
|
---|
| 908 | ASS_LISTBOX,
|
---|
| 909 | LM_SETITEMHANDLE,
|
---|
| 910 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 911 | WinSendDlgItemMsg(hwnd,
|
---|
| 912 | ASS_LISTBOX,
|
---|
| 913 | LM_SELECTITEM,
|
---|
| 914 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 915 | }
|
---|
| 916 | save_associations();
|
---|
| 917 | }
|
---|
[2] | 918 | }
|
---|
[551] | 919 | {
|
---|
| 920 | ASSOC temp;
|
---|
| 921 | CHAR dummy[34];
|
---|
| 922 |
|
---|
| 923 | WinSendDlgItemMsg(hwnd,
|
---|
| 924 | ASS_LISTBOX,
|
---|
| 925 | LM_SELECTITEM, MPFROMSHORT(y), MPFROMSHORT(TRUE));
|
---|
| 926 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 927 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 928 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 929 | rstrip(temp.sig);
|
---|
| 930 | if (*temp.sig) {
|
---|
| 931 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 932 | temp.offset = atol(dummy);
|
---|
| 933 | }
|
---|
| 934 | bstrip(temp.mask);
|
---|
| 935 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
| 936 | if (!kill_association(&temp))
|
---|
| 937 | Runtime_Error(pszSrcFile, __LINE__, "kill_association");
|
---|
| 938 | else {
|
---|
| 939 |
|
---|
| 940 | if (y >= 0) {
|
---|
| 941 | WinSendDlgItemMsg(hwnd,
|
---|
| 942 | ASS_LISTBOX,
|
---|
| 943 | LM_DELETEITEM, MPFROMSHORT(y), MPVOID);
|
---|
| 944 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
| 945 | MPFROMSHORT(x - 1), MPFROMSHORT(TRUE));
|
---|
| 946 | }
|
---|
| 947 | save_associations();
|
---|
| 948 | }
|
---|
| 949 | }
|
---|
| 950 | break;
|
---|
| 951 | }
|
---|
| 952 | return 0;
|
---|
| 953 | }
|
---|
| 954 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 955 | }
|
---|
| 956 |
|
---|
[551] | 957 | VOID EditAssociations(HWND hwnd)
|
---|
[342] | 958 | {
|
---|
[2] | 959 | static CHAR stop = 0;
|
---|
| 960 |
|
---|
[551] | 961 | if (stop)
|
---|
[2] | 962 | return;
|
---|
| 963 | stop++;
|
---|
[551] | 964 | if (!assloaded)
|
---|
[2] | 965 | load_associations();
|
---|
[551] | 966 | WinDlgBox(HWND_DESKTOP, hwnd, AssocDlgProc, FM3ModHandle, ASS_FRAME, NULL);
|
---|
[2] | 967 | stop = 0;
|
---|
| 968 | }
|
---|
[793] | 969 |
|
---|
| 970 | #pragma alloc_text(ASSOC2,free_commands,load_associations,save_associations)
|
---|
| 971 | #pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc)
|
---|
| 972 | #pragma alloc_text(ASSOC,add_association,kill_association,AssocDlgProc,EditAssociations)
|
---|