?? myclock.h
字號:
//clock 1.0
#ifndef __MYCLOCK
#define __MYCLOCK
#include "stdio.h"
class MYCLOCK
{
public:
MYCLOCK()
{
iNum=0;
iIsActive=0;
iNumShow=0;
iElapse=100;
ishow=0;
}
~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 ReStart(int timetotal)
{
iNumShow=timetotal;
iNum=1000/iElapse;
ishow=1;
}
//////////////////////////// 顯示部分
void SetDevice(HDC h)
{
hDC=h;
}
void Show(int x,int y)
{
char temp[20]={0};
if(!ishow)
return;
sprintf(temp,"TIME: %d ",iNumShow);
TextOut(hDC,x, y, temp,strlen(temp));
}
//計數,但不銷毀
int DecCount()
{
iNum--;
if(iNum==0)
{
//過了一秒
iNum=1000/iElapse;
iNumShow--;
if(iNumShow<=0)
{
//不銷毀
return 1;
}
}
return 0;
}
int Dec()
{
iNum--;
if(iNum<=0)
{
//過了一秒
iNum=1000/iElapse;
iNumShow--;
if(iNumShow<=0)
{
iNumShow=0;
Destroy();
return 1;
}
}
return 0;
}
//
void SetShow(int i)
{
ishow=i;
}
public:
HWND hWnd;
HDC hDC;
int iNum;
int iNumShow;
int iElapse;
int iIsActive;
int ishow;
};
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -