📄 myclock.h
字号:
#ifndef __MYCLOCK
#define __MYCLOCK
#include "stdio.h"
class MYCLOCK
{
public:
HWND hWnd;
HDC hDC;
int iNum;
int iNumShow;
int iElapse;
int iIsActive;
MYCLOCK()
{
iNum=0;
iIsActive=0;
iNumShow=0;
iElapse=100;
}
~MYCLOCK()
{
Destroy();
}
void Begin(HWND hw,int elapse,int timetotal)
{
if(iIsActive)
return;//已经启动了,直接返回
hWnd=hw;
iElapse=elapse;
SetTimer(hWnd,1,iElapse,NULL);
iNum=1000/iElapse;
iNumShow=timetotal;
iIsActive=1;
}
void Destroy()
{
if(iIsActive)
{
iIsActive=0;
KillTimer(hWnd,1);
}
}
void SetDC(HDC h)
{
hDC=h;
}
void Show()
{
char temp[20]={0};
sprintf(temp,"TIME: %d ",iNumShow);
TextOut(hDC,450,20,temp,strlen(temp));
}
int Dec()
{
iNum--;
if(iNum<=0)
{
//过了一秒
iNum=1000/iElapse;
iNumShow--;
if(iNumShow<=0)
{
iNumShow=0;
Destroy();
return 1;
}
}
return 0;
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -