| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1313 人关注过本帖
标题:HELP!谁会做时钟?
只看楼主 加入收藏
goggle
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-2-24
收藏
 问题点数:0 回复次数:13 
HELP!谁会做时钟?
我需要做1个有时针、分针、秒针的时钟,这是会考作业之一
请各位侠客帮帮忙~!
搜索更多相关主题的帖子: 时钟 HELP 
2005-03-10 22:06
chen__han1
Rank: 1
等 级:新手上路
帖 子:256
专家分:0
注 册:2004-9-16
收藏
得分:0 
记得在哪看过,去找找.明天给你代码.

路漫漫其修远兮 吾将上下而求索!
2005-03-11 05:10
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
这个很简单呀,看看我做的
图片附件: 游客没有浏览图片的权限,请 登录注册

天津网站建设 http://www./
2005-03-11 09:28
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
我上传一个简易版的源码(去掉了闹铃、半透明、加入SysTray等功能的,其中有一个编

源码如下: '//////////////////////////////// ' '闹钟程序,作者:griefforyou ' '//////////////////////////////// Option Explicit

Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Private Type POINTAPI x As Long y As Long End Type

Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2

Private OldX As Integer Private OldY As Integer Private MouseDown As Boolean

Const PI = 3.1415926 Dim BaseX As Integer, BaseY As Integer, R As Integer Dim r1 As Integer, r2 As Integer Dim Out As Boolean

Private Sub Form_Load() Dim mRGN As Long Dim rtn As Long SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE mRGN = CreateEllipticRgn(1, 1, Me.Width / Screen.TwipsPerPixelX, Me.Height / Screen.TwipsPerPixelY) SetWindowRgn Me.hwnd, mRGN, True DeleteObject mRGN Label1.Move 0, 0, Me.Width, Me.Height lblTime = Time

BaseX = 885 BaseY = 885 R = 685 r1 = 160 r2 = 80 drawclock End Sub

Private Sub drawclock() Dim Second As Integer Dim Minute As Integer Dim Hours As Integer

Second = DatePart("s", Time) Minute = DatePart("n", Time) Hours = DatePart("h", Time) If Hours > 12 Then Hours = Hours - 12 End If DrawLine BaseX - r1 * Sin(Second * PI / 30), BaseY + r1 * Cos(Second * PI / 30), BaseX + R * Sin(Second * PI / 30), BaseY - R * Cos(Second * PI / 30), 0 DrawLine BaseX - r2 * Sin(Minute * PI / 30), BaseY + r2 * Cos(Minute * PI / 30), BaseX + (R - 200) * Sin(Minute * PI / 30), BaseY - (R - 200) * Cos(Minute * PI / 30), 1 DrawLine BaseX - r2 * Sin((Hours + Minute / 60) * PI / 6), BaseY + r2 * Cos((Hours + Minute / 60) * PI / 6), BaseX + (R - 300) * Sin((Hours + Minute / 60) * PI / 6), BaseY - (R - 300) * Cos((Hours + Minute / 60) * PI / 6), 2 End Sub

Private Sub DrawLine(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Flag As Integer) Select Case Flag Case 0 Line1.x1 = x1 Line1.x2 = x2 Line1.y1 = y1 Line1.y2 = y2 Case 1 Line2.x1 = x1 Line2.x2 = x2 Line2.y1 = y1 Line2.y2 = y2 Case 2 Line3.x1 = x1 Line3.x2 = x2 Line3.y1 = y1 Line3.y2 = y2 End Select End Sub

Private Sub mnuExit_Click() Unload Me End Sub

Private Sub Timer1_Timer() On Error Resume Next Dim NowTime As Date

NowTime = Time

lblTime.Caption = NowTime Label1.ToolTipText = "当前时间:" & Format(Date, "yyyy年mm月dd日") & " " & Time NowTime = Now

Call drawclock End Sub

Private Sub label1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) SubMouseUp End Sub

Private Sub label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) SubMouseDown Button, x, y End Sub

Private Sub label1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) SubMouseMove Button, x, y Out = False End Sub

Private Sub SubMouseMove(Button As Integer, x As Single, y As Single) If Not MouseDown Or Button <> 1 Then Exit Sub Me.Move Me.Left + (x - OldX), Me.Top + (y - OldY) End Sub

Private Sub SubMouseDown(Button As Integer, x As Single, y As Single) If Button = 1 Then MouseDown = True OldX = x OldY = y Else PopupMenu mnuPopup End If End Sub

Private Sub SubMouseUp() MouseDown = False End Sub 打包下载工程窗体源文件:

XLAoUje3.rar (42.71 KB) HELP!谁会做时钟?

编译过程序不是非常完善,不过已经有了一些基本功能。

[此贴子已经被作者于2005-3-11 9:49:15编辑过]


天津网站建设 http://www./
2005-03-11 09:46
时空之蕊
Rank: 2
等 级:新手上路
威 望:3
帖 子:691
专家分:0
注 册:2004-10-31
收藏
得分:0 
哈哈哈,收下了

我渴望掌控时空的核心——用最先进的技术,打造无比美丽的世界!
2005-03-11 11:03
glober609
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2005-3-7
收藏
得分:0 
我也收下慢慢研究!
2005-03-11 11:22
温柔舞刀
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-3-13
收藏
得分:0 
有点漂亮
2005-03-13 20:50
chen__han1
Rank: 1
等 级:新手上路
帖 子:256
专家分:0
注 册:2004-9-16
收藏
得分:0 
的确精美,我只能做一个很难看的,不过还能转的出来,就不写上了。
哎,我对API还不能理解,griefforyou能不能介绍本学API的书啊!


路漫漫其修远兮 吾将上下而求索!
2005-03-17 01:44
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
得分:0 
我还没看过什么专门写API的书,只是了解了一些常用的API函数的用法。

天津网站建设 http://www./
2005-03-17 21:18
goggle
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-2-24
收藏
得分:0 
谢谢了~
2005-03-21 19:25
快速回复:HELP!谁会做时钟?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017448 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved