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

📄 ddbutton.h

📁 赤壁之战的游戏源代码
💻 H
字号:
/////////////////////////
// 	DDButton.h		:	v0010
//	Written by 	:	Li	Haijun
//	Compiler	:	Microsoft Visual C++ 4.2
//	v0010		:	Oct.25.1996
/////////////////////////

/////////////////////////////////////////////////////////////////////////////
// CDButton class
#ifndef __DDBUTTON_H__
#define __DDBUTTON_H__

#include	"stdafx.h"
#include	"ddapi.h"
#include	"marco.h"

/////////////////////////////////////////
// to test whether a button is clicked
/////////////////////////////////////////
BOOL	LeftButtonDownOnButton(int xPos, int yPos);
// to test whether cursor is on current button when left button up
BOOL	LeftButtonUpOnButton(int xPos, int yPos);
// to test whether cursor is moved on a button
BOOL	MouseMoveOnButton(int xPos, int yPos);
/////////////////////////////////////////
// to set all button's state when change the command state
void	FACE_SetAllButtonState(int state);
// to restore all button's state when change the command state
void	FACE_RestoreAllButtonState();
// to set pause button active when set program state to pause
void	FACE_SetPauseButtonActive();
//	to release all bitmap when you exit this game
void	FACE_DeleteAllButton();
///////////////////////////////////////////////////////////////////////
// class declear
class CDDButton
{
	//member
private:
// the surface that this button is load on
	CDDSurface	m_BitmapSurface;
// Attributes
private:

	int		m_nFileNameId;	// name of this DIB file name
	char	m_PromptString[256];	// to show this string then you move mouse on this button
	SIZE	m_szOneBitmap;	// the size of one state of a bitmap button
	RECT	m_rTotal;		// there is four state of a bitmap button in a DIB file	
	RECT	m_rCurrent;		// the rectangle of current state bitmap button
	int		m_dwX, m_dwY;		// the position of a bitmap button on the surface

	int  m_nID;		// button id
	int	 m_nPreviousState;	// to store the previous button state
	int  m_nPart;	// how many part should the dib image file be devided
					// that means,how many state image in one dib file

	BOOL m_bEnableSound;	// true for enable sound effects

public:
		int  m_nState;	// button state,0-up,1-down,2-disable,3-focus

public:
	CDDButton();		//constructor
	~CDDButton();		//destructor

// Initialize the data member
public:	
	// initializes
	BOOL PreLoad(int FilenameId, int x, int y, int OneBitmapWidth=0, int OneBitmapHeight=0, int ColorKeyFlag = FALSE ); //, int part);	// always used in the contructor of its parent
	void Release(void);
	void LoadSound(LPCTSTR lpszDown, LPCTSTR lpszUp, LPCTSTR lpszDisable);	// for playing sound

	// attributes
	// set the ID of this bitmap button
	void SetID(int ID);	//to set this button's ID
	// to get the ID of this bitmap button
	int  GetID(void);
	// set the state of this bitmap button
	void SetState(int state);	// let button up or down or ...
	// get the state of this bitmap button
	int GetState(){return m_nState;}	// get button state
	// to get the previous state of this bitmap button
	int GetPreState(){return m_nPreviousState;}
	// to get the size of this button
	SIZE GetSize(){return m_szOneBitmap;}	
	// to set the position of left top corner of this button to show
	void SetPosition(int PosX, int PosY);
	/////////////////////////////////////////
	// to set all button's state when change the command state
	void	SetAllButtonState(int state);
	// to restore all button's state when change the command state
	void	RestoreAllButtonState();
	// to get the name of this button's bitmap file
	int GetNameId(){return m_nFileNameId;}	// get button name id
	// to set the prompt string
	void	SetPromptString( LPCTSTR lpszPromptString );
	// to cat the four data (钱,粮,木,铁) to the prompt string
	void	CatPromptString( int Money, int Food, int Wood, int Iron );
	// to cat the 所需计谋 value to the prompt string
	void	CatJmString( int Jm );
	// to get the prompt string
	char*	GetPromptString( void ){ return m_PromptString; }
	// to show the prompt string
	void	ShowPromptString();
	// to erase the prompt area when mouse move out the command button or mouse-left-button down on the command button
	void CDDButton::ErasePromptRect();
	// operations
	//to test if the given point on this button
	BOOL OnButton( int x, int y);
	//blit the current part of image to the direct surface
	void Show(BOOL flag = TRUE); // flag = TRUE --> to place bitmap to back buffer and updata the front butter
								 //		   FALSE -> only to place bitmap to back buffer
	// to blit this button to back buffer
	void Blit();
	// to update the area of this button from back buffer to front buffer
	void Update();
	// blit the current part of image to back buffer
	void BlitToBackBuffer( );
	// send a message to the message quene
	LRESULT	SendAMessage( int lParam = 0 );
	// erase the rectangle of this bitmap button used (with black color)
};

class	CDDButtonUnit
{
	// Data member
	public:
		class CDDButton * m_pButton[MAX_BUTTONINUNIT];

	public:
		//construct
		CDDButtonUnit();
		//to set state to all members that in this button unit
		void	SetMemberState( int state );
		// to show this button unit
		void Show(BOOL flag = TRUE); // flag = TRUE --> to place bitmap to back buffer and updata the front butter
									 //		   FALSE -> only to place bitmap to back buffer
		// to blit every button of this button unit to back buffer
		void Blit();
		// to update the area of every one button in this button unit from back buffer to front buffer
		void Update();
		// to release all button in this button-unit
		void	Release();
};
/////////////////////////////////////////////////////////////////////////////
#endif

⌨️ 快捷键说明

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