Thread: simple app with MFC

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    24

    simple app with MFC

    I'm using Visual C++ 6.0 ...
    I create empty project (Win32 App) and new .cpp file:

    Code:
    #include <afxwin.h>
    
    class AppX : public CWinApp
    {
    	public:
    	BOOL InitInstance()
    	{
    		CFrameWnd *mainWinL = new CframeWnd;
    
    		mainWinL->Create (NULL, "Main Window Title");
    		mainWinL->ActivateFrame;
    
    		return true;
    	}
    }
    
    AppX MyApp;
    This gives to errors?
    error C2146: syntax error : missing ';' before identifier 'MyApp'
    fatal error C1004: unexpected end of file found

    Thank you!

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    I think you have to put a semicolon after the end of the AppX class (after the }).

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Quote Originally Posted by Dante Shamest
    I think you have to put a semicolon after the end of the AppX class (after the }).
    In C++ class decl. doesnt end with semicolon ;
    It gives 102 errors

  4. #4
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I'm not sure where those errors are coming from, but C++ classes definitely end with a ';'.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  5. #5
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Quote Originally Posted by fiff
    In C++ class decl. doesnt end with semicolon ;
    I'm quite sure you need a semicolon in C++. You don't need it in Java or C#, but your code looks like MFC so I'm ruling those out.

    I don't have a compiler right now, but I fixed some things that looked like syntactic mistakes so give this a shot. If it doesn't work, post the errors.

    Code:
    #include <afxwin.h>
    
    class AppX : public CWinApp
    {
    	public:
    	BOOL InitInstance()
    	{
    		CFrameWnd *mainWinL = new CFrameWnd;
    
    		mainWinL->Create (NULL, "Main Window Title");
    		mainWinL->ActivateFrame();
    		return TRUE ;
    	}
    };
    
    AppX MyApp;

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Quote Originally Posted by Dante Shamest
    I'm quite sure you need a semicolon in C++. You don't need it in Java or C#, but your code looks like MFC so I'm ruling those out.
    damn
    to long scripting PHP

    Thanks, your code works.
    I did'nt call the method ActivateFrame() correctly, missing ()

  7. #7
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    my opinion the hell with mfc stick to pre windows
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  8. #8
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    MFC is quite fine for rapid app development. Its not the best performer if you are writing something that needs optimal performance and is a speed demon. Its close though, too many people write it off as something that is useless, when in fact it is not. I use it quite frequently still, and aids in creating quick and useful applications.

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    From my experience, 90% of people who trash MFC have never used it.

  10. #10
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Quote Originally Posted by Fordy
    From my experience, 90% of people who trash MFC have never used it.
    Ditto. I doubt I'd be too far off in estimating that the other 10% are lazy programmers who tried it for a day and decided it was just too hard or simply wanted to climb back on the ignorance bandwagon screaming about how the API is incomparably superior.

  11. #11
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    A little extra info, you might seriously use the code auto-generator to really get a feel for MFC, its quite a lot to tackle at once, especially in the beginning, but it certainly helped me get more familiar with MFC quickly and familiarized myself with some of the classes.

  12. #12
    Registered User
    Join Date
    Aug 2005
    Location
    Pasadena, CA
    Posts
    6

    Smile

    I got a similar error to the one you have described before. If I remember correctly, you need to uncheck the use precompiled headers from the project properties. I hope this helps.


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client - Server TCP/IP MFC app..... Help!
    By amedinadiaz in forum C++ Programming
    Replies: 0
    Last Post: 10-26-2005, 11:57 AM
  2. A simple, buggy app
    By geek@02 in forum Windows Programming
    Replies: 7
    Last Post: 07-17-2005, 11:57 PM
  3. Simple Win32 console app using 99% of CPU?
    By c_olin3404 in forum C++ Programming
    Replies: 5
    Last Post: 02-17-2005, 03:04 PM
  4. Simple GUI for console app (How?)
    By Bill 101 in forum C Programming
    Replies: 3
    Last Post: 11-15-2002, 03:16 PM
  5. MFC is Challenging :: C++
    By kuphryn in forum C++ Programming
    Replies: 8
    Last Post: 02-05-2002, 01:33 AM