C++/que about Visual C++
Expert: vijayan - 11/2/2010
QuestionR/Sir
Colud you please help me in solving the error in my program's comiplation:
Below is the program:-
Program to attach a menu to a window.
===============================
#include<afxwin.h>
#include "resource.h"
class myframe : public CFrameWnd
{
public :
myframe()
{
Create(0, "Hello MFC", WS_OVERLAPPEDWINDOW,rectDefault,0,
MAKEINTRESOURCE(IDR_MENU1));
}
};
class myapp : public CWinApp
{
public :
int InitInstance()
{
myframe *p;
p=new myframe;
p->ShowWindow(1);
m_pMainWnd=p;
return 1;
}
};
myapp a;
=====================================
following error comes:-
--------------------Configuration: hello - Win32 Debug--------------------
Compiling...
f1.cpp
C:Program FilesMicrosoft Visual StudioMyProjectshello1.cpp(2) : fatal error C1083: Cannot open include file: 'resource.h': No such file or directory
Error executing cl.exe.
hello.exe - 1 error(s), 0 warning(s)
===============================================
Thanking you,
Sanjeev
AnswerMake sure that you have a file called "resource.h" in the project directory which contains the line:
#define IDR_MENU1 <some number like 101>
(If you had created a resource (eg. menu) using the resource editor of Visual studio, this file would be automatically created.)