不能打开cfiledialog [英] Cant open cfiledialog

查看:282
本文介绍了不能打开cfiledialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MFC库的源文件winocc.cpp中的函数GetDlgItem中收到消息未处理的异常抛出:读取访问冲突。这是nullptr



 CWnd * CWnd :: GetDlgItem(int nID)const 
{
ASSERT(:: IsWindow(m_hWnd));

if(m_pCtrlCont == NULL)
返回CWnd :: FromHandle(:: GetDlgItem(m_hWnd,nID));
else
返回m_pCtrlCont-> GetDlgItem(nID);
}







此功能来自:

 _AfxActivationWndProc(HWND hWnd,UINT nMsg,WPARAM wParam,LPARAM lParam)
{
WNDPROC oldWndProc =(WNDPROC):: GetProp(hWnd,_afxOldWndProc);
ASSERT(oldWndProc!= NULL);

LRESULT lResult = 0;
TRY
{
BOOL bCallDefault = TRUE;
开关(nMsg)
{
案例WM_INITDIALOG:
{
DWORD dwStyle;
CRect rectOld;
CWnd * pWnd = CWnd :: FromHandle(hWnd);
_AfxPreInitDialog(pWnd,& rectOld,& dwStyle);
bCallDefault = FALSE;
lResult = CallWindowProc (oldWndProc,hWnd,nMsg,wParam,lParam);
_AfxPostInitDialog(pWnd,rectOld,dwStyle);
}
休息;





我尝试过:



我无法观察 m_pCtrlCont 的值,而this的值为NULL

解决方案

< blockquote>如果 this 的值为NULL,那么当你做错了。



m_pCtrlCont用于CFileDialog的一些高级用法,以增强带有附加窗口的对话框。



我猜你没有实例化CFileDialog对象,但使用了NULL指针。在你创建对话框的地方开始调试。



看一下带有示例的Microsoft文档


I get the message "Unhandled exception thrown: read access violation. this was nullptr " in function GetDlgItem in source file "winocc.cpp" from MFC library

CWnd* CWnd::GetDlgItem(int nID) const
{
	ASSERT(::IsWindow(m_hWnd));

	if (m_pCtrlCont == NULL)
		return CWnd::FromHandle(::GetDlgItem(m_hWnd, nID));
	else
		return m_pCtrlCont->GetDlgItem(nID);
}




This function is called from :

_AfxActivationWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	WNDPROC oldWndProc = (WNDPROC)::GetProp(hWnd, _afxOldWndProc);
	ASSERT(oldWndProc != NULL);	

	LRESULT lResult = 0;
	TRY
	{
		BOOL bCallDefault = TRUE;
		switch (nMsg)
		{
		case WM_INITDIALOG:
			{
				DWORD dwStyle;
				CRect rectOld;
				CWnd* pWnd = CWnd::FromHandle(hWnd);
				_AfxPreInitDialog(pWnd, &rectOld, &dwStyle);
				bCallDefault = FALSE;
				lResult = CallWindowProc(oldWndProc, hWnd, nMsg, wParam, lParam);
				_AfxPostInitDialog(pWnd, rectOld, dwStyle);
			}
			break;



What I have tried:

I cant watch the value of m_pCtrlCont and the value of "this" is NULL

解决方案

If the value of this is NULL happens, when you had done something very wrong.

The m_pCtrlCont is used for some advanced use of the CFileDialog to enhance the dialog with a addtional windows.

I guess that you havent instanciated the CFileDialog object, but used pointer which is NULL. Start debugging where you create the dialog.

Take a look at the Microsoft documentation with an example.


这篇关于不能打开cfiledialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆