在vs2019中创建新项目,选择Windows桌面应用程序模板(C++)
要求设计一个程序完成对时钟的模拟,时针、分针、秒针,秒针走完一圈后分针走一格,从0点0分0秒开始计时
#include <windows.h>
#include <tchar.h>
#include <math.h>
typedef struct Time
{
int hour;
int min;
int sec;
}TimeStructure;
BOOLEAN InitWindowClass(HINSTANCE hInstance, int nCmdShow);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void AdjustTime(TimeStructure* x);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
if (!InitWindowClass(hInstance, nCmdShow))
{
MessageBox(NULL, L"创建窗口失败!", _T("创建窗口"), NULL);
return 1;
}
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
PAINTSTRUCT ps;
HBRUSH hBrush;
HPEN hPen;
RECT clientR