罗盘时钟代码怎么写(电脑桌面罗盘时钟源代码怎么写)

本文目录
- 电脑桌面罗盘时钟源代码怎么写
- c++时钟程序代码
- vb制作表盘时钟 并含有数字 要代码
- 用VB编写一个钟表的代码是
- C#中怎么制作时钟
- c语言时钟代码
- 用易语言怎样编时钟
- C语言 电子时钟源代码程序 带图 谢谢 最好有注释
- 时钟代码
电脑桌面罗盘时钟源代码怎么写
import java.awt.*;
导入Java.awt.event.*;
import javax.swing.*;
import java.lang.*;
import java.util.*;
publicclassrunabletestextendsjframeimplementsrunnable {
JPanel pnlMain; //定义变量
Jlabel Lbl时间; //定义变量
thread thd时间; //定义变量
日期数据显示
c++时钟程序代码
用c++的话还是弄成类比较好的,下面是我的解决方法:
#include 《ctime》
#include 《cstring》
class Timer
{
private:
static const int size = 50;
std::time_t time;
std::tm localTime;
char Ascll;
char flag;
public:
Timer()
{
std::time(&time);
flag = 0;
}
~Timer() {}
const char* printTime()
{
if(!flag)
{
localTime = *std::localtime(&time);
std::strcpy(Ascll, std::asctime(&localTime));
}
flag++;
return Ascll;
}
double timeDiff(Timer* time2) const
{
return difftime(time, time2 -》 time);
}
} ;
int main()
{
Timer t1;
for(int i = 0; i 《 10000; i++ )
{
cout 《《 i;
}
Timer t2;
std::cout 《《 t1.printTime() 《《 std::endl;
std::cout 《《 t2.printTime() 《《 std::endl;
std::cout 《《 t2.timeDiff(&t1) 《《 std::endl;
return 0;
}
vb制作表盘时钟 并含有数字 要代码
把以下代码保存成一个后缀名为.FRM的文件中,再用VB打开即可。
=====================
VERSION 5.00
Begin VB.Form frmClock
BorderStyle = 1 ’Fixed Single
Caption = "钟 by YTY"
ClientHeight = 2550
ClientLeft = 45
ClientTop = 330
ClientWidth = 2505
DrawWidth = 2
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 ’False
MinButton = 0 ’False
ScaleHeight = 2550
ScaleLeft = -1000
ScaleMode = 0 ’User
ScaleTop = -1000
ScaleWidth = 2505
StartUpPosition = 3 ’窗口缺省
Begin VB.Timer Timer1
Interval = 1000
Left = 120
Top = 2280
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 11
Left = 0
TabIndex = 12
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 10
Left = 0
TabIndex = 11
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 9
Left = 0
TabIndex = 10
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 8
Left = 0
TabIndex = 9
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 7
Left = 0
TabIndex = 8
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 6
Left = 0
TabIndex = 7
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 5
Left = 0
TabIndex = 6
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 4
Left = 0
TabIndex = 5
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 3
Left = 0
TabIndex = 4
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 2
Left = 0
TabIndex = 3
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 1
Left = 0
TabIndex = 2
Top = 0
Width = 375
End
Begin VB.Label Label2
Caption = "Label2"
Height = 375
Index = 0
Left = 960
TabIndex = 1
Top = 120
Width = 375
End
Begin VB.Label Label1
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 0
Weight = 400
Underline = 0 ’False
Italic = 0 ’False
Strikethrough = 0 ’False
EndProperty
Height = 615
Left = 0
TabIndex = 0
Top = 1800
Width = 2655
End
End
Attribute VB_Name = "frmClock"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim h As Integer, m As Integer, s As Integer, t
Const pi As Double = 3.14159265358979
Private Sub Form_Load()
Timer1.Interval = 1000
Me.ScaleLeft = -1000
Me.ScaleTop = -1000
For i = 0 To 11
Label2(i).AutoSize = True
Label2(i).Caption = i + 1
Label2(i).Left = 700 * Cos((i * 30 - 60) * pi / 180) - 80
Label2(i).Top = 700 * Sin((i * 30 - 60) * pi / 180) - 100
Next
End Sub
Private Sub Label1_Click()
t = InputBox("请输入时间")
If IsDate(t) = True Then
Label1.Caption = t
Timer1.Enabled = False
Refresh
For i = 1 To 60
PSet (600 * Cos(i * 6 * pi / 180), 600 * Sin(i * 6 * pi / 180)), vbBlack
Next
h = Format(t, "h")
m = Format(t, "n")
s = Format(t, "s")
Line (0, 0)-(300 * Cos(h * pi / 6 - pi / 2), 300 * Sin(h * pi / 6 - pi / 2)), vbRed
Line (0, 0)-(500 * Cos(m * pi / 30 - pi / 2), 500 * Sin(m * pi / 30 - pi / 2)), vbBlue
Line (0, 0)-(600 * Cos(s * pi / 30 - pi / 2), 600 * Sin(s * pi / 30 - pi / 2)), vbGreen
End If
End Sub
Private Sub Timer1_Timer()
Refresh
For i = 1 To 60
PSet (600 * Cos(i * 6 * pi / 180), 600 * Sin(i * 6 * pi / 180)), vbBlack
Next
Label1.Caption = Now
h = Format(Now, "h")
m = Format(Now, "n")
s = Format(Now, "s")
Line (0, 0)-(300 * Cos(h * pi / 6 - pi / 2), 300 * Sin(h * pi / 6 - pi / 2)), vbRed
Line (0, 0)-(500 * Cos(m * pi / 30 - pi / 2), 500 * Sin(m * pi / 30 - pi / 2)), vbBlue
Line (0, 0)-(600 * Cos(s * pi / 30 - pi / 2), 600 * Sin(s * pi / 30 - pi / 2)), vbGreen
End Sub
用VB编写一个钟表的代码是
Private Sub Command1_Click()
End Sub
Private Sub Check1_Click()
If Check1.Value = 0 Then
Timer1.Enabled = False
Check1.Caption = "钟表已停"
Else
Timer1.Enabled = True
Check1.Caption = "钟表正在走动"
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 0 Then
Label1.Visible = False
Check2.Caption = "钟表已关闭"
Else
Label1.Visible = True
Check2.Caption = "钟表已打开"
End If
End Sub
Private Sub Form_Load()
Label1.Caption = Time
End Sub
Private Sub HScroll1_Change()
Label1.ForeColor = RGB(Int(HScroll3.Value), Int(HScroll2.Value), Int(HScroll1.Value))
End Sub
Private Sub HScroll2_Change()
Label1.ForeColor = RGB(Int(HScroll3.Value), Int(HScroll2.Value), Int(HScroll1.Value))
End Sub
Private Sub HScroll3_Change()
Label1.ForeColor = RGB(Int(HScroll3.Value), Int(HScroll2.Value), Int(HScroll1.Value))
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
Private Sub Timer2_Timer()
Dim i, j, k As Integer
i = Int(Rnd() * 225 + 1) + 0
j = Int(Rnd() * 225 + 1) + 0
k = Int(Rnd() * 225 + 1) + 0
Label1.BackColor = RGB(i, j, k)
End Sub
C#中怎么制作时钟
下面是简易时钟的实现:
简易时钟的界面只有数字和指针。这里肯定要用到Timer控件啦,每秒钟刷新界面,这样的话就要求双缓冲。
第一步:添加用户控件,命名为myClock。
第二步:构造函数实例化控件和做双缓冲处理。
public myClock()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
myTimer = new Timer();
myTimer.Interval = 1000;
myTimer.Enabled = true;
myTimer.Tick += new EventHandler(myTimer_Tick);
}
第三步:Paint重绘事件
private void myClock_Paint(object sender, PaintEventArgs e)
{
Graphics gra = e.Graphics;//创建一个画板
/*********************************/
//表盘上的指针
using (SolidBrush sb = new SolidBrush(Color.Blue))
{
Font f = new Font("宋体", 18);
gra.DrawString("1", f, sb, 195, 20);
gra.DrawString("2", f, sb, 235, 60);
gra.DrawString("3", f, sb, 250, 123);
gra.DrawString("4", f, sb, 235, 183);
gra.DrawString("5", f, sb, 195, 225);
gra.DrawString("6", f, sb, 125, 245);
gra.DrawString("7", f, sb, 55, 225);
gra.DrawString("8", f, sb, 15, 183);
gra.DrawString("9", f, sb, 0, 123);
gra.DrawString("10", f, sb, 15, 60);
gra.DrawString("11", f, sb, 55, 20);
gra.DrawString("12", f, sb, 125, 0);
}
//表盘的框架:黑色,宽度是3
using (Pen p = new Pen(Color.Black, 3))
{
p.DashStyle = DashStyle.Solid;
gra.DrawEllipse(p, 0, 0, 270, 270);
}
//表盘上的三个指针i,j,k;
using (Pen p1 = new Pen(Color.Red))
{
using (Pen p2 = new Pen(Color.Blue))
{
using (Pen p3 = new Pen(Color.Yellow))
{
gra.DrawPie(p3, 20, 20, 230, 230, k, 0.1f);//秒
gra.DrawPie(p2, 30, 30, 210, 210, j, 0.1f);//分
gra.DrawPie(p1, 40, 40, 190, 190, i, 0.1f);//小时
}
}
}
//指针旋转的代码
if (i 《 360)
{
i += 6;
if (i == 270)
{
if (j 《= 360)
{
j += 6;
if (j == 270)
{
if (k 《= 360)
{
k += 30;
}
else
{
k = 30;
}
}
}
else
{
j = 6;
}
}
}
else
{
i = 6;
}
}
贴出所有代码:
//控件名:myClock
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace myControl
{
public partial class myClock : UserControl
{
public myClock()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
myTimer = new Timer();
myTimer.Interval = 1000;
myTimer.Enabled = true;
myTimer.Tick += new EventHandler(myTimer_Tick);
}
private Timer myTimer;
//定义三个变量
float i = 270, j = 270, k = 270;
private void myTimer_Tick(object sender, EventArgs e)
{
this.Invalidate();
}
private void myClock_Paint(object sender, PaintEventArgs e)
{
Graphics gra = e.Graphics;//创建一个画板
/*********************************/
//表盘上的指针
using (SolidBrush sb = new SolidBrush(Color.Blue))
{
Font f = new Font("宋体", 18);
gra.DrawString("1", f, sb, 195, 20);
gra.DrawString("2", f, sb, 235, 60);
gra.DrawString("3", f, sb, 250, 123);
gra.DrawString("4", f, sb, 235, 183);
gra.DrawString("5", f, sb, 195, 225);
gra.DrawString("6", f, sb, 125, 245);
gra.DrawString("7", f, sb, 55, 225);
gra.DrawString("8", f, sb, 15, 183);
gra.DrawString("9", f, sb, 0, 123);
gra.DrawString("10", f, sb, 15, 60);
gra.DrawString("11", f, sb, 55, 20);
gra.DrawString("12", f, sb, 125, 0);
}
//表盘的框架:黑色,宽度是3
using (Pen p = new Pen(Color.Black, 3))
{
p.DashStyle = DashStyle.Solid;
gra.DrawEllipse(p, 0, 0, 270, 270);
}
//表盘上的三个指针i,j,k;
using (Pen p1 = new Pen(Color.Red))
{
using (Pen p2 = new Pen(Color.Blue))
{
using (Pen p3 = new Pen(Color.Yellow))
{
gra.DrawPie(p3, 20, 20, 230, 230, k, 0.1f);//秒
gra.DrawPie(p2, 30, 30, 210, 210, j, 0.1f);//分
gra.DrawPie(p1, 40, 40, 190, 190, i, 0.1f);//小时
}
}
}
//指针旋转的代码
if (i 《 360)
{
i += 6;
if (i == 270)
{
if (j 《= 360)
{
j += 6;
if (j == 270)
{
if (k 《= 360)
{
k += 30;
}
else
{
k = 30;
}
}
}
else
{
j = 6;
}
}
}
else
{
i = 6;
}
}
}
}
c语言时钟代码
#include《graphics.h》 /* 引入graphic.h */
#include《math.h》 /* 引入math.h */
#include《dos.h》 /* 引入dos.h */
#define pi 3.1415926 /*定义pi=3.14159*/
#define X(a,b,c) x=a*cos(b*c*pi/180-pi/2)+300;
#define Y(a,b,c) y=a*sin(b*c*pi/180-pi/2)+240;
#define d(a,b,c) X(a,b,c);Y(a,b,c);line(300,240,x,y) /*定义……*/
void init() /*初始化程序*/
{int i,l,x1,x2,y1,y2; /*定义……*/
setbkcolor(1); /*设置颜色*/
circle(300,240,200); /*作园*/
circle(300,240,205);
circle(300,240,5);
for(i=0;i《60;i++) /*循环(算时间)*/
{if(i%5==0) l=15;
else l=5;
x1=200*cos(i*6*pi/180)+300;
y1=200*sin(i*6*pi/180)+240;
x2=(200-l)*cos(i*6*pi/180)+300;
y2=(200-l)*sin(i*6*pi/180)+240;
line(x1,y1,x2,y2);
}
}
main()
{
int x,y;
int gd=VGA,gm=2;
unsigned char h,m,s; /*定义*/
struct time t;
initgraph(&gd,&gm,"d:\\tc");
init();
setwritemode(1);
gettime(t);
h=t.ti_hour;
m=t.ti_min;
s=t.ti_sec; /*定义时分秒*/
setcolor(7); /*设置颜色*/
d(150,h,30);
setcolor(14);
d(170,m,6);
setcolor(4);
d(190,s,6);
while(!kbhit()) /*获取键盘相应*/
{while(t.ti_sec==s)
gettime(t); /*C语言中得到时间的函数*/
sound(400); /*计算时间……*/
delay(70);
sound(200);
delay(30);
nosound();
setcolor(4);
d(190,s,6);
s=t.ti_sec;
d(190,s,6);
if (t.ti_min!=m)
{
setcolor(14);
d(170,m,6);
m=t.ti_min;
d(170,m,6);
}
if (t.ti_hour!=h)
{ setcolor(7);
d(150,h,30);
h=t.ti_hour;
d(150,h,30);
sound(1000);
delay(240);
nosound();
delay(140);
sound(2000);
delay(240);
nosound();
}
}
getch(); /*设置空格后退出*/
closegraph();
}
具体的。。就是套用用几个函数算时间。。
不要对这种很长的东西害怕,其实大部分都是在画这个钟~
加油哦~
用易语言怎样编时钟
很简单的,,在窗口放一个 时钟组件和标签组件, 把时钟的时钟周期属性设置为1000。(1000=1秒 以此类推),然后双击时钟组件,在时钟的时钟周期写代码:
标签1.标题 = 到文本 (取年份 (取现行时间 ())) + “-” + 到文本 (取月份 (取现行时间 ())) + “-” + 到文本 (取日 (取现行时间 ())) + “ ” + 到文本 (取小时 (取现行时间 ())) + “:” + 到文本 (取分钟 (取现行时间 ())) + “:” + 到文本 (取秒 (取现行时间 ()))
运行结果是 xxxx-xx-xx xx:xx:xx 格式的时间。
或者写代码:
标签1.标题 = 到文本 (取现行时间 ())
运行结果是:xxxx年XX月XX日XX时XX分XX秒,这种格式的时间
C语言 电子时钟源代码程序 带图 谢谢 最好有注释
#include 《stdio.h》
#include 《time.h》
#include"stdlib.h"
#include "windows.h"
void main ()
{
while(1)
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "\007The current date/time is:\n %s", asctime (timeinfo) );
Sleep(1000);
system("cls");
}
}
时钟代码
回答:lillianrock
新手
6月21日 14:57 地址 ttp://www.aswis.net/100000/clock/clock1.swf
代码 BR》《EMBED src="时钟地址" type="application/x-shockwave- fash" width="180" height="180"》《/EMBED》《BR》
把以上一个地址复制--粘贴到地址栏中,然后按回车观看效果,看完一个,改变"clock1"中的数字,140个时钟,找到自己喜欢的了,把地址覆盖粘贴在上面代码中"时钟地址"上,然后把整理好的代码粘贴在一个新建立的模块中就好了!
***隐藏网址***

更多文章:
跷二郎腿太低好吗?想要通过贴墙站改正二郎腿影响的话,有哪些要点需要注意
2026年10月11日 05:10
易语言点击js按钮(易语言网页填表怎样点击链接为“javascript:void(0)“的按钮)
2026年10月11日 03:00
compare with造句(用compared with和compared to造句)
2026年10月10日 23:30
tensorflow与keras对应版本(为什么tensorflow2.8没有keras)
2026年10月10日 22:10
maven仓库jar网站(如何在maven仓库中添加jar包)
2026年10月10日 19:50







