On Feb 17, 11:37 pm, MrAsm <m...@usa.com> wrote:
On 17 Feb 2007 10:26:13 -0800, "abhichamp" <abhigup1...@gmail.com>
wrote:
Hi,
I have an application using MFC. The application code is compiling
fine
But when the application is executed
using debug mode following error is getting generated:
Debug Assertion Failed!
File: f:\..\..\afxwin.inl
Line: 21
Hope somebody could help me out by advising what may be wrong with my
code!!
Hi,
the problem is 0.1% in MFC code and 99,9% in your code :)
Assertions in debug mode are your friends: they signal you that your
code has problems, has bugs; they are an opportunity for you to fix
some bugs in your code.
Please show us your code that causes the assertion.
MrAsm
// myproj1.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "myproj1.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "myproj1Doc.h"
#include "myproj1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
using namespace std;
//using namespace tacrea;
// Cmyproj1App
BEGIN_MESSAGE_MAP(Cmyproj1App, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &Cmyproj1App::OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
// Cmyproj1App construction
Cmyproj1App::Cmyproj1App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only Cmyproj1App object
Cmyproj1App theApp;
// Cmyproj1App initialization
BOOL Cmyproj1App::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to
enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting
m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return
FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /
Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
cout<<"Where"<<endl;
CoInitialize(NULL); //my code
tacrea::Initialize();
tacrea::Scene scene;
scene.Initialize();
/*if( scene.Initialize() == tacrea::TACREA_NO_ERROR )
{
cout<<"Error initializing frame"<<endl;
//return 1;
}
*/
string strFilename="../../DATA/CONSTRUCT-HDB/PioneerNorth/
PioneerNorth.xsn";
/*
if( scene.OpenScene(strFilename) ==tacrea::TACREA_NO_ERROR )
{
// create camera and set position, orientation and
intrinsic parameters.
tacrea::Camera cam;
cam.SetPosition(1300,25,0);
cam.SetOrientation(tacrea::math::DegreeToRadian( tacrea::Vec3(0,-20,0) ) );
cam.SetViewFrustumFov(45,45,0.5,5000);
// sets camera
scene.SetCamera(cam);
// declare variables for map generation
tacrea::ColorMap colormap; // color map
tacrea::DistMap distmap; // distance map
tacrea::IdMap idmap; // id map
tacrea::Size width=256; // size of map
tacrea::Size height=256; // size of map
// generate the maps
cout << "generating maps" << endl;
tacrea::Error result = scene.GenerateMaps(width,height,
&colormap, &distmap, &idmap);
if( result == tacrea::TACREA_NO_ERROR )
{
// TODO: process the maps
for(tacrea::Size y=0;y<colormap.GetHeight();y++)
for(tacrea::Size x=0;x<colormap.GetWidth();x++)
{
const tacrea::Color & c=colormap.GetData(x,y);
cout<<"Red "<<c[0];
cout<<"Blue "<<c[1];
cout<<"Green "<<c[2];
}
for(tacrea::Size y=0;y<idmap.GetHeight();y++)
for(tacrea::Size x=0;x<idmap.GetWidth();x++)
{
tacrea::ObjId id=idmap.GetData(x,y);
cout<<"id"<<idmap.TranslateId(id)<<endl;
}
}
else
{
// error during map generation
cout << "error:" << result.what() << endl;
return 1;
}
}
else
{
// error during loading
cout << "error loading" << endl;
return 1;
}
*/
/*
// **** Create Render Window as Preview Window's Child****
m_pPreviewWnd = new TACREAMainWnd;
if (!m_pPreviewWnd->Create( "TACREA", &CRect(0,0,0,0)) )
{
AfxMessageBox("ERROR: Failed to create preview window\n");
return FALSE;
}
m_pRenderWnd = new CRenderWnd;
if( ! m_pRenderWnd->Create(NULL,NULL,WS_CHILD,CRect(0,0,0,0),m_pPreviewWnd,2000) )
{
AfxMessageBox("ERROR : failed to create render window\n");
return FALSE;
}
m_pRenderWnd->BindScene(scene);
*/
CoUninitialize();
return TRUE;
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV
support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// App command to run the dialog
void Cmyproj1App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// Cmyproj1App message handlers