Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error in a very simple VC++ program

error in a very simple VC++ program

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tyagineha
    wrote on last edited by
    #1

    hye, I m new to VC++ i wrote a simple program in VC++ following is the code : #include class CMainWin :public CFrameWnd { public: CMainWin(); Declare_Message_Map() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { bool InitInstace(); }; Bool CApp :: InitInstance() { m_pMainWnd=new MainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return true; } Begin_Message_Map(CMainWin,CFrameWnd) End_Message_Map() CApp App; but i m gtng two errors 1) syntax error : missing ';' before type 'long' 2)fatal error C1004: unexpected end of file found Neha

    A S 2 Replies Last reply
    0
    • T tyagineha

      hye, I m new to VC++ i wrote a simple program in VC++ following is the code : #include class CMainWin :public CFrameWnd { public: CMainWin(); Declare_Message_Map() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { bool InitInstace(); }; Bool CApp :: InitInstance() { m_pMainWnd=new MainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return true; } Begin_Message_Map(CMainWin,CFrameWnd) End_Message_Map() CApp App; but i m gtng two errors 1) syntax error : missing ';' before type 'long' 2)fatal error C1004: unexpected end of file found Neha

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      Use: #include "stdafx.h" and then try. for all string, write: _T("") instead of "". For example, write _T("Hello") instead of "Hello". I think this will help.

      Anurag Gandhi.

      T 1 Reply Last reply
      0
      • T tyagineha

        hye, I m new to VC++ i wrote a simple program in VC++ following is the code : #include class CMainWin :public CFrameWnd { public: CMainWin(); Declare_Message_Map() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { bool InitInstace(); }; Bool CApp :: InitInstance() { m_pMainWnd=new MainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return true; } Begin_Message_Map(CMainWin,CFrameWnd) End_Message_Map() CApp App; but i m gtng two errors 1) syntax error : missing ';' before type 'long' 2)fatal error C1004: unexpected end of file found Neha

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        Dear Neha, One thing is that, your project might have enabled precompiled header. So that you have to include stdafx.h in your project or remove the pre-compiled header setting for the file from project properties. Declare_Message_Map() is actually DECLARE_MESSAGE_MAP() hope you are aware about this. Please put the right source code and complete error message to get your problem solved. I think you can approach Visual C++ Create Simple SDI for you. I doubt your "Create" function will succeed because you have to give a valid class name for the window.

        -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

        My blog - Sharing My Thoughts, An Article - Understanding Statepattern

        T 1 Reply Last reply
        0
        • A Anurag Gandhi

          Use: #include "stdafx.h" and then try. for all string, write: _T("") instead of "". For example, write _T("Hello") instead of "Hello". I think this will help.

          Anurag Gandhi.

          T Offline
          T Offline
          tyagineha
          wrote on last edited by
          #4

          what u suggested is not working (stdafx.h) also,i m using create function then how to use : _T("Hello") instead of "Hello". neha

          H 1 Reply Last reply
          0
          • S Sarath C

            Dear Neha, One thing is that, your project might have enabled precompiled header. So that you have to include stdafx.h in your project or remove the pre-compiled header setting for the file from project properties. Declare_Message_Map() is actually DECLARE_MESSAGE_MAP() hope you are aware about this. Please put the right source code and complete error message to get your problem solved. I think you can approach Visual C++ Create Simple SDI for you. I doubt your "Create" function will succeed because you have to give a valid class name for the window.

            -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

            My blog - Sharing My Thoughts, An Article - Understanding Statepattern

            T Offline
            T Offline
            tyagineha
            wrote on last edited by
            #5

            Still not working any other clue??????? pls help me out neha

            S 1 Reply Last reply
            0
            • T tyagineha

              Still not working any other clue??????? pls help me out neha

              S Offline
              S Offline
              Sarath C
              wrote on last edited by
              #6

              Please post the correct code and error messages. Are you dealing everything in a single CPP file?

              -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

              My blog - Sharing My Thoughts, An Article - Understanding Statepattern

              T 1 Reply Last reply
              0
              • S Sarath C

                Please post the correct code and error messages. Are you dealing everything in a single CPP file?

                -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

                My blog - Sharing My Thoughts, An Article - Understanding Statepattern

                T Offline
                T Offline
                tyagineha
                wrote on last edited by
                #7

                Foloowing is the corrected code written in file called example.cpp: #include class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: bool InitInstance(); }; Bool CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; following error r encountered: 1)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : error C2144: syntax error : missing ';' before type 'long' 2)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : fatal error C1004: unexpected end of file found neha

                S D 2 Replies Last reply
                0
                • T tyagineha

                  Foloowing is the corrected code written in file called example.cpp: #include class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: bool InitInstance(); }; Bool CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; following error r encountered: 1)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : error C2144: syntax error : missing ';' before type 'long' 2)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : fatal error C1004: unexpected end of file found neha

                  S Offline
                  S Offline
                  Sarath C
                  wrote on last edited by
                  #8

                  What file you are supposed include at #include statement at the very beginning?

                  -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

                  My blog - Sharing My Thoughts, An Article - Understanding Statepattern

                  T 1 Reply Last reply
                  0
                  • S Sarath C

                    What file you are supposed include at #include statement at the very beginning?

                    -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

                    My blog - Sharing My Thoughts, An Article - Understanding Statepattern

                    T Offline
                    T Offline
                    tyagineha
                    wrote on last edited by
                    #9

                    Sorry following is the code: #include class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: bool InitInstance(); }; Bool CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; neha -- modified at 7:15 Wednesday 23rd May, 2007 neha

                    T 1 Reply Last reply
                    0
                    • T tyagineha

                      Sorry following is the code: #include class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: bool InitInstance(); }; Bool CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; neha -- modified at 7:15 Wednesday 23rd May, 2007 neha

                      T Offline
                      T Offline
                      tyagineha
                      wrote on last edited by
                      #10

                      i dnt know is this a problem in printing or what??? but i have included afxwin.h -- modified at 7:25 Wednesday 23rd May, 2007

                      S 1 Reply Last reply
                      0
                      • T tyagineha

                        i dnt know is this a problem in printing or what??? but i have included afxwin.h -- modified at 7:25 Wednesday 23rd May, 2007

                        S Offline
                        S Offline
                        Sarath C
                        wrote on last edited by
                        #11

                        Sorry Neha, I could not see any bug in your code unless some spelling mistakes #include <afxwin.h> class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: BOOL InitInstance(); }; BOOL CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; The above code worked fine for me. -- modified at 8:31 Wednesday 23rd May, 2007

                        -Sarath_._ "Great hopes make everything great possible" - Benjamin Franklin

                        My blog - Sharing My Thoughts, An Article - Understanding Statepattern

                        1 Reply Last reply
                        0
                        • T tyagineha

                          Foloowing is the corrected code written in file called example.cpp: #include class CMainWin :public CFrameWnd { public: CMainWin(); DECLARE_MESSAGE_MAP() }; CMainWin ::CMainWin() { Create(NULL,"Hello"); } class CApp:public CWinApp { public: bool InitInstance(); }; Bool CApp :: InitInstance() { m_pMainWnd= new CMainWin; m_pMainWnd ->ShowWindow(m_nCmdShow); m_pMainWnd ->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWin,CFrameWnd) END_MESSAGE_MAP() CApp App; following error r encountered: 1)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : error C2144: syntax error : missing ';' before type 'long' 2)c:\program files\microsoft visual studio\vc98\include\winnt.h(86) : fatal error C1004: unexpected end of file found neha

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          tyagineha wrote:

                          #include <afxwin.h>

                          This should be "stdafx.h" instead.


                          "A good athlete is the result of a good and worthy opponent." - David Crow

                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                          1 Reply Last reply
                          0
                          • T tyagineha

                            what u suggested is not working (stdafx.h) also,i m using create function then how to use : _T("Hello") instead of "Hello". neha

                            H Offline
                            H Offline
                            Hamid Taebi
                            wrote on last edited by
                            #13

                            Whats header file of your program ?


                            WhiteSky


                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups