#if !defined(__CECmdBar_h__) && defined(_WIN32_WCE)
#define __CECmdBar_h__
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <commctrl.h>
#include "CeWnd.h"
#include "CeMisc.h"
class CeCmdBar: public CeBaseWnd
{
private:
friend class CeCmdBand;
public:
CeCmdBar()
{}
virtual ~CeCmdBar()
{}
BOOL Create(HWND hwndParent, int idCmdBar)
{ CHW_ASSERT(::IsWindow(hwndParent));
m_hWnd = CommandBar_Create(CeGetAppInstance(), hwndParent, idCmdBar);
#ifdef _DEBUG
if (m_hWnd == NULL && ERROR_CANNOT_FIND_WND_CLASS == GetLastError())
{
::MessageBox(NULL, _T("You need to register the commandbar class before using it."),
_T("CeCmdBar"), MB_OK);
}
#endif
return m_hWnd != NULL; }
BOOL Show(BOOL fShow)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_Show(m_hWnd, fShow); }
int AddBitmap(int idBitmap, int iNumImages, int iImageWidth, int iImageHeight)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBar_AddBitmap(m_hWnd, CeGetAppInstance(), idBitmap, iNumImages, iImageWidth, iImageHeight); }
int AddStdBitmap(int idBitmap)
{ CHW_ASSERT(::IsWindow(m_hWnd));
// return CommandBar_AddBitmap(m_hWnd, HINST_COMMCTRL, idBitmap, 0, 16, 16); }
return CommandBar_AddBitmap(m_hWnd, HINST_COMMCTRL, idBitmap, 15, 0, 0); }
int AddBitmap(HBITMAP hBitmap, int iNumImages, int iImageWidth, int iImageHeight)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBar_AddBitmap(m_hWnd, NULL, (int) hBitmap, iNumImages, iImageWidth, iImageHeight); }
HWND InsertComboBox(int iWidth, UINT dwStyle, WORD idComboBox, WORD iButton)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBar_InsertComboBox(m_hWnd, CeGetAppInstance(), iWidth, dwStyle, idComboBox, iButton); }
BOOL InsertMenubar(WORD idMenu, WORD iButton)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBar_InsertMenubar(m_hWnd, CeGetAppInstance(), idMenu, iButton); }
BOOL InsertMenubarEx(LPTSTR pszMenu, WORD iButton)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_InsertMenubarEx(m_hWnd, CeGetAppInstance(), pszMenu, iButton); }
BOOL DrawMenuBar(HWND hwndCB, WORD iButton)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_DrawMenuBar(m_hWnd, iButton); }
HMENU GetMenu(WORD iButton) const
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_GetMenu(m_hWnd, iButton); }
BOOL AddAdornments(DWORD dwFlags)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_AddAdornments(m_hWnd, dwFlags, 0); }
int GetHeight() const
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_Height(m_hWnd); }
BOOL IsCommandBarMessage(LPMSG lpMsg)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return ::IsCommandBarMessage(m_hWnd, lpMsg); }
BOOL Destroy()
{ CHW_ASSERT(::IsWindow(m_hWnd)); return DestroyWindow(); }
BOOL IsVisible() const
{ CHW_ASSERT(::IsWindow(m_hWnd)); return ::IsWindowVisible(m_hWnd); }
BOOL AddButtons(UINT uNumButtons, PTBBUTTON lpButtons)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_AddButtons(m_hWnd, uNumButtons, lpButtons); }
BOOL InsertButton(HWND hwndCB, int iButton, PTBBUTTON lpButton)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_InsertButton(m_hWnd, iButton, lpButton); }
BOOL AddToolTips(UINT uNumToolTips, LPTSTR lpToolTips)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBar_AddToolTips(m_hWnd, uNumToolTips, lpToolTips); }
};
class CeCmdBand: public CeBaseWnd
{
private:
CeCmdBar* m_pBars;
public:
CeCmdBand()
{ m_pBars = NULL; }
BOOL Create(HWND hwndParent, UINT wID, DWORD dwStyles, HIMAGELIST himl)
{ CHW_ASSERT(::IsWindow(hwndParent) && !::IsWindow(m_hWnd));
m_hWnd = CommandBands_Create(CeGetAppInstance(), hwndParent, wID, dwStyles, himl);
#ifdef _DEBUG
if (m_hWnd == NULL && ERROR_CANNOT_FIND_WND_CLASS == GetLastError())
{
::MessageBox(NULL, _T("You need to register the commandband class before using it."),
_T("CeCmdBand"), MB_OK);
}
#endif
return m_hWnd != NULL; }
BOOL AddBands(UINT cBands, LPREBARBANDINFO prbbi)
{ CHW_ASSERT(::IsWindow(m_hWnd));
BOOL bRet = CommandBands_AddBands(m_hWnd, CeGetAppInstance(), cBands, prbbi);
if (bRet)
{
m_pBars = new CeCmdBar[cBands];
for (UINT ii = 0; ii < cBands; ii++)
m_pBars[ii].Attach( CommandBands_GetCommandBar(m_hWnd, ii));
}
return bRet;
}
CeCmdBar& GetCommandBar(UINT uBand)
{ CHW_ASSERT(::IsWindow(m_hWnd) && m_pBars); return m_pBars[uBand]; }
BOOL AddAdornments(DWORD dwFlags, LPREBARBANDINFO prbbi=NULL)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBands_AddAdornments(m_hWnd, CeGetAppInstance(), dwFlags, prbbi); }
BOOL Show(BOOL fShow)
{ CHW_ASSERT(::IsWindow(m_hWnd)); return CommandBands_Show(m_hWnd, fShow); }
BOOL GetRestoreInformation(UINT uBand, LPCOMMANDBANDSRESTOREINFO pcbri)
{ CHW_ASSERT(::IsWindow(m_hWnd));
return CommandBands_GetRestoreInformation(m_hWnd, uBand, pcbri); }
UINT Height()
{ return (!m_hWnd) ? 0: (UINT) SendMessage(RB_GETBARHEIGHT); };
};
#endif // __CECmdBar_h__