Creation of a Simple Dialog Box


Program to create a Simple Dialog box

#include <afxwin.h>

#include”resource.h”

class mydialog:public CDialog

{

public:

mydialog(int n):CDialog(n)

{

}

void OnOK()

{

CDialog::OnOK();

MessageBox(“you have pressed the OK button”,”OnOK handler”);

}

void OnCancel()

{

CDialog::OnCancel();

MessageBox(“you have pressed the cancel button”,”Oncancel handler”);

}

};

class myframe : public CFrameWnd

{

public:

myframe()

{

Create(0,”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;

Advertisements