📄 vc06view.cpp
字号:
// vc06View.cpp : implementation of the CVc06View class
//
#include "stdafx.h"
#include "vc06.h"
#include "vc06Doc.h"
#include "vc06View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVc06View
IMPLEMENT_DYNCREATE(CVc06View, CView)
BEGIN_MESSAGE_MAP(CVc06View, CView)
//{{AFX_MSG_MAP(CVc06View)
ON_UPDATE_COMMAND_UI(ID_PATTERN, OnUpdatePattern)
ON_UPDATE_COMMAND_UI(ID_CHORD, OnUpdateChord)
ON_COMMAND(ID_BUTTON32773, OnButton32773)
ON_UPDATE_COMMAND_UI(ID_BUTTON32773, OnUpdateButton32773)
ON_COMMAND(ID_BUTTON32774, OnButton32774)
ON_UPDATE_COMMAND_UI(ID_BUTTON32774, OnUpdateButton32774)
ON_COMMAND(ID_BUTTON32775, OnButton32775)
ON_UPDATE_COMMAND_UI(ID_BUTTON32775, OnUpdateButton32775)
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVc06View construction/destruction
CVc06View::CVc06View()
{
// TODO: add construction code here
x1=0;
y1=0;
x2=0;
y2=0;
x3=0;
y3=0;
x4=0;
y4=0;
x5=0;
y5=0;
m_chord = FALSE;
m_pattern = FALSE;
}
CVc06View::~CVc06View()
{
}
BOOL CVc06View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CVc06View drawing
void CVc06View::OnDraw(CDC* pDC)
{
CVc06Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush brush(HS_BDIAGONAL, 255L); // 红色条形刷
if (m_pattern) {
pDC->SelectObject(&brush);
}
else {
pDC->SelectStockObject(LTGRAY_BRUSH);
}
if (m_chord) {
pDC->RoundRect(x1,y1,x2,y2,x5,y5);
}
else {
pDC->Chord(x1,y1,x2,y2,x3,y3,x4,y4);
}
pDC->SelectStockObject(WHITE_BRUSH); // 恢复刷子颜色
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CVc06View diagnostics
#ifdef _DEBUG
void CVc06View::AssertValid() const
{
CView::AssertValid();
}
void CVc06View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CVc06Doc* CVc06View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVc06Doc)));
return (CVc06Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVc06View message handlers
void CVc06View::OnButton32773()
{
// TODO: Add your command handler code here
m_chord = TRUE;
x1 += 5;
y1 += 5;
x2 += 25;
y2 += 20;
x3 = x1;
y3 = (y1+y2)/2;
x4 = x2;
y4 = (y1+y2)/2;
m_rect = CRect(0,0,x2,y2);
InvalidateRect(m_rect);
}
void CVc06View::OnUpdateButton32773(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(!m_chord);
}
void CVc06View::OnButton32774()
{
// TODO: Add your command handler code here
m_chord = FALSE;
x1 += 5;
y1 += 5;
x2 += 25;
y2 += 20;
x5 += 5;
y5 += 6;
m_rect = CRect(0,0,x2,y2);
InvalidateRect(m_rect);
}
void CVc06View::OnUpdateButton32774(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_chord);
}
void CVc06View::OnButton32775()
{
// TODO: Add your command handler code here
m_pattern = m_pattern ^ 1;
}
void CVc06View::OnUpdateButton32775(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_pattern);
}
void CVc06View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
char text[100];
CStatusBar* pStatus = (CStatusBar*)
AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_STATUSBAR);
if (pStatus) {
wsprintf(text, "mouse.x = %d mouse.y = %d " , point.x , point.y);
pStatus->SetPaneText(0, text); // second pane
wsprintf(text, "img.x = %d img.y = %d " , (x1+x2)/2 , (y1+y2)/2);
pStatus->SetPaneText(1, text); // second pane
// pStatus->SetPaneStyle(0, SBPS_POPOUT);
// pStatus->SetPaneStyle(1, SBPS_POPOUT);
}
CView::OnMouseMove(nFlags, point);
}
void CVc06View::OnUpdatePattern(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_pattern);
}
void CVc06View::OnUpdateChord(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_chord);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -