📄 exam1_1_12dlg.cpp
字号:
// Exam1_1_12Dlg.cpp : Implementierungsdatei
//
#include "stdafx.h"
#include "Exam1_1_12.h"
#include "CMyProperty.h"
#include "PropPage1.h"
#include "PropPage2.h"
#include "Exam1_1_12Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg-Dialogfeld f黵 Anwendungsbefehl "Info"
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialogfelddaten
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Vom Klassenassistenten generierte 躡erladungen virtueller Funktionen
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterst黷zung
//}}AFX_VIRTUAL
// Implementierung
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// Keine Nachrichten-Handler
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExam1_1_12Dlg Dialogfeld
CExam1_1_12Dlg::CExam1_1_12Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CExam1_1_12Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExam1_1_12Dlg)
// HINWEIS: Der Klassenassistent f黦t hier Member-Initialisierung ein
//}}AFX_DATA_INIT
// Beachten Sie, dass LoadIcon unter Win32 keinen nachfolgenden DestroyIcon-Aufruf ben鰐igt
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CExam1_1_12Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExam1_1_12Dlg)
// HINWEIS: Der Klassenassistent f黦t an dieser Stelle DDX- und DDV-Aufrufe ein
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExam1_1_12Dlg, CDialog)
//{{AFX_MSG_MAP(CExam1_1_12Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExam1_1_12Dlg
BOOL CExam1_1_12Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDM_ABOUTBOX
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// 创建 CMyPropertysheet
m_propertySheet.m_Rect.left = 10; // 设定它的屏幕坐标
m_propertySheet.m_Rect.top = 10;
m_propertySheet.m_Rect.right = 410;
m_propertySheet.m_Rect.bottom = 210;
m_propertySheet.m_nPages = -1; // 初始化页面数
m_propertySheet.m_nActPage = 0; // 初始化活动页面
m_propertySheet.m_nCtrlID = 2000; // 控件ID
// 在屏幕上显示
m_propertySheet.Create (WS_VISIBLE | WS_CHILD | WS_TABSTOP,
m_propertySheet.m_Rect, this, m_propertySheet.m_nCtrlID);
// 添加页面
TC_ITEM Item;
Item.mask = TCIF_TEXT;
CMyPropertyPage *pPropPage;
int nN;
int nPages = 2; // 有2个页面
for (nN = 0; nN < nPages; nN++) {
pPropPage = new (CMyPropertyPage); // new it
// 创建对话框
switch (nN) {
case 0: // page number 1 - a small Exam1_1_12
Item.pszText = "Page 1";
pPropPage->m_strTitle = "&Page1"; // or get the title of m_fontPage - whatwever you want
pPropPage->m_pDialogPage = (CMyPropDialog *) &m_propPage1;
pPropPage->m_pDialogPage->Create (IDD_PROPPAGE1, &m_propertySheet);
break;
case 1:
Item.pszText = "Page 2";
pPropPage->m_strTitle = "&Page2";
pPropPage->m_pDialogPage = (CMyPropDialog *) &m_propPage2;
pPropPage->m_pDialogPage->Create (IDD_PROPPAGE2, &m_propertySheet);
break;
}
m_propertySheet.InsertItem (nN, &Item);
pPropPage->m_hLocal = NULL;
// 添加到对话框数组
m_propertySheet.m_Dialogs.Add (pPropPage);
m_propertySheet.m_nPages++;
// 设定显示区域
pPropPage->m_Rect.top = 30;
pPropPage->m_Rect.left = 10;
pPropPage->m_Rect.bottom = m_propertySheet.m_Rect.bottom - m_propertySheet.m_Rect.top - 10;
pPropPage->m_Rect.right = m_propertySheet.m_Rect.right - m_propertySheet.m_Rect.left - 10;
// 设定活动页面
if (nN > 0) {
pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_HIDEWINDOW | SWP_NOSIZE);
}
else {
pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_SHOWWINDOW | SWP_NOSIZE);
}
}
return TRUE;
}
void CExam1_1_12Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// Wollen Sie Ihrem Dialogfeld eine Schaltfl鋍he "Minimieren" hinzuf黦en, ben鰐igen Sie
// den nachstehenden Code, um das Symbol zu zeichnen. F黵 MFC-Anwendungen, die das
// Dokument/Ansicht-Modell verwenden, wird dies automatisch f黵 Sie erledigt.
void CExam1_1_12Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // Ger鋞ekontext f黵 Zeichnen
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Symbol in Client-Rechteck zentrieren
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Symbol zeichnen
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// Die Systemaufrufe fragen den Cursorform ab, die angezeigt werden soll, w鋒rend der Benutzer
// das zum Symbol verkleinerte Fenster mit der Maus zieht.
HCURSOR CExam1_1_12Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -