home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / bin / DXUtils / AppWizard / DXAppwiz.awx / TEMPLATE / NETCONNECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-25  |  5.5 KB  |  124 lines

  1. //-----------------------------------------------------------------------------
  2. // File: NetConnect.h
  3. //
  4. // Desc:
  5. //-----------------------------------------------------------------------------
  6. #ifndef NETCONNECT_H
  7. #define NETCONNECT_H
  8.  
  9.  
  10. #include <windows.h>
  11. #include <dplay8.h>
  12. #include <dpaddr.h>
  13. #include <tchar.h>
  14.  
  15.  
  16. //-----------------------------------------------------------------------------
  17. // Defines, structures, and error codes
  18. //-----------------------------------------------------------------------------
  19. #define DISPLAY_REFRESH_RATE        250
  20. #define TIMERID_DISPLAY_HOSTS       1
  21. #define TIMERID_CONNECT_COMPLETE    2
  22.  
  23. #define NCW_S_FORWARD      0x01000001  // Dialog success, so go forward
  24. #define NCW_S_BACKUP       0x01000002  // Dialog canceled, show previous dialog
  25. #define NCW_S_QUIT         0x01000003  // Dialog quit, close app
  26. #define NCW_S_LOBBYCONNECT 0x01000004  // Dialog connected from lobby, connect success
  27.  
  28.  
  29. class CNetConnectWizard
  30. {
  31. public:
  32.     CNetConnectWizard( HINSTANCE hInst, HWND hWndParent, TCHAR* strAppName, GUID* pGuidApp );
  33.     virtual ~CNetConnectWizard();
  34.  
  35.     HRESULT WINAPI MessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
  36.     HRESULT WINAPI LobbyMessageHandler( PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer );
  37.  
  38.     VOID    Init( IDirectPlay8Peer* pDP, IDirectPlay8LobbiedApplication* pLobbiedApp );
  39.     VOID    Shutdown();
  40.     HRESULT DoConnectWizard( BOOL bBackTrack );
  41.     HRESULT ConnectUsingLobbySettings();
  42.  
  43.     void   SetMaxPlayers( DWORD dwMaxPlayers )                 { m_dwMaxPlayers = dwMaxPlayers; }
  44.     void   SetPlayerName( TCHAR* strPlayerName )               { _tcscpy( m_strLocalPlayerName, strPlayerName ); }
  45.     void   SetSessionName( TCHAR* strSessionName )             { _tcscpy( m_strSessionName, strSessionName ); }
  46.     void   SetPreferredProvider( TCHAR* strPreferredProvider ) { _tcscpy( m_strPreferredProvider, strPreferredProvider ); }
  47.  
  48.     TCHAR* GetPlayerName()                                     { return m_strLocalPlayerName; }
  49.     TCHAR* GetSessionName()                                    { return m_strSessionName; }
  50.     TCHAR* GetPreferredProvider()                              { return m_strPreferredProvider; }
  51.     BOOL   IsHostPlayer()                                      { return m_bHostPlayer; }
  52.     BOOL   IsMigrateHost()                                     { return m_bMigrateHost; }
  53.     BOOL   HaveConnectionSettingsFromLobby()                   { return m_bHaveConnectionSettingsFromLobby; }
  54.  
  55. protected:
  56.     struct DPHostEnumInfo
  57.     {
  58.         DWORD                 dwRef;
  59.         DPN_APPLICATION_DESC* pAppDesc;
  60.         IDirectPlay8Address* pHostAddr;
  61.         IDirectPlay8Address* pDeviceAddr;
  62.         TCHAR                szSession[MAX_PATH];
  63.         DWORD                dwLastPollTime;
  64.         BOOL                 bValid;
  65.         DPHostEnumInfo*      pNext;
  66.     };
  67.  
  68.     static INT_PTR CALLBACK StaticConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  69.     static INT_PTR CALLBACK StaticSessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  70.     static INT_PTR CALLBACK StaticCreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  71.     static INT_PTR CALLBACK StaticLobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  72.     INT_PTR CALLBACK ConnectionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  73.     INT_PTR CALLBACK SessionsDlgProc( HWND, UINT, WPARAM, LPARAM );
  74.     INT_PTR CALLBACK CreateSessionDlgProc( HWND, UINT, WPARAM, LPARAM );
  75.     INT_PTR CALLBACK LobbyWaitDlgProc( HWND, UINT, WPARAM, LPARAM );
  76.  
  77.     HRESULT ConnectionsDlgFillListBox( HWND hDlg );
  78.     HRESULT ConnectionsDlgOnOK( HWND hDlg );
  79.     VOID    ConnectionsDlgCleanup( HWND hDlg );
  80.  
  81.     VOID    SessionsDlgInitListbox( HWND hDlg );
  82.     HRESULT SessionsDlgEnumHosts( HWND hDlg );
  83.     HRESULT SessionsDlgNoteEnumResponse( PDPNMSG_ENUM_HOSTS_RESPONSE pEnumHostsResponse );
  84.     VOID    SessionsDlgExpireOldHostEnums();
  85.     HRESULT SessionsDlgDisplayEnumList( HWND hDlg );
  86.     HRESULT SessionsDlgJoinGame( HWND hDlg );
  87.     HRESULT SessionsDlgCreateGame( HWND hDlg );
  88.     VOID    SessionsDlgEnumListCleanup();
  89.  
  90.     IDirectPlay8Peer*       m_pDP;
  91.     IDirectPlay8LobbiedApplication* m_pLobbiedApp;
  92.     CRITICAL_SECTION        m_csHostEnum;
  93.     GUID                    m_guidApp;
  94.     HRESULT                 m_hrDialog;
  95.     HWND                    m_hDlg;
  96.     HINSTANCE               m_hInst;
  97.     HWND                    m_hWndParent;
  98.     DWORD                   m_dwMaxPlayers;
  99.     TCHAR                   m_strAppName[MAX_PATH];
  100.     TCHAR                   m_strPreferredProvider[MAX_PATH];
  101.     TCHAR                   m_strSessionName[MAX_PATH];
  102.     TCHAR                   m_strLocalPlayerName[MAX_PATH];
  103.     BOOL                    m_bSearchingForSessions;
  104.     BOOL                    m_bMigrateHost;
  105.     IDirectPlay8Address*    m_pDeviceAddress;
  106.     IDirectPlay8Address*    m_pHostAddress;
  107.     DPHostEnumInfo          m_DPHostEnumHead;
  108.     BOOL                    m_bEnumListChanged;
  109.     DPNHANDLE               m_hEnumAsyncOp;
  110.     BOOL                    m_bHostPlayer;
  111.     DWORD                   m_dwEnumHostExpireInterval;
  112.     BOOL                    m_bConnecting;
  113.     DPNHANDLE               m_hConnectAsyncOp;
  114.     HANDLE                  m_hConnectCompleteEvent;
  115.     HANDLE                  m_hLobbyConnectionEvent;
  116.     HRESULT                 m_hrConnectComplete;
  117.     BOOL                    m_bHaveConnectionSettingsFromLobby;
  118.     DPNHANDLE                m_hLobbyClient;
  119. };
  120.  
  121.  
  122. #endif // NETCONNECT_H
  123.  
  124.