www.pudn.com > ExpBar_src.zip > ExpBarXP.cpp


/* 
 * file           : ExpBarXP.cpp 
 * language       : Visual C++ (6+) 
 * plattform      : Win32 (Windows 98/Me/NT/2000/XP) 
 * description    : implements a MFC wrapper for the xp-style explorer bar 
 *                  (explorerbar.dll) 
 * dependencies   : 1.) this source depends on sizecbar.cpp, scbarg.cpp and scbarcf.cpp 
 *                      (sizeable control bar by Cristi Posea http://www.datamekanix.com 
 *                       or http://www.codeproject.com/docking/sizecbar.asp) 
 *                  2.) explorerbar[D|U|UD].dll by Ingo A. Kubbilun 
 * 
 * revision history: 
 * ================= 
 * 
 * date:       author:           description: 
 * -------------------------------------------------------------------------- 
 * 02/17/2004  Ingo A. Kubbilun  first published version 1.0 
 */ 
 
#include "stdafx.h" 
#include "explorerbar.h" 
#include "ExpBarXP.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CExpBarXP 
 
CExpBarXP::CExpBarXP() : m_hwndExpBar(NULL) 
{ 
  m_szMinHorz   = CSize(100, 100); 
  m_szMinVert   = CSize(100, 100); 
  m_szMinFloat  = CSize(100, 100); 
  m_szHorz      = CSize(320, 320); 
  m_szVert      = CSize(320, 320); 
  m_szFloat     = CSize(320, 540); 
} 
 
CExpBarXP::~CExpBarXP() 
{ 
} 
 
BEGIN_MESSAGE_MAP(CExpBarXP, _baseclassExpBarXP) 
	//{{AFX_MSG_MAP(CExpBarXP) 
	ON_WM_CREATE() 
	ON_WM_DESTROY() 
	ON_WM_SIZE() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// message handler CExpBarXP  
 
int CExpBarXP::OnCreate(LPCREATESTRUCT lpCreateStruct)  
{ 
	if (_baseclassExpBarXP::OnCreate(lpCreateStruct) == -1) 
		return -1; 
 
  m_hwndExpBar = CreateColXPBar(GetSafeHwnd(),0L,0L,0,0,0,0); 
 
  if (!IsWindow(m_hwndExpBar)) return -1; 
	 
	return 0; 
} 
 
void CExpBarXP::OnDestroy()  
{ 
  if (IsWindow(m_hwndExpBar)) 
    DestroyColXPBar(m_hwndExpBar); 
 
  m_hwndExpBar = NULL; 
	 
  _baseclassExpBarXP::OnDestroy(); 
} 
 
BOOL CExpBarXP::Create ( LPCTSTR lpszWindowName, CWnd* pParentWnd, 
                         UINT nID, DWORD dwStyle ) 
{ 
  return _baseclassExpBarXP::Create(lpszWindowName,pParentWnd,nID, 
         dwStyle|WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS); 
} 
 
void CExpBarXP::OnSize(UINT nType, int cx, int cy)  
{ 
	_baseclassExpBarXP::OnSize(nType, cx, cy); 
 
  if (IsWindow(m_hwndExpBar)) 
  { 
    ::SetWindowPos(m_hwndExpBar,HWND_TOP, 
                   0,0,cx,cy, 
                   SWP_NOACTIVATE|/*SWP_NOOWNERZORDER|*/SWP_NOSENDCHANGING); 
  } 
} 
 
BOOL CExpBarXP::AddPane ( UINT       uPaneId, 
                          LPCTSTR    lpcszHeaderTitle, 
                          UINT       uHeaderStyle, 
                          LPCTSTR    lpcszDlgTemplate, 
                          CWnd      *pCWndMsg, 
                          int        iIndex ) 
{ 
  return AddPane(uPaneId,lpcszHeaderTitle,uHeaderStyle,lpcszDlgTemplate,pCWndMsg, 
                 (HIMAGELIST)NULL,0,iIndex); 
} 
 
BOOL CExpBarXP::AddPane ( UINT         uPaneId, 
                          LPCTSTR      lpcszHeaderTitle, 
                          UINT         uHeaderStyle, 
                          LPCTSTR      lpcszDlgTemplate, 
                          CWnd        *pCWndMsg, 
                          CImageList  *pImgList, 
                          int          iIconIdx, 
                          int          iIndex ) 
{ 
  PANEDEF   PD; 
 
  if ((!IsWindow(m_hwndExpBar)) || (!pCWndMsg)) return FALSE; 
 
  memset(&PD,0,sizeof(PANEDEF)); 
  PD.cbSize           = sizeof(PANEDEF); 
  PD.uPaneId          = uPaneId; 
  PD.hInstance        = AfxGetApp()->m_hInstance; 
  PD.lpcszDlgTemplate = lpcszDlgTemplate; 
  PD.hwndMsg          = pCWndMsg->GetSafeHwnd(); 
  PD.uHeaderStyle     = uHeaderStyle; 
  PD.lpcszHeaderTitle = lpcszHeaderTitle ? lpcszHeaderTitle : _T(""); 
 
  if (pImgList) 
  { 
    PD.hPaneIcon    = pImgList->GetSafeHandle(); 
    PD.iPaneIconIdx = iIconIdx; 
  } 
 
  return (BOOL)::SendMessage(m_hwndExpBar,CBM_ADDPANE,(WPARAM)iIndex,(LPARAM)&PD); 
} 
 
BOOL CExpBarXP::AddPane ( UINT         uPaneId, 
                          LPCTSTR      lpcszHeaderTitle, 
                          UINT         uHeaderStyle, 
                          LPCTSTR      lpcszDlgTemplate, 
                          CWnd        *pCWndMsg, 
                          HIMAGELIST   hImgList, 
                          int          iIconIdx, 
                          int          iIndex ) 
{ 
  PANEDEF   PD; 
 
  if ((!IsWindow(m_hwndExpBar)) || (!pCWndMsg)) return FALSE; 
 
  memset(&PD,0,sizeof(PANEDEF)); 
  PD.cbSize           = sizeof(PANEDEF); 
  PD.uPaneId          = uPaneId; 
  PD.hInstance        = AfxGetApp()->m_hInstance; 
  PD.lpcszDlgTemplate = lpcszDlgTemplate; 
  PD.hwndMsg          = pCWndMsg->GetSafeHwnd(); 
  PD.uHeaderStyle     = uHeaderStyle; 
  PD.lpcszHeaderTitle = lpcszHeaderTitle ? lpcszHeaderTitle : _T(""); 
  PD.hPaneIcon        = hImgList; 
  PD.iPaneIconIdx     = iIconIdx; 
 
  return (BOOL)::SendMessage(m_hwndExpBar,CBM_ADDPANE,(WPARAM)iIndex,(LPARAM)&PD); 
} 
 
BOOL CExpBarXP::DelPane ( UINT uPaneId ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return FALSE; 
  else 
    return (BOOL)::SendMessage(m_hwndExpBar,CBM_DELPANEBYID,(WPARAM)uPaneId,0L); 
} 
 
BOOL CExpBarXP::ExpandPane ( UINT uPaneId, UINT uAnimate ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return FALSE; 
  else 
    return (BOOL)::SendMessage(m_hwndExpBar,CBM_EXPANDPANEBYID,(WPARAM)uPaneId,(LPARAM)uAnimate); 
} 
 
BOOL CExpBarXP::CollapsePane ( UINT uPaneId, UINT uAnimate ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return FALSE; 
  else 
    return (BOOL)::SendMessage(m_hwndExpBar,CBM_COLLAPSEPANEBYID,(WPARAM)uPaneId,(LPARAM)uAnimate); 
} 
 
BOOL CExpBarXP::ScrollPaneVisible ( UINT uPaneId ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return FALSE; 
  else 
    return (BOOL)::SendMessage(m_hwndExpBar,CBM_SCROLLVISIBLEBYID,(WPARAM)uPaneId,0L); 
} 
 
HWND CExpBarXP::GetPaneHeaderWindow ( UINT uPaneId ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return NULL; 
  else 
    return (HWND)::SendMessage(m_hwndExpBar,CBM_GETPANEHEADERBYID,(WPARAM)uPaneId,0L); 
} 
 
HWND CExpBarXP::GetPaneDialogWindow ( UINT uPaneId ) 
{ 
  if (!IsWindow(m_hwndExpBar))  
    return NULL; 
  else 
    return (HWND)::SendMessage(m_hwndExpBar,CBM_GETPANEDIALOGBYID,(WPARAM)uPaneId,0L); 
}