Click here to Skip to main content
15,895,746 members
Articles / Mobile Apps / Windows Mobile

A Selection Bar for the PocketPC 2002

Rate me:
Please Sign up or sign in to vote.
4.67/5 (13 votes)
12 Mar 2003CPOL2 min read 127.4K   285   27  
An implementation of the selection bars found on PocketPC 2002 applications.
#if !defined(AFX_CESELECTBAR_H__0BAD68EF_E369_45D8_81A9_63786F1DAED9__INCLUDED_)
#define AFX_CESELECTBAR_H__0BAD68EF_E369_45D8_81A9_63786F1DAED9__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// CeSelectBar.h : header file
//


//---------------------------------------------------------------------------
//
//	CCeSelectBar window
//
//---------------------------------------------------------------------------


class CCeSelectBar : public CControlBar
{
	struct MenuRec
	{
		HICON	m_hIcon;		//!< Menu icon. NULL if none
		CString	m_strOption,	//!< Menu title when at rest
				m_strTitle;		//!< Menu title when selected
		CMenu*	m_pMenu;		//!< Menu pointer. NULL if none
		CRect	m_rectAll,		//!< The containing rect
				m_rectArr;		//!< The arrow rect
		int		m_nState;		//!< The menu state
	};

	enum SSMS
	{
		SSMS_REST		= 0,
		SSMS_ARROW_SEL	= 1,
		SSMS_ALL_SEL	= 2,
		SSMS_DRAW_RECT	= 4,
		SSMS_SHOW_MENU	= 8
	};

public:
	CCeSelectBar();

// Attributes
public:

// Operations
public:


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCeSelectBar)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CCeSelectBar();

	BOOL Create(CWnd* pParentWnd, DWORD dwStyle = WS_CHILD|WS_VISIBLE, UINT nID = AFX_IDW_TOOLBAR);

	void SetMenu(int nPos, UINT nStrID, CMenu *pMenu, HICON hIcon = NULL);
	void SetMenu(int nPos, LPCTSTR pszTitle, CMenu *pMenu, HICON hIcon = NULL);
	void SetOption(int nPos, LPCTSTR pszOption, HICON hIcon = NULL);
	void SetOption(int nPos, UINT nStrID, HICON hIcon = NULL);

	void ClearMenu(int nPos);
	void ShowMenu(int nPos);

	virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
	virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
	virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);

protected:
	MenuRec	m_recMenu[2];		//!< Menu description
	CFont	m_fntDefault;		//!< The default font

	void DrawArrow(CDC &dc, int x, BOOL bSelected = FALSE);
	void MenuBtnDn(int nPos, CPoint point);
	void MenuBtnUp(int nPos, CPoint point);
	void CalcArrowRect(CRect &rc, int x);

	// Generated message map functions
	//{{AFX_MSG(CCeSelectBar)
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//---------------------------------------------------------------------------

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CESELECTBAR_H__0BAD68EF_E369_45D8_81A9_63786F1DAED9__INCLUDED_)

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
Software Developer (Senior) Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

Comments and Discussions