Click here to Skip to main content
15,896,207 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 282.7K   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 __CeCombo_h__
#define __CeCombo_h__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "CeWnd.h"

class CeCombo : public CeWnd
{
// Constructors
public:
	CeCombo();
	BOOL Create(LPCTSTR lpszText, DWORD dwStyle, DWORD dwExStyle, const RECT& rect, HWND hParentWnd, UINT nID, HINSTANCE hInst=NULL);

// Attributes
	// for entire combo box
	int GetCount() const;
	int GetCurSel() const;
	int SetCurSel(int nSelect);
	LCID GetLocale() const;
	LCID SetLocale(LCID nNewLocale);
// Win4
	int GetTopIndex() const;
	int SetTopIndex(int nIndex);
	int InitStorage(int nItems, UINT nBytes);
	void SetHorizontalExtent(UINT nExtent);
	UINT GetHorizontalExtent() const;
	int SetDroppedWidth(UINT nWidth);
	int GetDroppedWidth() const;

	// for edit control
	DWORD GetEditSel() const;
	BOOL LimitText(int nMaxChars);
	BOOL SetEditSel(int nStartChar, int nEndChar);

	// for combobox item
	DWORD GetItemData(int nIndex) const;
	int SetItemData(int nIndex, DWORD dwItemData);
	void* GetItemDataPtr(int nIndex) const;
	int SetItemDataPtr(int nIndex, void* pData);
	int GetLBText(int nIndex, LPTSTR lpszText) const;
	int GetLBTextLen(int nIndex) const;

	int SetItemHeight(int nIndex, UINT cyItemHeight);
	int GetItemHeight(int nIndex) const;
	int FindStringExact(int nIndexStart, LPCTSTR lpszFind) const;
	int SetExtendedUI(BOOL bExtended = TRUE);
	BOOL GetExtendedUI() const;
	void GetDroppedControlRect(LPRECT lprect) const;
	BOOL GetDroppedState() const;

// Operations
	// for drop-down combo boxes
	void ShowDropDown(BOOL bShowIt = TRUE);

	// manipulating listbox items
	int AddString(LPCTSTR lpszString);
	int DeleteString(UINT nIndex);
	int InsertString(int nIndex, LPCTSTR lpszString);
	void ResetContent();
	int Dir(UINT attr, LPCTSTR lpszWildCard);

	// selection helpers
	int FindString(int nStartAfter, LPCTSTR lpszString) const;
	int SelectString(int nStartAfter, LPCTSTR lpszString);

	// Clipboard operations
	void Clear();
	void Copy();
	void Cut();
	void Paste();

// Overridables (must override draw, measure and compare for owner draw)
//	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
//	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
//	virtual int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct);
//	virtual void DeleteItem(LPDELETEITEMSTRUCT lpDeleteItemStruct);

// Implementation
public:
	virtual ~CeCombo();

protected:
//	virtual BOOL OnChildNotify(UINT, WPARAM, LPARAM, LRESULT*);
};


inline CeCombo::CeCombo()
	{ }
inline CeCombo::~CeCombo()
	{ }

inline BOOL CeCombo::Create(LPCTSTR lpszText, DWORD dwStyle, DWORD dwExStyle, const RECT& rect, HWND hParentWnd, UINT nID, HINSTANCE hInst)
	{ return CeWnd::Create(_T("COMBOBOX"), hParentWnd, rect, lpszText, dwStyle, dwExStyle, nID, hInst); }

inline int CeCombo::GetCount() const
	{ return (int) ((CeCombo*)this)->SendMessage(CB_GETCOUNT, 0, 0); }
inline int CeCombo::GetCurSel() const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETCURSEL, 0, 0); }
inline int CeCombo::SetCurSel(int nSelect)
	{ return (int)SendMessage(CB_SETCURSEL, nSelect, 0); }
inline DWORD CeCombo::GetEditSel() const
	{ return ((CeCombo*)this)->SendMessage(CB_GETEDITSEL, 0, 0); }
inline BOOL CeCombo::LimitText(int nMaxChars)
	{ return (BOOL)SendMessage(CB_LIMITTEXT, nMaxChars, 0); }
inline BOOL CeCombo::SetEditSel(int nStartChar, int nEndChar)
	{ return (BOOL)SendMessage(CB_SETEDITSEL, 0, MAKELONG(nStartChar, nEndChar)); }
inline DWORD CeCombo::GetItemData(int nIndex) const
	{ return ((CeCombo*)this)->SendMessage(CB_GETITEMDATA, nIndex, 0); }
inline int CeCombo::SetItemData(int nIndex, DWORD dwItemData)
	{ return (int)SendMessage(CB_SETITEMDATA, nIndex, (LPARAM)dwItemData); }
inline void* CeCombo::GetItemDataPtr(int nIndex) const
	{ return (LPVOID)GetItemData(nIndex); }
inline int CeCombo::SetItemDataPtr(int nIndex, void* pData)
	{ return SetItemData(nIndex, (DWORD)(LPVOID)pData); }
inline int CeCombo::GetLBText(int nIndex, LPTSTR lpszText) const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETLBTEXT, nIndex, (LPARAM)lpszText); }
inline int CeCombo::GetLBTextLen(int nIndex) const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETLBTEXTLEN, nIndex, 0); }
inline void CeCombo::ShowDropDown(BOOL bShowIt)
	{ SendMessage(CB_SHOWDROPDOWN, bShowIt, 0); }
inline int CeCombo::AddString(LPCTSTR lpszString)
	{ return (int)SendMessage(CB_ADDSTRING, 0, (LPARAM)lpszString); }
inline int CeCombo::DeleteString(UINT nIndex)
	{ return (int)SendMessage(CB_DELETESTRING, nIndex, 0);}
inline int CeCombo::InsertString(int nIndex, LPCTSTR lpszString)
	{ return (int)SendMessage(CB_INSERTSTRING, nIndex, (LPARAM)lpszString); }
inline void CeCombo::ResetContent()
	{ SendMessage(CB_RESETCONTENT, 0, 0); }
inline int CeCombo::FindString(int nStartAfter, LPCTSTR lpszString) const
	{ return (int)((CeCombo*)this)->SendMessage(CB_FINDSTRING, nStartAfter,	(LPARAM)lpszString); }
inline int CeCombo::SelectString(int nStartAfter, LPCTSTR lpszString)
	{ return (int)SendMessage(CB_SELECTSTRING, nStartAfter, (LPARAM)lpszString); }
inline void CeCombo::Clear()
	{ SendMessage(WM_CLEAR, 0, 0); }
inline void CeCombo::Copy()
	{ SendMessage(WM_COPY, 0, 0); }
inline void CeCombo::Cut()
	{ SendMessage(WM_CUT, 0, 0); }
inline void CeCombo::Paste()
	{ SendMessage(WM_PASTE, 0, 0); }
inline int CeCombo::SetItemHeight(int nIndex, UINT cyItemHeight)
	{ return (int)SendMessage(CB_SETITEMHEIGHT, nIndex, MAKELONG(cyItemHeight, 0)); }
inline int CeCombo::GetItemHeight(int nIndex) const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETITEMHEIGHT, nIndex, 0L); }
inline int CeCombo::FindStringExact(int nIndexStart, LPCTSTR lpszFind) const
	{ return (int)((CeCombo*)this)->SendMessage(CB_FINDSTRINGEXACT, nIndexStart, (LPARAM)lpszFind); }
inline int CeCombo::SetExtendedUI(BOOL bExtended )
	{ return (int)SendMessage(CB_SETEXTENDEDUI, bExtended, 0L); }
inline BOOL CeCombo::GetExtendedUI() const
	{ return (BOOL)((CeCombo*)this)->SendMessage(CB_GETEXTENDEDUI, 0, 0L); }
inline void CeCombo::GetDroppedControlRect(LPRECT lprect) const
	{ ((CeCombo*)this)->SendMessage(CB_GETDROPPEDCONTROLRECT, 0, (DWORD)lprect); }
inline BOOL CeCombo::GetDroppedState() const
	{ return (BOOL)((CeCombo*)this)->SendMessage(CB_GETDROPPEDSTATE, 0, 0L); }
inline LCID CeCombo::GetLocale() const
	{ return (LCID)((CeCombo*)this)->SendMessage(CB_GETLOCALE, 0, 0); }
inline LCID CeCombo::SetLocale(LCID nNewLocale)
	{ return (LCID)SendMessage(CB_SETLOCALE, (WPARAM)nNewLocale, 0); }

#ifndef _WIN32_WCE
inline int CeCombo::Dir(UINT attr, LPCTSTR lpszWildCard)
	{ return (int)SendMessage(CB_DIR, attr, (LPARAM)lpszWildCard); }
#endif

#if (WINVER >= 0x400)
inline int CeCombo::GetTopIndex() const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETTOPINDEX, 0, 0); }
inline int CeCombo::SetTopIndex(int nIndex)
	{ return (int)SendMessage(CB_SETTOPINDEX, nIndex, 0); }
inline int CeCombo::InitStorage(int nItems, UINT nBytes)
	{ return (int)SendMessage(CB_INITSTORAGE, (WPARAM)nItems, nBytes); }
inline void CeCombo::SetHorizontalExtent(UINT nExtent)
	{ SendMessage(CB_SETHORIZONTALEXTENT, nExtent, 0); }
inline UINT CeCombo::GetHorizontalExtent() const
	{ return (UINT)((CeCombo*)this)->SendMessage(CB_GETHORIZONTALEXTENT, 0, 0); }
inline int CeCombo::SetDroppedWidth(UINT nWidth)
	{ return (int)SendMessage(CB_SETDROPPEDWIDTH, nWidth, 0); }
inline int CeCombo::GetDroppedWidth() const
	{ return (int)((CeCombo*)this)->SendMessage(CB_GETDROPPEDWIDTH, 0, 0); }
#endif


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