Click here to Skip to main content
15,881,898 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 278.1K   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.
#ifndef __CeTab_h__
#define __CeTab_h__

#include <commctrl.h>

#include "CeWnd.h"
#include "CeDialog.h"
#include "CeMisc.h"
#include "CeArray.h"

///////////////////////////////////////////////////////////////////////////////
//
// Wrapper around a dialog imbedded in a tab control
//
class CeTabPage: public CeScrollDialog
{
private:
	WCHAR m_szPage[32];

public:
	CeTabPage(UINT nDlgID = 0, LPCTSTR lpszLabel = NULL):
		CeScrollDialog(nDlgID)
		{
			if (lpszLabel)
				_tcsncpy(m_szPage, lpszLabel, 32);
			else
				*m_szPage = 0;
		}

	virtual ~CeTabPage()
		{}

	// need to be available BEFORE the dialog is created, used to create it
	// and it's tab
	virtual LPCTSTR GetTabTitle()
		{ return m_szPage; }
	virtual LPCTSTR GetID()
		{ return m_lpTemplateName; }

	virtual BOOL OnSetActive()
		{ return TRUE; }
	virtual BOOL OnKillActive()
		{ return TRUE; }
	virtual void OnApply()
		{ }
	virtual void OnReset()
		{ }
};


///////////////////////////////////////////////////////////////////////////////
//
// Wrapper around a Tab Control
//
class CeTabCtrl: public CeWnd
{
// Constructors
public:
	CeTabCtrl();
	virtual BOOL Create(DWORD dwStyle, const RECT& rect, HWND hWndParent, UINT nID, HINSTANCE hInst);

// Attributes
	int GetItemCount() const;
	BOOL GetItem(int nItem, TCITEM* pTabCtrlItem) const;
	BOOL SetItem(int nItem, TCITEM* pTabCtrlItem);
	BOOL SetItemExtra(int nBytes);
	BOOL GetItemRect(int nItem, LPRECT lpRect) const;
	int GetCurSel() const;
	int SetCurSel(int nItem);
	void SetCurFocus(int nItem);
	//CeSize SetItemSize(CeSize size);
	void SetPadding(const SIZE& size);
	int GetRowCount() const;
	int GetCurFocus() const;
	int SetMinTabWidth(int cx);
	DWORD GetExtendedStyle();
	DWORD SetExtendedStyle(DWORD dwNewStyle, DWORD dwExMask = 0);
	DWORD GetItemState(int nItem, DWORD dwMask) const;
	BOOL SetItemState(int nItem, DWORD dwMask, DWORD dwState);

// Operations
	BOOL InsertItem(int nItem, TCITEM* pTabCtrlItem);
	BOOL InsertItem(int nItem, LPCTSTR lpszItem);
	BOOL InsertItem(int nItem, LPCTSTR lpszItem, int nImage);
	BOOL InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem,
		int nImage, LPARAM lParam);
	BOOL InsertItem(UINT nMask, int nItem, LPCTSTR lpszItem,
		int nImage, LPARAM lParam, DWORD dwState, DWORD dwStateMask);
	BOOL DeleteItem(int nItem);
	BOOL DeleteAllItems();
	void AdjustRect(BOOL bLarger, LPRECT lpRect);
	void RemoveImage(int nImage);
	int HitTest(TCHITTESTINFO* pHitTestInfo) const;
	void DeselectAll(BOOL fExcludeFocus);
	BOOL HighlightItem(int idItem, BOOL fHighlight = TRUE);

	HIMAGELIST SetImageList(HIMAGELIST hImageList);
	HIMAGELIST GetImageList() const;

// Implementation
public:
	virtual ~CeTabCtrl();
protected:
//	virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
//	virtual void OnDestroy();
};

#include "CeTab.inl"

/////////////////////////////////////////////////////////////////////////////
// CeTabSheet window
//
// A control reponsible for creating, holding and displaying embedded
// tab pages (dialogs).  The pages will be sized with the control
// so that the control can be embedded in any application window
// and not worry about it's children
//

class CeTabSheet : public CeWnd
{
private:
	void FindSizeOfTabWindow(HWND hWndPage, LPRECT pRect);
	int FindPage(CeTabPage *pPage) const;

	HINSTANCE m_hInst;
	CeTabCtrl m_tabCtrl;
	CeArray<CeTabPage*> m_arPages;
	int m_nActivePage;
	DWORD m_dwTabStyle;

// Construction
public:
	CeTabSheet();
	virtual BOOL Create(DWORD dwStyle, const RECT& rect, HWND hWndParent, UINT nID, HINSTANCE hInst = NULL);

// Attributes
public:
	int GetPageIndex(CeTabPage* pPage) const { return FindPage(pPage); }
	int GetPageCount() const { return m_arPages.GetSize(); }
	CeTabPage* GetPage(int nPage) const { return (nPage < 0) ? NULL: (CeTabPage*)m_arPages[nPage]; }
	int GetActiveIndex() const { return m_nActivePage; }
	CeTabPage* GetActivePage() const { return GetPage(m_nActivePage); }
    void GetPageRect(LPRECT rectWnd);

// Operations
public:
	BOOL SetActivePage(int nPage);
	BOOL SetActivePage(CeTabPage* pPage);
//	BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
	void AddPage(CeTabPage* pPage, int nBitmap=-1); 
	void RemovePage(CeTabPage* Page);
	void RemovePage(int nPage);
	
	void Apply();
	void Reset();

	void RemoveImage(int nImage)
		{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); m_tabCtrl.RemoveImage(nImage); }
	HIMAGELIST SetImageList(HIMAGELIST hImageList)
		{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); return m_tabCtrl.SetImageList(hImageList); }
	HIMAGELIST GetImageList() const
		{ ASSERT(::IsWindow(m_tabCtrl.m_hWnd)); return m_tabCtrl.GetImageList(); }

// Overrides
	virtual LRESULT OnNotifyTabChanged();
	virtual LRESULT OnNotifyTabChanging();

// Implementation
public:
	virtual ~CeTabSheet();

protected:
	virtual int OnCreate( LPCREATESTRUCT lpCS, bool& bHandled ); 
	virtual void OnPaint( bool& bHandled );
	virtual void OnSize( UINT nType, int cx, int cy, bool& bHandled );
	virtual LRESULT OnNotify(int nCtrlId, LPNMHDR pNMH, bool& bHandled);
	virtual LRESULT OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
};


#endif // __CeTab_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