📄 exampleview.cpp
字号:
// ExampleView.cpp : implementation of the CExampleView class
//
#include "stdafx.h"
#include "Example.h"
#include "ExampleDoc.h"
#include "ExampleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExampleView
IMPLEMENT_DYNCREATE(CExampleView, CView)
BEGIN_MESSAGE_MAP(CExampleView, CView)
//{{AFX_MSG_MAP(CExampleView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExampleView construction/destruction
CExampleView::CExampleView()
{
// TODO: add construction code here
}
CExampleView::~CExampleView()
{
}
BOOL CExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CExampleView drawing
void CExampleView::OnDraw(CDC* pDC)
{
CExampleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
using namespace Gdiplus;
Graphics myGraphics(pDC->m_hDC);
if(pDoc->str_File!="")
{
USES_CONVERSION;
Bitmap bitmap(A2W((LPCTSTR)pDoc->str_File));
Pen pen(Color(255, 0, 0, 0), 50);
ColorMatrix colorMatrix = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.6f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
ImageAttributes imageAtt;
imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault,
ColorAdjustTypeBitmap);
myGraphics.DrawLine(&pen, Point(10, 30), Point(150, 30));
INT iWidth = bitmap.GetWidth();
INT iHeight = bitmap.GetHeight();
myGraphics.DrawImage( &bitmap, Rect(30, 0, iWidth, iHeight),
0,0,iWidth,iHeight,UnitPixel,&imageAtt);
}
myGraphics.ReleaseHDC(pDC->m_hDC);
}
/////////////////////////////////////////////////////////////////////////////
// CExampleView diagnostics
#ifdef _DEBUG
void CExampleView::AssertValid() const
{
CView::AssertValid();
}
void CExampleView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CExampleDoc* CExampleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExampleDoc)));
return (CExampleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExampleView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -