Click here to Skip to main content
15,891,951 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 280.8K   998   70  
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.
#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__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions