CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2012
    Posts
    20

    Newbie How do applications start?

    I was given a project to make a flow chart of a windows application. I was given all the source files and the project file that opens with microsoft visual studio. There are about 30 header files and the MFC, which I know very very little about.

    My question where does the flow start. All I know is the class, <<Cmainfrm>> has gui functions and functions that activate things when buttons are pressed. I also know that there is a function called create(). But what calls Cmainfrm? And what calls the create() function. How does c++ know to call these functions first?

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

  3. #3
    Join Date
    Mar 2012
    Posts
    20

    Re: Newbie How do applications start?

    Thank you.

    I looked for instance declarations under the CWinApp class and couldn't find any.

    I did find this though:

    CWinThread *g_pBasThread=NULL;


    Is my logic correct?:
    So the initialization of this object invokes the constructors to create the GUI of the applet.
    The GUI is looped forever.
    The MFC message handler invokes functions when buttons are pressed on the GUI.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Newbie How do applications start?

    I looked for instance declarations under the CWinApp class and couldn't find any.
    CWinApp class is typically inherited by your app class which instance must be declared in the global scope with the name theApp.

    As well, a really good insight into MFC internals is the follwing article from Paul Dilascia:
    Meandering Through the Maze of MFC Message and Command Routing
    Best regards,
    Igor

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Newbie How do applications start?

    Quote Originally Posted by printz0r View Post
    ... My question where does the flow start. ...
    For another explanation, see "MFC under the hood" by Nish Sivakumar at http://www.codeproject.com/Articles/...under-the-hood

    Basically, the MFC framework provides a hidden WinMain() function, which calls your implementation of CWinThread::InitInstance and then calls CWinThread::Run to run the message loop.

    Quote Originally Posted by printz0r
    Is my logic correct?:
    So the initialization of this object invokes the constructors to create the GUI of the applet.
    The GUI is looped forever.
    The MFC message handler invokes functions when buttons are pressed on the GUI.
    This is somewhat muddled thinking. All Windows applications need a WinMain() function. Do you have experience with plain-C programming for Windows?

    Mike

  6. #6
    Join Date
    Mar 2012
    Posts
    20

    Re: Newbie How do applications start?

    I'm being thrown in the deep end - There are multiple layers of the code, and I figured the flow chart shouldn't talk about how the MFC works, but more on how the functions work. The second disparity is the functions have their own layers =( which invokes other cpp files. The other cpp files actually communicate with class interface functions part of a .dll file for communicating between microcontrollers.

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