home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / activex / inetsdk / samples / msconf / cnftest / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-03  |  10.6 KB  |  345 lines

  1. /* ----------------------------------------------------------------------
  2.  
  3.     CNFTEST sample for Microsoft ActiveX Conferencing
  4.  
  5.     Unpublished work.
  6.     Copyright (c) 1996, Microsoft Corporation
  7.     All rights reserved.
  8.  
  9.     global.h
  10.  
  11. ---------------------------------------------------------------------- */
  12.  
  13. #ifndef GLOBAL_H
  14. #define GLOBAL_H
  15.  
  16. //-------------------------------------------------------
  17. // Useful constants
  18. #define fFalse   0
  19. #define fTrue    1
  20.  
  21. #define chNull   ('\0')
  22. #define lpNil    (NULL)
  23.  
  24. #define hwndNil      ((HWND) NULL)
  25. #define hfontNil     ((HFONT) NULL)
  26. #define hgdiNil      ((HGDIOBJ) NULL)
  27.  
  28. #define FileIdNil    (0xffffffff)
  29.  
  30. #define MAX_USERS    10
  31.  
  32. //-------------------------------------------------------
  33. // Useful macros
  34.  
  35. #define CchSz(pcsz)                ( lstrlen(pcsz) )
  36. #define CbSz(pcsz)                ( lstrlen(pcsz)+1 )
  37.  
  38. #define ClearBytes(lpv, cb)        ZeroMemory((LPVOID) (lpv), (cb))
  39. #define ClearStruct(lpv)        ZeroMemory((LPVOID) (lpv), sizeof(*(lpv)))
  40. #define InitStruct(lpv)        {ClearStruct(lpv); (* (LPDWORD) lpv) = sizeof(*(lpv));}
  41.  
  42. #define SetEmptySz(sz)            ( *(sz) = '\0' )
  43. #define FEmptySz(sz)            (((sz) == NULL) || (*(sz) == '\0'))
  44.  
  45.  
  46. //-------------------------------------------------------
  47. // Assert macros
  48.  
  49. VOID FAR PASCAL AssertProc(LPSTR lpszMsg, LPSTR lpszAssert, LPSTR lpszFile, UINT line);
  50.  
  51. #define DEBASSERT(exp,szMsg)  \
  52.     if (!(exp))                                                      \
  53.     {                                                                \
  54.         static char _szAssert[] = #exp ;   \
  55.         static char _szMsg[]    = szMsg;   \
  56.         AssertProc(_szMsg,_szAssert,__FILE__,__LINE__); \
  57.     }
  58.  
  59. #define ASSERT(f)       Assert(f)
  60. #define Assert(f)       DEBASSERT(f, "")
  61. #define AssertEx(f)     DEBASSERT(f, "!(" #f ")")
  62. #define AssertSz(f,sz)  DEBASSERT(f, sz)
  63. #define AssertBool(f)   DEBASSERT((f) == fFalse || (f) == fTrue, "")
  64. #define NotReached()    DEBASSERT(FALSE, "NotReached declaration was reached!")
  65.  
  66. #define Log1(grf, lpsz, d1)       \
  67.     {                             \
  68.     char _szT[MAX_PATH];           \
  69.     wsprintf(_szT, lpsz, d1);     \
  70.     Log(grf, _szT);               \
  71.     }
  72. #define Log2(grf, lpsz, d1, d2)   \
  73.     {                             \
  74.     char _szT[MAX_PATH];           \
  75.     wsprintf(_szT, lpsz, d1, d2); \
  76.     Log(grf, _szT);               \
  77.     }
  78. #define Log3(grf, lpsz, d1,d2,d3) \
  79.     {                             \
  80.     char _szT[MAX_PATH];           \
  81.     wsprintf(_szT,lpsz,d1,d2,d3); \
  82.     Log(grf, _szT);               \
  83.     }
  84. #define Log4(grf, lpsz, d1,d2,d3,d4) \
  85.     {                                \
  86.     char _szT[MAX_PATH];              \
  87.     wsprintf(_szT,lpsz,d1,d2,d3,d4); \
  88.     Log(grf, _szT);                  \
  89.     }
  90.  
  91.  
  92. #define LOG_ALWAYS   0xFFFF
  93. #define LOG_ERROR    0x0001
  94. #define LOG_NORMAL   0x0100
  95.  
  96.  
  97. //-------------------------------------------------------------------------
  98. // Functions for handling main window messages.  The message-dispatching
  99. // mechanism expects all message-handling functions to have the following
  100. // prototype:
  101. //
  102. // Function pointer prototype for message handling functions.
  103. //     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
  104.  
  105. typedef LRESULT (*PFNMSG)(HWND, UINT, WPARAM, LPARAM);
  106.  
  107. // This structure maps messages to message handling functions.
  108. typedef struct _MSD
  109. {
  110.     UINT   uMsg;
  111.     PFNMSG pfnmsg;
  112. } MSD;                 // MeSsage Dispatch structure
  113. typedef MSD * LPMSD;
  114.  
  115.  
  116. //-------------------------------------------------------------------------
  117. // Functions for handling main window commands--ie. functions for
  118. // processing WM_COMMAND messages based on the wParam value.
  119. // The message-dispatching mechanism expects all command-handling
  120. // functions to have the following prototype:
  121.  
  122. typedef VOID (*PFNCMD)(HWND, WORD, WORD, HWND);
  123.  
  124. // This structure maps command IDs to command handling functions.
  125. typedef struct _CMD
  126. {
  127.     WORD   wCmd;
  128.     PFNCMD pfncmd;
  129. } CMD;                 // CoMmand Dispatch structure
  130. typedef CMD * LPCMD;
  131.  
  132. typedef struct _USERS
  133. {
  134.     CHAR szUserName[64];
  135.     DWORD dwUserId;
  136. } USERS;
  137. typedef USERS * LPUSERS;
  138.  
  139. //-------------------------------------------------------------------------
  140. // Preferences
  141. typedef struct _PREF
  142. {
  143.     BOOL  fConfirm;          // Confirm before receiving files
  144.     BOOL  fSbar;             // Show status bar
  145.     DWORD grfLog;            // Logging flags
  146.     DWORD iAddrType;         // Address Type
  147.     DWORD dwMediaType;       // Media Types
  148.     LOGFONT lf;              // Font to use for main message window
  149.     WINDOWPLACEMENT wpMain;
  150.     CHAR  szDefName[MAX_PATH];  // Default Address information (machine name, ip addr)
  151.     CHAR  szConferenceName[MAX_PATH];
  152.     CHAR  szAppName[MAX_PATH];
  153.     CHAR  szCmdLine[MAX_PATH];
  154.     CHAR  szCurrDir[MAX_PATH];
  155.     GUID  guid;
  156.     GUID  guidRemote;
  157.     CHAR  szFileName[MAX_PATH];
  158.  
  159.     // items not saved
  160.     HCONF hConf;             // Current Conference
  161.     DWORD dwRemoteId;
  162.     CHAR  szData[1024];
  163.     HCONFNOTIFY hConfNotify;
  164.     CHAR szUserName[64];
  165. } PREF;
  166.  
  167.  
  168.  
  169.  
  170.  
  171. //-------------------------------------------------------------------------
  172. // Global Function Prototypes.
  173.  
  174. LRESULT DispatchMsg(LPMSD, HWND, UINT, WPARAM, LPARAM);
  175. LRESULT DispatchCmd(LPCMD, HWND, WPARAM, LPARAM);
  176.  
  177. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  178.  
  179. // command handlers
  180. VOID DefCmdProc(HWND, WORD, WORD, HWND);
  181. VOID CmdExit(HWND, WORD, WORD, HWND);
  182. VOID CmdHelp(HWND, WORD, WORD, HWND);
  183. VOID CmdAbout(HWND, WORD, WORD, HWND);
  184. VOID CmdOptions(HWND, WORD, WORD, HWND);
  185. VOID CmdStatus(HWND, WORD, WORD, HWND);
  186. VOID CmdViewSbar(HWND, WORD, WORD, HWND);
  187. VOID CmdFont(HWND, WORD, WORD, HWND);
  188. VOID CmdClear(HWND, WORD, WORD, HWND);
  189. VOID CmdViewEnviron(HWND, WORD, WORD, HWND);
  190.  
  191. VOID CmdMsgClear(HWND, WORD, WORD, HWND);
  192.  
  193. VOID DlgExit(HWND, WORD, WORD, HWND);
  194.  
  195. // from test.c
  196. VOID CmdCancelTransfer(HWND, WORD, WORD, HWND);
  197. VOID CmdConnect(HWND, WORD, WORD, HWND);
  198. VOID CmdDisconnect(HWND, WORD, WORD, HWND);
  199. VOID CmdGetInfo(HWND, WORD, WORD, HWND);
  200. VOID CmdLaunchRemote(HWND, WORD, WORD, HWND);
  201. VOID CmdListen(HWND, WORD, WORD, HWND);
  202. VOID CmdRemoveNotify(HWND, WORD, WORD, HWND);
  203. VOID CmdSetInfo(HWND, WORD, WORD, HWND);
  204. VOID CmdSetNotify(HWND, WORD, WORD, HWND);
  205. VOID CmdSendData(HWND, WORD, WORD, HWND);
  206. VOID CmdSendFile(HWND, WORD, WORD, HWND);
  207. VOID CmdShareWindow(HWND, WORD, WORD, HWND);
  208.  
  209. VOID CmdIsWindowShared(HWND, WORD, WORD, HWND);
  210. VOID CmdUnShareWindow(HWND, WORD, WORD, HWND);
  211.  
  212. VOID CmdEnumConf(HWND, WORD, WORD, HWND);
  213. VOID CmdEnumUser(HWND, WORD, WORD, HWND);
  214. VOID CmdSetGuid(HWND, WORD, WORD, HWND);
  215. VOID CmdSetNotifyProc(HWND, WORD, WORD, HWND);
  216.  
  217. // message handlers
  218. LRESULT MsgCmdMain(HWND, UINT, WPARAM, LPARAM);
  219. LRESULT MsgCreate(HWND, UINT, WPARAM, LPARAM);
  220. LRESULT MsgDestroy(HWND, UINT, WPARAM, LPARAM);
  221. LRESULT MsgDrop(HWND, UINT, WPARAM, LPARAM);
  222. LRESULT MsgMove(HWND, UINT, WPARAM, LPARAM);
  223. LRESULT MsgSize(HWND, UINT, WPARAM, LPARAM);
  224. LRESULT MsgSetCursor(HWND, UINT, WPARAM, LPARAM);
  225. LRESULT MsgClose(HWND, UINT, WPARAM, LPARAM);
  226. LRESULT MsgGetMinMax(HWND, UINT, WPARAM, LPARAM);
  227. LRESULT MsgNotify(HWND, UINT, WPARAM, LPARAM);
  228. LRESULT MsgMenuSelect(HWND, UINT, WPARAM, LPARAM);
  229. LRESULT MsgDrawItem(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  230.  
  231.  
  232. // from util.c
  233. BOOL  GetIniBool(LPSTR szEntry, BOOL f);
  234. DWORD GetIniInt(LPSTR szEntry, DWORD dwDefault);
  235. LPSTR GetIniStr(LPSTR szEntry, LPSTR szDefault);
  236. VOID GetIniHex(LPSTR szEntry, LPVOID lpv, int cb);
  237. VOID WriteIniBool(LPSTR szEntry, BOOL f);
  238. VOID WriteIniInt(LPSTR szEntry, DWORD dw);
  239. VOID WriteIniStr(LPSTR szEntry, LPSTR sz);
  240. VOID WriteIniHex(LPSTR szEntry, LPVOID lpv, int cb);
  241. VOID CenterWindow(HWND hwndChild, HWND hwndParent);
  242. LPVOID LpvAlloc(int cb);
  243. VOID FreePlpv(LPVOID plpv);
  244. VOID UpdateHdlgIdText(HWND hdlg, int id, LPVOID lpv);
  245. VOID UpdateHdlgIdInt(HWND hdlg, int id, LPINT lpint);
  246. char ChFromHex(LPSTR lpch);
  247. VOID GetDlgItemsRc(HWND hdlg, int id1, int id2, LPRECT prc);
  248. VOID HexToData(LPSTR lpchSrc, LPVOID lpchDest, int cb);
  249. VOID DataToHex(LPSTR lpchSrc, LPSTR lpchDest, int cb);
  250. VOID SetMenuCheck(UINT idm, BOOL fCheck);
  251. VOID MaybeDeleteObject(HGDIOBJ * phgdi);
  252. int GetRadioButton(HWND hdlg, int idrFirst, int idrLast);
  253.  
  254. VOID GuidToSz(GUID * pguid, LPSTR sz);
  255. VOID SzToGuid(LPSTR sz, GUID * pguid);
  256.  
  257.  
  258. // from rtns.c
  259. VOID DumpConfInfo(LPCONFINFO lpConfInfo);
  260. VOID DumpUserInfo(LPCONFUSERINFO lpUserInfo);
  261.  
  262. LPCTSTR GetConfnString(DWORD dwCode);
  263. LPCTSTR GetConferrString(DWORD dwErr);
  264. DWORD DwIpAddrFromSz(LPSTR lpsz);
  265.  
  266. BOOL FSetNotifyProc(void);
  267.  
  268. // from dlg.c
  269. BOOL DlgConferenceConnect(VOID);
  270. BOOL DlgGuid(VOID);
  271. BOOL DlgLaunchRemote(VOID);
  272. BOOL DlgSendData(VOID);
  273. BOOL DlgSendFile(VOID);
  274. BOOL DlgRemoveNotify(VOID);
  275.  
  276.  
  277. // from init.c
  278. BOOL FInitApp(LPSTR lpszCmd);
  279. BOOL FInitInstance(int nCmdShow);
  280. VOID ReadPref(void);
  281. VOID WritePref(void);
  282.  
  283. // from dlg.c
  284. VOID DisplayStatus(BOOL fShow);
  285. VOID DisplayDlg(BOOL fShow, HWND * phdlg, int id, int idm);
  286.  
  287.  
  288. // from sbar.c
  289. BOOL FCreateSbar(void);
  290.  
  291. // from cmd.c
  292. VOID RecalcMsgWindow(void);
  293. VOID ShowHwnd(HWND hwnd, BOOL fShow, int idm);
  294.  
  295. // from msg.c
  296. INT MsgBoxIMbd(int iMbd);
  297. INT MsgBoxIMbdDw(int iMbd, DWORD dw);
  298. INT MsgBoxIMbdSz(int iMbd, LPSTR lpsz);
  299.  
  300. // other random prototypes
  301. WPARAM MsgLoop(BOOL fForever);
  302.  
  303. // from util.c
  304. VOID Log(DWORD grf, LPSTR lpsz);
  305. VOID ClearLog(void);
  306. VOID LogTestStart(LPSTR sz);
  307. VOID LogTestStop(LPSTR sz);
  308. VOID LogTestCancel(LPSTR sz);
  309. VOID LogResult(LPSTR sz, DWORD dwTest, DWORD dwResult);
  310. VOID InitDbg(void);
  311. LPSTR ConfErrToSz(DWORD dwError, LPSTR sz);
  312. BOOL FGetFileName(LPSTR szFileName);
  313. BOOL FGetDirectory(LPSTR szDir);
  314.  
  315.  
  316. #define SetPropResult(hdlg, f)  SetWindowLong(GetParent(hdlg), DWL_MSGRESULT, f)
  317.  
  318. //-------------------------------------------------------------------------
  319. // Global Variables
  320.  
  321. extern HINSTANCE ghInst;          // The current instance handle
  322. extern HINSTANCE ghInstDll;
  323. extern HANDLE    ghAccelTable;    // Menu accelerators
  324. extern PREF      gPref;           // User preferences
  325. extern HWND      ghwndMain;       // Main Window
  326. extern HMENU     ghMenu;          // Main Menu
  327. extern HWND      ghdlgStatus;     // Modeless Status Dialog
  328. extern HWND      ghwndSbar;       // Status bar
  329. extern HWND      ghwndMsg;        // Message Window
  330. extern HFONT     ghfontEntry;     // Font for message Window
  331.  
  332. extern int       gdxWndMin;       // maximum width of window
  333. extern int       gdyWndMin;       // maximum width of window
  334. extern int       giCount;         // count of hConfNotify handles
  335.  
  336. extern DWORD     gdwFileId;       // ID of current file being transferred
  337.  
  338. extern HCONFNOTIFY grhConfNotify[10]; // array of handles to notification callback routines
  339.  
  340. // Special resource constants
  341. #define IDW_MSG 100
  342. #define IDW_SBAR 101
  343.  
  344. #endif /* GLOBAL_H */
  345.