home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / directx / bellhop / bellhop.h < prev    next >
C/C++ Source or Header  |  1997-07-14  |  5KB  |  119 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1996-1997 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:       bellhop.h
  6.  *  Content:    Header file for bellhop.cpp
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #define IDIRECTPLAY2_OR_GREATER
  11. #include <windows.h>
  12. #include <windowsx.h>
  13. #include <dplay.h>
  14. #include <dplobby.h>
  15. #include "CGRpTree.h"
  16.  
  17. // constants
  18. const DWORD MAXPLAYERS = 10;            // max no. players in the session
  19. const DWORD MAXSTRLEN = 200;            // max. size of a string
  20.  
  21. // structure used to store DirectPlay information
  22. typedef struct {
  23.     LPDIRECTPLAY3A        lpDirectPlay3A;            // IDirectPlay3A interface pointer
  24.     LPDIRECTPLAYLOBBY2A    lpDirectPlayLobby2A;    // IDirectPlayLobby2A interface pointer
  25.     HANDLE                hPlayerEvent;            // player event to use
  26.     DPID                dpidPlayer;                // ID of player created
  27.     BOOL                bIsHost;                // TRUE if we are hosting the session
  28.     BOOL                bSecureSession;            // TRUE if the session is secure.
  29.     DWORD                dwPlayerFlags;
  30.     CGroupTree    *        lpGroupTree;
  31.     int                    xPaneSplit;
  32.     int                    xHalfSplitWidth;
  33.     int                    ySpacing;
  34.     int                    xSpacing;
  35.     BOOL                bSplitMove;
  36.     char                szSecureName[256];
  37.     char                szSecurePassword[256];
  38.     char                szSecureDomain[256];
  39. } DPLAYINFO, *LPDPLAYINFO;
  40.  
  41. typedef struct {
  42.     HWND    hWnd;
  43.     int        idCombo;
  44. } ENUMCONNSTRUCT, *LPENUMCONNSTRUCT;
  45.  
  46. typedef struct {
  47.     GUID    guidSP;
  48.     BYTE    Connection[1];
  49. } CONNECTIONINFO, *LPCONNECTIONINFO;
  50.  
  51. typedef struct {
  52.     GUID    guidInstance;
  53.     DWORD    dwFlags;
  54. } SESSIONINFO, *LPSESSIONINFO;
  55.  
  56. typedef struct {
  57.     LPDPLAYINFO        lpDPInfo;
  58.     DPID            dpidRoom;
  59. } LOBBYGROUPCONTEXT, *LPLOBBYGROUPCONTEXT;
  60.  
  61. typedef struct {
  62.     GUID    guidApplication;
  63.     CHAR    szAppName[MAXSTRLEN];
  64. } APPNAMECONTEXT, *LPAPPNAMECONTEXT;
  65.  
  66. // guid for this application
  67. // {4BF5D540-BDA5-11d0-9C4F-00A0C905425E}
  68. DEFINE_GUID(BELLHOP_GUID, 
  69. 0x4bf5d540, 0xbda5, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
  70.  
  71. // prototypes
  72. extern HRESULT    CreateDirectPlayInterface(LPDIRECTPLAY3A *lplpDirectPlay3A );
  73. extern HRESULT    CreateDirectPlayLobbyInterface(LPDIRECTPLAYLOBBY2A *lplpDirectPlayLobby2A );
  74. extern HRESULT    ConnectUsingDialog(HINSTANCE hInstance, LPDPLAYINFO lpDPInfo);
  75. extern void        ErrorBox(LPSTR lpszErrorStr, HRESULT hr);
  76.  
  77. // prototypes BELLHOP.CPP
  78. BOOL CALLBACK    LobbyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  79. BOOL CALLBACK    ConnectionSettingsDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  80.  
  81. HRESULT            SetupConnection(HINSTANCE hInstance, LPDPLAYINFO lpDPInfo);
  82. HRESULT            ShutdownConnection(LPDPLAYINFO lpDPInfo);
  83. DWORD WINAPI    ReceiveThread(LPVOID lpThreadParameter);
  84. HRESULT            ReceiveMessage(LPDPLAYINFO lpDPInfo);
  85. void            HandleApplicationMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  86.                                          DPID idFrom, DPID idTo);
  87. void            HandleSystemMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  88.                                     DPID idFrom, DPID idTo);
  89. HRESULT            GetPlayerName(LPDIRECTPLAY3A lpDirectPlay3A, DPID dpidPlayer,
  90.                               LPDPNAME *lplpName);
  91. HRESULT            GetGroupName(LPDIRECTPLAY3A lpDirectPlay3A, DPID dpidGroup,
  92.                              LPDPNAME *lplpName);
  93. HRESULT            NewChatString(LPDIRECTPLAY3A lpDirectPlay3A, DPID dpidPlayer,
  94.                               LPSTR lpszMsg, LPSTR *lplpszStr);
  95. HRESULT            DoCreateRoom(HWND hWnd, LPDPLAYINFO lpDPInfo);
  96. HRESULT            DoDeleteRoom(HWND hWnd, LPDPLAYINFO lpDPInfo);
  97. HRESULT            DoCreateTable(HWND hWnd, LPDPLAYINFO lpDPInfo);
  98. HRESULT            DoDeleteTable(HWND hWnd, LPDPLAYINFO lpDPInfo);
  99. HRESULT            DoDeletePlayerFromGroup(HWND hWnd, LPDPLAYINFO lpDPInfo);
  100. HRESULT            DoLaunch(HWND hWnd, LPDPLAYINFO lpDPInfo);
  101. HRESULT            DoGroupConnectionSettings(HWND hWnd, LPDPLAYINFO lpDPInfo);
  102. HRESULT            InitializeLobby(HWND hWnd, LPDPLAYINFO lpDPInfo);
  103. HRESULT            UpdateLobbyDisplay(HWND hWnd, LPDPLAYINFO lpDPInfo);
  104. void            UpdateButtons(HWND hWnd, LPDPLAYINFO lpDPInfo);
  105. HRESULT            SendChatMessage(HWND hWnd, LPDPLAYINFO lpDPInfo);
  106.  
  107. extern void        EnableDlgButton(HWND hWnd, int nIDDlgItem, BOOL bEnable);
  108. void            HandleStartSession(LPDPLCONNECTION lpConn, LPDPLAYINFO lpDPInfo );
  109. BOOL FAR PASCAL    EnumApp(LPCDPLAPPINFO lpAppInfo, LPVOID lpContext, DWORD dwFlags);
  110. HRESULT            GetComboBoxGuid(HWND hWnd, LONG iDialogItem, LPGUID lpguidReturn);
  111. HRESULT            GetLocalAppName(LPDIRECTPLAYLOBBY lpIDPL,
  112.                                 LPGUID lpguidApplication, LPSTR lpszAppName);
  113. void            LogString(LPSTR lpszDisplayFormat, LPSTR lpszDataStr);
  114. void            OnSize(HWND hWnd, LPDPLAYINFO lpDPInfo);
  115.  
  116. // Globals
  117. extern HINSTANCE ghInstance;
  118.  
  119.