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