Difference between the return value of the CDialogBar::HandleInitDialog function in Visual C++ 6.0 and that in Visual C++ .NET or that in Visual C++ 2005 (839297)



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

INTRODUCTION

In Microsoft Visual C++ 6.0, the CDialogBar::HandleInitDialog function returns a TRUE value. In Microsoft Visual C++ .NET 2002, in Microsoft Visual C++ .NET 2003, and in Microsoft Visual C++ 2005, the return value of the CDialogBar::HandleInitDialog function in the bardlg.cpp file that is part of Microsoft Foundation Classes (MFC) class library has been changed to FALSE.

MORE INFORMATION

You can still return a TRUE value if you want. To do this, you must override the HandleInitDialog function of the CDialogBar class in the derived class, and then add your own handler for the WM_INITDIALOG message that returns the TRUE value. Your derived class code must look similar to the following code:
BEGIN_MESSAGE_MAP(CMyDlgBar,CDialogBar)
	ON_MESSAGE(WM_INITDIALOG, HandleInitDialog)
END_MESSAGE_MAP()

LRESULT CMyDlgBar::HandleInitDialog(WPARAM, LPARAM)
{
	Default();  // allow default to initialize first (common dialogs/etc)

	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
	{
		if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName,
			m_pOccDialogInfo))
		{
			TRACE0("Warning: CreateDlgControls failed during dialog bar init.\n");
			return FALSE;
		}
	}
	return TRUE;  <-- this is set to FALSE in VC++ .NET 2002/2003
}

REFERENCES

For additional information about how to override CDialogBar class functions, click the following article number to view the article in the Microsoft Knowledge Base:

185672 HOWTO: How to initialize child controls in a derived CDialogBar


Modification Type:MajorLast Reviewed:1/17/2006
Keywords:kbMFCCtrlBar kbDlg kbcode kbinfo KB839297 kbAudDeveloper