Thread: Creating and Empty MFC project in Visual Studio?

  1. #1
    Registered User
    Join Date
    Aug 2007
    Location
    U.K.
    Posts
    148

    Creating and Empty MFC project in Visual Studio?

    Hi all, happy weekend!

    I'm starting to learn MFC at school and so got myself a copy of Windows Programming with MFC to help me.

    My problem is that the first program in the book, a 'Hello World' program, simply compromises of just 2 files:

    Hello.cpp
    Hello.h


    Now, when I create an MFC program in Visual Studio 2005, it adds LOTS files - .h files, .cpp files and also resource files.

    I simply want to use the two mentioned above, not all these others which are created. I've tried creating a blank project like I do for C++ for console apps, but despite trying various options during the program creation wizard, I still end up with many of these 'extra' files.

    I'm unable to create a blank MFC project, which will allow to just add the two files listed in the book, and run the 'Hello World' program.

    So basically, how can I create a blank MFC project, so I can just add Hello.cpp and Hello.h.

    Or am I missing the point somewhere?

    Many thanks!!

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I am not sure you should use a "empty mfc project," seeing as the wizard generates everything necessary to start off creating a MFC application.
    Using the dialog approach, it creates the basic code to display your dialog box, for example.
    Are you sure it is a hello world for mfc and not just normal C++?
    If it is mfc, then a dialog mfc project is what you typically would use; otherwise you would have to do a lot of things to show your Hello World.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Well, in any case you can try to create normal files and use the command prompt to compile.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Umm, no. Do you know much about MFC or what it is that you suggest?
    MFC is not special. It uses "normal" files. And why suggest using the command prompt?
    What you suggest makes no sense...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Make sure you are not creating an SDI or MDI program. What you want is a dialog app to get closest to what Prosise describes in the first chapters. But really his goal in the first chapter he states is for you to make the program without the wizards. This is supposed to get you more used to the format of an mfc app. (The basic derivations / required overrides).

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by valaris View Post
    But really his goal in the first chapter he states is for you to make the program without the wizards. This is supposed to get you more used to the format of an mfc app. (The basic derivations / required overrides).
    Who in their right minds would create an MFC app w/o the wizard?
    A proper first chapter might be create a dialog app through the wizard.
    Put a label on the dialog. Add a member for the label.
    Print Hello World on the label during the initialization of the dialog.

    This is what I believe to be the first step, but without seeing the actual book, I can only speculate.
    But in every MFC app - you are not going to get much less then the 7 files listed below:
    Your App.cpp/.h - will contain the class of your application object
    Your AppDlg.cpp/.h - will contain your class for your main dialog (in a dialog project)
    resource.rcc - will contain your program resources, including your icon and your main dialog
    resource.h - will be the companion of resource.rcc with defines for your controls and dialogs
    stdafx.h - precompiled header that will contain various important includes, including MFC headers

    In a real project, you will not be getting much less, and you cannot make it work with much less, except perhaps the precompiled header (but it is still useful).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Quote Originally Posted by Elysia View Post
    Who in their right minds would create an MFC app w/o the wizard?
    Jeff Prosise

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    OK, that was not so much a question, but more of a statement whose meaning was to imply: "You create your MFC apps via the wizards and never without." It may be possible, but it only adds work for you to do without any benefits.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating an application
    By Cpro in forum C++ Programming
    Replies: 21
    Last Post: 05-30-2008, 12:21 AM
  2. Visual C++ 2005 linking and file sizes
    By Rune Hunter in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2005, 10:41 PM

Tags for this Thread