模式对话框
创建
Win32:DialogBox()
MFC:DoMoal()
销毁:EndDialog()
非模式 自己手动销毁
创建:
Win32: CreateWindow()
MFC: Create() ShowWindow UpdateWindow
销毁:DestroyWindow()
//颜色对话框
CColorDialog colDlg;
if (IDOK == colDlg.DoModal())
{
CString str("123");
CClientDC dc(this);
int nCount = colDlg.GetColor();
dc.SetTextColor(nCount);
dc.TextOut(10,20,str);
}
//字体对话框¨°
CFontDialog fontDlg;
if (IDOK == fontDlg.DoModal())
{
CString str("lwm");
CClientDC dc(this);
CFont *pOldFont, font;
font.CreateFontIndirect(fontDlg.m_cf.lpLogFont);
pOldFont = dc.SelectObject(&font);
dc.TextOut(30,50,str);
dc.SelectObject(pOldFont);
}
//文件对话框 TRUE打开 FALSE保存
CFileDialog fileDlg(TRUE,0,0,OFN_HIDEREADONLY,_T("cpp|*.cpp|所有文件|*.*|"));
if (IDOK == fileDlg.DoModal())
{
CString str;
CClientDC dc(this);
str = fileDlg.GetPathName();
dc.TextOut(20,100,str);
}
控件:
m_btn1.MoveWindow(0,0,50,30);
m_btn1.SetWindowText(_T("xxx"));
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
m_btn1.SetBitmap(bmp);
ID范围内控件处理:
ON_COMMAND_RANGE(IDC_BUTTON1,IDC_BUTTON10,OnFun)
afx_msg void OnFun(UINT id);
void CMy12Dlg::OnFun(UINT id)
{
switch(id)
{
case IDC_BUTTON1:
break;
…
default:
break;
}
}
原文:http://www.cnblogs.com/xslwm/p/7173018.html