void CDemoDlg::OnFileOpen()
{
// TODO: 在此添加命令处理程序代码
CFileDialog dlg(TRUE, NULL, NULL,
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST,
_T("文本文件(*.txt)|*.txt|所有文件(*.*)|*.*||"),
this);
dlg.m_ofn.lpstrInitialDir = _T("C:\\");
if(dlg.DoModal() == IDOK)
{
AfxMessageBox(dlg.GetPathName());
//继续写C++ 文件IO进行打开文件,读文件
}
}
void CDemoDlg::OnFileSave()
{
// TODO: 在此添加命令处理程序代码
CFileDialog dlg(FALSE, NULL, NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
_T("*.txt|*.txt||"),this);
if(dlg.DoModal() == IDOK)
{
AfxMessageBox(dlg.GetPathName());
//继续写C++ 文件IO进行保存文件
}
}
void CDemoDlg::OnFormatFont()
{
// TODO: 在此添加命令处理程序代码
CHARFORMAT cf = {0};
cf.cbSize = sizeof(cf);
m_edtContent.GetSelectionCharFormat(cf);
CFontDialog dlg(cf);
if(dlg.DoModal() == IDOK)
{
dlg.GetCharFormat(cf);
m_edtContent.SetSelectionCharFormat(cf);
}
}
void CDemoDlg::OnFormatColor()
{
// TODO: 在此添加命令处理程序代码
CHARFORMAT cf = {0};
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR;
m_edtContent.GetSelectionCharFormat(cf);
CColorDialog dlg(cf.crTextColor);
if(dlg.DoModal() == IDOK)
{
cf.crTextColor = dlg.GetColor();
cf.dwEffects = 0;
m_edtContent.SetSelectionCharFormat(cf);
}
}