📄 colorwnd.cpp
字号:
// ColorWnd.cpp : implementation file
//
#include "stdafx.h"
#include "ColorWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CColorWnd
CColorWnd::CColorWnd()
{
}
CColorWnd::~CColorWnd()
{
}
BEGIN_MESSAGE_MAP(CColorWnd, CStatic)
//{{AFX_MSG_MAP(CColorWnd)
ON_WM_CREATE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColorWnd message handlers
int CColorWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_bkcolor=RGB(0,0,0);
return 0;
}
void CColorWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//CClientDC dc(this);
RECT rect;
//GetWindowRect(&rect);
GetClientRect(&rect);
int w,h;
w=rect.right-rect.left+1;
h=rect.bottom-rect.top+1;
CBrush brush;
brush.CreateSolidBrush(m_bkcolor);
CBrush *oldbrush=dc.SelectObject(&brush);
dc.Rectangle(0,0,w-1,h-1);
dc.SelectObject(oldbrush);
brush.DeleteObject();
// Do not call CStatic::OnPaint() for painting messages
}
void CColorWnd::SetBkColor(COLORREF m_color)
{
m_bkcolor=m_color;
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -