Click here to Skip to main content
15,889,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am migrating VS2008 to VS2012 in VC++. I having a subclassing of CFileDialog (Custom FileDialog).

When i invoke CFileDialog the custom file dialog must show Edit Contol in CFileDialog. But
when i am acessing the Edit Control Pointer in Custom CFile Dialog i am getting NULL Handle
for Edit Control.

My Code.
--------

CFileDialogEX.h File
--------------------

C++
class CFileDialogEX : public CFileDialog
{
	DECLARE_DYNAMIC(CFileDialogEX)

public:
	CFileDialogEX(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
		LPCTSTR lpszDefExt = NULL,
		LPCTSTR lpszFileName = NULL,
		DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		LPCTSTR lpszFilter = NULL,
		CWnd* pParentWnd = NULL);
protected:
	//{{AFX_MSG(CFileDialogEX)
	virtual BOOL OnInitDialog();
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
	virtual void OnFileNameChange();
	virtual void OnFolderChange();
	virtual BOOL OnFileNameOK(); 
}; 


CFileDialogEX.cpp File
----------------------

C++
//Code is getting Assert when calling the EditControl in my Custom File Dialog.

void CFileDialogEX ::l_SetDescription(bool flag)
{
     CRichEditCtrl *ptr = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT_DESCRIPTION); //--> Getting      NULL Pointer Here and Application Crash.... in VS2012.
}


Also I observed OnInitDialog is not Called when Invoking the Custom File Dialog.

Please suggest what to do.

Thanks,
Uday.
Posted
Updated 28-Aug-13 22:45pm
v5
Comments
Richard MacCutchan 29-Aug-13 5:37am    
Use your debugger to step through the code and see exactly which pointer is null, and try working backwards to find out why.
chandanadhikari 29-Aug-13 8:38am    
hi,
is this working fine in VS2008? asking because you did not mention it and if its working then maybe some library changes between VS2008 and VS2012 triggered this .Take a look at this :
http://stackoverflow.com/questions/15632788/cfiledialogoninitdialog-does-not-call

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900