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

📄 keyboard.hpp

📁 一个完整的桌面日历程序
💻 HPP
字号:
// ------------------------------------------------------------------------------------------------------------------------------------------------------
// -																																					-
// - File:			keyboard.hpp.																														-
// -																																					-
// - Contents: 		-																																	-
// -																																					-
// - Purpose:  		-																																	-
// -																																					-
// - Remarks:    	-																																	-
// -																																					-
// - Originator: 	Michael Mogensen, MM-IT Consult 2003.																								-
// -																																					-
// - Compiler:		MS Visual C++ ver6.0.																											    -
// -																																					-
// - Period:		00.00.00 - 00.00.00.																											    -
// -																																					-
// - Version:		1.00. 																																-
// -																																					-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Miscellaneous.																																		-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Header(s).																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
#pragma once

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Global(s), Predecleration(s).																														-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
inline const int IsKeyPressed(const int);
inline const int IsKeyPressed(const int, const int);
inline const int IsAlpha(const int);
inline const int IsAlphaPressed();
inline const int IsANSI(const int);
inline const int IsDigit(const int);
inline const int IsDigitPressed();
inline const int IsLetter(const int);
inline const int IsLetterPressed();
inline const int IsSign();

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// - Global(s).																																			-
// ------------------------------------------------------------------------------------------------------------------------------------------------------
inline const int IsKeyPressed(const int iKey)
// Return 1 if this key was pressed when called and 0 if not.
{
	SHORT shKeyState = ::GetAsyncKeyState(iKey);
	return(shKeyState & 0x8000);
}

inline const int IsKeyPressed(const int iKey_Low, const int iKey_High)
// Return 1 if this key-range was pressed when called and 0 if not.
{
	int iState = 0;
	for(register int iKey = iKey_Low; iKey <= iKey_High && !iState; iKey++)
		iState = ::GetAsyncKeyState(iKey) & 0x8000;
	return iState;
}

inline const int IsAlpha(const int iKey)
// Return 1 if this key is a alpha-key and 0 if not.
{ return(IsDigit(iKey) || IsLetter(iKey)); }

inline const int IsAlphaPressed()
// Return 1 if alphanumeric key was pressed when called and 0 if not.
{
	return(
		IsKeyPressed(0x41, 0x5A) || // Between 'a' and 'z' or 'A' and 'Z'.
		IsKeyPressed(0x30, 0x39)); // Between '0' and '9'.
}

inline const int IsANSI(const int iKey)
// Return 1 if ANSI key was pressed when called and 0 if not.
{ return(iKey >= 0x00 && iKey <= 0xFF); }

inline const int IsDigit(const int iKey)
// Return 1 if this key is a digit-key and 0 if not.
{ return(iKey >= 0x30 && iKey <= 0x39); }

inline const int IsDigitPressed()
// Return 1 if digit-key was pressed when called and 0 if not.
{
	return(IsKeyPressed(0x30, 0x39)); // Between '0' and '9'.
}

inline const int IsLetter(const int iKey)
// Return 1 if this key is a letter-key and 0 if not.
{ return((iKey >= 0x41 && iKey <= 0x5A) || (iKey >= 0x61 && iKey <= 0x7A)); }

inline const int IsLetterPressed()
// Return 1 if letter-key was pressed when called and 0 if not.
{
	return(IsKeyPressed(0x41, 0x5A)); // Between 'a' and 'z' or 'A' and 'Z'.
}

inline const int IsSign(const int iKey)
// Return 1 if this key is a sign-key and 0 if not.
{ return((iKey >= 0x20 && iKey >= 0x7E && !IsLetter(iKey) && !IsDigit(iKey)) || iKey >= 0xA0); }

// ------------------------------------------------------------------------------------------------------------------------------------------------------
// -																																				  	-
// ------------------------------------------------------------------------------------------------------------------------------------------------------

// 0. Data. (alphabetical).
// 1. Object. (alphabetical).
// 2. Event's. (alphabetical).
// 3.0. Menu choice. (menu order).
// 3.1. Menu choice, enablers. (menu order).
// 4. Slaves. (alphabetical).
// 5. Other. (alphabetical).

⌨️ 快捷键说明

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