📄 bitmapstatic.cpp
字号:
// BitmapStatic.cpp : implementation file//#include "stdafx.h"#include "fusion.h"#include "BitmapStatic.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// RxBitmapStaticRxBitmapStatic::RxBitmapStatic(){ m_nBitmapID = -1;}RxBitmapStatic::~RxBitmapStatic(){}BEGIN_MESSAGE_MAP(RxBitmapStatic, CWnd) //{{AFX_MSG_MAP(RxBitmapStatic) ON_WM_PAINT() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// RxBitmapStatic message handlersBOOL RxBitmapStatic::PreCreateWindow(CREATESTRUCT& cs) { cs.style |= WS_CLIPCHILDREN; return CWnd::PreCreateWindow(cs);}void RxBitmapStatic::LoadBitmap(UINT nBitmapID){ if(nBitmapID == -1) return; m_nBitmapID = nBitmapID;}BOOL RxBitmapStatic::OnCommand(WPARAM wParam, LPARAM lParam) { CWnd *pWnd = (CWnd *)GetOwner(); pWnd->SendMessage(WM_COMMAND, wParam, lParam); return CWnd::OnCommand(wParam, lParam);}BOOL RxBitmapStatic::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { CWnd *pWnd = (CWnd *)GetOwner(); pWnd->SendMessage(WM_NOTIFY, wParam, lParam); return CWnd::OnNotify(wParam, lParam, pResult);}void RxBitmapStatic::PostNcDestroy() { CWnd::PostNcDestroy(); delete this;}void RxBitmapStatic::OnPaint() { CPaintDC dc(this); // device context for painting if(m_nBitmapID > 0) { CRect rcClient; GetClientRect(rcClient); CDC dcMem; CBitmap bmpMem, *pOldBitmap; BITMAP bm; dcMem.CreateCompatibleDC(&dc); bmpMem.LoadBitmap(m_nBitmapID); bmpMem.GetBitmap(&bm); pOldBitmap = dcMem.SelectObject(&bmpMem); dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY); dcMem.SelectObject(pOldBitmap); bmpMem.DeleteObject(); dcMem.DeleteDC(); } // Do not call CWnd::OnPaint() for painting messages}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -