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