#ifndef __CGRPTREE__
#define __CGRPTREE__
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <dplay.h>
#include <dplobby.h>
#include "resource.h"
//#DEFINES
#define ST_NO_SUBGROUPS0
#define ST_SEARCH_SUBGROUPS1
class CGroupTree;
typedef enum { BT_INVALID = 0,
BT_GROUP,
BT_SHORTCUT_IN_GROUP,
BT_PLAYER_IN_GROUP,
BT_PLAYER,
} BRANCH_TYPE;
typedef struct tagBRANCHSTRUCT
{
DPIDdpid;
BRANCH_TYPEbtType;
DWORDdwFlags;
} BRANCHSTRUCT, *LPBRANCHSTRUCT;
typedef struct tagENUMTREESTRUCT
{
DPIDdpidParent;
CGroupTree *lpTree;
BOOLbRecursive;
} ENUMTREESTRUCT, *LPENUMTREESTRUCT;
class CGroupTree{
private:
HINSTANCEm_hInst;
HWNDm_hwndTreeView;
HWNDm_hwndParent;
HWNDm_hwndEditCtrl;
HIMAGELISTm_hImageList;
intm_nStagingAreaImg;
intm_nGroupImg;
intm_nInGroupImg;
intm_nPlayerImg;
intm_nShortcutInGroupImg;
intm_nSpectatorImg;
intm_nSessionInProgressImg;
BOOLm_fDragging;
BRANCHSTRUCTm_bsParentOfDragging;
BRANCHSTRUCTm_bsDragging;
BRANCHSTRUCTm_bsDropTarget;
HMENUm_hMenu,
m_hRootMenu,
m_hGroupMenu,
m_hPlayerMenu,
m_hShortcutMenu,
m_hPlayerInGroupMenu;
DPIDm_dpidMenuTarget;
DPIDm_dpidPlayer;
DPIDm_dpidLastGroup;
private:
HTREEITEM FindItem( HTREEITEM htiSearchRoot,
DPID dpidTarget,
BRANCH_TYPE bt,
DWORD dwSearch );
HTREEITEM Insert(HTREEITEM htiParent,
DPID dpID,
LPSTR lpShortNameA,
BRANCH_TYPE bt, DWORD dwFlags );
HRESULTRecursiveRename(HTREEITEM htiSearchRoot,
DPID dpidTarget,
LPSTR lpszName );
DPIDGetBranchStructOfParent( HTREEITEM htChildItem, LPBRANCHSTRUCT lpbt);
public:
LPDIRECTPLAY3Am_lpDP3A;
public:
CGroupTree();
~CGroupTree();
BOOLInit( HWND hWnd, LPDIRECTPLAY3A lpDP3A, DPID dpidPlayer );
HRESULT CreateGroup( DPID dpidGroup, LPSTR lpszShortNameA, DWORD dwFlags );
HRESULT CreatePlayer( DPID dpidPlayer, LPSTR lpszShortNameA, DWORD dwFlags );
HRESULT DestroyGroup( DPID dpidGroup );
HRESULT DestroyPlayer( DPID dpidPlayer );
HRESULT CreateGroupInGroup( DPID dpidParentGroup, DPID dpidChildGroup, LPSTR lpszShortNameA, DWORD dwFlags );
HRESULT AddPlayerToGroup(DPID dpidGroup, DPID dpidPlayer, DWORD dwFlags);
HRESULT AddGroupToGroup( DPID dpidParentGroup, DPID dpidShortcut, DWORD dwFlags );
HRESULT DeletePlayerFromGroup(DPID dpidGroup, DPID dpidPlayer );
HRESULT DeleteGroupFromGroup( DPID dpidParentGroup, DPID dpidShortcut );
HRESULT GetPlayerName( DPID dpidPlayerName, LPDPNAME * lplpName );
HRESULT GetGroupName( DPID dpidGroupName, LPDPNAME * lplpName );
DPIDGetDPIDOfCurrentSelection(LPBRANCHSTRUCT lpbt = NULL);
DPIDGetDPIDOfCurrentSelectionParent( LPBRANCHSTRUCT lpbt = NULL);
HRESULTSetPlayerName( DPID dpidPlayer, LPSTR lpszShortName );
HRESULT SetGroupName( DPID dpidPlayer, LPSTR lpszShortName );
HRESULT Refresh( BOOL bRecursive = TRUE );
BOOLUpdate(LPVOID lpvMsg);
voidOnBeginDrag(NM_TREEVIEW *lpnmtv);
voidOnMouseMove( LONG xCur, LONG yCur);
voidOnLButtonUp(void);
voidOnRButtonDown( LONG xCur, LONG yCur);
voidOnDblClk( LONG xCur, LONG yCur);
voidRedraw();
HRESULTBeginLabelEdit();
voidEndLabelEdit(TV_DISPINFO FAR * lpTVDisp );
BOOLOnWM_NOTIFY( WPARAM wParam, LPARAM lParam );
HRESULTEditLabel();
HRESULT CheckAccessRights(TV_DISPINFO FAR * lpTVDisp = NULL);
};
#endif