Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

GekkoCube

Over-riding CWinApp::OnFileNew() does nothing.

This topic is 5484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to over-ride this function so that when i click File ->New it will simply clear the screen and reset the program to startup settings. However, by simply having an empty function, void CSdiogl2App::OnFileNew() { // TODO: Add your command handler code here } when i execture the MFC app the program doesnt even start. what am i to do here?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
quote:
Original post by GekkoCube
what am i to do here?

Sorry if this is a dumb question, but have you tried debugging the app to see why/where/how it exits?

Share this post


Link to post
Share on other sites
i printed stuff out to a file, text stuff.
and OnFileNew is being called - but apparently the app iquits after that.

it never really occured to me to use the actual vc debugger.

let me try.

Share this post


Link to post
Share on other sites
ok, i wasnt making any progress there so im not going to use the onfilenew feature.

i have another problem now, im working on OnSaveFile() and im using the same CFileDialog that i used for OnFileOpen().

Now opening a file working fine and dandy.


CString csFile;
const int FILESIZE = 64000;

static char BASED_CODE szFilter[] = "Path map files (*.gdp)|*.gdp;||";
PSZ pszFile = new char[FILESIZE];

CFileDialog cfd(TRUE,".gdp",NULL,
OFN_HIDEREADONLY|
OFN_FILEMUSTEXIST|
OFN_LONGNAMES,
szFilter);

ZeroMemory(pszFile, FILESIZE);
cfd.m_ofn.lpstrFile = pszFile;
cfd.m_ofn.nMaxFile = FILESIZE;
cfd.m_ofn.nFileOffset = 0;

if(cfd.DoModal() == IDOK)
{
// do open file code here.

}
}


using the same dialog (with first parameter as FALSE) brings up a save as dialog. but when i click Save (whether i checked a file or not) the app freezes.

this comes to a deerp question which MSDN is not very clear about. its not very clear on dialogs for saving.

here is my save file fucntion

void CSdiogl2App::OnFileSave()
{
// TODO: Add your command handler code here


CString csFile;
const int FILESIZE = 64000;

static char BASED_CODE szFilter[] = "Path map files (*.gdp)|*.gdp;||";
PSZ pszFile = new char[FILESIZE];

CFileDialog cfd(FALSE);/*,".gdp",NULL,
OFN_HIDEREADONLY|
OFN_FILEMUSTEXIST|
OFN_LONGNAMES,
szFilter);

ZeroMemory(pszFile, FILESIZE);
cfd.m_ofn.lpstrFile = pszFile;
cfd.m_ofn.nMaxFile = FILESIZE;
cfd.m_ofn.nFileOffset = 0;*/

return; // it still crashes even with this return.

if(cfd.DoModal() == IDOK)
{
// do save stuff here!

}

fclose(file);
}
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!