求助:一个时钟问题

Viking_ 2010-02-15 10:09:25
今天看到一个小程序上自带一个时钟(八段LED管类型的),该时钟是由0~9总共10个.bmp图片组成

小弟的问题是:如何让这十个图片显示的当前时间呢?(时间格式是hh:mm:ss)


在这里先谢过大家了,并祝大家新年快乐!
...全文
176 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
pjagz 2010-02-18
  • 打赏
  • 举报
回复
重发图片
subMain 2010-02-18
  • 打赏
  • 举报
回复
引用 9 楼 viking_ 的回复:
引用 8 楼 submain 的回复:你可以先把0~9这十个图片命名为0.bmp, 1.bmp, ... 9.bmp。 然后在时钟的触发控件里写个循环,循环时间里面的每一位(时间格式:HHmmss)再根据每一位的字数,把相应的BMP图片加载到窗口上,所以说窗口上要有八个显示图片的控件(包括两个分号) 例如:当读取到第一个H是1的时候,就加载1.bmp图片,并显示到小时所对应该的控件上

写个循环我倒是能做到,不过要让随时显示当前系统时间,这个我做不到~~~55555


既然能做到,你把能做到的这段代码放到那个“随时”的触发时机里就可以了。
pjagz 2010-02-18
  • 打赏
  • 举报
回复
上面代码的示例图片
重发图片
panqingchuan 2010-02-18
  • 打赏
  • 举报
回复
我觉得在图片上显示当前时间是不可能的,除非你把原图片上的数字去掉,然后再在图片上刷新当前系统时间
pjagz 2010-02-17
  • 打赏
  • 举报
回复
图片可用BMP的格式的
pjagz 2010-02-17
  • 打赏
  • 举报
回复


'示例
Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim BP1 As New Bitmap(100, 24)

Dim dys As String() = {Format(Date.Now, "hh"), Format(Date.Now, "mm"), Format(Date.Now, "ss")}

Using G As Graphics = Graphics.FromImage(BP1)

'时
Dim dyTmp As String() = {dys(2).Chars(0), dys(2).Chars(1)}
G.DrawImage(Dwimag(dyTmp(1)), BP1.Width - 15, 0)
G.DrawImage(Dwimag(dyTmp(0)), BP1.Width - 29, 0)

G.DrawImage(Image.FromFile("E:\Test_vb8\桌面日历\Bz.png"), BP1.Width - 34, 0) '秒点

'分
dyTmp = New String() {dys(1).Chars(0), dys(1).Chars(1)}
G.DrawImage(Dwimag(dyTmp(1)), BP1.Width - 49, 0)
G.DrawImage(Dwimag(dyTmp(0)), BP1.Width - 63, 0)

G.DrawImage(Image.FromFile("E:\Test_vb8\桌面日历\Bz.png"), BP1.Width - 68, 0) '秒点

'秒
dyTmp = New String() {dys(0).Chars(0), dys(0).Chars(1)}
G.DrawImage(Dwimag(dyTmp(1)), BP1.Width - 83, 0)
G.DrawImage(Dwimag(dyTmp(0)), BP1.Width - 97, 0)
End Using

'这里改为API效果更好
Dim mG As Graphics = Me.CreateGraphics
mG.DrawImage(BP1, 0, 0)
BP1.Dispose()

End Sub

'图片可输入到资原文件 '提高效率
' Dim Dwimag As Image() = {My.Resources.Bx0, My.Resources.Bx1, My.Resources.Bx2, My.Resources.Bx3, My.Resources.Bx4, _
' My.Resources.Bx5, My.Resources.Bx6, My.Resources.Bx7, My.Resources.Bx8, My.Resources.Bx9}


Dim Dwimag As Image()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Timer1.Interval = 10
Timer1.Enabled = True

Dim dirPth As String = "E:\Test_vb8\桌面日历\"
Dwimag = New Image() {Image.FromFile(dirPth & "Bx0.png"), Image.FromFile(dirPth & "Bx1.png"), _
Image.FromFile(dirPth & "Bx2.png"), Image.FromFile(dirPth & "Bx3.png"), _
Image.FromFile(dirPth & "Bx4.png"), Image.FromFile(dirPth & "Bx5.png"), _
Image.FromFile(dirPth & "Bx6.png"), Image.FromFile(dirPth & "Bx7.png"), _
Image.FromFile(dirPth & "Bx8.png"), Image.FromFile(dirPth & "Bx9.png")}
End Sub

End Class
Viking_ 2010-02-16
  • 打赏
  • 举报
回复
引用 8 楼 submain 的回复:
你可以先把0~9这十个图片命名为0.bmp, 1.bmp, ... 9.bmp。

然后在时钟的触发控件里写个循环,循环时间里面的每一位(时间格式:HHmmss)
再根据每一位的字数,把相应的BMP图片加载到窗口上,所以说窗口上要有八个显示图片的控件(包括两个分号)

例如:
当读取到第一个H是1的时候,就加载1.bmp图片,并显示到小时所对应该的控件上


写个循环我倒是能做到,不过要让随时显示当前系统时间,这个我做不到~~~55555
Viking_ 2010-02-16
  • 打赏
  • 举报
回复
引用 3 楼 wuyq11 的回复:
通过Timer定时刷新显示图片
Calendar/LEDControl


呵呵,用Timer刷新图片这个我倒是能做到(就是用这十个图片做个计数器我可以的:)),但如何让图片随时显示当前时间呢~~~
Viking_ 2010-02-16
  • 打赏
  • 举报
回复
引用 2 楼 supper168 的回复:
把当前时间的数字提取出来,然后把数字对应到0~9的文件名上。


请问这是怎么做到的,用什么函数啊?
Viking_ 2010-02-16
  • 打赏
  • 举报
回复
引用 1 楼 asdfy 的回复:
应该是DrawString上去的吧。


呵呵,其实真不是~~~那个时钟不是自己画的~~
cg2003 2010-02-16
  • 打赏
  • 举报
回复
使用VC++.net做一个应用程序。该应用程序需要与SVN的工具联合起来使用。
subMain 2010-02-16
  • 打赏
  • 举报
回复
你可以先把0~9这十个图片命名为0.bmp, 1.bmp, ... 9.bmp。

然后在时钟的触发控件里写个循环,循环时间里面的每一位(时间格式:HHmmss)
再根据每一位的字数,把相应的BMP图片加载到窗口上,所以说窗口上要有八个显示图片的控件(包括两个分号)

例如:
当读取到第一个H是1的时候,就加载1.bmp图片,并显示到小时所对应该的控件上
wuyq11 2010-02-15
  • 打赏
  • 举报
回复
通过Timer定时刷新显示图片
Calendar/LEDControl
春天的气息 2010-02-15
  • 打赏
  • 举报
回复
把当前时间的数字提取出来,然后把数字对应到0~9的文件名上。
古今多少事 2010-02-15
  • 打赏
  • 举报
回复
应该是DrawString上去的吧。

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧