Re: Again problem with afxCurrentResourceHandle == NULL
ScottMcP [MVP] wrote on 07/29/2010 20:22 ET :
On Jul 29, 7:41 pm, narcomancer wrote:
Hello,
I`m new to VC++ and I can`t build even simplest application. I want to
show
dialog with DoModal() for start. I have red tens of examples and
manuals
but
still having the same problem - afxwin1.inl on line 24 is throwing
Assertion
error on runtime. I even tried to rebuild my IDD_DIALOG1 and resouce
container
but that does not help. I need to reuse existing code where similar
lines of
code are working well so I just don`t understand where is the problem.
-ConfigWindow.h-
#pragma once
#include "resource.h"
class ConfigWindow : public CDialog {
public:
ConfigWindow(CWnd* pParent = NULL);
enum { IDD = IDD_DIALOG1 };
};
-ConfigWindow.cpp-
#include "stdafx.h"
#include "ConfigWindow.h"
ConfigWindow::ConfigWindow(CWnd* pParent /*=NULL*/)
: CDialog(ConfigWindow::IDD, pParent)
{
}
-stdafx.h-
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if
!defined(AFX_STDAFX_H__B30E7969_C2D1_11D3_9ECA_00A024503B95__INCLUDED_)
#define AFX_STDAFX_H__B30E7969_C2D1_11D3_9ECA_00A024503B95__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#define VC_EXTRALEAN
#include <afxwin.h>
#include <afxext.h>
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h>
#include <afxodlgs.h>
#include <afxdisp.h>
#endif
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h>
#endif
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h>
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif
#endif //
!defined(AFX_STDAFX_H__B30E7969_C2D1_11D3_9ECA_00A024503B95__INCLUDED_)
-finally my block of code-
ConfigWindow *window = new ConfigWindow;
window->DoModal();
Somebody please help! I`m trying to fix this 2nd evening already with
no
success
:(
Based on what you have shown, the problem is that you are using MFC
without initializing it. Do you know you are using MFC? You must
have a CWinApp object and your code must start at
CYourWinApp::InitInstance.
Do not do these things by hand: There are too many details for a
beginner to get right. Visual C++ will set it all up properly for you
when you start a new project (menu File, New, Project, MFC, select
Dialog-Based). After you go through these wizard steps the program
should build and run, displaying a dialog.
Ok, I feel I have missed some more info. My goal is to make .dll which will
open
dialog for me. That`s why I can`t make default MFC application and am doing
that
by hands.
I can`t use CYourWinApp::InitInstance because I don`t have full class
structure
in my main cpp file. I need to override functions like "public
init(...)" to get it integrated with external system.
I can give a try to make another class with ::InitInstance which will be
initialized from my main cpp and then will open dialog from it. Will that
help?
Please give example what should I do with that ::InitInstance. Just define it
or
there`s something more?