Create 返回0 原因创建非模态对话框Create后返回0失败,资源号IDD_DIALOG_TALK是对应一个Dialog,日志错误码
Create 返回0 原因
创建非模态对话框Create后返回0失败,资源号IDD_DIALOG_TALK是对应一个Dialog,日志错误码为0
int ret;
ret = pTalkDlg->Create(IDD_DIALOG_TALK,NULL);
strFriTips.Format(_T("errcode:%u,create return:%u"),GetLastError(),ret);
log_file("other",strFriTips);
那位大神说说原因?,很急!!
[解决办法]
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER
[解决办法]
FORMAT_MESSAGE_FROM_SYSTEM
[解决办法]
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
AfxMessageBox((LPTSTR)lpMsgBuf);
LocalFree( lpMsgBuf );
[解决办法]为什么new 一个 还要去调create 重写一个CTalkDlg构造函数 将控件关联起来
[解决办法]没什么问题呀
// ModelessDlg.h : header file
//
class CModelessDlg : public CDialog
{
// Construction
enum { IDD = IIDD_DIALOG_TALK };
public:
CModelessDlg(CWnd* pParent = NULL);
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void PostNcDestroy();
public:
//BOOL Create(CWnd *pParentWnd=NULL){return Create (IDD,pParentWnd);};
//BOOL Create(UINT nID,CWnd *pParentWnd=NULL){ return CDialog::Create (IDD,pParentWnd);};
}
};
//// ModelessDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelessDlg.h"
BOOL CModelessDlg::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::Create(IDD, pParentWnd);
}
void CModelessDlg::PostNcDestroy()
{
//CDialog::PostNcDestroy();
delete this;
}
//1)
pTalkDlg=new CModelessDlg ;在某个界面的构造函数中。
//2)
pTalkDlg->Create(); //某界面的第一次显示的时候。
//3 Create() 后的任何时候。
pTalkDlg->ShowWindow(SW_SHOW); //弹出
//4 Create() 后的任何时候。
pTalkDlg->ShowWindow(SW_HIDE); //关闭
一般不会创建失败的。