CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 36
  1. #16
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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();

  2. #17
    Join Date
    Sep 2011
    Posts
    75

    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?

  3. #18
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Proper Usage of the MFC Framework

    Quote Originally Posted by kingting View Post
    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.

  4. #19
    Join Date
    Sep 2011
    Posts
    75

    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.

  5. #20
    Join Date
    Sep 2011
    Posts
    75

    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...

  6. #21
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Proper Usage of the MFC Framework

    Quote Originally Posted by kingting View Post
    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

  7. #22
    Join Date
    Sep 2011
    Posts
    75

    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

  8. #23
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    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

  9. #24
    Join Date
    Sep 2011
    Posts
    75

    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.

  10. #25
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Proper Usage of the MFC Framework

    RT_ImportCopyObject(myGUI.rto, &rto);

    Are you sure it wants a pointer to a pointer there?

  11. #26
    Join Date
    Sep 2011
    Posts
    75

    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

  12. #27
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Proper Usage of the MFC Framework

    Quote Originally Posted by kingting View Post
    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?

  13. #28
    Join Date
    Sep 2011
    Posts
    75

    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

  14. #29
    Join Date
    Sep 2011
    Posts
    75

    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?

  15. #30
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Proper Usage of the MFC Framework

    Quote Originally Posted by kingting View Post
    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.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured