-
September 23rd, 2011, 02:51 PM
#16
Re: Proper Usage of the MFC Framework
Export whatever functions you want to call. Call dialogs the same way you would in an exe.
CMyDialog dlg;
dlg.DoModal();
-
September 23rd, 2011, 03:07 PM
#17
Re: Proper Usage of the MFC Framework
Would they be static functions?
I guess my question here is:
Back when my app was just an exe, the winmain function was essentially the InitInstance() and the app would run when you debugged or well... ran it. From my understanding, when the CwinApp object is declared in global space, it calls InitInstance() to begin generating the dialogs. From my understanding, myDialogInstance.DoModal() is called in InitInstance(). Therefore, would I only have to export the CwinApp class? When the DLL is utilized in my text bench, do I just create an instance of:
CmyApp myapp?
-
September 23rd, 2011, 03:11 PM
#18
Re: Proper Usage of the MFC Framework
Originally Posted by kingting
Would they be static functions?
I guess my question here is:
Back when my app was just an exe, the winmain function was essentially the InitInstance() and the app would run when you debugged or well... ran it. From my understanding, when the CwinApp object is declared in global space, it calls InitInstance() to begin generating the dialogs. From my understanding, myDialogInstance.DoModal() is called in InitInstance(). Therefore, would I only have to export the CwinApp class? When the DLL is utilized in my text bench, do I just create an instance of:
CmyApp myapp?
You're way too hung up on the CWinApp class. Ordinarily you won't have much in the way of dealing with it. You can create and display dialogs in any function you choose to. You never create an instance of your app yourself. The framework does that for you.
All you should need to export is the functions you need to call.
-
September 23rd, 2011, 03:15 PM
#19
Re: Proper Usage of the MFC Framework
OK I will try this. Thanks for your help.
I am hung up on it because I don't really understand what it does haha.
-
September 23rd, 2011, 03:29 PM
#20
Re: Proper Usage of the MFC Framework
How do I edit my resources (the appearance of the windows) If Im using a MFC DLL template? Also when compiling a DLL, can I have multiple header files linked to it or do I have to compile all my classes and functions into 1 header? Sorry for my noobish questions...
-
September 24th, 2011, 04:53 AM
#21
Re: Proper Usage of the MFC Framework
Originally Posted by kingting
How do I edit my resources (the appearance of the windows) If Im using a MFC DLL template?
The same way like you do that with MFC App. Resource can be embedded into any binary, exe or dll, so its editing is supported in both project types.
Also when compiling a DLL, can I have multiple header files linked to it or do I have to compile all my classes and functions into 1 header? Sorry for my noobish questions...
Sure you can. DLL is just another type of executable binary file. So there's no limitations of the kind.
Best regards,
Igor
-
September 27th, 2011, 09:28 AM
#22
Re: Proper Usage of the MFC Framework
Hi All,
Am I able to compile a MFC DLL and utilize it in a normal console application?
When I try to execute the console app, I don't have the exact error, but it tells me I must be compiling a MFC C++ application
Thanks for the help
-
September 27th, 2011, 10:50 AM
#23
Re: Proper Usage of the MFC Framework
Am I able to compile a MFC DLL and utilize it in a normal console application?
Sure you can. DLL is a binary module able to be loaded into any Windows process.
When I try to execute the console app, I don't have the exact error, but it tells me I must be compiling a MFC C++ application
I have to admit I do not understand what exactly you do, execute or compile.
Last edited by Igor Vartanov; September 27th, 2011 at 10:52 AM.
Best regards,
Igor
-
September 29th, 2011, 10:46 AM
#24
Re: Proper Usage of the MFC Framework
Hi guys,
I'm giving this one last shot. I decided not to compile a DLL and simply place all source files and header files into the project directory. I got rid of anything pertaining to CwinApp and simply wrote a main method:
#include "stdafx.h"
#include "GCE_GUIDlg.h"
int main (void){
RT_Object *rto = NULL;
CGCE_GUIDlg myGUI;
myGUI.DoModal();
RT_ImportCopyObject(myGUI.rto, &rto);
return 0;
}
This is supposed to represent the C application performing a function call to attain the RT_Object
Also, being a complete noob, how do you write code neatly in a forum post?
It is compiling, however, i get this error:
First-chance exception at 0x789394ea (mfc100ud.dll) in GCE_GUI.exe: 0xC0000005: Access violation reading location 0x00000000.
Is this a lost cause? I am trying to learn the winAPI and start from scratch using this http://www.songho.ca/opengl/gl_mvc.html . I do have a deadline coming up though, and I am having trouble understanding this MVC framework. The reason for doing this is that I can code consistently with what the developers of the C Application have already done, thus guaranteeing that my app can be called from their app.
-
September 29th, 2011, 12:35 PM
#25
Re: Proper Usage of the MFC Framework
RT_ImportCopyObject(myGUI.rto, &rto);
Are you sure it wants a pointer to a pointer there?
-
September 29th, 2011, 01:54 PM
#26
Re: Proper Usage of the MFC Framework
Thanks for the reply
But yes, that is what the API dictates. I've tried adding break points when the main function starts, but the error occurs before anything even happens
-
September 29th, 2011, 02:00 PM
#27
Re: Proper Usage of the MFC Framework
Originally Posted by kingting
Thanks for the reply
But yes, that is what the API dictates. I've tried adding break points when the main function starts, but the error occurs before anything even happens
Is your app actually crashing or is that just something you see in the output window and your app keeps running?
-
September 29th, 2011, 02:16 PM
#28
Re: Proper Usage of the MFC Framework
It continues running but essentially will not progress past
// Perform specific initializations
if (!pThread->InitInstance())
{
within winmain.cpp
-
September 29th, 2011, 02:18 PM
#29
Re: Proper Usage of the MFC Framework
Actually now that I trhink about it, that is happening because I've completrely gotten rid of my CWinApp Classes, is there anyway I can just use my own main as opposed to the winmain used when creating a MFC application?
-
September 29th, 2011, 02:26 PM
#30
Re: Proper Usage of the MFC Framework
Originally Posted by kingting
Actually now that I trhink about it, that is happening because I've completrely gotten rid of my CWinApp Classes, is there anyway I can just use my own main as opposed to the winmain used when creating a MFC application?
winmain is for windows apps, main is for console apps. You seem to be making this a lot harder than it should be though. Hard to say how without seeing your whole project. At this point, I'd suggest getting a tutorial book on how Visual Studio and MFC work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|