Click here to Skip to main content
15,896,269 members
Articles / Desktop Programming / MFC

Using Custom Controls in a Dialog Bar

Rate me:
Please Sign up or sign in to vote.
4.81/5 (25 votes)
9 Nov 20077 min read 214.5K   5.4K   94  
How to implement owner drawn or subclassed controls in a Dialog Bar
// MyDlgBar.cpp : implementation file
//

#include "stdafx.h"
#include "DerivedDB.h"
#include "MyDlgBar.h"

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

int check=1;
/////////////////////////////////////////////////////////////////////////////
// CMyDlgBar dialog


CMyDlgBar::CMyDlgBar()
{
	//{{AFX_DATA_INIT(CMyDlgBar)
	//}}AFX_DATA_INIT
}


void CMyDlgBar::DoDataExchange(CDataExchange* pDX)
{
	CDialogBar::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDlgBar)
	DDX_Control(pDX, IDC_BUTTON_BITMAP, m_bmButton);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyDlgBar, CDialogBar)
	//{{AFX_MSG_MAP(CMyDlgBar)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_INITDIALOG, OnInitDialog )
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlgBar message handlers

LONG CMyDlgBar::OnInitDialog ( UINT wParam, LONG lParam)
{

            BOOL bRet = HandleInitDialog(wParam, lParam);

            if (!UpdateData(FALSE))
            {
               TRACE0("Warning: UpdateData failed during dialog init.\n");
            }

            return bRet;

}


BOOL CMyDlgBar::Create(CWnd* pParent, UINT nIDTemplate, UINT nStyle, UINT nID) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	BOOL bReturn = CDialogBar::Create(pParent, nIDTemplate, nStyle, nID);

	if(bReturn)
	{
		m_bmButton.AutoLoad(IDC_BUTTON_BITMAP, this);
		m_subButton.SubclassDlgItem(IDC_DBSUB_BUTTON, this);
	}

	return bReturn;
}


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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
I have no biography, but then, I don't have an obituary yet either -- Thank God!!

Comments and Discussions