i have written the following application using MFC in visual c++ that includes two resources (a menu and a dialogbox) (created using the resource editor)...the program works absolutely fine except that it displays only one resource ie. it displays only the menu but it does not display the dialogbox... what to do?? this is the code...
#include<afxwin.h>
#include"stdafx.h"
#include"resource.h"
class mydialog:public CDialog
{
private:
int id;
public:
mydialog(int n):CDialog(n)
{
id=n;
}
int OnInitDialog()
{
CDialog::OnInitDialog();
if(id==IDD_DIALOG1)
CenterWindow(GetDesktopWindow());
else
CenterWindow();
return TRUE;
}
void OnOK()
{
CDialog::OnOK() ;
MessageBox(TEXT("You have Pressed the OK Button"),TEXT("OnOK handler"));
}
};
class myframe:public CFrameWnd
{
public:
myframe()
{
Create(0,TEXT("Simple Dialog Box"),WS_OVERLAPPEDWINDOW,rectDefault,0,MAKEINTRESOURCE(IDR_MENU1));
}
void about()
{
mydialog d(IDD_DIALOG1);
d.DoModal();
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_COMMAND(101,about)
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;