Ahh where is main()?

This is a discussion on Ahh where is main()? within the Windows Programming forums, part of the Platform Specific Boards category; Im a C++ programmer just entering the world of MFC and MSVC++ i have made an empty dialog project. Now ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    57

    Ahh where is main()?

    Im a C++ programmer just entering the world of MFC and MSVC++
    i have made an empty dialog project. Now i know in what file to put main() (.cpp hope its still that way in this) but in all the jumble of pre-generated code i dont see main() am i just to put it in the bottom after everything or...? thanks for any help with it
    =@-OmegatronO-@=

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    In a GUI Windows app, there is not a main() instead, there is a winmain().

    I would advise you to learn at least the basics of the API before fiddling with MFC. There are others who would disagree of course, there always are.

    The wizard generated code is crap, and in some cases, will not even compile.

    Start with this...
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Okay, so don't take my file! Try again...
    Attached Files Attached Files
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    In MFC WinMain is hidden away in the MFC libraries......I havent looked at it for a while, but if I remember rightly, WinMain calls AfxWinInit and also calls AfxGetApp which returns the reference to the global application object you create with an MFC app. So all you have to do is create this global object and you are fine - WinMain is handled

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    If you are really interested in whats going on under the hood with MFC then to start with peruse the articles at codeproject about it. hang on ill dig up a link .Thats just 1 there are other articles. There is a good book on this also called MFC internals but that is probably overkill unless you are a hardcore mfcer
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Well looking at the interworkings of MFC seems a little counter-productive. MFC exists so you don't have to deal with WinMain() or thinking. Maybe if I ever used MFC I'd take a different side here but if there is something that you are just plain not being able to accomplish via MFC the API is sitting right there ready to be used too.

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    I dont think it's that clean cut....sometimes NOT using MFC is difficult (if you are creating ActiveX apps for instance). All that boilerplate code is very hard to do without.

    And if you use MFC enough, then a peek at the insides is very usefull....same as knowing how the STL implements a std::list - maybe no essential, but a benefit if you know how it works

  8. #8
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Fair enough, though I find that I use wxWindows much more frequently than I use MFC. Of course I'm shooting myself in the foot with this example since I find myself looking into wxWindow's source whenever I use it. The ActiveX issue is really the only thing that ever makes MFC necessary.

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by master5001
    ActiveX issue is really the only thing that ever makes MFC necessary.
    Damn you master!!!

    Your not baiting me with that one!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  2. confused about adding controls to main window
    By terracota in forum Windows Programming
    Replies: 4
    Last Post: 11-24-2004, 12:35 PM
  3. Int Main or Void Main?
    By FromHolland in forum C++ Programming
    Replies: 9
    Last Post: 06-12-2003, 05:29 PM
  4. int main (), main (), main (void), int main (void) HELP!!!
    By SmokingMonkey in forum C++ Programming
    Replies: 7
    Last Post: 05-31-2003, 10:46 PM
  5. getting a function to return to main??
    By Neildadon in forum C++ Programming
    Replies: 7
    Last Post: 12-16-2002, 10:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21