📄 wtlscribbleview.h
字号:
// WTLScribbleView.h : interface of the CWTLScribbleView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_HELLOWTLVIEW_H__094B5DE2_A908_11D4_81E1_006008438F29__INCLUDED_)
#define AFX_HELLOWTLVIEW_H__094B5DE2_A908_11D4_81E1_006008438F29__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "atlmisc.h"
#include "atlcrack.h"
#include "atlgdi.h"
class CWTLScribbleView : public CWindowImpl<CWTLScribbleView>
{
public:
DECLARE_WND_CLASS(NULL)
BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}
CPoint m_startPoint;
CPoint m_endPoint;
CWTLScribbleView()
{
m_startPoint.x = m_startPoint.y = -1;
m_endPoint.x = m_endPoint.y = -1;
m_color = RGB(255,0,0);
}
BEGIN_MSG_MAP_EX(CWTLScribbleView)
MSG_WM_LBUTTONDOWN(OnLButtonDown)
MSG_WM_LBUTTONUP(OnLButtonUp)
MSG_WM_MOUSEMOVE(OnMouseMove)
COMMAND_ID_HANDLER_EX(ID_COLOR_RED, OnColorRed)
COMMAND_ID_HANDLER_EX(ID_COLOR_GREEN, OnColorGreen)
COMMAND_ID_HANDLER_EX(ID_COLOR_BLUE, OnColorBlue)
END_MSG_MAP()
LRESULT OnLButtonDown (UINT flags, CPoint point)
{
m_startPoint = point;
return 0;
}
LRESULT OnLButtonUp (UINT flags, CPoint point)
{
m_startPoint.x = m_startPoint.y = -1;
return 0;
}
LRESULT OnMouseMove (UINT flags, CPoint point)
{
m_endPoint = point;
CClientDC dc(this->m_hWnd);
CPen np;
np.CreatePen(PS_SOLID, 2, m_color);
HPEN op = dc.SelectPen(np.m_hPen);
if (m_startPoint.x != -1 )
{
dc.MoveTo(m_startPoint.x, m_startPoint.y, NULL);
dc.LineTo(m_endPoint.x, m_endPoint.y);
m_startPoint.x = m_endPoint.x;
m_startPoint.y = m_endPoint.y;
}
dc.SelectPen(op);
return 0;
}
LRESULT OnColorRed(UINT, int, HWND)
{
m_color = RGB(255,0,0);
return 0;
}
LRESULT OnColorGreen(UINT, int, HWND)
{
m_color = RGB(0,255,0);
return 0;
}
LRESULT OnColorBlue(UINT, int, HWND)
{
m_color = RGB(0,0,255);
return 0;
}
protected:
COLORREF m_color;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_HELLOWTLVIEW_H__094B5DE2_A908_11D4_81E1_006008438F29__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -