home *** CD-ROM | disk | FTP | other *** search
- /* ----------------------------------------------------------------------
-
- CNFTEST sample for Microsoft ActiveX Conferencing
-
- Unpublished work.
- Copyright (c) 1996, Microsoft Corporation
- All rights reserved.
-
- global.h
-
- ---------------------------------------------------------------------- */
-
- #ifndef GLOBAL_H
- #define GLOBAL_H
-
- //-------------------------------------------------------
- // Useful constants
- #define fFalse 0
- #define fTrue 1
-
- #define chNull ('\0')
- #define lpNil (NULL)
-
- #define hwndNil ((HWND) NULL)
- #define hfontNil ((HFONT) NULL)
- #define hgdiNil ((HGDIOBJ) NULL)
-
- #define FileIdNil (0xffffffff)
-
- #define MAX_USERS 10
-
- //-------------------------------------------------------
- // Useful macros
-
- #define CchSz(pcsz) ( lstrlen(pcsz) )
- #define CbSz(pcsz) ( lstrlen(pcsz)+1 )
-
- #define ClearBytes(lpv, cb) ZeroMemory((LPVOID) (lpv), (cb))
- #define ClearStruct(lpv) ZeroMemory((LPVOID) (lpv), sizeof(*(lpv)))
- #define InitStruct(lpv) {ClearStruct(lpv); (* (LPDWORD) lpv) = sizeof(*(lpv));}
-
- #define SetEmptySz(sz) ( *(sz) = '\0' )
- #define FEmptySz(sz) (((sz) == NULL) || (*(sz) == '\0'))
-
-
- //-------------------------------------------------------
- // Assert macros
-
- VOID FAR PASCAL AssertProc(LPSTR lpszMsg, LPSTR lpszAssert, LPSTR lpszFile, UINT line);
-
- #define DEBASSERT(exp,szMsg) \
- if (!(exp)) \
- { \
- static char _szAssert[] = #exp ; \
- static char _szMsg[] = szMsg; \
- AssertProc(_szMsg,_szAssert,__FILE__,__LINE__); \
- }
-
- #define ASSERT(f) Assert(f)
- #define Assert(f) DEBASSERT(f, "")
- #define AssertEx(f) DEBASSERT(f, "!(" #f ")")
- #define AssertSz(f,sz) DEBASSERT(f, sz)
- #define AssertBool(f) DEBASSERT((f) == fFalse || (f) == fTrue, "")
- #define NotReached() DEBASSERT(FALSE, "NotReached declaration was reached!")
-
- #define Log1(grf, lpsz, d1) \
- { \
- char _szT[MAX_PATH]; \
- wsprintf(_szT, lpsz, d1); \
- Log(grf, _szT); \
- }
- #define Log2(grf, lpsz, d1, d2) \
- { \
- char _szT[MAX_PATH]; \
- wsprintf(_szT, lpsz, d1, d2); \
- Log(grf, _szT); \
- }
- #define Log3(grf, lpsz, d1,d2,d3) \
- { \
- char _szT[MAX_PATH]; \
- wsprintf(_szT,lpsz,d1,d2,d3); \
- Log(grf, _szT); \
- }
- #define Log4(grf, lpsz, d1,d2,d3,d4) \
- { \
- char _szT[MAX_PATH]; \
- wsprintf(_szT,lpsz,d1,d2,d3,d4); \
- Log(grf, _szT); \
- }
-
-
- #define LOG_ALWAYS 0xFFFF
- #define LOG_ERROR 0x0001
- #define LOG_NORMAL 0x0100
-
-
- //-------------------------------------------------------------------------
- // Functions for handling main window messages. The message-dispatching
- // mechanism expects all message-handling functions to have the following
- // prototype:
- //
- // Function pointer prototype for message handling functions.
- // LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
-
- typedef LRESULT (*PFNMSG)(HWND, UINT, WPARAM, LPARAM);
-
- // This structure maps messages to message handling functions.
- typedef struct _MSD
- {
- UINT uMsg;
- PFNMSG pfnmsg;
- } MSD; // MeSsage Dispatch structure
- typedef MSD * LPMSD;
-
-
- //-------------------------------------------------------------------------
- // Functions for handling main window commands--ie. functions for
- // processing WM_COMMAND messages based on the wParam value.
- // The message-dispatching mechanism expects all command-handling
- // functions to have the following prototype:
-
- typedef VOID (*PFNCMD)(HWND, WORD, WORD, HWND);
-
- // This structure maps command IDs to command handling functions.
- typedef struct _CMD
- {
- WORD wCmd;
- PFNCMD pfncmd;
- } CMD; // CoMmand Dispatch structure
- typedef CMD * LPCMD;
-
- typedef struct _USERS
- {
- CHAR szUserName[64];
- DWORD dwUserId;
- } USERS;
- typedef USERS * LPUSERS;
-
- //-------------------------------------------------------------------------
- // Preferences
- typedef struct _PREF
- {
- BOOL fConfirm; // Confirm before receiving files
- BOOL fSbar; // Show status bar
- DWORD grfLog; // Logging flags
- DWORD iAddrType; // Address Type
- DWORD dwMediaType; // Media Types
- LOGFONT lf; // Font to use for main message window
- WINDOWPLACEMENT wpMain;
- CHAR szDefName[MAX_PATH]; // Default Address information (machine name, ip addr)
- CHAR szConferenceName[MAX_PATH];
- CHAR szAppName[MAX_PATH];
- CHAR szCmdLine[MAX_PATH];
- CHAR szCurrDir[MAX_PATH];
- GUID guid;
- GUID guidRemote;
- CHAR szFileName[MAX_PATH];
-
- // items not saved
- HCONF hConf; // Current Conference
- DWORD dwRemoteId;
- CHAR szData[1024];
- HCONFNOTIFY hConfNotify;
- CHAR szUserName[64];
- } PREF;
-
-
-
-
-
- //-------------------------------------------------------------------------
- // Global Function Prototypes.
-
- LRESULT DispatchMsg(LPMSD, HWND, UINT, WPARAM, LPARAM);
- LRESULT DispatchCmd(LPCMD, HWND, WPARAM, LPARAM);
-
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-
- // command handlers
- VOID DefCmdProc(HWND, WORD, WORD, HWND);
- VOID CmdExit(HWND, WORD, WORD, HWND);
- VOID CmdHelp(HWND, WORD, WORD, HWND);
- VOID CmdAbout(HWND, WORD, WORD, HWND);
- VOID CmdOptions(HWND, WORD, WORD, HWND);
- VOID CmdStatus(HWND, WORD, WORD, HWND);
- VOID CmdViewSbar(HWND, WORD, WORD, HWND);
- VOID CmdFont(HWND, WORD, WORD, HWND);
- VOID CmdClear(HWND, WORD, WORD, HWND);
- VOID CmdViewEnviron(HWND, WORD, WORD, HWND);
-
- VOID CmdMsgClear(HWND, WORD, WORD, HWND);
-
- VOID DlgExit(HWND, WORD, WORD, HWND);
-
- // from test.c
- VOID CmdCancelTransfer(HWND, WORD, WORD, HWND);
- VOID CmdConnect(HWND, WORD, WORD, HWND);
- VOID CmdDisconnect(HWND, WORD, WORD, HWND);
- VOID CmdGetInfo(HWND, WORD, WORD, HWND);
- VOID CmdLaunchRemote(HWND, WORD, WORD, HWND);
- VOID CmdListen(HWND, WORD, WORD, HWND);
- VOID CmdRemoveNotify(HWND, WORD, WORD, HWND);
- VOID CmdSetInfo(HWND, WORD, WORD, HWND);
- VOID CmdSetNotify(HWND, WORD, WORD, HWND);
- VOID CmdSendData(HWND, WORD, WORD, HWND);
- VOID CmdSendFile(HWND, WORD, WORD, HWND);
- VOID CmdShareWindow(HWND, WORD, WORD, HWND);
-
- VOID CmdIsWindowShared(HWND, WORD, WORD, HWND);
- VOID CmdUnShareWindow(HWND, WORD, WORD, HWND);
-
- VOID CmdEnumConf(HWND, WORD, WORD, HWND);
- VOID CmdEnumUser(HWND, WORD, WORD, HWND);
- VOID CmdSetGuid(HWND, WORD, WORD, HWND);
- VOID CmdSetNotifyProc(HWND, WORD, WORD, HWND);
-
- // message handlers
- LRESULT MsgCmdMain(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgCreate(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgDestroy(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgDrop(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgMove(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgSize(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgSetCursor(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgClose(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgGetMinMax(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgNotify(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgMenuSelect(HWND, UINT, WPARAM, LPARAM);
- LRESULT MsgDrawItem(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-
- // from util.c
- BOOL GetIniBool(LPSTR szEntry, BOOL f);
- DWORD GetIniInt(LPSTR szEntry, DWORD dwDefault);
- LPSTR GetIniStr(LPSTR szEntry, LPSTR szDefault);
- VOID GetIniHex(LPSTR szEntry, LPVOID lpv, int cb);
- VOID WriteIniBool(LPSTR szEntry, BOOL f);
- VOID WriteIniInt(LPSTR szEntry, DWORD dw);
- VOID WriteIniStr(LPSTR szEntry, LPSTR sz);
- VOID WriteIniHex(LPSTR szEntry, LPVOID lpv, int cb);
- VOID CenterWindow(HWND hwndChild, HWND hwndParent);
- LPVOID LpvAlloc(int cb);
- VOID FreePlpv(LPVOID plpv);
- VOID UpdateHdlgIdText(HWND hdlg, int id, LPVOID lpv);
- VOID UpdateHdlgIdInt(HWND hdlg, int id, LPINT lpint);
- char ChFromHex(LPSTR lpch);
- VOID GetDlgItemsRc(HWND hdlg, int id1, int id2, LPRECT prc);
- VOID HexToData(LPSTR lpchSrc, LPVOID lpchDest, int cb);
- VOID DataToHex(LPSTR lpchSrc, LPSTR lpchDest, int cb);
- VOID SetMenuCheck(UINT idm, BOOL fCheck);
- VOID MaybeDeleteObject(HGDIOBJ * phgdi);
- int GetRadioButton(HWND hdlg, int idrFirst, int idrLast);
-
- VOID GuidToSz(GUID * pguid, LPSTR sz);
- VOID SzToGuid(LPSTR sz, GUID * pguid);
-
-
- // from rtns.c
- VOID DumpConfInfo(LPCONFINFO lpConfInfo);
- VOID DumpUserInfo(LPCONFUSERINFO lpUserInfo);
-
- LPCTSTR GetConfnString(DWORD dwCode);
- LPCTSTR GetConferrString(DWORD dwErr);
- DWORD DwIpAddrFromSz(LPSTR lpsz);
-
- BOOL FSetNotifyProc(void);
-
- // from dlg.c
- BOOL DlgConferenceConnect(VOID);
- BOOL DlgGuid(VOID);
- BOOL DlgLaunchRemote(VOID);
- BOOL DlgSendData(VOID);
- BOOL DlgSendFile(VOID);
- BOOL DlgRemoveNotify(VOID);
-
-
- // from init.c
- BOOL FInitApp(LPSTR lpszCmd);
- BOOL FInitInstance(int nCmdShow);
- VOID ReadPref(void);
- VOID WritePref(void);
-
- // from dlg.c
- VOID DisplayStatus(BOOL fShow);
- VOID DisplayDlg(BOOL fShow, HWND * phdlg, int id, int idm);
-
-
- // from sbar.c
- BOOL FCreateSbar(void);
-
- // from cmd.c
- VOID RecalcMsgWindow(void);
- VOID ShowHwnd(HWND hwnd, BOOL fShow, int idm);
-
- // from msg.c
- INT MsgBoxIMbd(int iMbd);
- INT MsgBoxIMbdDw(int iMbd, DWORD dw);
- INT MsgBoxIMbdSz(int iMbd, LPSTR lpsz);
-
- // other random prototypes
- WPARAM MsgLoop(BOOL fForever);
-
- // from util.c
- VOID Log(DWORD grf, LPSTR lpsz);
- VOID ClearLog(void);
- VOID LogTestStart(LPSTR sz);
- VOID LogTestStop(LPSTR sz);
- VOID LogTestCancel(LPSTR sz);
- VOID LogResult(LPSTR sz, DWORD dwTest, DWORD dwResult);
- VOID InitDbg(void);
- LPSTR ConfErrToSz(DWORD dwError, LPSTR sz);
- BOOL FGetFileName(LPSTR szFileName);
- BOOL FGetDirectory(LPSTR szDir);
-
-
- #define SetPropResult(hdlg, f) SetWindowLong(GetParent(hdlg), DWL_MSGRESULT, f)
-
- //-------------------------------------------------------------------------
- // Global Variables
-
- extern HINSTANCE ghInst; // The current instance handle
- extern HINSTANCE ghInstDll;
- extern HANDLE ghAccelTable; // Menu accelerators
- extern PREF gPref; // User preferences
- extern HWND ghwndMain; // Main Window
- extern HMENU ghMenu; // Main Menu
- extern HWND ghdlgStatus; // Modeless Status Dialog
- extern HWND ghwndSbar; // Status bar
- extern HWND ghwndMsg; // Message Window
- extern HFONT ghfontEntry; // Font for message Window
-
- extern int gdxWndMin; // maximum width of window
- extern int gdyWndMin; // maximum width of window
- extern int giCount; // count of hConfNotify handles
-
- extern DWORD gdwFileId; // ID of current file being transferred
-
- extern HCONFNOTIFY grhConfNotify[10]; // array of handles to notification callback routines
-
- // Special resource constants
- #define IDW_MSG 100
- #define IDW_SBAR 101
-
- #endif /* GLOBAL_H */
-