-
March 31st, 2009, 07:07 AM
#1
[RESOLVED] CDialog::Create return fails, saying can't find the IDD resource of the dialog
forgive me, please allow me to start from the begining.
I choose win32 project to create an empty project.
Then I import some existing codes to the project.(a Main.cpp file with WinMain, CMyDlg.h and CMyDlg.cpp file
implementing a dialog class CMyDlg, the CMyDlg.h having line enum{IDD = IDD_MYDLG})
Then I compile the codes, for I copy the IDD_MYDLG's defines in my .h file, so it compiles fine.
Then I notice, I've never renew a .rc file to create a dialog resource.
So I start from menu 'Insert'->'Resource' to create a dialog resource. and name the dialog resource
IDD_MYDLG.
In Main.cpp I declare a CMyDlg *ptrDlg;
Code:
ptrDlg = new CMyDlg;
if (ptrDlg)
{
BOOL bRet = FALSE;
bRet = ptrDlg->Create(CMyDlg::IDD);
}
But I still debug to find ptrDlg->Create return FALSE.
Then debug to follow, found the code here dlgcore.cpp
Code:
BOOL AFXAPI _AfxCheckDialogTemplate(LPCTSTR lpszResource, BOOL bInvisibleChild)
{
ASSERT(lpszResource != NULL);
HINSTANCE hInst = AfxFindResourceHandle(lpszResource, RT_DIALOG);-->Saying can't find the resource
HRSRC hResource = ::FindResource(hInst, lpszResource, RT_DIALOG);
Saying can't find the resource.
I've add the resource, I can't clear my mind to figure out where's wrong.
Please help me unlock my mind!
-
March 31st, 2009, 11:16 AM
#2
Re: CDialog::Create return fails, saying can't find the IDD resource of the dialog
First, if you are using MFC stuff in a Win32 application you have to initialize MFC:
Code:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if(! AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
{
TRACE0("Initializing MFC failed");
return -1;
}
// ...
return 0;
}
If the problem still persists, check in resource.h to have unique resource ID values.
-
March 31st, 2009, 08:34 PM
#3
Re: [RESOLVED] CDialog::Create return fails, saying can't find the IDD resource of th
Thx very much.
It does work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|