📄 commondlg.cpp
字号:
// CommonDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ex5.h"
#include "CommonDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommonDlg dialog
CCommonDlg::CCommonDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCommonDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCommonDlg)
m_strEdit1 = _T("");
//}}AFX_DATA_INIT
}
void CCommonDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCommonDlg)
DDX_Control(pDX, IDC_Title, m_Title);
DDX_Text(pDX, IDC_EDIT1, m_strEdit1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCommonDlg, CDialog)
//{{AFX_MSG_MAP(CCommonDlg)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommonDlg message handlers
void CCommonDlg::OnOK()
{
// TODO: Add extra validation here
CString szFilter="所有文件|*.*|Text files(*.txt)|*.txt|Word documents(*.doc)|*.doc||";
CFileDialog fd1(true,"","",1,szFilter);
fd1.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
fd1.m_ofn.lStructSize=88;
fd1.m_ofn.lpstrInitialDir="c:\\";
int nResult=fd1.DoModal();
if(nResult==IDOK)
m_strEdit1=fd1.GetPathName();
UpdateData(false);
// CDialog::OnOK();
}
void CCommonDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
delete this;
CDialog::PostNcDestroy();
}
void CCommonDlg::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();
// CDialog::OnCancel();
}
BOOL CCommonDlg::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DestroyWindow();
}
void CCommonDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight=30;
lf.lfCharSet=GB2312_CHARSET;
strcpy(lf.lfFaceName,"黑体");
// strcpy((LPSTR)&(lf.lfFaceName),"黑体");
CFont cf;
cf.CreateFontIndirect(&lf);
m_Title.SetFont(&cf);
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -