createfilesheet.cpp
来自「IO函数调用测试」· C++ 代码 · 共 222 行
CPP
222 行
// CreateFileSheet.cpp : implementation file
//
#include "stdafx.h"
#include "afxtempl.h"
#include "IOExplorer.h"
#include "TraceEvent.h"
#include "handle.h"
#include "handleManager.h"
#include "TraceManager.h"
#include "CreateFileSheet.h"
#include "about.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreateFileSheet
IMPLEMENT_DYNAMIC(CCreateFileSheet, CPropertySheet)
CCreateFileSheet::CCreateFileSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
log = NULL; // no log established yet
}
CCreateFileSheet::CCreateFileSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
FlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
CCreateFileSheet::~CCreateFileSheet()
{
}
BEGIN_MESSAGE_MAP(CCreateFileSheet, CPropertySheet)
//{{AFX_MSG_MAP(CCreateFileSheet)
ON_WM_CLOSE()
ON_WM_SYSCOMMAND()
ON_WM_NCDESTROY()
ON_WM_PAINT()
ON_COMMAND(IDOK, OnOK)
ON_COMMAND(IDCANCEL, OnCancel)
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreateFileSheet message handlers
/****************************************************************************
* CCreateFileSheet::OnOK
* Result: void
*
* Effect:
* Causes "OK" command to be ignored
****************************************************************************/
void CCreateFileSheet::OnOK()
{
// do nothing, forces OnOK to be ignored
}
/****************************************************************************
* CCreateFileSheet::OnCancel
* Result: void
*
* Effect:
* Ignores cancel requests
****************************************************************************/
void CCreateFileSheet::OnCancel()
{
// does nothing, forces cancel to be ignored
}
void CCreateFileSheet::OnClose()
{
if(0) // there is any script
{ /* ask about script */
switch(AfxMessageBox(IDS_SAVE_BODY, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
{ /* save */
case IDYES:
// do a save
break;
case IDNO:
break;
case IDCANCEL:
return;
} /* save */
} /* ask about script */
CPropertySheet::OnClose();
}
BOOL CCreateFileSheet::OnInitDialog()
{
CPropertySheet::OnInitDialog();
m_bModeless = TRUE; // this is a modeless dialog
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
ASSERT((IDM_HELP & 0xFFF0) == IDM_HELP);
ASSERT(IDM_HELP < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
CString s;
s.LoadString(IDS_HELP);
pSysMenu->AppendMenu(MF_SEPARATOR);
if(!s.IsEmpty())
{ /* add help */
pSysMenu->AppendMenu(MF_STRING, IDM_HELP, s);
} /* add help */
s.LoadString(IDS_ABOUTBOX);
if (!s.IsEmpty())
{
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, s);
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
GetDlgItem(IDOK)->EnableWindow(FALSE);
GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
return TRUE;
}
void CCreateFileSheet::OnSysCommand(UINT nID, LPARAM lParam)
{
switch(nID & 0xFFF0)
{ /* nID */
case SC_CLOSE:
SendMessage(WM_CLOSE);
break;
case IDM_ABOUTBOX:
{
CAbout aboutDlg;
aboutDlg.DoModal();
}
break;
case IDM_HELP:
AfxGetApp()->WinHelp(0, HELP_CONTENTS);
break;
default:
CPropertySheet::OnSysCommand(nID, lParam);
} /* nID */
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCreateFileSheet::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CWnd::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCreateFileSheet::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCreateFileSheet::OnDestroy()
{
WinHelp(0L, HELP_QUIT);
CPropertySheet::OnDestroy();
}
void CCreateFileSheet::PostNcDestroy()
{
CPropertySheet::PostNcDestroy();
}
void CCreateFileSheet::OnNcDestroy()
{
EndModalLoop(FALSE);
CPropertySheet::OnNcDestroy();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?