Skip to main content
GameDev.net gamedev.net
🔒 Locked

CFileDialog

Started by cheez_keeper Oct 8, 2001 at 8:43 AM 1 replies 3.5k views
Original Post
cheez_keeper
cheez_keeper
So I want a nice cute MFC dialog to pop up in the middle of my game. Here is the code that crashes (or at least pops up a debug assertion failure) sFilename = g_CurrentOptions.sFileLocation; fileDlg = new CFileDialog(TRUE, NULL, sFilename, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, NULL,NULL); and then I run fileDlg->DoModal() if I comment out everything icluding DoModal() and just leave those top 2 lines it still gives me the assertion failure (which leads to a crash later if I ignore it) and just to be sure I entered a vaild filename instead of sFilename and that still didn''t fix the problem. Aslo if I comment out sFilename = g_CurrentOptions.sFileLocation (the reg key for the file name) it still doest work... any clues? has this happened to any of you? Brett Lynnes cheez_keeper@hotmail.com
Brett Lynnescheez_keeper@hotmail.com
cheez_keeper
cheez_keeper
Your first reaction may be: "why the heck did this guy just reply to himself" It isn't because I have a spit personality disorder... it's just that i wanted to move this post back up from the depths of the stack so people would look at it.... i am SOOOOOoooo close to finishing this project only to get shot down by this at the VERY END!!!... ok here is some more info that may help you solve my problem:

i didn't start the project with MFC included (I dindt think i would need it)... turns out i needed to open a file using a dialog box... the ONLY way i could find to do this was to use CFileDialog (woo hoo looks like i get to include "afxdlgs.h" now huh). I took out all of my includes to "windows.h" "commdlg.h" etc. and put in the same basic libraries you use when you start a project using MFC. I can get the CFileDialog box to work in other applications that i STARTED by using MFC but i can't get it to work in this one since. i am assuming now because there is somthing i cant see going on behind the scene when you start a project using MFC (i checked the settings and check all the included .dll and .lib NOTHING i can see is different tho). like i said earlier... it compiles fine but gives me that stupid assertion failed (its not a user assertion i can tell you cuz i dont use em) when i actually click the "browse" function. if i ignore the assertion it actually lets me into the dialog box, but then the program crasehes if i go back in (crash = big major core dump of the ENTIRE 23 megs... i can only crash my computer 5 times before my __asm wont give me a pointer to the stack OOM... hehe i guess i need more memory to run my program.... OR i could just FIX THIS!!!) Help me Please!!! ok i will get off my knees now... but please help if you can

/************************This just in!!!
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL);
return afxCurrentResourceHandle; }

that is the windows code (duh hit debug brett... thats what VS is for *smack*) in "afxdlgs.h" (the inline part) that puts out the ASSERT... here are the options I am looking at now...
1) is this caused because i sent NULL in for cWnd param (the last one) WHY? because it DEFAULTS to NULL... can i get and send in a parameter there... (i have a handle to HWND but dont know the proper conversion... do i need to getDC or something?)
2)is it because the this pointer in the CFontDialog doesnt function? ... i think when i compile for release it will ignore (as will I)this assertion then...

So i guess my question is can i ignore it??? will this cause bad repurcussions?
\************************/
Brett Lynnes
cheez_keeper@hotmail.com

Edited by - cheez_keeper on October 8, 2001 8:44:07 PM
Brett Lynnescheez_keeper@hotmail.com
Zeke
Zeke
Is there a particular reason you cant use the win32 OPENFILENAME and GetOpenFileName() instead of using MFC?
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.