Click here to Skip to main content
15,884,177 members
Articles / Mobile Apps / Windows Mobile

CCeListCtrlEx for Pocket PC 2002

Rate me:
Please Sign up or sign in to vote.
4.71/5 (7 votes)
14 May 2003CPOL2 min read 132.4K   710   38  
A owner drawn list control to emulate a single select list box with a little icon at the beginning of each line.
// NewItemDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "NewItemDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CNewItemDlg dialog

CNewItemDlg::CNewItemDlg(int nMaxImage, CWnd* pParent /*=NULL*/)
	: CDialog(CNewItemDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNewItemDlg)
	m_strCaption = _T("New Item");
	m_nImage = 0;
	//}}AFX_DATA_INIT

    ASSERT(nMaxImage >= 0);
    m_nMaxImage = nMaxImage;

    m_bFullScreen = FALSE;
}

void CNewItemDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNewItemDlg)
	DDX_Text(pDX, IDC_CAPTION, m_strCaption);
	DDX_Text(pDX, IDC_IMAGE, m_nImage);
    //}}AFX_DATA_MAP

    DDV_MinMaxInt(pDX, m_nImage, 0, m_nMaxImage);
}

BEGIN_MESSAGE_MAP(CNewItemDlg, CDialog)
	//{{AFX_MSG_MAP(CNewItemDlg)
	ON_WM_CTLCOLOR()
    ON_WM_LBUTTONDOWN()
    ON_NOTIFY_REFLECT(NM_RECOGNIZEGESTURE, OnRecognizeGesture)
	ON_WM_ACTIVATE()
	ON_WM_SETTINGCHANGE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNewItemDlg message handlers

BOOL CNewItemDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

    ASSERT(::IsWindow(::GetDlgItem(m_hWnd, IDC_SPIN1)));
    ((CSpinButtonCtrl*) GetDlgItem(IDC_SPIN1))->SetRange(0, m_nMaxImage);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

HBRUSH CNewItemDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO: Change any attributes of the DC here

	// TODO: Return a different brush if the default is not desired

    if (nCtlColor == CTLCOLOR_STATIC)
    {
        pDC->SetBkMode(TRANSPARENT);

        hbr = CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
    }
    else if (pWnd == this)
    {
        hbr = CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
    }

	return hbr;
}

void CNewItemDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
	CWnd::OnActivate(nState, pWndOther, bMinimized);
}

void CNewItemDlg::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
	CWnd::OnSettingChange(uFlags, lpszSection);
}

void CNewItemDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
    Default(); // call default message handler
}

void CNewItemDlg::OnRecognizeGesture(NMHDR* pNMHDR, LRESULT* pResult)
{
    *pResult = TRUE; // cancel the red dot animation
}

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
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions