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