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