【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,Ex05_6View.cpp,希望对大家有所帮助!
// Ex05_6View.cpp : implementation of the CEx05_6View class
//
#include "stdafx.h"
#include "Ex05_6.h"
#include "Ex05_6Doc.h"
#include "Ex05_6View.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View
IMPLEMENT_DYNCREATE(CEx05_6View, CView)
BEGIN_MESSAGE_MAP(CEx05_6View, CView)
//{{AFX_MSG_MAP(CEx05_6View)
ON_COMMAND(ID_ENLARGE, OnEnlarge)
ON_COMMAND(ID_ZOOM_25, OnZoom25)
ON_UPDATE_COMMAND_UI(ID_ZOOM_25, OnUpdateZoom25)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnDropDown)//添加ON_NOTIFY消息映射
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View construction/destruction
CEx05_6View::CEx05_6View()
{
// TODO: add construction code here
bCheck25=0;
}
CEx05_6View::~CEx05_6View()
{
}
BOOL CEx05_6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View drawing
void CEx05_6View::OnDraw(CDC* pDC)
{
CEx05_6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View printing
BOOL CEx05_6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx05_6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx05_6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View diagnostics
#ifdef _DEBUG
void CEx05_6View::AssertValid() const
{
CView::AssertValid();
}
void CEx05_6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx05_6Doc* CEx05_6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx05_6Doc)));
return (CEx05_6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx05_6View message handlers
void CEx05_6View::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult)
{
NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct;
CRect rect;
CMainFrame *pWnd=(CMainFrame *)AfxGetMainWnd(); // 将工具栏按钮的矩形转换为屏幕坐标,以便确定从何处打开下拉菜单
pWnd->m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
rect.top = rect.bottom;
::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft());
if(pNMToolBar->iItem == ID_ENLARGE)
{
CMenu menuR;
CMenu* pPopupR;
menuR.LoadMenu(IDR_ZOOM); // 从资源中载入菜单
pPopupR = menuR.GetSubMenu(0);
pPopupR->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
}
*pResult = TBDDRET_DEFAULT;
}
void CEx05_6View::OnEnlarge()
{
// TODO: Add your command handler code here
}
void CEx05_6View::OnZoom25()
{
// TODO: Add your command handler code here
AfxMessageBox("缩放25%!"); bCheck25=1;//bCheck25为Bool型在Ex05_6View.h文件中定义,在构造函数中赋初值0;
}
void CEx05_6View::OnUpdateZoom25(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(bCheck25);
}
上一篇:
Ex05_6Doc.cpp
下一篇:
科研管理杂志简介