Ø
Class
|
Dialog Type(s)
|
CFileDialog
|
Open and Save As dialog
boxes
|
CPrintDialog
|
Print and Print Setup
dialog boxes
|
CPageSetupDialog
|
Page setup dialog box.
|
CFindReplaceDialog
|
Find and Replace dialog
boxes
|
CColorDialog
|
Color dialog box
|
CFontDialog
|
Font dialog box
|
Ø MFC’s
common dialog classes are very easy to use.
Ø Each of the
common dialog classes is based on CCommonDialog, which itself derived from
CDialog.
Ø The header
file ‘afxdlgs.h’ needs to be included since it contains the declaration of
common dialogs.
Ø Ex:Color Dialog Box:
#include
"afxwin.h"
#include
"afxdlgs.h"
classMyFrame:publicCFrameWnd
{
CButton b;
public:MyFrame()
{
Create(NULL,"Simple
Window");
}
intOnCreate()
{
b.Create("Display
Dialog",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,CRect(200,100,350,150),this,1);
return 0;
}
void display()
{
CClientDCd(this);
CColorDialog c;
if(c.DoModal()==IDOK)
{
CBrushb(c.GetColor());
d.SelectObject(&b);
d.Rectangle(10,10,100,100);
}
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(MyFrame,CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(1,display)
END_MESSAGE_MAP()
classMyMain:publicCWinApp
{
public:intInitInstance()
{
MyFrame *f=new MyFrame();
f->ShowWindow(1);
m_pMainWnd=f;
return 1;
}
};
MyMain m;
No comments:
Write comments