wzdlogo.cpp

来自「MFC扩展编程实例」· C++ 代码 · 共 67 行

CPP
67
字号
// WzdLogo.cpp : implementation file
//

#include "stdafx.h"
#include "WzdLogo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWzdLogo

CWzdLogo::CWzdLogo()
{
}

CWzdLogo::~CWzdLogo()
{
}


BEGIN_MESSAGE_MAP(CWzdLogo, CWnd)
	//{{AFX_MSG_MAP(CWzdLogo)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CWzdLogo message handlers

void CWzdLogo::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	// get bitmap colors
	CPalette *pOldPal = dc.SelectPalette(m_bitmap.GetPalette(),FALSE);
	dc.RealizePalette();

	// get device context to select bitmap into
	CDC dcComp;
	dcComp.CreateCompatibleDC(&dc);
	dcComp.SelectObject(&m_bitmap);

	// draw bitmap
	dc.BitBlt(0,0,m_bitmap.m_Width,m_bitmap.m_Height, &dcComp, 0,0,SRCCOPY);

	// reselect old palette
	dc.SelectPalette(pOldPal,FALSE);
}

void CWzdLogo::CreateBX(CWnd *pWnd, UINT nBitmapID, UINT nChildID )
{
	m_bitmap.LoadBitmapEx(nBitmapID,TRUE);
	CRect rect(0,0,0,0);
	Create(NULL,_T(""),WS_CHILD|WS_VISIBLE,rect,pWnd,nChildID);
}


void CWzdLogo::MoveLogo( int nWidth, int nHeight )
{
	MoveWindow(nWidth-m_bitmap.m_Width,0,m_bitmap.m_Width,nHeight);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?