Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC in a win32 app

Status
Not open for further replies.

timmay3141

Programmer
Joined
Dec 3, 2002
Messages
468
Location
US
I'm just starting using win32, and I've decided that for a certain program I'm working on, I should use MFC for the dialog boxes, but the rest I will handle on my own. I tried adding a dialog box with the class wizard, but it said CDialog not defined. I tried some stuff, but I never got it working. Help?
 
You'll have to include loads of stuff for MFC support. But if you do that, why doing win32? Then it's just as simple as creating an MFC application, since you're already suffering from its overhead....

Greetings,
Rick
 
Well, I'm using Direct3D in this app, and I don't like the SDI format when using Direct3D. For this particular program, SDI would just get in the way.
 
OK, I got it compiling. However, it won't run correctly. When I call DoModal, I get an assertion failure in afxwin1.inl. This is the line that fails: ASSERT(afxCurrentResourceHandle != NULL). To make it work, I created an stdafx.h file and pasted code from a previous MFC app into it. That allowed it to compile, as long as I #include it before windows.h. I also had to change some settings so I'd include MFC as a shared .dll. As I said, it compiles fine, but it won't launch the dialog. Any suggestions?
 
From the message you get I'd say that MFC hasn't opened the resource file yet. Search for that in a working app and do it yourself, I guess...

Greetings,
Rick
 
I did a search, and apparently the solution to the problem lies in the InitInstance function of the CWinApp class. Unfortunately, the code to the member functions of CWinApp that are called from InitInstance are hidden, so I don't know what is going on in it. I guess I won't be using MFC for this program.
 
Why don't you just use the dialog editor to create a dialog resource and then use the win32 dialog APIs to load it?

Greetings,
Rick
 
That's what I'm doing, it is just a bit simpler to use the class wizard to do some of the coding. I suppose I could write my own version of CDialog and derive all my dialog classes from it, I just didn't want to do the extra work if I didn't have to.
 
Ah, ok; get your point....

Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top