资源简介
用c编写的模拟时钟。模拟时钟不用考虑国际化问题,但图形复杂。而且我们还需要一些三角函数知识。
已修正,既有代码亦有效果。exe在release文件夹内。可直接使用。

代码片段和文件信息
#include
#include
#define ID_TIMER 1
#define TWOPI (2 * 3.14159)
LRESULT CALLBACK WndProc (HWND UINT WPARAM LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance HINSTANCE hPrevInstance
PSTR szCmdLine int iCmdShow)
{
static TCHAR szAppName[] = TEXT (“Clock“) ;
HWND hwnd;
MSG msg;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL ;
wndclass.hCursor = LoadCursor (NULL IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockobject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL TEXT (“Program requires Windows NT!“)
szAppName MB_IConerror) ;
return 0 ;
}
hwnd = CreateWindow (szAppName TEXT (“Analog Clock“)
WS_OVERLAPPEDWINDOW
CW_USEDEFAULT CW_USEDEFAULT
CW_USEDEFAULT CW_USEDEFAULT
NULL NULL hInstance NULL) ;
ShowWindow (hwnd iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg NULL 0 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
void SetIsotropic (HDC hdc int cxClient int cyClient)
{
SetMapMode (hdc MM_ISOTROPIC) ;
SetWindowExtEx (hdc 1000 1000 NULL) ;
SetViewportExtEx (hdc cxClient / 2 -cyClient / 2 NULL) ;
SetViewportOrgEx (hdc cxClient / 2 cyClient / 2 NULL) ;
}
void RotatePoint (POINT pt[] int iNum int iAngle)
{
int i ;
POINT ptTemp ;
for (i = 0 ; i < iNum ; i++)
{
ptTemp.x = (int) (pt[i].x * cos (TWOPI * iAngle / 360) +
pt[i].y * sin (TWOPI * iAngle / 360)) ;
ptTemp.y = (int) (pt[i].y * cos (TWOPI * iAngle / 360) -
pt[i].x * sin (TWOPI * iAngle / 360)) ;
pt[i] = ptTemp ;
}
}
void DrawClock (HDC hdc)
{
int iAngle ;
POINT pt[3] ;
for (iAngle = 0 ; iAngle < 360 ; iAngle += 6)
{
pt[0].x = 0 ;
pt[0].y = 900 ;
RotatePoint (pt 1 iAngle) ;
pt[2].x = pt[2].y = iAngle % 5 ? 33 : 100 ;
pt[0].x -= pt[2].x / 2 ;
pt[0].y -= pt[2].y / 2 ;
pt[1].x = pt[0].x + pt[2].x ;
pt[1].y = pt[0].y + pt[2].y ;
Selectobject (hdc GetStockobject (BLACK_BRUSH)) ;
Ellipse (hdc pt[0].x pt[0].y pt[1].x pt[1].y) ;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-08 10:34 Clock\
文件 5513 2013-12-08 10:34 Clock\Clock.c
文件 875 2009-09-25 12:05 Clock\Clock.sln
文件 8192 2009-09-25 12:05 Clock\Clock.suo
文件 5055 2009-09-25 12:05 Clock\Clock.vcproj
目录 0 2013-12-08 10:34 Clock\Debug\
文件 485888 2009-09-25 12:05 Clock\Debug\Clock.exe
目录 0 2013-12-08 10:34 Clock\Release\
文件 64000 2009-09-25 12:05 Clock\Release\Clock.exe
相关资源
- (MFC) 时钟日期程序
- zlib 最新 1.2.8 win32 win64 编译好的dll
- Win32 API大全.chm
- eetop.cn_eetop.cn_hfss15_win32crack
- nginx-rtmp-win32-master.rar
- sunxi-tools-win32-support_f1c100s_32M(32M fl
- ipscan-win32
- ffplay_win32
- cmake-3.7.0-win32-x86.zip官方绿色包
- ffmpeg-3.2-win32-shared.zip
- windows32位系统的ffmpeg
- ffmpeg-2.5.2-win32-shared
- OpenCC-1.0.5-Win32
- Notepad++的Json格式化插件win32和x64两版
- Eclipse64位4.3开普勒版eclipse-standard-ke
- award_bios_editor1.2_win32.zip
- Eclipse64位4.3.2开普勒版eclipse-jee-keple
- ninja(windows 32/64位)
- ffmpeg-4.2.1-win32-dev.zip
- Eclipse64位4.3开普勒版eclipse-jee-kepler-
- Eclipse32位4.3开普勒版eclipse-standard-ke
- pywin32-225-cp38-cp38-win_amd64.whl
- 基于ISE的基本数字时钟工程
- openssl-0.9.8k_WIN32.rar
- chromedriver_win32适用于 72.0.3626.119正式版
- 操作系统程序 WIN32API 进程的控制通信
- Pywin32-222.win-amd64-py3.7
- TimeControl定时提醒小工具源码
- protoc-3.4.0-win32
- 3DxWare-SDK_v2-0-4_win32
评论
共有 条评论