chronometre.cpp

来自「code source for a chronometer which disp」· C++ 代码 · 共 46 行

CPP
46
字号

#define _WIN32_WINNT  0x0500 // Windows 2000 et sup閞ieur
#include <windows.h>

// D閒inition des identificateurs:
#define WM_SHELLNOTIFY	WM_APP +1
#define ID_TRAY			1000
#define ID_QUIT			1001
#define ID_SHOW			1002
#define ID_HIDE			1003
#define ID_START		1004
#define ID_PAUSE		1005
#define ID_CONTINUE		1006
#define ID_STOP			1007
#define ID_LIMIT		1008
#define ID_RAZ			1009

#define ID_SECONDES		2001
#define ID_MINUTES		2002
#define ID_HEURES		2003

// Variables globales:
HHOOK hHook; // Handle du hook clavier
HWND hWnd;   // HWND de notre fen阾re transparente
DWORD limite,hourslimit,minuteslimit,secondslimit;// Pour m閙oriser la limite
BOOL isrunning,paused,limited;// Diff閞ents flags

/*******************************  Fonction de gestion du hook  ****************************/
LRESULT CALLBACK HookProc ( int nCode, WPARAM wParam, LPARAM lParam)
{
	if ((nCode == HC_ACTION) && (wParam == WM_KEYDOWN))
	{
		// Obtenir pointeur sur structure KBDLLHOOKSTRUCT:
		KBDLLHOOKSTRUCT* hookstruct = ((KBDLLHOOKSTRUCT*)lParam);  
		// S'assurer que l'une des touches Windows est enfonc閑:
		if((GetKeyState(VK_LWIN) & 0x8000) || (GetKeyState(VK_RWIN) & 0x8000))
		{
			switch(hookstruct->vkCode)
			{
			case 'A': 
				// Envoi du message permettant d'afficher ou cacher le chronom鑤re:
				if(!IsWindowVisible(hWnd))PostMessage(hWnd,WM_COMMAND,MAKEWPARAM(ID_SHOW,0),0);
				else PostMessage(hWnd,WM_COMMAND,MAKEWPARAM(ID_HIDE,0),0);
				return 1;
			case 'Z': 
				// Envoi du message de remise 

⌨️ 快捷键说明

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