📄 staticbitmap.cpp
字号:
// StaticBitmap.cpp : implementation file
//
#include "stdafx.h"
#include "StaticBitmap.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaticBitmap
CStaticBitmap::CStaticBitmap()
{ // we want to set the current bitmap to what is currently
// displayed, which should always be the ON_HOOK bmp.
m_resource_id = 0;
}
CStaticBitmap::~CStaticBitmap()
{
}
BEGIN_MESSAGE_MAP(CStaticBitmap, CStatic)
//{{AFX_MSG_MAP(CStaticBitmap)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaticBitmap message handlers
void CStaticBitmap::OnPaint()
{
CPaintDC dc(this);
CBitmap bmp;
CDC memdc;
WINDOWPLACEMENT wndpl;
if (m_resource_id)
{
GetWindowPlacement(&wndpl); // for the size stuff later used
bmp.LoadBitmap(m_resource_id); // load into CBitmap correct resource
memdc.CreateCompatibleDC(&dc); // where we do time-consuming op
memdc.SelectObject(&bmp); // stuck it into similar DC
dc.BitBlt(0, 0,
wndpl.rcNormalPosition.right - wndpl.rcNormalPosition.left, // width
wndpl.rcNormalPosition.bottom - wndpl.rcNormalPosition.top, // height
&memdc, 0, 0, SRCCOPY); // and copy memdc to dc
}
else
{
}
}
void CStaticBitmap::SetBitmap
(UINT resource_id)
{ /* set's the current bitmap to the passed resource id,
* and forces a paint.
*/
m_resource_id = resource_id;
RedrawWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -