///////////////////////////////////////////////////////////////////////////////
// atlspctl.h - Spring Computing Windows Controls Wrapper Classes for ATL/WTL
// Version 1.0
// Maxime Labelle
#ifndef __ATLSPCTL_H__
#define __ATLSPCTL_H__
#pragma once
#ifndef __cplusplus
#error atlspctl requires C++ compilation (use a .cpp suffix)
#endif
#ifndef __ATLAPP_H__
#error atlspctl.h requires atlapp.h to be included first
#endif
#ifndef __ATLWIN_H__
#error atlspctl.h requires atlwin.h to be included first
#endif
#include "SpringCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// Forward declarations
template <class TBase> class CCaptionBarCtrlT;
template <class TBase> class CShortcutCtrlT;
template <class TBase> class CToolBandCtrlT;
/////////////////////////////////////////////////////////////////////////////
// CShortcutCtrl - client side for a Spring Computing CaptionBar Control
template <class TBase>
class CCaptionBarCtrlT : public TBase
{
public:
// Constructors
CCaptionBarCtrlT(HWND hWnd = NULL) : TBase(hWnd) { }
CCaptionBarCtrlT< TBase >& operator=(HWND hWnd)
{
m_hWnd = hWnd;
return *this;
}
HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
DWORD dwStyle = 0, DWORD dwExStyle = 0,
_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
{
return CWindow::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
}
// Attributes
static LPCTSTR GetWndClassName()
{
return CAPTIONBARCLASSNAME;
}
HBITMAP GetBitmap(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (HBITMAP) ::SendMessage(m_hWnd, CBM_GETBITMAP, (WPARAM) 0, (LPARAM) 0);
}
COLORREF GetBkColor(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (HBITMAP) ::SendMessage(m_hWnd, CBM_GETBKCOLOR, (WPARAM) 0, (LPARAM) 0);
}
COLORREF GetTextColor(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (HBITMAP) ::SendMessage(m_hWnd, CBM_GETEXTCOLOR, (WPARAM) 0, (LPARAM) 0);
}
COLORREF GetTransparentColor(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (HBITMAP) ::SendMessage(m_hWnd, CBM_GETTRANSPARENTCOLOR, (WPARAM) 0, (LPARAM) 0);
}
BOOL GetState(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, CBM_GETSTATE, (WPARAM) 0, (LPARAM) 0);
}
HBITMAP SetBitmap(HBITMAP hBitmap)
{
ATLASSERT(::IsWindow(m_hWnd));
return (HBITMAP) ::SendMessage(m_hWnd, CBM_SETBITMAP, (WPARAM) hBitmap, (LPARAM) 0);
}
void SetBkColor(COLORREF rgbBack)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, CBM_SETBKCOLOR, (WPARAM) rgbBack, (LPARAM) 0);
}
void SetTextColor(COLORREF rgbText)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, CBM_SETTEXTCOLOR, (WPARAM) rgbText, (LPARAM) 0);
}
void SetTransparentColor(COLORREF rgbTransparent)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, CBM_SETTRANSPARENTCOLOR, (WPARAM) rgbTransparent, (LPARAM) 0);
}
void SetState(BOOL bPushed = TRUE)
{
ATLASSERT(::IsWindow(m_hWnd));
::SendMessage(m_hWnd, CBM_SETSTATE, (WPARAM) bPushed, (LPARAM) 0);
}
};
typedef CCaptionBarCtrlT<CWindow> CCaptionBarCtrl;
/////////////////////////////////////////////////////////////////////////////
// CShortcutCtrl - client side for a Spring Computing ShortCut Control
template <class TBase>
class CShortcutCtrlT : public TBase
{
public:
// Constructors
CShortcutCtrlT(HWND hWnd = NULL) : TBase(hWnd) { }
CShortcutCtrlT< TBase >& operator=(HWND hWnd)
{
m_hWnd = hWnd;
return *this;
}
HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL,
DWORD dwStyle = 0, DWORD dwExStyle = 0,
_U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
{
return CWindow::Create(GetWndClassName(), hWndParent, rect.m_lpRect, szWindowName, dwStyle, dwExStyle, MenuOrID.m_hMenu, lpCreateParam);
}
// Attributes
static LPCTSTR GetWndClassName()
{
return SHORTCUTCLASSNAME;
}
void SetAnimation(BOOL bAnimate = TRUE)
{
LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
if (bAnimate) dwStyle |= SCS_ANIMATION;
else dwStyle &= ~SCS_ANIMATION;
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
}
BOOL DeletePane(UINT nIndex)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_DELETEPANE, (WPARAM) nIndex, (LPARAM) 0);
}
HWND EditLabel(UINT nIndex)
{
ATLASSERT(::IsWindow(m_hWnd));
return (HWND) ::SendMessage(m_hWnd, SCM_EDITLABEL, (WPARAM) nIndex, (LPARAM) 0);
}
UINT GetCurrentPane(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_GETCURRENTPANE, (WPARAM) 0, (LPARAM) 0);
}
UINT GetPaneCount(void) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_GETPANECOUNT, (WPARAM) 0, (LPARAM) 0);
}
BOOL GetPaneInfo(UINT nIndex, LPSHORTCUTPANEINFO lpspi) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_GETPANEINFO, (WPARAM) nIndex, (LPARAM) lpspi);
}
BOOL GetPaneText(UINT nIndex, LPTSTR szText, int cchTextMax) const
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
paneInfo.mask = SCPIM_TEXT;
paneInfo.pszText = szText;
paneInfo.cchTextMax = cchTextMax;
return GetPaneInfo(nIndex, &paneInfo);
}
HWND GetPaneChild(UINT nIndex) const
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
paneInfo.mask = SCPIM_CHILD;
if (GetPaneInfo(nIndex, &paneInfo)) return paneInfo.hwndChild;
else return 0;
}
UINT HitTest(LPSCHITTESTINFO lpsci) const
{
ATLASSERT(::IsWindow(m_hWnd));
return (UINT) ::SendMessage(m_hWnd, SCM_HITTEST, (WPARAM) 0, (LPARAM) lpsci);
}
BOOL InsertPane(UINT nIndex, LPCSHORTCUTPANEINFO lpscpi)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_INSERTPANE, (WPARAM) nIndex, (LPARAM) lpscpi);
}
BOOL InsertPane(UINT nIndex, LPCTSTR szText, HWND hWndChild, LPARAM lParam = 0)
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
paneInfo.mask = SCPIM_TEXT | SCPIM_CHILD;
paneInfo.pszText = (LPTSTR) szText;
paneInfo.hwndChild = hWndChild;
if (lParam != 0) {
paneInfo.mask |= SCPIM_LPARAM;
paneInfo.lParam = lParam;
}
return InsertPane(nIndex, &paneInfo);
}
BOOL SetCurrentPane(UINT nIndex)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_SETCURRENTPANE, (WPARAM) nIndex, (LPARAM) 0);
}
BOOL SetPaneInfo(UINT nIndex, LPCSHORTCUTPANEINFO lpcspi)
{
ATLASSERT(::IsWindow(m_hWnd));
return (BOOL) ::SendMessage(m_hWnd, SCM_SETPANEINFO, (WPARAM) nIndex, (LPARAM) lpcspi);
}
BOOL SetPaneInfo(UINT nIndex, LPCTSTR szText, HWND hWndChild, LPARAM lParam = 0)
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
paneInfo.mask = SCPIM_TEXT | SCPIM_CHILD;
paneInfo.pszText = (LPTSTR) szText;
if (lParam != 0) {
paneInfo.mask |= SCPIM_LPARAM;
paneInfo.lParam = lParam;
}
paneInfo.hwndChild = hWndChild;
return SetPaneInfo(nIndex, &paneInfo);
}
BOOL SetPaneText(UINT nIndex, LPCTSTR szText)
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
if (GetPaneInfo(nIndex, &paneInfo)) {
paneInfo.mask = SCPIM_TEXT;
paneInfo.pszText = (LPTSTR) szText;
return SetPaneInfo(nIndex, &paneInfo);
}
return FALSE;
}
BOOL SetPaneChild(UINT nIndex, HWND hWndChild)
{
SHORTCUTPANEINFO paneInfo;
paneInfo.cbSize = sizeof(paneInfo);
if (GetPaneInfo(nIndex, &paneInfo)) {
paneInfo.mask = SCPIM_CHILD;
paneInfo.hwndChild = hWndChild;
return SetPaneInfo(nIndex, &paneInfo);
}
return FALSE;
}
};
typedef CShortcutCtrlT<CWindow> CShortcutCtrl;
#endif // __ATLSPCTL_H__