home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / ipc / ddeml / client / client.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  9KB  |  252 lines

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