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

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1997  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. // PURPOSE:
  9. //    Contains declarations for all globally scoped names in the program.
  10. //
  11.  
  12. //-------------------------------------------------------------------------
  13. // Product identifier string defines
  14.  
  15. // #define APPNAME       IPXChat
  16. // #define SZVERSION     "Version 4.0"
  17.  
  18.  
  19. //-------------------------------------------------------------------------
  20. // Functions for handling main window messages.  The message-dispatching
  21. // mechanism expects all message-handling functions to have the following
  22. // prototype:
  23. //
  24. //     LRESULT FunctionName(HWND, UINT, WPARAM, LPARAM);
  25.  
  26. LRESULT MsgCreate(HWND, UINT, WPARAM, LPARAM);
  27. LRESULT MsgSize(HWND, UINT, WPARAM, LPARAM);
  28. LRESULT MsgSetfocus(HWND, UINT, WPARAM, LPARAM);
  29. LRESULT MsgCommand(HWND, UINT, WPARAM, LPARAM);
  30. LRESULT MsgDataready(HWND, UINT, WPARAM, LPARAM);
  31. LRESULT MsgRefreshdisplay(HWND, UINT, WPARAM, LPARAM);
  32. LRESULT MsgDisconnected(HWND, UINT, WPARAM, LPARAM);
  33. LRESULT MsgDestroy(HWND, UINT, WPARAM, LPARAM);
  34.  
  35.  
  36. //-------------------------------------------------------------------------
  37. // Functions for handling main window commands--ie. functions for
  38. // processing WM_COMMAND messages based on the wParam value.
  39. // The message-dispatching mechanism expects all command-handling
  40. // functions to have the following prototype:
  41. //
  42. //     LRESULT FunctionName(HWND, WORD, WORD, HWND);
  43.  
  44. LRESULT CmdConnect(HWND, WORD, WORD, HWND);
  45. LRESULT CmdListen(HWND, WORD, WORD, HWND);
  46. LRESULT CmdExit(HWND, WORD, WORD, HWND);
  47. LRESULT CmdAbout(HWND, WORD, WORD, HWND);
  48. LRESULT CmdOutbox(HWND, WORD, WORD, HWND);
  49. LRESULT CmdDisconnect(HWND, WORD, WORD, HWND);
  50.  
  51.  
  52. //-------------------------------------------------------------------------
  53. // Global function prototypes.
  54.  
  55. BOOL InitApplication(HINSTANCE, int);
  56. BOOL CenterWindow(HWND, HWND);
  57. BOOL ReceiveInBox(HWND, WPARAM, LPARAM, char *, int);
  58. void SendOutBox(char *, int);
  59. void AtoH(char *, char *, int);
  60. unsigned char BtoH(char);
  61. void CleanUp(void);
  62. void GetAddrString(PSOCKADDR_IPX, char *);
  63. void HtoA(char *, char *, int);
  64. char HtoB(UCHAR);
  65. LPTSTR GetStringRes (int id);
  66.  
  67. // Callback functions.  These are called by Windows.
  68.  
  69. // **TODO**  Add new callback function prototypes here.
  70.  
  71. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  72.  
  73.  
  74. //-------------------------------------------------------------------------
  75. // Command ID definitions.  These definitions are used to associate menu
  76. // items with commands.
  77.  
  78. // Options menu
  79. #define IDM_CONNECT    1000
  80. #define IDM_LISTEN     1001
  81. #define IDM_DISCONNECT 1002
  82. #define IDM_EXIT       1003
  83.  
  84. // Help menu
  85. #define IDM_ABOUT      1100
  86.  
  87. //-------------------------------------------------------------------------
  88. // User Defined Messages.  These definitions are used for indicating 
  89. // network events.
  90.  
  91. #define MW_DATAREADY       501
  92. #define MW_DISPLAYREFRESH  502
  93. #define MW_DISCONNECTED    503
  94. #define LDM_CONNECTED      504
  95.  
  96. //-------------------------------------------------------------------------
  97. // String Table ID definitions.
  98.  
  99. #define IDS_APPNAME     1
  100. #define IDS_DESCRIPTION 2
  101.  
  102. //-------------------------------------------------------------------------
  103. //  Main Window Edit Control defines.
  104.  
  105. #define ID_OUTBOX          601
  106. #define ID_INBOX           602
  107.  
  108. //-------------------------------------------------------------------------
  109. //  About dialog defines.
  110.  
  111. #define IDD_VERFIRST    100
  112. #define IDD_VERLAST     104
  113.  
  114. //-------------------------------------------------------------------------
  115. //  Connect dialog defines.
  116.  
  117. #define CD_STATUS       200
  118. #define CD_NETWORK      201
  119. #define CD_NODE         202
  120. #define CD_SOCKET       203
  121.  
  122. //-------------------------------------------------------------------------
  123. //  Listen dialog defines.
  124.  
  125. #define LD_SOCKET       300
  126. #define LD_STATUS       301
  127.  
  128. //-------------------------------------------------------------------------
  129. // Global variable declarations.
  130.  
  131. extern HINSTANCE hInst;          // The current instance handle
  132. extern char      szAppName[];    // The name of this application
  133. extern char      szTitle[];      // The title bar text
  134. SOCKET sock, SrvSock;
  135. SOCKADDR_IPX RemAddr;
  136. PSOCKADDR_IPX pSockAddr, pRemAddr;
  137. struct sockaddr addr;
  138. int addrlen;
  139. HWND hOutWnd, hInWnd;
  140. char szRcvBuf[0x8000];
  141. char szSndBuf[0x8000];
  142. extern char szConnectNetwork[];
  143. extern char szConnectNode[];
  144. extern char szConnectSocket[];
  145. extern char szListenSocket[];
  146. extern BOOL i_should_sleep;
  147.  
  148. // For NON-MDI applications, uncomment line 1 below and comment
  149. // line 2.  For MDI applications, uncomment line 2 below, comment
  150. // line 1, and then define hwndMDIIPXChat as a global variable in
  151. // INIT.C
  152. #define hwndMDIIPXChat NULL        /* (1) Stub for NON-MDI applications. */
  153. // extern HWND hwndMDIIPXChat;     /* (2) For MDI applications.          */
  154.  
  155.  
  156. //-------------------------------------------------------------------------
  157. // Message and command dispatch infrastructure.  The following type
  158. // definitions and functions are used by the message and command dispatching
  159. // mechanism and do not need to be changed.
  160.  
  161.     // Function pointer prototype for message handling functions.
  162. typedef LRESULT (*PFNMSG)(HWND,UINT,WPARAM,LPARAM);
  163.  
  164.     // Function pointer prototype for command handling functions.
  165. typedef LRESULT (*PFNCMD)(HWND,WORD,WORD,HWND);
  166.  
  167.     // Enumerated type used to determine which default window procedure
  168.     // should be called by the message- and command-dispatching mechanism
  169.     // if a message or command is not handled explicitly.
  170. typedef enum
  171. {
  172.    edwpNone,            // Do not call any default procedure.
  173.    edwpWindow,          // Call DefWindowProc.
  174.    edwpDialog,          // Call DefDlgProc (This should be used only for
  175.                         // custom dialogs - standard dialog use edwpNone).
  176.    edwpMDIChild,        // Call DefMDIChildProc.
  177.    edwpMDIFrame         // Call DefFrameProc.
  178. } EDWP;                // Enumeration for Default Window Procedures
  179.  
  180.     // This structure maps messages to message handling functions.
  181. typedef struct _MSD
  182. {
  183.     UINT   uMessage;
  184.     PFNMSG pfnmsg;
  185. } MSD;                 // MeSsage Dispatch structure
  186.  
  187.     // This structure contains all of the information that a window
  188.     // procedure passes to DispMessage in order to define the message
  189.     // dispatching behavior for the window.
  190. typedef struct _MSDI
  191. {
  192.     int  cmsd;          // Number of message dispatch structs in rgmsd
  193.     MSD *rgmsd;         // Table of message dispatch structures
  194.     EDWP edwp;          // Type of default window handler needed.
  195. } MSDI, FAR *LPMSDI;   // MeSsage Dipatch Information
  196.  
  197.     // This structure maps command IDs to command handling functions.
  198. typedef struct _CMD
  199. {
  200.     WORD   wCommand;
  201.     PFNCMD pfncmd;
  202. } CMD;                 // CoMmand Dispatch structure
  203.  
  204.     // This structure contains all of the information that a command
  205.     // message procedure passes to DispCommand in order to define the
  206.     // command dispatching behavior for the window.
  207. typedef struct _CMDI
  208. {
  209.     int  ccmd;          // Number of command dispatch structs in rgcmd
  210.     CMD *rgcmd;         // Table of command dispatch structures
  211.     EDWP edwp;          // Type of default window handler needed.
  212. } CMDI, FAR *LPCMDI;   // CoMmand Dispatch Information
  213.  
  214.     // Message and command dispatching functions.  They look up messages
  215.     // and commands in the dispatch tables and call the appropriate handler
  216.     // function.
  217. LRESULT DispMessage(LPMSDI, HWND, UINT, WPARAM, LPARAM);
  218. LRESULT DispCommand(LPCMDI, HWND, WPARAM, LPARAM);
  219.  
  220.     // Message dispatch information for the main window
  221. extern MSDI msdiMain;
  222.     // Command dispatch information for the main window
  223. extern CMDI cmdiMain;
  224.  
  225.  
  226.  
  227. //-------------------------------------------------------------------------
  228. // Version string definitions--Leave these alone.
  229.  
  230. #define SZRCOMPANYNAME "CompanyName"
  231. #define SZRDESCRIPTION "FileDescription"
  232. #define SZRVERSION     "FileVersion"
  233. #define SZRAPPNAME     "InternalName"
  234. #define SZRCOPYRIGHT   "LegalCopyright"
  235. #define SZRTRADEMARK   "LegalTrademarks"
  236. #define SZRPRODNAME    "ProductName"
  237. #define SZRPRODVER     "ProuctVersion"
  238.