我在一个VC工程中使用Create()函数创建一个窗体,为什么一到Create()这里程序就会崩溃呢?以下是Create()函数的定义以及调用的语句,各位大侠帮我看看啊,到底是哪里有问题呢,尽量说详细一点哈,我是个菜鸟
定义(不知道为什么有两个?):
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey); }调用:
bool CDiCom4K::Init(short ComNo,CString ComSet,CWnd* pParent,int ID)
{
BSTR bStrLicense = ::SysAllocStringLen(pwchLicenseKey,sizeof(pwchLicenseKey)/sizeof(WCHAR));
Create(NULL,0,CRect(0,0,0,0),pParent,ID,NULL,FALSE,bStrLicense);
}
定义(不知道为什么有两个?):
virtual BOOL Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{ return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey); }调用:
bool CDiCom4K::Init(short ComNo,CString ComSet,CWnd* pParent,int ID)
{
BSTR bStrLicense = ::SysAllocStringLen(pwchLicenseKey,sizeof(pwchLicenseKey)/sizeof(WCHAR));
Create(NULL,0,CRect(0,0,0,0),pParent,ID,NULL,FALSE,bStrLicense);
}
WCHAR pwchLicenseKey[] =
{
0x0043, 0x006F, 0x0070, 0x0079, 0x0072, 0x0069,
0x0067, 0x0068, 0x0074, 0x0020, 0x0028, 0x0063,
0x0029, 0x0020, 0x0031, 0x0039, 0x0039, 0x0034,
0x0020
};