undeclared identifier error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NitinSawant
    Contributor
    • Oct 2007
    • 271

    undeclared identifier error

    hi,
    i'm new to mfc vc++ programming,
    when i write following code i get error
    Code:
    Error	1	error C2065: 'IDE_ACCELERATOR1' : undeclared identifier	c:\documents and settings\nitin.mycomputer\desktop\mfc keyboard keys\mfc keyboard keys\mfc keyboard keys.cpp	10
    pls help me

    here is the whole code:

    Code:
    #include "stdafx.h"
    #include<afxwin.h>
    #include "Resource.h"
    
    class myframe:public CFrameWnd
    {
    public:
    	myframe()
    	{
    		LoadAccelTable(MAKEINTRESOURCE(IDE_ACCELERATOR1));
    		Create(0,TEXT("Accelerator"),WS_OVERLAPPEDWINDOW,rectDefault,0,MAKEINTRESOURCE(IDR_MENU1));
    	}
    	void fun1()
    	{
    		MessageBox(TEXT("Reached here to draw a line"),TEXT("Title"));
    	}
    	void fun2()
    	{
    		MessageBox(TEXT("Reached here to draw a Rectangle"),TEXT("Title"));
    	}
    	void fun3()
    	{
    		MessageBox(TEXT("Reached here to draw a Circle"),TEXT("Title"));
    	}
    	void fun4()
    	{
    		MessageBox(TEXT("Reached here to draw a Triangle"),TEXT("Title"));
    	}
    	DECLARE_MESSAGE_MAP()
    };
    BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
    	ON_COMMAND(101,fun1)
    	ON_COMMAND(102,fun2)
    	ON_COMMAND(103,fun3)
    	ON_COMMAND(104,fun4)
    END_MESSAGE_MAP()
    class myapp:public CWinApp
    {
    public:
    	int InitInstance()
    	{
    		myframe *p;
    		p=new myframe;
    		p->ShowWindow(3);
    		m_pMainWnd=p;
    		return 1; 
    	}
    };
    myapp a;
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by Nitin646
    i get error
    Error 1 error C2065: 'IDE_ACCELERATO R1' : undeclared identifier c:\documents and settings\nitin. mycomputer\desk top\mfc keyboard keys\mfc keyboard keys\mfc keyboard keys.cpp 10
    That is because IDE_ACCELERATOR 1 has not been declared anyway, see the error tells you what the problem is.

    The problem is not in the code you posted but rather in another file, if IDE_ACCELERATOR 1 is supposed to be a resource definition it should be defined in Resource.h, however you need to open you your resources in your IDE and see how you have defined your accelerator table.


    As an aside MFC is an ancient technology and wasn't a very good one to start with. If you are looking to write Windows programs and have only just started out you would be better advised to use the .NET Framework.

    You can download Visual Studio 2005 Express for free (or Visual Studio 2008 Express Beta) this will allow you to do .NET development.

    Comment

    • NitinSawant
      Contributor
      • Oct 2007
      • 271

      #3
      any idea??
      how to remove that error??

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by Nitin646
        any idea??
        how to remove that error??
        Didn't you read what Banfa wrote:

        Originally posted by Banfa
        That is because IDE_ACCELERATOR 1 has not been declared anyway, see the error tells you what the problem is.
        So if something isn't declared and your compiler whines about it, you should
        declare it somehow; it's up to you, it's your code.

        kind regards,

        Jos

        Comment

        • NitinSawant
          Contributor
          • Oct 2007
          • 271

          #5
          gr8!!

          problem solved!

          I defined the variable in Resource.h

          Comment

          Working...