|
|
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: #include <windows.h>
13: #include <ddeml.h>
14:
1.1.1.3 root 15: #define WINDOWMENU 3 /* position of window menu */
1.1 root 16:
17: /* resource ID's */
18: #define IDCLIENT 1
1.1.1.3 root 19: #define IDCONV 2
20: #define IDLIST 3
1.1 root 21:
22:
23: /* menu ID's */
24:
1.1.1.3 root 25: #define IDM_EDITPASTE 2004
1.1 root 26:
27: #define IDM_CONNECT 3000 // enabled always
28: #define IDM_RECONNECT 3001 // enabled if list selected
29: #define IDM_DISCONNECT 3002 // enabled if conversation selected
30: #define IDM_TRANSACT 3003 // enabled if conversation selected
31: #define IDM_ABANDON 3004 // enabled if transaction selected
32: #define IDM_ABANDONALL 3005 // enabled if conv. selected &&
33: // and any transaction windows exist
34:
35: #define IDM_BLOCKCURRENT 3010 // enabled if conv. sel. chkd if conv. blocked
36: #define IDM_ENABLECURRENT 3011 // enabled if conv. sel. chkd if not blocked
37: #define IDM_ENABLEONECURRENT 3012 // enabled if conv. sel.
38:
39: #define IDM_BLOCKALLCBS 3013 // enabled if any convs.
40: #define IDM_ENABLEALLCBS 3014 // enabled if any convs.
41: #define IDM_ENABLEONECB 3015 // enabled if any convs.
42:
43: #define IDM_BLOCKNEXTCB 3016 // enabled always, chkd if set.
44: #define IDM_TERMNEXTCB 3017 // enabled if any convs. chked if set.
45:
46: #define IDM_TIMEOUT 3021
47: #define IDM_DELAY 3022
48: #define IDM_CONTEXT 3023
49: #define IDM_AUTORECONNECT 3024
50:
1.1.1.3 root 51: #define IDM_WINDOWTILE 4001
1.1 root 52: #define IDM_WINDOWCASCADE 4002
53: #define IDM_WINDOWCLOSEALL 4003
54: #define IDM_WINDOWICONS 4004
55:
1.1.1.3 root 56: #define IDM_XACTTILE 4005
1.1 root 57: #define IDM_XACTCASCADE 4006
58: #define IDM_XACTCLOSEALL 4007
59:
60: #define IDM_WINDOWCHILD 4100
61:
1.1.1.3 root 62: #define IDM_HELP 5001
63: #define IDM_HELPABOUT 5002
1.1 root 64:
65:
66: #define DEFTIMEOUT 1000
67:
68: #include "dialog.h"
69:
70: // predefined format list item
71:
72: typedef struct {
73: DWORD fmt;
74: PSTR sz;
75: } FORMATINFO;
76: #define CFORMATS 3
77:
78: // conversation (MDI child) window information
79: typedef struct {
80: HWND hwndXaction; // last xaction window with focus, 0 if none.
81: BOOL fList;
82: HCONV hConv;
83: HSZ hszTopic;
84: HSZ hszApp;
85: INT x; // next child coord.
86: INT y;
87: CONVINFO ci; // most recent status info.
88: } MYCONVINFO; // parameters to AddConv() in reverse order.
1.1.1.3 root 89: #define CHILDCBWNDEXTRA sizeof(HWND)
1.1 root 90: #define UM_GETNEXTCHILDX (WM_USER + 200)
91: #define UM_GETNEXTCHILDY (WM_USER + 201)
92: #define UM_DISCONNECTED (WM_USER + 202)
93:
94: // transaction processing structure - this structure is associated with
95: // infoctrl control windows. A handle to this structure is placed into
96: // the first window word of the control.
97: typedef struct { // used to passinfo to/from TransactionDlgProc and
98: DWORD ret; // TextEntryDlgProc.
99: DWORD Result;
100: DWORD ulTimeout;
101: DWORD wType;
102: HCONV hConv;
103: HDDEDATA hDdeData;
104: DWORD wFmt;
105: HSZ hszItem;
106: DWORD fsOptions;
107: } XACT;
108:
109: typedef struct {
110: HDDEDATA hData;
111: HSZ hszItem;
112: DWORD wFmt;
113: } OWNED;
114:
115: // transaction option flags - for fsOptions field and DefOptions global.
116:
117: #define XOPT_NODATA 0x0001
118: #define XOPT_ACKREQ 0x0002
119: #define XOPT_DISABLEFIRST 0x0004
120: #define XOPT_ABANDONAFTERSTART 0x0008
121: #define XOPT_BLOCKRESULT 0x0010
122: #define XOPT_ASYNC 0x0020
123: #define XOPT_COMPLETED 0x8000 // used internally only.
124:
125: /* strings */
1.1.1.3 root 126: #define IDS_ILLFNM 1
127: #define IDS_ADDEXT 2
128: #define IDS_CLOSESAVE 3
1.1 root 129: #define IDS_HELPNOTAVAIL 4
130: #define IDS_CLIENTTITLE 5
1.1.1.3 root 131: #define IDS_APPNAME 6
1.1 root 132: #define IDS_DDEMLERR 7
133: #define IDS_BADLENGTH 8
134:
135: /* attribute flags for DlgDirList */
1.1.1.3 root 136: #define ATTR_DIRS 0xC010 /* find drives and directories */
137: #define ATTR_FILES 0x0000 /* find ordinary files */
138: #define PROP_FILENAME szPropertyName /* name of property for dialog */
1.1 root 139: #define MAX_OWNED 20
140:
141: /*
142: * GLOBALS
143: */
144: extern CONVCONTEXT CCFilter;
145: extern DWORD idInst;
1.1.1.3 root 146: extern HANDLE hInst; /* application instance handle */
147: extern HANDLE hAccel; /* resource handle of accelerators */
148: extern HWND hwndFrame; /* main window handle */
149: extern HWND hwndMDIClient; /* handle of MDI Client window */
150: extern HWND hwndActive; /* handle of current active MDI child */
151: extern HWND hwndActiveEdit; /* handle of edit control in active child */
152: extern LONG styleDefault; /* default child creation state */
1.1 root 153: extern DWORD SyncTimeout;
154: extern LONG DefTimeout;
155: extern DWORD wDelay;
156: extern BOOL fEnableCBs;
157: extern BOOL fEnableOneCB;
158: extern BOOL fBlockNextCB;
159: extern BOOL fTermNextCB;
160: extern BOOL fAutoReconnect;
161: extern HDDEDATA hDataOwned;
162: extern DWORD fmtLink; // registered LINK clipboard fmt
163: extern DWORD DefOptions;
1.1.1.3 root 164: extern CHAR szChild[]; /* class of child */
165: extern CHAR szList[]; /* class of child */
166: extern CHAR szSearch[]; /* search string */
167: extern CHAR *szDriver; /* name of printer driver */
168: extern CHAR szPropertyName[]; /* filename property for dialog box */
169: extern INT iPrinter; /* level of printing capability */
170: extern BOOL fCase; /* searches case sensitive */
171: extern DWORD cFonts; /* number of fonts enumerated */
1.1 root 172: extern FORMATINFO aFormats[];
173: extern OWNED aOwned[MAX_OWNED];
174: extern DWORD cOwned;
175: extern FARPROC lpMsgFilterProc;
1.1.1.2 root 176: extern HSZ hszHuge;
177: extern HHOOK ghhk;
1.1 root 178:
179:
180: // MACROS
181:
182: #ifdef NODEBUG
183: #define MyAlloc(cb) (PSTR)LocalAlloc(LPTR, (cb))
184: #define MyFree(p) (LocalUnlock((HANDLE)(p)), LocalFree((HANDLE)(p)))
185: #else // DEBUG
186:
187: #define MyAlloc(cb) DbgAlloc((DWORD)cb)
188: #define MyFree(p) DbgFree((PSTR)p)
189: #endif //NODEBUG
190:
191:
192: /* externally declared functions
193: */
194:
195: // client.c
196:
197: BOOL APIENTRY InitializeApplication(VOID);
198: BOOL APIENTRY InitializeInstance(DWORD);
1.1.1.4 ! root 199: INT FAR cdecl MPError(DWORD,DWORD, ...);
1.1 root 200: LONG APIENTRY FrameWndProc(HWND, UINT, WPARAM, LPARAM);
201: LONG APIENTRY MDIChildWndProc(HWND, UINT, WPARAM, LPARAM);
202: HCONV CreateConv(HSZ hszApp, HSZ hszTopic, BOOL fList);
203: HWND APIENTRY AddConv(HSZ hszApp, HSZ hszTopic, HCONV hConv, BOOL fList);
204: PSTR GetConvListText(HCONVLIST hConvList);
205: PSTR GetConvInfoText(HCONV hConv, CONVINFO *pci);
206: PSTR GetConvTitleText(HCONV hConv, HSZ hszApp, HSZ hszTopic, BOOL fList);
207: PSTR Status2String(DWORD status);
208: PSTR State2String(DWORD state);
209: PSTR Error2String(DWORD error);
210: PSTR Type2String(DWORD wType, DWORD fsOptions);
211: PSTR GetHSZName(HSZ hsz);
1.1.1.2 root 212: LRESULT CALLBACK MyMsgFilterProc(int nCode, WPARAM wParam, LPARAM lParam);
1.1 root 213:
214: // dialog.c
215:
216:
1.1.1.2 root 217: INT FAR DoDialog(LPSTR lpTemplateName, DLGPROC lpDlgProc, LONG param,
1.1 root 218: BOOL fRememberFocus);
219: BOOL APIENTRY AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
220: BOOL APIENTRY ConnectDlgProc(HWND, UINT, WPARAM, LPARAM);
221: BOOL APIENTRY TransactDlgProc(HWND, UINT, WPARAM, LPARAM);
222: BOOL APIENTRY AdvOptsDlgProc(HWND, UINT, WPARAM, LPARAM);
223: BOOL APIENTRY TextEntryDlgProc(HWND, UINT, WPARAM, LPARAM);
224: BOOL APIENTRY ViewHandleDlgProc(HWND, UINT, WPARAM, LPARAM);
225: BOOL APIENTRY TimeoutDlgProc(HWND, UINT, WPARAM, LPARAM);
226: BOOL APIENTRY DelayDlgProc(HWND, UINT, WPARAM, LPARAM);
227: BOOL APIENTRY ContextDlgProc(HWND, UINT, WPARAM, LPARAM);
228: VOID Delay(DWORD delay);
229:
230: // dde.c
231:
232:
233: BOOL ProcessTransaction(XACT *pxact);
234: VOID CompleteTransaction(HWND hwndInfoCtr, XACT *pxact);
235: HDDEDATA CALLBACK DdeCallback(UINT wType, UINT wFmt, HCONV hConv, HSZ hsz1,
236: HSZ hsz2, HDDEDATA hData, DWORD lData1, DWORD lData2);
237: HWND MDIChildFromhConv(HCONV hConv);
238: HWND FindAdviseChild(HWND hwndMDI, HSZ hszItem, DWORD wFmt);
239: HWND FindListWindow(HCONVLIST hConvList);
240: PSTR GetTextData(HDDEDATA hData);
241: PSTR GetFormatData(HDDEDATA hData);
242: INT MyGetClipboardFormatName(DWORD fmt, LPSTR lpstr, INT cbMax);
243: PSTR GetFormatName(DWORD wFmt);
244: BOOL MyDisconnect(HCONV hConv);
245:
246: // mem.c
247:
248:
249: PSTR DbgAlloc(DWORD cb);
250: PSTR DbgFree(PSTR p);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.