📄 myassistantview.cpp
字号:
// MyAssistantView.cpp : implementation of the CMyAssistantView class
//
#include "stdafx.h"
#include "MyAssistant.h"
#include "MyAssistantDoc.h"
#include "MyAssistantView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyAssistantView
IMPLEMENT_DYNCREATE(CMyAssistantView, CFormView)
BEGIN_MESSAGE_MAP(CMyAssistantView, CFormView)
//{{AFX_MSG_MAP(CMyAssistantView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
ON_BN_CLICKED(IDC_DSP_MONEY, OnDspMoney)
ON_BN_CLICKED(IDC_DSP_ADDRLIST, OnDspAddrList)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyAssistantView construction/destruction
CMyAssistantView::CMyAssistantView()
: CFormView(CMyAssistantView::IDD)
{
//{{AFX_DATA_INIT(CMyAssistantView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
m_Leaf = 0;
}
CMyAssistantView::~CMyAssistantView()
{
}
void CMyAssistantView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyAssistantView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CMyAssistantView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CMyAssistantView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
CRect rect(0,0,800,600); //调整主窗口大小
MoveWindow(&rect,TRUE );
rect.CopyRect(new CRect(30,20,800-30,600-50));
m_PropertySheet.m_Rect = rect;
m_PropertySheet.m_nPages = -1; // init this membervariable
m_PropertySheet.m_nActPage = 0; // init this membervariable
//创建属性页
m_PropertySheet.Create (WS_VISIBLE | WS_CHILD | WS_TABSTOP,
m_PropertySheet.m_Rect, this, m_PropertySheet.m_nCtrlID);
InitPropertySheet(0);
}
/////////////////////////////////////////////////////////////////////////////
// CMyAssistantView printing
BOOL CMyAssistantView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMyAssistantView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMyAssistantView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CMyAssistantView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CMyAssistantView diagnostics
#ifdef _DEBUG
void CMyAssistantView::AssertValid() const
{
CFormView::AssertValid();
}
void CMyAssistantView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CMyAssistantDoc* CMyAssistantView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyAssistantDoc)));
return (CMyAssistantDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyAssistantView message handlers
void CMyAssistantView::InitPropertySheet(UINT flag)
{
m_PropertySheet.DeleteAllItems();
//添加属性页
CPropertyPages * pPropPage = NULL;
TC_ITEM Item;
Item.mask = TCIF_TEXT;
if(flag == 0)
{
int nN;
int nPages = 3; // in my example I have two pages
for (nN = 0; nN < nPages; nN++) {
pPropPage = new (CPropertyPages); // new it
// Create the tab and the dialog
switch (nN)
{
case 0:
Item.pszText = "编辑";
pPropPage->m_pDialogPage = (CDialog*)&m_MoneyDlg;
pPropPage->m_pDialogPage->
Create(IDD_MONEY_EDIT, &m_PropertySheet);
break;
case 1:
Item.pszText = "查看";
pPropPage->m_pDialogPage = (CDialog*)&m_MoneyViewDlg;
pPropPage->m_pDialogPage->
Create(IDD_MONEY_VIEW, &m_PropertySheet);
break;
case 2:
Item.pszText = "图解";
pPropPage->m_pDialogPage = (CDialog*)&m_MoneyChart;
pPropPage->m_pDialogPage->
Create(IDD_MONEY_CHART, &m_PropertySheet);
break;
}
m_PropertySheet.InsertItem (nN,&Item);
m_PropertySheet.m_Dialogs.Add(pPropPage);
m_PropertySheet.m_nPages++;
pPropPage->m_Rect.top =
m_PropertySheet.m_Rect.top + 15;
pPropPage->m_Rect.left =
m_PropertySheet.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;
pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_HIDEWINDOW | SWP_NOSIZE);
} //
m_MoneyDlg.SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_SHOWWINDOW | SWP_NOSIZE);
}
else if(flag == 1)
{
int nN;
int nPages = 1; // in my example I have two pages
for (nN = 0; nN < nPages; nN++) {
pPropPage = new (CPropertyPages); // new it
// Create the tab and the dialog
switch (nN)
{
case 0:
Item.pszText = "地址";
pPropPage->m_pDialogPage = (CDialog*)&m_AddrListDlg;
pPropPage->m_pDialogPage->
Create(IDD_ADDR_EDITLIST, &m_PropertySheet);
break;
}
m_PropertySheet.InsertItem (nN,&Item);
m_PropertySheet.m_Dialogs.Add(pPropPage);
m_PropertySheet.m_nPages++;
pPropPage->m_Rect.top =
m_PropertySheet.m_Rect.top + 15;
pPropPage->m_Rect.left =
m_PropertySheet.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;
pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_HIDEWINDOW | SWP_NOSIZE);
} //
pPropPage->m_pDialogPage->SetWindowPos(NULL, pPropPage->m_Rect.left,
pPropPage->m_Rect.top, 0, 0,
SWP_SHOWWINDOW | SWP_NOSIZE);
}
}
void CMyAssistantView::OnDspMoney()
{
if(m_Leaf != 0) {
m_AddrListDlg.DestroyWindow();
InitPropertySheet(0);
m_Leaf = 0;
}
}
void CMyAssistantView::OnDspAddrList()
{
if(m_Leaf != 2) {
m_MoneyDlg.DestroyWindow();
m_MoneyViewDlg.DestroyWindow();
m_MoneyChart.DestroyWindow();
InitPropertySheet(1);
m_Leaf = 2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -