|
|
1.1 ! root 1: /*************************************************************************** ! 2: * * ! 3: * MODULE : dialog.c * ! 4: * * ! 5: * PURPOSE : Contains all dialog procedures and related functions. * ! 6: * * ! 7: ***************************************************************************/ ! 8: #include "client.h" ! 9: #include "infoctrl.h" ! 10: #include <string.h> ! 11: #include <stdio.h> ! 12: #include "huge.h" ! 13: ! 14: #define MAX_NAME 100 // max size for edit controls with app/topic/item names. ! 15: CHAR szWild[] = "*"; // used to indicate wild names ("" is also cool) ! 16: CHAR szT[MAX_NAME]; // temp buf for munging names. ! 17: ! 18: ! 19: ! 20: /**************************************************************************** ! 21: * * ! 22: * FUNCTION : DoDialog() * ! 23: * * ! 24: * PURPOSE : Generic dialog invocation routine. Handles procInstance * ! 25: * stuff, focus management and param passing. * ! 26: * RETURNS : result of dialog procedure. * ! 27: * * ! 28: ****************************************************************************/ ! 29: INT FAR DoDialog( ! 30: LPSTR lpTemplateName, ! 31: WNDPROC lpDlgProc, ! 32: LONG param, ! 33: BOOL fRememberFocus) ! 34: { ! 35: DWORD wRet; ! 36: HWND hwndFocus; ! 37: ! 38: if (fRememberFocus) ! 39: hwndFocus = GetFocus(); ! 40: lpDlgProc = MakeProcInstance(lpDlgProc, hInst); ! 41: wRet = DialogBoxParam(hInst, lpTemplateName, hwndFrame, (DLGPROC)lpDlgProc, param); ! 42: FreeProcInstance(lpDlgProc); ! 43: if (fRememberFocus) ! 44: SetFocus(hwndFocus); ! 45: return wRet; ! 46: } ! 47: ! 48: ! 49: ! 50: /**************************************************************************** ! 51: * * ! 52: * FUNCTION : * ! 53: * * ! 54: * PURPOSE : * ! 55: * * ! 56: * RETURNS : * ! 57: * * ! 58: ****************************************************************************/ ! 59: BOOL APIENTRY AboutDlgProc ( hwnd, msg, wParam, lParam ) ! 60: HWND hwnd; ! 61: UINT msg; ! 62: WPARAM wParam; ! 63: LPARAM lParam; ! 64: { ! 65: switch (msg){ ! 66: case WM_INITDIALOG: ! 67: /* nothing to initialize */ ! 68: break; ! 69: ! 70: case WM_COMMAND: ! 71: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 72: case IDOK: ! 73: case IDCANCEL: ! 74: EndDialog(hwnd, 0); ! 75: break; ! 76: ! 77: default: ! 78: return FALSE; ! 79: } ! 80: break; ! 81: ! 82: default: ! 83: return(FALSE); ! 84: } ! 85: ! 86: return TRUE; ! 87: } ! 88: ! 89: ! 90: ! 91: ! 92: /**************************************************************************** ! 93: * * ! 94: * FUNCTION : * ! 95: * * ! 96: * PURPOSE : * ! 97: * * ! 98: * RETURNS : * ! 99: * * ! 100: ****************************************************************************/ ! 101: BOOL APIENTRY ConnectDlgProc( ! 102: HWND hwnd, ! 103: UINT msg, ! 104: WPARAM wParam, ! 105: LPARAM lParam) ! 106: { ! 107: static BOOL fReconnect; ! 108: CHAR szT[MAX_NAME]; ! 109: HSZ hszApp, hszTopic; ! 110: MYCONVINFO *pmci; ! 111: ! 112: switch (msg){ ! 113: case WM_INITDIALOG: ! 114: SendDlgItemMessage(hwnd, IDEF_APPLICATION, EM_LIMITTEXT, MAX_NAME, 0); ! 115: SendDlgItemMessage(hwnd, IDEF_TOPIC, EM_LIMITTEXT, MAX_NAME, 0); ! 116: fReconnect = (BOOL)lParam; ! 117: if (fReconnect) { ! 118: PSTR psz; ! 119: ! 120: pmci = (MYCONVINFO *)GetWindowLong(hwndActive, 0); ! 121: SetWindowText(hwnd, "DDE Reconnect List"); ! 122: psz = GetHSZName(pmci->hszApp); ! 123: SetDlgItemText(hwnd, IDEF_APPLICATION, psz); ! 124: MyFree(psz); ! 125: psz = GetHSZName(pmci->hszTopic); ! 126: SetDlgItemText(hwnd, IDEF_TOPIC, psz); ! 127: MyFree(psz); ! 128: ShowWindow(GetDlgItem(hwnd, IDCH_CONNECTLIST), SW_HIDE); ! 129: } ! 130: break; ! 131: ! 132: case WM_COMMAND: ! 133: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 134: case IDOK: ! 135: GetDlgItemText(hwnd, IDEF_APPLICATION, szT, MAX_NAME); ! 136: if (!strcmp(szT, szWild)) ! 137: szT[0] = '\0'; ! 138: hszApp = DdeCreateStringHandle(idInst, szT, 0); ! 139: ! 140: GetDlgItemText(hwnd, IDEF_TOPIC, szT, MAX_NAME); ! 141: if (!strcmp(szT, szWild)) ! 142: szT[0] = '\0'; ! 143: hszTopic = DdeCreateStringHandle(idInst, szT, 0); ! 144: ! 145: if (fReconnect) { ! 146: HCONV hConv; ! 147: CONVINFO ci; ! 148: DWORD cHwnd; ! 149: HWND *aHwnd, *pHwnd, hwndSave; ! 150: ! 151: ci.cb = sizeof(CONVINFO); ! 152: pmci = (MYCONVINFO *)GetWindowLong(hwndActive, 0); ! 153: hwndSave = hwndActive; ! 154: ! 155: // count the existing conversations and allocate aHwnd ! 156: ! 157: cHwnd = 0; ! 158: hConv = NULL; ! 159: while (hConv = DdeQueryNextServer((HCONVLIST)pmci->hConv, hConv)) ! 160: cHwnd++; ! 161: aHwnd = (HWND *)MyAlloc(cHwnd * sizeof(HWND)); ! 162: ! 163: // save all the old conversation windows into aHwnd. ! 164: ! 165: pHwnd = aHwnd; ! 166: hConv = NULL; ! 167: while (hConv = DdeQueryNextServer((HCONVLIST)pmci->hConv, hConv)) { ! 168: DdeQueryConvInfo(hConv, QID_SYNC, &ci); ! 169: *pHwnd++ = (HWND)ci.hUser; ! 170: } ! 171: ! 172: // reconnect ! 173: ! 174: if (!(hConv = DdeConnectList(idInst, hszApp, hszTopic, pmci->hConv, &CCFilter))) { ! 175: MPError(MB_OK, IDS_DDEMLERR, (LPSTR)Error2String(DdeGetLastError(idInst))); ! 176: DdeFreeStringHandle(idInst, hszApp); ! 177: DdeFreeStringHandle(idInst, hszTopic); ! 178: return 0; ! 179: } ! 180: ! 181: // fixup windows corresponding to the new conversations. ! 182: ! 183: pmci->hConv = hConv; ! 184: hConv = NULL; ! 185: while (hConv = DdeQueryNextServer((HCONVLIST)pmci->hConv, hConv)) { ! 186: DdeQueryConvInfo(hConv, QID_SYNC, &ci); ! 187: // preserve corresponding window by setting its list ! 188: // entry to 0 ! 189: for (pHwnd = aHwnd; pHwnd < &aHwnd[cHwnd]; pHwnd++) { ! 190: if (*pHwnd == (HWND)ci.hUser) { ! 191: *pHwnd = NULL; ! 192: break; ! 193: } ! 194: } ! 195: } ! 196: ! 197: // destroy all windows left in the old list ! 198: ! 199: for (pHwnd = aHwnd; pHwnd < &aHwnd[cHwnd]; pHwnd++) ! 200: if (*pHwnd) { ! 201: SendMessage(hwndMDIClient, WM_MDIDESTROY, ! 202: (WPARAM)*pHwnd, 0L); ! 203: } ! 204: MyFree((PSTR)aHwnd); ! 205: ! 206: // create any new windows needed ! 207: ! 208: hConv = NULL; ! 209: while (hConv = DdeQueryNextServer((HCONVLIST)pmci->hConv, hConv)) { ! 210: DdeQueryConvInfo(hConv, QID_SYNC, &ci); ! 211: if (ci.hUser) { ! 212: InvalidateRect((HWND)ci.hUser, NULL, TRUE); ! 213: } else { ! 214: AddConv(ci.hszSvcPartner, ci.hszTopic, hConv, FALSE); ! 215: } ! 216: } ! 217: ! 218: // make list window update itself ! 219: ! 220: InvalidateRect(hwndSave, NULL, TRUE); ! 221: SetFocus(hwndSave); ! 222: } else { ! 223: if (!CreateConv(hszApp, hszTopic, ! 224: IsDlgButtonChecked(hwnd, IDCH_CONNECTLIST))) { ! 225: MPError(MB_OK, IDS_DDEMLERR, (LPSTR)Error2String(DdeGetLastError(idInst))); ! 226: return 0; ! 227: } ! 228: } ! 229: DdeFreeStringHandle(idInst, hszApp); ! 230: DdeFreeStringHandle(idInst, hszTopic); ! 231: // fall through ! 232: case IDCANCEL: ! 233: EndDialog(hwnd, 0); ! 234: break; ! 235: ! 236: default: ! 237: return(FALSE); ! 238: } ! 239: break; ! 240: ! 241: default: ! 242: return(FALSE); ! 243: } ! 244: } ! 245: ! 246: ! 247: ! 248: ! 249: /* ! 250: * Fills a XACT structure and calls ProcessTransaction. ! 251: * ! 252: * On initiation lParam == hConv. ! 253: */ ! 254: /**************************************************************************** ! 255: * * ! 256: * FUNCTION : * ! 257: * * ! 258: * PURPOSE : * ! 259: * * ! 260: * RETURNS : * ! 261: * * ! 262: ****************************************************************************/ ! 263: BOOL APIENTRY TransactDlgProc( ! 264: HWND hwnd, ! 265: UINT msg, ! 266: WPARAM wParam, ! 267: LPARAM lParam) ! 268: { ! 269: static DWORD id2type[] = { ! 270: XTYP_REQUEST, // IDCH_REQUEST ! 271: XTYP_ADVSTART, // IDCH_ADVISE ! 272: XTYP_ADVSTOP, // IDCH_UNADVISE ! 273: XTYP_POKE, // IDCH_POKE ! 274: XTYP_EXECUTE, // IDCH_EXECUTE ! 275: }; ! 276: static XACT *pxact; // ONLY ONE AT A TIME! ! 277: INT i; ! 278: ! 279: switch (msg){ ! 280: case WM_INITDIALOG: ! 281: pxact = (XACT *)MyAlloc(sizeof(XACT)); ! 282: pxact->hConv = (HCONV)lParam; ! 283: pxact->fsOptions = DefOptions; ! 284: pxact->ulTimeout = DefTimeout; ! 285: ! 286: // The item index == the index to the format atoms in aFormats[]. ! 287: for (i = 0; i < CFORMATS; i++) ! 288: SendDlgItemMessage(hwnd, IDCB_FORMAT, CB_INSERTSTRING, i, ! 289: (DWORD)(LPSTR)aFormats[i].sz); ! 290: SendDlgItemMessage(hwnd, IDCB_FORMAT, CB_INSERTSTRING, i, ! 291: (DWORD)(LPSTR)"NULL"); ! 292: SendDlgItemMessage(hwnd, IDCB_FORMAT, CB_SETCURSEL, 0, 0); ! 293: CheckRadioButton(hwnd, IDCH_REQUEST, IDCH_EXECUTE, IDCH_REQUEST); ! 294: SendDlgItemMessage(hwnd, IDEF_ITEM, EM_LIMITTEXT, MAX_NAME, 0); ! 295: ! 296: // If there is a top transaction window, use its contents to ! 297: // anticipate what the user will want to do. ! 298: ! 299: if (IsWindow(hwndActive)) { ! 300: HWND hwndXaction; ! 301: XACT *pxact; ! 302: PSTR pszItem; ! 303: ! 304: hwndXaction = GetWindow(hwndActive, GW_CHILD); ! 305: if (IsWindow(hwndXaction)) { ! 306: pxact = (XACT *)GetWindowLong(hwndXaction, GWL_USER); ! 307: pszItem = GetHSZName(pxact->hszItem); ! 308: if ((pxact->wType & XTYP_ADVSTART) == XTYP_ADVSTART || ! 309: pxact->wType == XTYP_ADVDATA) { ! 310: CheckRadioButton(hwnd, IDCH_REQUEST, IDCH_EXECUTE, IDCH_UNADVISE); ! 311: } ! 312: SetDlgItemText(hwnd, IDEF_ITEM, pszItem); ! 313: for (i = 0; i < CFORMATS; i++) { ! 314: if (aFormats[i].fmt == pxact->wFmt) { ! 315: SendDlgItemMessage(hwnd, IDCB_FORMAT, CB_SETCURSEL, i, 0); ! 316: break; ! 317: } ! 318: } ! 319: MyFree(pszItem); ! 320: } ! 321: } ! 322: break; ! 323: ! 324: case WM_COMMAND: ! 325: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 326: case IDCH_EXECUTE: ! 327: SetDlgItemText(hwnd, IDEF_ITEM, ""); ! 328: case IDCH_REQUEST: ! 329: case IDCH_ADVISE: ! 330: case IDCH_UNADVISE: ! 331: case IDCH_POKE: ! 332: EnableWindow(GetDlgItem(hwnd, IDEF_ITEM), GET_WM_COMMAND_ID(wParam, lParam) != IDCH_EXECUTE); ! 333: EnableWindow(GetDlgItem(hwnd, IDTX_ITEM), GET_WM_COMMAND_ID(wParam, lParam) != IDCH_EXECUTE); ! 334: break; ! 335: ! 336: case IDOK: ! 337: case IDBN_OPTIONS: ! 338: { ! 339: INT id; ! 340: ! 341: // set pxact->wType ! 342: ! 343: for (id = IDCH_REQUEST; id <= IDCH_EXECUTE; id++) { ! 344: if (IsDlgButtonChecked(hwnd, id)) { ! 345: pxact->wType = id2type[id - IDCH_REQUEST]; ! 346: break; ! 347: } ! 348: } ! 349: ! 350: if (GET_WM_COMMAND_ID(wParam, lParam) == IDBN_OPTIONS) { ! 351: DoDialog(MAKEINTRESOURCE(IDD_ADVISEOPTS), ! 352: (WNDPROC)AdvOptsDlgProc, (LONG)pxact, TRUE); ! 353: return 0; ! 354: } ! 355: ! 356: id = (INT)SendDlgItemMessage(hwnd, IDCB_FORMAT, CB_GETCURSEL, 0, 0); ! 357: if (id == LB_ERR) { ! 358: return 0; ! 359: } ! 360: if (id == CFORMATS) ! 361: pxact->wFmt = 0; ! 362: else ! 363: pxact->wFmt = aFormats[id].fmt; ! 364: ! 365: if (pxact->wType == XTYP_ADVSTART) { ! 366: if (pxact->fsOptions & XOPT_NODATA) ! 367: pxact->wType |= XTYPF_NODATA; ! 368: if (pxact->fsOptions & XOPT_ACKREQ) ! 369: pxact->wType |= XTYPF_ACKREQ; ! 370: } ! 371: ! 372: GetDlgItemText(hwnd, IDEF_ITEM, szT, MAX_NAME); ! 373: pxact->hszItem = DdeCreateStringHandle(idInst, szT, NULL); ! 374: ! 375: pxact->hDdeData = 0; ! 376: /* ! 377: * If this transaction needs data, invoke data input dialog. ! 378: */ ! 379: if (pxact->wType == XTYP_POKE || pxact->wType == XTYP_EXECUTE) { ! 380: if (!DoDialog(MAKEINTRESOURCE(IDD_TEXTENTRY), ! 381: (WNDPROC)TextEntryDlgProc, (DWORD)(LPSTR)pxact, ! 382: TRUE)) ! 383: return 0; ! 384: } ! 385: ! 386: // now start the transaction ! 387: ! 388: ProcessTransaction(pxact); ! 389: MyFree((PSTR)pxact); ! 390: } ! 391: EndDialog(hwnd, 1); ! 392: break; ! 393: ! 394: case IDCANCEL: ! 395: MyFree((PSTR)pxact); ! 396: EndDialog(hwnd, 0); ! 397: break; ! 398: ! 399: default: ! 400: return(FALSE); ! 401: } ! 402: break; ! 403: ! 404: case WM_DESTROY: ! 405: break; ! 406: ! 407: default: ! 408: return(FALSE); ! 409: } ! 410: return 0; ! 411: } ! 412: ! 413: ! 414: ! 415: ! 416: ! 417: ! 418: ! 419: /**************************************************************************** ! 420: * * ! 421: * FUNCTION : AdvOptsDlgProc * ! 422: * * ! 423: * LIMITATIONS: Because we use Get/SetDlgItemInt() the timeout value used * ! 424: * can't be greater than 65K ms. * ! 425: * * ! 426: * RETURNS : * ! 427: * * ! 428: ****************************************************************************/ ! 429: BOOL APIENTRY AdvOptsDlgProc( ! 430: HWND hwnd, ! 431: UINT msg, ! 432: WPARAM wParam, ! 433: LPARAM lParam) ! 434: { ! 435: static struct { ! 436: DWORD id; ! 437: DWORD opt; ! 438: } id2Opt[] = { ! 439: { IDCH_NODATA , XOPT_NODATA } , ! 440: { IDCH_ACKREQ , XOPT_ACKREQ } , ! 441: { IDCH_DISABLEFIRST , XOPT_DISABLEFIRST } , ! 442: { IDCH_ABANDON , XOPT_ABANDONAFTERSTART } , ! 443: { IDCH_BLOCKRESULT , XOPT_BLOCKRESULT } , ! 444: { IDCH_ASYNC , XOPT_ASYNC } , ! 445: }; ! 446: #define CCHBOX 6 ! 447: INT i; ! 448: static XACT *pxact; // only one instance at a time!! ! 449: ! 450: switch (msg){ ! 451: case WM_INITDIALOG: ! 452: pxact = (XACT *)lParam; ! 453: ! 454: for (i = 0; i < CCHBOX; i++) { ! 455: CheckDlgButton(hwnd, id2Opt[i].id, pxact->fsOptions & id2Opt[i].opt); ! 456: } ! 457: SetDlgItemInt(hwnd, IDEF_TIMEOUT, (DWORD)pxact->ulTimeout, FALSE); ! 458: if (pxact->wType != XTYP_ADVSTART) { ! 459: EnableWindow(GetDlgItem(hwnd, IDCH_NODATA), FALSE); ! 460: EnableWindow(GetDlgItem(hwnd, IDCH_ACKREQ), FALSE); ! 461: } ! 462: SendMessage(hwnd, WM_COMMAND, GET_WM_COMMAND_MPS(IDCH_ASYNC, 0, 0)); // enable async checkboxes ! 463: break; ! 464: ! 465: case WM_COMMAND: ! 466: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 467: case IDCH_ASYNC: ! 468: { ! 469: BOOL fEnable; ! 470: ! 471: fEnable = IsDlgButtonChecked(hwnd, IDCH_ASYNC); ! 472: EnableWindow(GetDlgItem(hwnd, IDCH_DISABLEFIRST), fEnable); ! 473: EnableWindow(GetDlgItem(hwnd, IDCH_ABANDON), fEnable); ! 474: EnableWindow(GetDlgItem(hwnd, IDCH_BLOCKRESULT), fEnable); ! 475: EnableWindow(GetDlgItem(hwnd, IDEF_TIMEOUT), !fEnable); ! 476: } ! 477: break; ! 478: ! 479: case IDOK: ! 480: pxact->fsOptions = 0; ! 481: for (i = 0; i < CCHBOX; i++) { ! 482: if (IsDlgButtonChecked(hwnd, id2Opt[i].id)) ! 483: pxact->fsOptions |= id2Opt[i].opt; ! 484: } ! 485: if (!(pxact->fsOptions & XOPT_ASYNC)) ! 486: pxact->ulTimeout = (DWORD)GetDlgItemInt(hwnd, IDEF_TIMEOUT, ! 487: &i, FALSE); ! 488: // fall through ! 489: case IDCANCEL: ! 490: EndDialog(hwnd, 0); ! 491: break; ! 492: } ! 493: break; ! 494: ! 495: default: ! 496: return(FALSE); ! 497: } ! 498: return 0; ! 499: #undef CCHBOX ! 500: } ! 501: ! 502: ! 503: ! 504: ! 505: ! 506: ! 507: /**************************************************************************** ! 508: * * ! 509: * FUNCTION : TextEntryDlgProc * ! 510: * * ! 511: * PURPOSE : Allows user to enter text data which is to be sent to a * ! 512: * server. The user can opt to have a huge text piece of * ! 513: * data created automaticlly. * ! 514: * It uses the XACT structure for passing info in and out. * ! 515: * Must have wFmt and hszItem set on entry. * ! 516: * Sets hDDEData on return if TRUE was returned. * ! 517: * * ! 518: * RETURNS : TRUE on success, FALSE on failure or cancel * ! 519: * * ! 520: ****************************************************************************/ ! 521: BOOL APIENTRY TextEntryDlgProc( ! 522: HWND hwnd, ! 523: UINT msg, ! 524: WPARAM wParam, ! 525: LPARAM lParam) ! 526: { ! 527: static XACT FAR *pxact; ! 528: DWORD cb; ! 529: LONG length; ! 530: LPBYTE pData; ! 531: BOOL fOwned; ! 532: INT id, i; ! 533: ! 534: switch (msg){ ! 535: case WM_INITDIALOG: ! 536: pxact = (XACT FAR *)lParam; ! 537: fOwned = FALSE; ! 538: for (i = 0; i < (INT)cOwned; i++) { ! 539: if (aOwned[i].wFmt == pxact->wFmt && ! 540: aOwned[i].hszItem == pxact->hszItem) { ! 541: fOwned = TRUE; ! 542: break; ! 543: } ! 544: } ! 545: EnableWindow(GetDlgItem(hwnd, IDBN_USEOWNED), fOwned); ! 546: CheckDlgButton(hwnd, IDCH_MAKEOWNED, 0); ! 547: EnableWindow(GetDlgItem(hwnd, IDCH_MAKEOWNED), cOwned < MAX_OWNED); ! 548: break; ! 549: ! 550: case WM_COMMAND: ! 551: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 552: case IDOK: ! 553: case IDBN_GENHUGE: ! 554: fOwned = IsDlgButtonChecked(hwnd, IDCH_MAKEOWNED); ! 555: cb = SendDlgItemMessage(hwnd, IDEF_DATA, WM_GETTEXTLENGTH, 0, 0) + 1; ! 556: pxact->hDdeData = DdeCreateDataHandle(idInst, NULL, 0, cb, pxact->hszItem, ! 557: pxact->wFmt, fOwned ? HDATA_APPOWNED : 0); ! 558: if (pxact->hDdeData == 0) { ! 559: MessageBeep(0); ! 560: return(0); ! 561: } ! 562: // ! 563: // Note that at this time we have not yet given the data handle ! 564: // to DDEML for transmission to any application, therefore, we ! 565: // are at liberty to write to it using DdeAccessData() or any ! 566: // other DDEML api. It is only data handles received from DDEML ! 567: // or given to DDEML for transmission that are readonly. ! 568: // ! 569: pData = DdeAccessData(pxact->hDdeData, NULL); ! 570: if (pData == NULL) { ! 571: MessageBeep(0); ! 572: return(0); ! 573: } ! 574: GetDlgItemText(hwnd, IDEF_DATA, pData, (DWORD)cb); ! 575: DdeUnaccessData(pxact->hDdeData); ! 576: if (GET_WM_COMMAND_ID(wParam, lParam) == IDBN_GENHUGE) { ! 577: CHAR szT[40]; ! 578: ! 579: /* ! 580: * we assume in this case that the text entered is the decimal ! 581: * value of the size of the huge object desired. We parse ! 582: * this string and create a randomly generated huge block ! 583: * of text data and place it into pxact->hDdeData. ! 584: */ ! 585: _fmemcpy(szT, pData, min((DWORD)cb, 40)); ! 586: szT[39] = '\0'; ! 587: if (sscanf(szT, "%ld", &length) == 1) { ! 588: DdeFreeDataHandle(pxact->hDdeData); ! 589: pxact->hDdeData = CreateHugeDataHandle(length, 4325, ! 590: 345, 5, pxact->hszItem, pxact->wFmt, ! 591: fOwned ? HDATA_APPOWNED : 0); ! 592: } else { ! 593: /* ! 594: * The string cannot be parsed. Inform the user of ! 595: * what is expected. ! 596: */ ! 597: MPError(MB_OK, IDS_BADLENGTH); ! 598: return 0; ! 599: } ! 600: } ! 601: if (fOwned) { ! 602: aOwned[cOwned].hData = pxact->hDdeData; ! 603: aOwned[cOwned].hszItem = pxact->hszItem; ! 604: aOwned[cOwned].wFmt = pxact->wFmt; ! 605: cOwned++; ! 606: } ! 607: EndDialog(hwnd, TRUE); ! 608: break; ! 609: ! 610: case IDBN_USEOWNED: ! 611: /* ! 612: * the user has chosen to use an existing owned data for sending ! 613: * to the server. ! 614: */ ! 615: id = DoDialog(MAKEINTRESOURCE(IDD_HDATAVIEW), (WNDPROC)ViewHandleDlgProc, ! 616: (DWORD)pxact, TRUE); ! 617: ! 618: switch (id) { ! 619: case IDCANCEL: ! 620: return(0); ! 621: ! 622: case IDOK: ! 623: EndDialog(hwnd, TRUE); ! 624: ! 625: case IDBN_VIEW: ! 626: pData = DdeAccessData(pxact->hDdeData, NULL); ! 627: SetDlgItemText(hwnd, IDEF_DATA, pData); ! 628: DdeUnaccessData(pxact->hDdeData); ! 629: break; ! 630: } ! 631: break; ! 632: ! 633: case IDCANCEL: ! 634: EndDialog(hwnd, FALSE); ! 635: break; ! 636: } ! 637: break; ! 638: ! 639: default: ! 640: return(FALSE); ! 641: } ! 642: } ! 643: ! 644: ! 645: ! 646: BOOL APIENTRY ViewHandleDlgProc( ! 647: HWND hwnd, ! 648: UINT msg, ! 649: WPARAM wParam, ! 650: LPARAM lParam) ! 651: { ! 652: static XACT FAR *pxact; ! 653: INT i, itm; ! 654: ! 655: switch (msg){ ! 656: case WM_INITDIALOG: ! 657: pxact = (XACT FAR *)lParam; ! 658: // load listbox with handles that fit pxact constraints ! 659: ! 660: for (i = 0; i < (INT)cOwned; i++) { ! 661: if (aOwned[i].hszItem == pxact->hszItem && ! 662: aOwned[i].wFmt == pxact->wFmt) { ! 663: wsprintf(szT, "[%d] %lx : length=%ld", i, aOwned[i].hData, ! 664: DdeGetData(aOwned[i].hData, NULL, 0, 0)); ! 665: SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_ADDSTRING, 0, (LONG)(LPSTR)szT); ! 666: } ! 667: } ! 668: SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_SETCURSEL, 0, 0); ! 669: break; ! 670: ! 671: case WM_COMMAND: ! 672: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 673: case IDOK: // use selectted handle ! 674: case IDBN_DELETE: // delete selected handle ! 675: case IDBN_VIEW: // view selected handle ! 676: itm = (INT)SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_GETCURSEL, 0, 0); ! 677: if (itm != LB_ERR) { ! 678: SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_GETTEXT, itm, (LONG)(LPSTR)szT); ! 679: sscanf(szT, "[%d]", &i); ! 680: pxact->hDdeData = aOwned[i].hData; ! 681: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 682: case IDOK: // use selectted handle ! 683: EndDialog(hwnd, GET_WM_COMMAND_ID(wParam, lParam)); ! 684: break; ! 685: ! 686: case IDBN_DELETE: // delete selected handle ! 687: DdeFreeDataHandle(aOwned[i].hData); ! 688: aOwned[i] = aOwned[--cOwned]; ! 689: SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_DELETESTRING, itm, 0); ! 690: if (SendDlgItemMessage(hwnd, IDLB_HANDLES, LB_GETCOUNT, 0, 0) == 0) ! 691: EndDialog(hwnd, IDCANCEL); ! 692: break; ! 693: ! 694: case IDBN_VIEW: // view selected handle ! 695: EndDialog(hwnd, GET_WM_COMMAND_ID(wParam, lParam)); ! 696: } ! 697: } ! 698: break; ! 699: ! 700: case IDCANCEL: ! 701: EndDialog(hwnd, FALSE); ! 702: break; ! 703: } ! 704: break; ! 705: ! 706: default: ! 707: return(FALSE); ! 708: } ! 709: } ! 710: ! 711: ! 712: ! 713: BOOL APIENTRY DelayDlgProc( ! 714: HWND hwnd, ! 715: UINT msg, ! 716: WPARAM wParam, ! 717: LPARAM lParam) ! 718: { ! 719: switch (msg){ ! 720: case WM_INITDIALOG: ! 721: SetWindowText(hwnd, "Advise data response time"); ! 722: SetDlgItemInt(hwnd, IDEF_VALUE, wDelay, FALSE); ! 723: SetDlgItemText(hwnd, IDTX_VALUE, "Delay in milliseconds:"); ! 724: break; ! 725: ! 726: case WM_COMMAND: ! 727: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 728: case IDOK: ! 729: wDelay = (DWORD)GetDlgItemInt(hwnd, IDEF_VALUE, NULL, FALSE); ! 730: case IDCANCEL: ! 731: EndDialog(hwnd, 0); ! 732: break; ! 733: ! 734: default: ! 735: return(FALSE); ! 736: } ! 737: break; ! 738: ! 739: default: ! 740: return(FALSE); ! 741: } ! 742: } ! 743: ! 744: ! 745: ! 746: ! 747: ! 748: /**************************************************************************** ! 749: * * ! 750: * FUNCTION : TimeoutDlgProc() * ! 751: * * ! 752: * PURPOSE : Allows user to alter the synchronous timeout value. * ! 753: * * ! 754: * RETURNS : TRUE on success, FALSE on cancel or failure. * ! 755: * * ! 756: ****************************************************************************/ ! 757: BOOL APIENTRY TimeoutDlgProc( ! 758: HWND hwnd, ! 759: UINT msg, ! 760: WPARAM wParam, ! 761: LPARAM lParam) ! 762: { ! 763: switch (msg){ ! 764: case WM_INITDIALOG: ! 765: SetWindowText(hwnd, "Synchronous transaction timeout"); ! 766: SetDlgItemInt(hwnd, IDEF_VALUE, (INT)DefTimeout, FALSE); ! 767: SetDlgItemText(hwnd, IDTX_VALUE, "Timeout in milliseconds:"); ! 768: break; ! 769: ! 770: case WM_COMMAND: ! 771: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 772: case IDOK: ! 773: DefTimeout = GetDlgItemInt(hwnd, IDEF_VALUE, NULL, FALSE); ! 774: case IDCANCEL: ! 775: EndDialog(hwnd, 0); ! 776: break; ! 777: ! 778: default: ! 779: return(FALSE); ! 780: } ! 781: break; ! 782: ! 783: default: ! 784: return(FALSE); ! 785: } ! 786: } ! 787: ! 788: ! 789: ! 790: ! 791: BOOL APIENTRY ContextDlgProc( ! 792: HWND hwnd, ! 793: UINT msg, ! 794: WPARAM wParam, ! 795: LPARAM lParam) ! 796: { ! 797: BOOL fSuccess; ! 798: ! 799: switch (msg){ ! 800: case WM_INITDIALOG: ! 801: SetDlgItemInt(hwnd, IDEF_FLAGS, CCFilter.wFlags, FALSE); ! 802: SetDlgItemInt(hwnd, IDEF_COUNTRY, CCFilter.wCountryID, FALSE); ! 803: SetDlgItemInt(hwnd, IDEF_CODEPAGE, CCFilter.iCodePage, TRUE); ! 804: SetDlgItemInt(hwnd, IDEF_LANG, CCFilter.dwLangID, FALSE); ! 805: SetDlgItemInt(hwnd, IDEF_SECURITY, CCFilter.dwSecurity, FALSE); ! 806: return(1); ! 807: break; ! 808: ! 809: case WM_COMMAND: ! 810: switch (GET_WM_COMMAND_ID(wParam, lParam)) { ! 811: case IDOK: ! 812: CCFilter.wFlags = (WORD)GetDlgItemInt(hwnd, IDEF_FLAGS, &fSuccess, FALSE); ! 813: if (!fSuccess) return(0); ! 814: CCFilter.wCountryID = (WORD)GetDlgItemInt(hwnd, IDEF_COUNTRY, &fSuccess, FALSE); ! 815: if (!fSuccess) return(0); ! 816: CCFilter.iCodePage = GetDlgItemInt(hwnd, IDEF_CODEPAGE, &fSuccess, TRUE); ! 817: if (!fSuccess) return(0); ! 818: CCFilter.dwLangID = (DWORD)GetDlgItemInt(hwnd, IDEF_LANG, &fSuccess, FALSE); ! 819: if (!fSuccess) return(0); ! 820: CCFilter.dwSecurity = (DWORD)GetDlgItemInt(hwnd, IDEF_SECURITY, &fSuccess, FALSE); ! 821: if (!fSuccess) return(0); ! 822: // fall through ! 823: case IDCANCEL: ! 824: EndDialog(hwnd, 0); ! 825: break; ! 826: ! 827: default: ! 828: return(FALSE); ! 829: } ! 830: break; ! 831: } ! 832: return(FALSE); ! 833: } ! 834: ! 835: ! 836: VOID Delay( ! 837: DWORD delay) ! 838: { ! 839: MSG msg; ! 840: ! 841: delay = GetCurrentTime() + delay; ! 842: while (GetCurrentTime() < delay) { ! 843: if (PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) { ! 844: TranslateMessage(&msg); ! 845: DispatchMessage(&msg); ! 846: } ! 847: } ! 848: } ! 849:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.