▍1. 时钟 走动
一个应用线程实现指针运动的指针时钟程序。程序应用绘制函数时钟面板,根据线程休眠时间间隔,每隔1000ms进行一次重绘。程序通过获取系统时间函数并加以计算个指针位置,再利用绘制函数将其绘制在面板上,通过设置指针长度及颜色,实现时针、分针、秒针的区分。次外,通过获取窗体大小,设置圆面圆心坐标及半径,可依据窗口大小动态划分圆面大小,并动态绘制刻度点位置。(A pointer clock program that uses threads to implement pointer movement. The program draws the function clock panel and redraws it every 1000ms according to the interval of thread dormancy. The program obtains the system time function and calculates the position of a pointer, then draws it on the panel by drawing function. By setting the length and color of the pointer, it achieves the distinction of clockwise, minute and secondhand. Secondly, by acquiring the size of the form and setting the coordinates and radius of the circle center, the circle size can be dynamically divided according to the size of the window, and the location of the scale points can be dynamically plotted.)