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

📄 cstatusbar.cpp

📁 俄罗斯方块3D 程序+源码俄罗斯方块3D(程序+源码
💻 CPP
字号:
#include "CStatusBar.h"

#define ID_STATUSBAR 0xff

const char *state[6] = {
	"准备下落",
	"下落中",
	"清除满行",
	"整理方块",
	"游戏暂停",
	"游戏结束",
};


CStatusBar::CStatusBar()
{

}

CStatusBar::~CStatusBar()
{

}

bool CStatusBar::Init( HWND hwnd, HINSTANCE hInstance )
{
	if ( m_hwnd == NULL )
	{
		m_hwnd = CreateStatusWindow( WS_CHILD | WS_VISIBLE,
								"READY", hwnd, ID_STATUSBAR );

		if ( m_hwnd == NULL ) 
		{
			return false;
		}
		else
		{
			SetParts();
			return true;
		}
	}
	return false;
}

bool CStatusBar::HandleMsg(  HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	return true;
}

void CStatusBar::SetParts()
{
	RECT rc;
	int w;
	int PartWidth[3];		//状态栏四个部分的宽度

	GetWindowRect( m_hwnd, &rc );
	w = ( rc.right - rc.left ) / 3;
	PartWidth[0] = w;
	PartWidth[1] = 2 * w;
	PartWidth[2] = 3 * w;

	SendMessage( m_hwnd, SB_SETPARTS, (WPARAM)3, (LPARAM)(LPINT)PartWidth );
}


void CStatusBar::UpdateStatusBar( int fps )
{
	if ( m_hwnd != NULL )
	{
		char sz[16];
		wsprintf( sz, "fps:%d", fps );
		SendMessage( m_hwnd, SB_SETTEXT, 2, (LPARAM)(LPSTR)sz );
	}
}


void CStatusBar::UpdateState( int index )
{
	SendMessage( m_hwnd, SB_SETTEXT, 0, (LPARAM)(LPSTR)state[index] );
}


void CStatusBar::UpdateScore( int score )
{
	char sz[32];
	wsprintf( sz, "score:%d", score );
	SendMessage( m_hwnd, SB_SETTEXT, 1, (LPARAM)(LPSTR)sz );
}

⌨️ 快捷键说明

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