Thread: Problem

  1. #1
    C++, using Dev C++
    Join Date
    May 2004
    Posts
    7

    Problem

    Hi, again
    what have I did wrong in this code?


    Code:
    #include <iostream>
    
    // The CHelloApp class
    class CHelloApp : public CWinApp
    {
        public:
            BOOL InitInstance();
    };
    
    // The CHelloWnd class
    class CHelloWnd : public CFrameWnd
    {
        public:
            CHelloWnd();
        protected:
            afx_msg void OnPaint();
            DECLARE_MESSAGE_MAP()
    };
    
    // InitInstance - Returns TRUE if initialization is successful.
    BOOL CHelloApp::InitInstance()
    {
        m_pMainWnd = new CHelloWnd;
        if( m_pMainWnd != 0 )
        {
            m_pMainWnd->ShowWindow( m_nCmdShow );
            m_pMainWnd->UpdateWindow();
            return TRUE;
        }
        else
            return FALSE;
    }
    
    // Create a message map that handles one message - WM_PAINT
    BEGIN_MESSAGE_MAP( CHelloWnd, CFrameWnd )
        ON_WM_PAINT()
    END_MESSAGE_MAP()
    
    CHelloWnd::CHelloWnd()
    {
        Create( NULL, "Hello" );
    }
    
    // OnPaint - Handles the WM_PAINT message from Windows.
    void CHelloWnd::OnPaint()
    {
        CPaintDC    dc(this);
        dc.TextOut(50, 50, "Hello World!", 12);
    }
    
    // Create a single instance of the application.
    CHelloApp   theApplication;






    Compilator: Default compiler
    Kör g++.exe...
    g++.exe "C:\Documents and Settings\Andreas\Mina dokument\project\DOS\Hellowin.cpp" -o "C:\Documents and Settings\Andreas\Mina dokument\project\DOS\Hellowin.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:5: parse
    error before `{' token
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:12: parse
    error before `{' token
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:18: ISO
    C++ forbids declaration of `DECLARE_MESSAGE_MAP' with no type
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In

    function `int DECLARE_MESSAGE_MAP()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:18: parse
    error before `}' token
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:22: invalid
    use of undefined type `class CHelloApp'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:4: forward

    declaration of `class CHelloApp'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In
    member function `BOOL CHelloApp::InitInstance()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:23: `
    m_pMainWnd' undeclared (first use this function)
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:23: (Each
    undeclared identifier is reported only once for each function it appears
    in.)
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:23: invalid

    use of undefined type `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:11: forward
    declaration of `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:26: `
    m_nCmdShow' undeclared (first use this function)

    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: At
    global scope:
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:35: type
    specifier omitted for parameter `CFrameWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:36: ISO
    C++ forbids declaration of `BEGIN_MESSAGE_MAP' with no type
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In
    function `int BEGIN_MESSAGE_MAP(CHelloWnd)':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:36: `
    <anonymous>' has incomplete type
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:11: forward
    declaration of `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:36: parse
    error before `(' token
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:37: ISO
    C++ forbids declaration of `ON_WM_PAINT' with no type
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In

    function `int ON_WM_PAINT()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:39: ISO
    C++ forbids declaration of `END_MESSAGE_MAP' with no type
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In
    function `int END_MESSAGE_MAP()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:40: invalid
    use of undefined type `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:11: forward
    declaration of `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In
    constructor `CHelloWnd::CHelloWnd()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:41: `
    Create' undeclared (first use this function)

    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:46: invalid
    use of undefined type `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:11: forward
    declaration of `class CHelloWnd'
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: In
    member function `void CHelloWnd::OnPaint()':
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:47: `
    CPaintDC' undeclared (first use this function)

    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:47: parse
    error before `(' token
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:48: `
    dc' undeclared (first use this function)

    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp: At
    global scope:
    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:52: aggregate
    `CHelloApp theApplication' has incomplete type and cannot be defined

    C:/Documents and Settings/Andreas/Mina dokument/project/DOS/Hellowin.cpp:52: storage
    size of `theApplication' isn't known

    Running complete

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    First you should include windows.h
    That will probably get rid of most of the errors.

  3. #3
    C++, using Dev C++
    Join Date
    May 2004
    Posts
    7
    But i won´t works

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Did you include windows.h?? If so then I believe this is MFC code which you cant (at least what I know) use in dev.

  5. #5
    Registered User
    Join Date
    May 2004
    Posts
    11
    #include <iostream>

    ---> #include <iostream.h> ?? not sure if that maters

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    That is not it. This is windows code. I have a small suspicion he tries to use MFC code but MFC is (as far as I know) not supported by his compiler.

  7. #7
    C++, using Dev C++
    Join Date
    May 2004
    Posts
    7
    why not?

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    I dont know if it is MFC code but if it is it is completely microsoft specific and I think only their compilers support it ( Visual C++).

  9. #9
    Well this looks exactly like a basic MFC app so I will assume that it is, and like the rest of you, my first thought was Dev-C++ doesn't support MFC.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM