[123] | 1 |
|
---|
[506] | 2 | /**************************************************************************************
|
---|
[123] | 3 |
|
---|
| 4 | $Id: assoc.c 618 2007-04-20 19:19:03Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
[552] | 7 | Copyright (c) 2004, 2007 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
|
---|
[123] | 16 |
|
---|
[506] | 17 | **************************************************************************************/
|
---|
[123] | 18 |
|
---|
[2] | 19 | #define INCL_DOS
|
---|
| 20 | #define INCL_WIN
|
---|
[506] | 21 | #define INCL_PM
|
---|
| 22 | #define INCL_WINHOOKS
|
---|
[2] | 23 |
|
---|
| 24 | #include <os2.h>
|
---|
| 25 | #include <stdio.h>
|
---|
| 26 | #include <stdlib.h>
|
---|
| 27 | #include <string.h>
|
---|
| 28 | #include <ctype.h>
|
---|
| 29 | #include <share.h>
|
---|
| 30 | #include "fm3dll.h"
|
---|
| 31 | #include "fm3dlg.h"
|
---|
| 32 | #include "fm3str.h"
|
---|
| 33 |
|
---|
| 34 | #pragma data_seg(DATA1)
|
---|
| 35 |
|
---|
[551] | 36 | typedef struct
|
---|
| 37 | {
|
---|
| 38 | CHAR mask[CCHMAXPATH];
|
---|
| 39 | CHAR cl[1001];
|
---|
| 40 | CHAR sig[CCHMAXPATH];
|
---|
| 41 | LONG offset;
|
---|
[2] | 42 | ULONG flags;
|
---|
[551] | 43 | }
|
---|
| 44 | ASSOC;
|
---|
[2] | 45 |
|
---|
[551] | 46 | typedef struct LINKASSOC
|
---|
| 47 | {
|
---|
| 48 | CHAR *mask;
|
---|
| 49 | CHAR *cl;
|
---|
| 50 | CHAR *sig;
|
---|
| 51 | LONG offset;
|
---|
| 52 | ULONG flags;
|
---|
[2] | 53 | struct LINKASSOC *prev;
|
---|
| 54 | struct LINKASSOC *next;
|
---|
[551] | 55 | }
|
---|
| 56 | LINKASSOC;
|
---|
[2] | 57 |
|
---|
[551] | 58 | static LINKASSOC *asshead = NULL, *asstail = NULL;
|
---|
| 59 | static BOOL assloaded = FALSE, replace = FALSE;
|
---|
[506] | 60 |
|
---|
[342] | 61 | static PSZ pszSrcFile = __FILE__;
|
---|
| 62 |
|
---|
[2] | 63 | #pragma alloc_text(ASSOC2,free_commands,load_associations,save_associations)
|
---|
| 64 | #pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc)
|
---|
| 65 |
|
---|
[551] | 66 | MRESULT EXPENTRY AssocTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[342] | 67 | {
|
---|
[551] | 68 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 69 | static BOOL emphasized = FALSE;
|
---|
| 70 |
|
---|
[551] | 71 | switch (msg) {
|
---|
| 72 | case DM_DRAGOVER:
|
---|
| 73 | if (!emphasized) {
|
---|
| 74 | emphasized = TRUE;
|
---|
| 75 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 76 | }
|
---|
[618] | 77 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
[551] | 78 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
| 79 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
[2] | 80 |
|
---|
[551] | 81 | case DM_DRAGLEAVE:
|
---|
| 82 | if (emphasized) {
|
---|
| 83 | emphasized = FALSE;
|
---|
| 84 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 85 | }
|
---|
| 86 | break;
|
---|
[2] | 87 |
|
---|
[551] | 88 | case DM_DROPHELP:
|
---|
| 89 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_ASSOCDROPHELPTEXT));
|
---|
| 90 | return 0;
|
---|
[2] | 91 |
|
---|
[551] | 92 | case DM_DROP:
|
---|
| 93 | {
|
---|
| 94 | char szFrom[CCHMAXPATH + 5];
|
---|
[2] | 95 |
|
---|
[551] | 96 | if (emphasized) {
|
---|
| 97 | emphasized = FALSE;
|
---|
| 98 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
[2] | 99 | }
|
---|
[618] | 100 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) {
|
---|
[551] | 101 | strcat(szFrom, " %a");
|
---|
| 102 | WinSetWindowText(hwnd, szFrom);
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | return 0;
|
---|
[2] | 106 | }
|
---|
[551] | 107 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
| 108 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 109 | }
|
---|
| 110 |
|
---|
[551] | 111 | VOID free_associations(VOID)
|
---|
[342] | 112 | {
|
---|
[551] | 113 | LINKASSOC *info, *next;
|
---|
[2] | 114 |
|
---|
| 115 | info = asshead;
|
---|
[551] | 116 | while (info) {
|
---|
[2] | 117 | next = info->next;
|
---|
| 118 | free(info->mask);
|
---|
| 119 | free(info->cl);
|
---|
[551] | 120 | if (info->sig)
|
---|
[2] | 121 | free(info->sig);
|
---|
| 122 | free(info);
|
---|
| 123 | info = next;
|
---|
| 124 | }
|
---|
| 125 | asshead = asstail = NULL;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[551] | 128 | VOID load_associations(VOID)
|
---|
[342] | 129 | {
|
---|
[551] | 130 | FILE *fp;
|
---|
[2] | 131 | LINKASSOC *info;
|
---|
[551] | 132 | CHAR cl[1024];
|
---|
| 133 | CHAR mask[CCHMAXPATH + 24];
|
---|
| 134 | CHAR sig[CCHMAXPATH + 24];
|
---|
| 135 | CHAR offset[72];
|
---|
| 136 | CHAR flags[72];
|
---|
[2] | 137 |
|
---|
[551] | 138 | if (asshead)
|
---|
[2] | 139 | free_associations();
|
---|
| 140 | assloaded = TRUE;
|
---|
| 141 | save_dir2(mask);
|
---|
[551] | 142 | if (mask[strlen(mask) - 1] != '\\')
|
---|
| 143 | strcat(mask, "\\");
|
---|
| 144 | strcat(mask, "ASSOC.DAT");
|
---|
| 145 | fp = _fsopen(mask, "r", SH_DENYWR);
|
---|
[342] | 146 | if (fp) {
|
---|
[551] | 147 | while (!feof(fp)) {
|
---|
| 148 | if (!xfgets(mask, sizeof(mask), fp, pszSrcFile, __LINE__)) // fixme why +24?
|
---|
| 149 | break;
|
---|
[2] | 150 | mask[CCHMAXPATH] = 0;
|
---|
[123] | 151 | bstripcr(mask);
|
---|
[551] | 152 | if (!*mask || *mask == ';')
|
---|
| 153 | continue;
|
---|
| 154 | if (!xfgets(cl, sizeof(cl), fp, pszSrcFile, __LINE__) ||
|
---|
| 155 | !xfgets(sig, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__) ||
|
---|
| 156 | !xfgets(offset, sizeof(offset), fp, pszSrcFile, __LINE__) ||
|
---|
| 157 | !xfgets(flags, sizeof(flags), fp, pszSrcFile, __LINE__))
|
---|
| 158 | break; /* error! */
|
---|
[2] | 159 | cl[1000] = 0;
|
---|
[405] | 160 | bstripcr(cl);
|
---|
[2] | 161 | sig[CCHMAXPATH] = 0;
|
---|
[405] | 162 | bstripcr(sig);
|
---|
[2] | 163 | offset[34] = 0;
|
---|
[405] | 164 | bstripcr(offset);
|
---|
[2] | 165 | flags[34] = 0;
|
---|
[123] | 166 | bstripcr(flags);
|
---|
[405] | 167 | if (!*cl)
|
---|
[551] | 168 | continue;
|
---|
| 169 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
[342] | 170 | if (info) {
|
---|
[551] | 171 | info->cl = xstrdup(cl, pszSrcFile, __LINE__);
|
---|
| 172 | info->mask = xstrdup(mask, pszSrcFile, __LINE__);
|
---|
| 173 | if (*sig)
|
---|
| 174 | info->sig = xstrdup(sig, pszSrcFile, __LINE__);
|
---|
| 175 | info->offset = atol(offset);
|
---|
| 176 | info->flags = atol(flags);
|
---|
| 177 | if (!info->cl || !info->mask) {
|
---|
| 178 | if (info->cl)
|
---|
| 179 | free(info->cl);
|
---|
| 180 | if (info->mask)
|
---|
| 181 | free(info->mask);
|
---|
| 182 | free(info);
|
---|
| 183 | break;
|
---|
| 184 | }
|
---|
| 185 | if (!asshead)
|
---|
| 186 | asshead = info;
|
---|
| 187 | else {
|
---|
| 188 | asstail->next = info;
|
---|
| 189 | info->prev = asstail;
|
---|
| 190 | }
|
---|
| 191 | asstail = info;
|
---|
[2] | 192 | }
|
---|
| 193 | }
|
---|
| 194 | fclose(fp);
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 |
|
---|
[551] | 198 | VOID save_associations(VOID)
|
---|
[342] | 199 | {
|
---|
[2] | 200 | LINKASSOC *info;
|
---|
[551] | 201 | FILE *fp;
|
---|
| 202 | CHAR s[CCHMAXPATH + 14];
|
---|
[2] | 203 |
|
---|
[551] | 204 | if (!assloaded || !asshead)
|
---|
[2] | 205 | return;
|
---|
| 206 | info = asshead;
|
---|
| 207 | #ifdef NEVER
|
---|
[551] | 208 | while (info) {
|
---|
[2] | 209 | next = info->next;
|
---|
[551] | 210 | if (!strcmp("*", info->mask)) {
|
---|
| 211 | if (info != asshead) { /* already top record */
|
---|
| 212 | if (info->prev)
|
---|
| 213 | (info->prev)->next = info->next;
|
---|
| 214 | if (info->next)
|
---|
| 215 | (info->next)->prev = info->prev;
|
---|
| 216 | if (info == asstail)
|
---|
| 217 | asstail = info->prev;
|
---|
| 218 | info->next = asshead->next;
|
---|
| 219 | info->prev = NULL;
|
---|
| 220 | asshead = info;
|
---|
[2] | 221 | }
|
---|
| 222 | }
|
---|
| 223 | info = next;
|
---|
| 224 | }
|
---|
| 225 | #endif
|
---|
| 226 | save_dir2(s);
|
---|
[551] | 227 | if (s[strlen(s) - 1] != '\\')
|
---|
| 228 | strcat(s, "\\");
|
---|
| 229 | strcat(s, "ASSOC.DAT");
|
---|
| 230 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
---|
[342] | 231 | if (fp) {
|
---|
[551] | 232 | fputs(GetPString(IDS_ASSOCFILETEXT), fp);
|
---|
[2] | 233 | info = asshead;
|
---|
[551] | 234 | while (info) {
|
---|
[2] | 235 | fprintf(fp,
|
---|
[551] | 236 | ";\n%0.*s\n%0.1000s\n%0.*s\n%lu\n%lu\n",
|
---|
| 237 | CCHMAXPATH,
|
---|
| 238 | info->mask,
|
---|
| 239 | info->cl,
|
---|
| 240 | CCHMAXPATH,
|
---|
| 241 | (info->sig) ? info->sig : NullStr, info->offset, info->flags);
|
---|
[2] | 242 | info = info->next;
|
---|
| 243 | }
|
---|
| 244 | fclose(fp);
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 |
|
---|
| 248 | #pragma alloc_text(ASSOC,add_association,kill_association,AssocDlgProc,EditAssociations)
|
---|
| 249 |
|
---|
[551] | 250 | LINKASSOC *add_association(ASSOC * addme)
|
---|
[342] | 251 | {
|
---|
[2] | 252 | LINKASSOC *info;
|
---|
| 253 |
|
---|
[551] | 254 | if (addme && *addme->cl && *addme->mask) {
|
---|
[2] | 255 | info = asshead;
|
---|
[551] | 256 | while (info) {
|
---|
| 257 | if ((!replace) && (!stricmp(info->mask, addme->mask) &&
|
---|
| 258 | ((!info->sig && !*addme->sig) || (!replace) &&
|
---|
| 259 | (info->sig && !strcmp(addme->sig, info->sig)))))
|
---|
| 260 | return NULL;
|
---|
[2] | 261 | info = info->next;
|
---|
| 262 | }
|
---|
[551] | 263 | if (!info) {
|
---|
| 264 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
| 265 | if (info) {
|
---|
| 266 | info->cl = xstrdup(addme->cl, pszSrcFile, __LINE__);
|
---|
| 267 | info->mask = xstrdup(addme->mask, pszSrcFile, __LINE__);
|
---|
| 268 | if (*addme->sig)
|
---|
| 269 | info->sig = xstrdup(addme->sig, pszSrcFile, __LINE__);
|
---|
| 270 | if (addme->offset)
|
---|
| 271 | info->offset = addme->offset;
|
---|
| 272 | if (addme->flags)
|
---|
| 273 | info->flags = addme->flags;
|
---|
| 274 | if (!info->cl || !info->mask) {
|
---|
| 275 | if (info->cl)
|
---|
| 276 | free(info->cl);
|
---|
| 277 | if (info->mask)
|
---|
| 278 | free(info->mask);
|
---|
| 279 | free(info);
|
---|
| 280 | }
|
---|
| 281 | else {
|
---|
| 282 | if (!asshead) /* only item in list */
|
---|
| 283 | asshead = asstail = info;
|
---|
| 284 | else {
|
---|
| 285 | if (asstail) { /* place at tail */
|
---|
| 286 | asstail->next = info;
|
---|
| 287 | info->prev = asstail;
|
---|
| 288 | }
|
---|
| 289 | asstail = info;
|
---|
| 290 | }
|
---|
| 291 | return info;
|
---|
| 292 | }
|
---|
[2] | 293 | }
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 | return NULL;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
[551] | 299 | BOOL kill_association(ASSOC * killme)
|
---|
[342] | 300 | {
|
---|
[2] | 301 | LINKASSOC *info;
|
---|
| 302 |
|
---|
[551] | 303 | if (killme && *killme->mask) {
|
---|
[2] | 304 | info = asshead;
|
---|
[551] | 305 | while (info) {
|
---|
| 306 | if (!stricmp(info->mask, killme->mask) &&
|
---|
| 307 | info->offset == killme->offset &&
|
---|
| 308 | (((!info->sig || !*info->sig) && !*killme->sig) ||
|
---|
| 309 | (info->sig && !strcmp(killme->sig, info->sig)))) {
|
---|
| 310 | if (info == asshead) {
|
---|
| 311 | asshead = info->next;
|
---|
| 312 | if (info == asstail)
|
---|
| 313 | asstail = info->prev;
|
---|
| 314 | }
|
---|
| 315 | else {
|
---|
| 316 | if (info->next)
|
---|
| 317 | (info->next)->prev = info->prev;
|
---|
| 318 | if (info->prev)
|
---|
| 319 | (info->prev)->next = info->next;
|
---|
| 320 | if (info == asstail)
|
---|
| 321 | asstail = info->prev;
|
---|
| 322 | }
|
---|
| 323 | free(info->cl);
|
---|
| 324 | free(info->mask);
|
---|
| 325 | if (info->sig)
|
---|
| 326 | free(info->sig);
|
---|
| 327 | free(info);
|
---|
| 328 | return TRUE;
|
---|
[2] | 329 | }
|
---|
| 330 | info = info->next;
|
---|
| 331 | }
|
---|
| 332 | }
|
---|
| 333 | return FALSE;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[551] | 336 | INT ExecAssociation(HWND hwnd, CHAR * datafile)
|
---|
[342] | 337 | {
|
---|
[551] | 338 | CHAR *file, sig[CCHMAXPATH], sigl[CCHMAXPATH], mask[CCHMAXPATH], *p;
|
---|
| 339 | FILE *fp;
|
---|
| 340 | BOOL didmatch, exclude;
|
---|
| 341 | ULONG offset;
|
---|
[2] | 342 | LINKASSOC *info;
|
---|
| 343 |
|
---|
[551] | 344 | if (!assloaded)
|
---|
[2] | 345 | load_associations();
|
---|
[551] | 346 | if (!asshead)
|
---|
[2] | 347 | return -1;
|
---|
[551] | 348 | if (!datafile || !*datafile)
|
---|
[2] | 349 | return -1;
|
---|
[551] | 350 | file = strrchr(datafile, '\\');
|
---|
| 351 | if (!file)
|
---|
| 352 | file = strrchr(datafile, ':');
|
---|
| 353 | if (file)
|
---|
[2] | 354 | file++;
|
---|
| 355 | else
|
---|
| 356 | file = datafile;
|
---|
| 357 | info = asshead;
|
---|
[551] | 358 | while (info) {
|
---|
| 359 | strcpy(mask, info->mask);
|
---|
| 360 | p = strtok(mask, ";");
|
---|
| 361 | while (p) {
|
---|
| 362 | if (*p == '/') {
|
---|
| 363 | p++;
|
---|
| 364 | exclude = TRUE;
|
---|
[2] | 365 | }
|
---|
| 366 | else
|
---|
[551] | 367 | exclude = FALSE;
|
---|
| 368 | didmatch = wildcard((strchr(p, '\\') ||
|
---|
| 369 | strchr(p, ':')) ? datafile : file, p, FALSE);
|
---|
| 370 | if (exclude && didmatch)
|
---|
| 371 | didmatch = FALSE;
|
---|
| 372 | if (didmatch) {
|
---|
| 373 | if (info->sig && *info->sig) {
|
---|
| 374 | strcpy(sigl, info->sig);
|
---|
| 375 | literal(sigl);
|
---|
| 376 | fp = _fsopen(datafile, "rb", SH_DENYNO);
|
---|
| 377 | if (fp) {
|
---|
| 378 | if (info->offset < 0L) {
|
---|
| 379 | fseek(fp, 0L, SEEK_END);
|
---|
| 380 | offset = ftell(fp) + info->offset;
|
---|
| 381 | }
|
---|
| 382 | else
|
---|
| 383 | offset = info->offset;
|
---|
| 384 | fseek(fp, offset, SEEK_SET);
|
---|
| 385 | if (fread(sig,
|
---|
| 386 | 1,
|
---|
| 387 | strlen(sigl),
|
---|
| 388 | fp) != strlen(sigl) || strncmp(sigl, sig, strlen(sigl)))
|
---|
| 389 | didmatch = FALSE;
|
---|
| 390 | fclose(fp);
|
---|
| 391 | }
|
---|
| 392 | }
|
---|
[2] | 393 | }
|
---|
[551] | 394 | if (didmatch) { /* got a match; do it... */
|
---|
[2] | 395 |
|
---|
[551] | 396 | CHAR *list[2];
|
---|
| 397 | INT flags, rc;
|
---|
| 398 | BOOL dieafter = FALSE;
|
---|
[2] | 399 |
|
---|
[551] | 400 | if (fAmAV2) {
|
---|
| 401 | if (stristr(info->cl, "AV2.EXE") ||
|
---|
| 402 | stristr(info->cl, "AV2.CMD") || stristr(info->cl, "<>"))
|
---|
| 403 | return -1;
|
---|
| 404 | }
|
---|
| 405 | if (!strcmp(info->cl, "<>")) {
|
---|
| 406 | OpenObject(datafile, Default, hwnd);
|
---|
| 407 | return 0;
|
---|
| 408 | }
|
---|
| 409 | list[0] = datafile;
|
---|
| 410 | list[1] = NULL;
|
---|
| 411 | flags = info->flags;
|
---|
| 412 | if (!(flags & FULLSCREEN))
|
---|
| 413 | flags |= WINDOWED;
|
---|
| 414 | if (flags & KEEP)
|
---|
| 415 | flags |= SEPARATEKEEP;
|
---|
| 416 | else
|
---|
| 417 | flags |= SEPARATE;
|
---|
| 418 | flags &= (~KEEP);
|
---|
| 419 | if (flags & DIEAFTER)
|
---|
| 420 | dieafter = TRUE;
|
---|
| 421 | flags &= (~DIEAFTER);
|
---|
| 422 | rc = ExecOnList(hwnd,
|
---|
| 423 | info->cl,
|
---|
| 424 | flags,
|
---|
| 425 | NULL, list, GetPString(IDS_EXECASSOCTITLETEXT));
|
---|
| 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 | {
|
---|
| 619 | CHAR filename[CCHMAXPATH + 9];
|
---|
[2] | 620 |
|
---|
[551] | 621 | *filename = 0;
|
---|
| 622 | if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
|
---|
| 623 | strcat(filename, " %a");
|
---|
| 624 | WinSetDlgItemText(hwnd, ASS_CL, filename);
|
---|
| 625 | }
|
---|
| 626 | }
|
---|
| 627 | break;
|
---|
[2] | 628 |
|
---|
[551] | 629 | case DID_OK:
|
---|
| 630 | {
|
---|
| 631 | ASSOC temp;
|
---|
| 632 | CHAR dummy[34];
|
---|
[506] | 633 |
|
---|
[551] | 634 | replace = FALSE;
|
---|
| 635 | {
|
---|
| 636 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 637 | ASS_LISTBOX,
|
---|
| 638 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
| 639 | if (x == LIT_NONE)
|
---|
| 640 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 641 | ASS_LISTBOX,
|
---|
| 642 | LM_SELECTITEM,
|
---|
| 643 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
| 644 | }
|
---|
| 645 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 646 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 647 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
| 648 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 649 | rstrip(temp.sig);
|
---|
| 650 | if (*temp.sig) {
|
---|
| 651 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 652 | temp.offset = atol(dummy);
|
---|
| 653 | }
|
---|
| 654 | bstrip(temp.mask);
|
---|
| 655 | bstrip(temp.cl);
|
---|
| 656 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 657 | temp.flags = 0;
|
---|
| 658 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 659 | temp.flags = FULLSCREEN;
|
---|
| 660 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 661 | temp.flags = MINIMIZED;
|
---|
| 662 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 663 | temp.flags = MAXIMIZED;
|
---|
| 664 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 665 | temp.flags = INVISIBLE;
|
---|
| 666 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 667 | temp.flags |= KEEP;
|
---|
| 668 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 669 | temp.flags |= DIEAFTER;
|
---|
| 670 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
| 671 | temp.flags |= PROMPT;
|
---|
| 672 | info = add_association(&temp);
|
---|
| 673 | if (!info)
|
---|
| 674 | WinDismissDlg(hwnd, 1); /* Runtime_Error(pszSrcFile, __LINE__, "add_association"); */
|
---|
| 675 | else {
|
---|
[506] | 676 |
|
---|
[551] | 677 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
[2] | 678 |
|
---|
[551] | 679 | *s = 0;
|
---|
| 680 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 681 | bstripcr(s);
|
---|
| 682 | if (*s)
|
---|
| 683 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 684 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 685 | temp.cl, (*temp.sig) ?
|
---|
| 686 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 687 | (*temp.sig) ? "]" : NullStr);
|
---|
| 688 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 689 | ASS_LISTBOX,
|
---|
| 690 | LM_INSERTITEM,
|
---|
| 691 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 692 | if (x >= 0) {
|
---|
| 693 | WinSendDlgItemMsg(hwnd,
|
---|
| 694 | ASS_LISTBOX,
|
---|
| 695 | LM_SETITEMHANDLE,
|
---|
| 696 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 697 | WinSendDlgItemMsg(hwnd,
|
---|
| 698 | ASS_LISTBOX,
|
---|
| 699 | LM_SELECTITEM,
|
---|
| 700 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 701 | }
|
---|
| 702 | save_associations();
|
---|
| 703 | }
|
---|
| 704 | }
|
---|
| 705 | WinDismissDlg(hwnd, 1);
|
---|
| 706 | break;
|
---|
[2] | 707 |
|
---|
[551] | 708 | case DID_CANCEL:
|
---|
| 709 | WinDismissDlg(hwnd, 0);
|
---|
| 710 | break;
|
---|
[2] | 711 |
|
---|
[551] | 712 | case IDM_HELP:
|
---|
| 713 | if (hwndHelp)
|
---|
| 714 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 715 | MPFROM2SHORT(HELP_ASSOC, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 716 | break;
|
---|
[2] | 717 |
|
---|
[551] | 718 | case ASS_ADD:
|
---|
| 719 | {
|
---|
| 720 | ASSOC temp;
|
---|
| 721 | CHAR dummy[34];
|
---|
[2] | 722 |
|
---|
[551] | 723 | replace = FALSE;
|
---|
[2] | 724 |
|
---|
[551] | 725 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 726 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 727 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
| 728 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 729 | rstrip(temp.sig);
|
---|
| 730 | if (*temp.sig) {
|
---|
| 731 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 732 | temp.offset = atol(dummy);
|
---|
| 733 | }
|
---|
| 734 | bstrip(temp.mask);
|
---|
| 735 | bstrip(temp.cl);
|
---|
| 736 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 737 | temp.flags = 0;
|
---|
| 738 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 739 | temp.flags = FULLSCREEN;
|
---|
| 740 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 741 | temp.flags = MINIMIZED;
|
---|
| 742 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 743 | temp.flags = MAXIMIZED;
|
---|
| 744 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 745 | temp.flags = INVISIBLE;
|
---|
| 746 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 747 | temp.flags |= KEEP;
|
---|
| 748 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 749 | temp.flags |= DIEAFTER;
|
---|
| 750 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
| 751 | temp.flags |= PROMPT;
|
---|
| 752 | info = add_association(&temp);
|
---|
| 753 | //Add will fail if mask is not changed
|
---|
| 754 | if (info) {
|
---|
[2] | 755 |
|
---|
[551] | 756 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
[2] | 757 |
|
---|
[551] | 758 | *s = 0;
|
---|
| 759 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 760 | bstripcr(s);
|
---|
| 761 | if (*s)
|
---|
| 762 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 763 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 764 | temp.cl, (*temp.sig) ?
|
---|
| 765 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 766 | (*temp.sig) ? "]" : NullStr);
|
---|
| 767 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 768 | ASS_LISTBOX,
|
---|
| 769 | LM_INSERTITEM,
|
---|
| 770 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 771 | if (x >= 0) {
|
---|
| 772 | WinSendDlgItemMsg(hwnd,
|
---|
| 773 | ASS_LISTBOX,
|
---|
| 774 | LM_SETITEMHANDLE,
|
---|
| 775 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 776 | WinSendDlgItemMsg(hwnd,
|
---|
| 777 | ASS_LISTBOX,
|
---|
| 778 | LM_SELECTITEM,
|
---|
| 779 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 780 | }
|
---|
| 781 | save_associations();
|
---|
| 782 | }
|
---|
| 783 | }
|
---|
| 784 | break;
|
---|
[506] | 785 |
|
---|
[551] | 786 | case ASS_DELETE:
|
---|
| 787 | {
|
---|
| 788 | ASSOC temp;
|
---|
| 789 | CHAR dummy[34];
|
---|
[506] | 790 |
|
---|
[551] | 791 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 792 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 793 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 794 | rstrip(temp.sig);
|
---|
| 795 | if (*temp.sig) {
|
---|
| 796 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 797 | temp.offset = atol(dummy);
|
---|
| 798 | }
|
---|
| 799 | bstrip(temp.mask);
|
---|
| 800 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
[552] | 801 | if (kill_association(&temp))
|
---|
| 802 | /* Runtime_Error(pszSrcFile, __LINE__, "kill_association");
|
---|
| 803 | else */{
|
---|
[551] | 804 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 805 | ASS_LISTBOX,
|
---|
| 806 | LM_QUERYSELECTION,
|
---|
| 807 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 808 | if (x >= 0) {
|
---|
| 809 | WinSendDlgItemMsg(hwnd,
|
---|
| 810 | ASS_LISTBOX,
|
---|
| 811 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
| 812 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
| 813 | MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
|
---|
| 814 | }
|
---|
| 815 | save_associations();
|
---|
| 816 | }
|
---|
| 817 | }
|
---|
| 818 | break;
|
---|
| 819 | case ASS_REPLACE:
|
---|
[506] | 820 |
|
---|
[551] | 821 | {
|
---|
| 822 | ASSOC temp;
|
---|
| 823 | CHAR dummy[34];
|
---|
[506] | 824 |
|
---|
[551] | 825 | replace = TRUE;
|
---|
[506] | 826 |
|
---|
[551] | 827 | y = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 828 | ASS_LISTBOX,
|
---|
| 829 | LM_QUERYSELECTION,
|
---|
| 830 | MPFROMSHORT(LIT_CURSOR), MPVOID);
|
---|
| 831 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 832 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 833 | WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
|
---|
| 834 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 835 | rstrip(temp.sig);
|
---|
| 836 | if (*temp.sig) {
|
---|
| 837 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 838 | temp.offset = atol(dummy);
|
---|
| 839 | }
|
---|
| 840 | bstrip(temp.mask);
|
---|
| 841 | bstrip(temp.cl);
|
---|
| 842 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
| 843 | temp.flags = 0;
|
---|
| 844 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
| 845 | temp.flags = FULLSCREEN;
|
---|
| 846 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
| 847 | temp.flags = MINIMIZED;
|
---|
| 848 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
| 849 | temp.flags = MAXIMIZED;
|
---|
| 850 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
| 851 | temp.flags = INVISIBLE;
|
---|
| 852 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
| 853 | temp.flags |= KEEP;
|
---|
| 854 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
| 855 | temp.flags |= DIEAFTER;
|
---|
| 856 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
| 857 | temp.flags |= PROMPT;
|
---|
| 858 | info = add_association(&temp);
|
---|
| 859 | //Add will fail if mask is not changed
|
---|
| 860 | if (info) {
|
---|
[529] | 861 |
|
---|
[551] | 862 | CHAR s[1002 + CCHMAXPATH + 6];
|
---|
| 863 |
|
---|
| 864 | *s = 0;
|
---|
| 865 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 1000, s);
|
---|
| 866 | bstripcr(s);
|
---|
| 867 | if (*s)
|
---|
| 868 | PrfWriteProfileString(fmprof, FM3Str, temp.cl, s);
|
---|
| 869 | sprintf(s, "%-12s \x1a %-24s %s%s%s", temp.mask,
|
---|
| 870 | temp.cl, (*temp.sig) ?
|
---|
| 871 | "[" : NullStr, (*temp.sig) ? temp.sig : NullStr,
|
---|
| 872 | (*temp.sig) ? "]" : NullStr);
|
---|
| 873 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 874 | ASS_LISTBOX,
|
---|
| 875 | LM_INSERTITEM,
|
---|
| 876 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
| 877 | if (x >= 0) {
|
---|
| 878 | WinSendDlgItemMsg(hwnd,
|
---|
| 879 | ASS_LISTBOX,
|
---|
| 880 | LM_SETITEMHANDLE,
|
---|
| 881 | MPFROMSHORT(x), MPFROMP(info));
|
---|
| 882 | WinSendDlgItemMsg(hwnd,
|
---|
| 883 | ASS_LISTBOX,
|
---|
| 884 | LM_SELECTITEM,
|
---|
| 885 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
| 886 | }
|
---|
| 887 | save_associations();
|
---|
| 888 | }
|
---|
[2] | 889 | }
|
---|
[551] | 890 | {
|
---|
| 891 | ASSOC temp;
|
---|
| 892 | CHAR dummy[34];
|
---|
| 893 |
|
---|
| 894 | WinSendDlgItemMsg(hwnd,
|
---|
| 895 | ASS_LISTBOX,
|
---|
| 896 | LM_SELECTITEM, MPFROMSHORT(y), MPFROMSHORT(TRUE));
|
---|
| 897 | memset(&temp, 0, sizeof(ASSOC));
|
---|
| 898 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
| 899 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
| 900 | rstrip(temp.sig);
|
---|
| 901 | if (*temp.sig) {
|
---|
| 902 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
| 903 | temp.offset = atol(dummy);
|
---|
| 904 | }
|
---|
| 905 | bstrip(temp.mask);
|
---|
| 906 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
| 907 | if (!kill_association(&temp))
|
---|
| 908 | Runtime_Error(pszSrcFile, __LINE__, "kill_association");
|
---|
| 909 | else {
|
---|
| 910 |
|
---|
| 911 | if (y >= 0) {
|
---|
| 912 | WinSendDlgItemMsg(hwnd,
|
---|
| 913 | ASS_LISTBOX,
|
---|
| 914 | LM_DELETEITEM, MPFROMSHORT(y), MPVOID);
|
---|
| 915 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
| 916 | MPFROMSHORT(x - 1), MPFROMSHORT(TRUE));
|
---|
| 917 | }
|
---|
| 918 | save_associations();
|
---|
| 919 | }
|
---|
| 920 | }
|
---|
| 921 | break;
|
---|
| 922 | }
|
---|
| 923 | return 0;
|
---|
| 924 | }
|
---|
| 925 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 926 | }
|
---|
| 927 |
|
---|
[551] | 928 | VOID EditAssociations(HWND hwnd)
|
---|
[342] | 929 | {
|
---|
[2] | 930 | static CHAR stop = 0;
|
---|
| 931 |
|
---|
[551] | 932 | if (stop)
|
---|
[2] | 933 | return;
|
---|
| 934 | stop++;
|
---|
[551] | 935 | if (!assloaded)
|
---|
[2] | 936 | load_associations();
|
---|
[551] | 937 | WinDlgBox(HWND_DESKTOP, hwnd, AssocDlgProc, FM3ModHandle, ASS_FRAME, NULL);
|
---|
[2] | 938 | stop = 0;
|
---|
| 939 | }
|
---|