⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitmap~3.cpp

📁 经典的一款俄罗斯方块-源程序.java.~
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////
// This file is part of the completely free tetris clone "CGTetris".
//
// This is free software.
// You may redistribute it by any means providing it is not sold for profit
// without the authors written consent.
//
// No warrantee of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
/////////////////////////////////////////////////////////////////////////////


// BitmapPropSheet.cpp : implementation file
//

#include "stdafx.h"
#include "tetris.h"
#include "BitmapPropSheet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBitmapPropSheet

IMPLEMENT_DYNAMIC(CBitmapPropSheet, CPropertySheet)

CBitmapPropSheet::CBitmapPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
	CommonConstruct();
}

CBitmapPropSheet::CBitmapPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	CommonConstruct();
}

CBitmapPropSheet::~CBitmapPropSheet()
{
}


void CBitmapPropSheet::CommonConstruct()
{
	VERIFY(m_bmpBackground.LoadBitmap(IDB_Background));
	VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
}

BEGIN_MESSAGE_MAP(CBitmapPropSheet, CPropertySheet)
	//{{AFX_MSG_MAP(CBitmapPropSheet)
	ON_WM_ERASEBKGND()
	ON_WM_QUERYNEWPALETTE()
	ON_WM_PALETTECHANGED()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBitmapPropSheet message handlers

BOOL CBitmapPropSheet::OnEraseBkgnd(CDC* pDC) 
{
	if(m_bmpBackground.GetPixelPtr() != 0)
		m_bmpBackground.DrawDIB(pDC);
	else
		// no bitmap set. behave like a normal property sheet
		return CPropertySheet::OnEraseBkgnd(pDC);

	return TRUE;
}

BOOL CBitmapPropSheet::OnQueryNewPalette() 
{
	CPalette * pPal = m_bmpBackground.GetPalette();
	if( pPal != 0 && GetSafeHwnd() != 0 ) {
		CClientDC dc(this);
		CPalette * pOldPalette = dc.SelectPalette(pPal, FALSE);
		UINT nChanged = dc.RealizePalette();
		dc.SelectPalette(pOldPalette, TRUE);

		if (nChanged == 0)
			return FALSE;

		Invalidate();
		return TRUE;
	}
	return CPropertySheet::OnQueryNewPalette();
}

void CBitmapPropSheet::OnPaletteChanged(CWnd* pFocusWnd) 
{
	CPalette * pPal = m_bmpBackground.GetPalette();
	if( pPal != 0 && GetSafeHwnd() != 0 && pFocusWnd != this && ! IsChild(pFocusWnd) ) {
		CClientDC dc(this);
		CPalette * pOldPalette = dc.SelectPalette(pPal, TRUE);
		UINT nChanged = dc.RealizePalette();
		dc.SelectPalette(pOldPalette, TRUE);

		if( nChanged )
			Invalidate();
	} else
		CPropertySheet::OnPaletteChanged(pFocusWnd);
}

HBRUSH CBitmapPropSheet::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	if(m_bmpBackground.GetPixelPtr() != 0) {
		switch(nCtlColor) {
			case CTLCOLOR_STATIC:
			case CTLCOLOR_BTN:
				// let static controls shine through
				pDC->SetBkMode(TRANSPARENT);
				return HBRUSH(m_HollowBrush);

			default:
				break;
		}
	}
	
	// if we reach that line, we haven't set a brush so far
	return CPropertySheet::OnCtlColor(pDC, pWnd, nCtlColor);
}

⌨️ 快捷键说明

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