
《老J时间》播放PPT时候在主屏和副屏上同时显示时间或显示倒计时。
Const xStr As String = "0123456789"
'先声明一个常量,把禁用或允许输入的内容赋值给它
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 Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'只能输入数字
KeyAscii = IIf(InStr(xStr & Chr(8), Chr(KeyAscii)), KeyAscii, 0)
End Sub
Private Sub Command2_Click()
WindowsMediaPlayer1.settings.setMode "loop", True
If WindowsMediaPlayer1.playState = 3 Then
WindowsMediaPlayer1.Controls.pause
Command2.Caption = "播"
Else
WindowsMediaPlayer1.Controls.play
Command2.Caption = "停"
End If
End Sub
Private Sub Form_Load()
res% = SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
WindowsMediaPlayer1.settings.setMode "loop", True
WindowsMediaPlayer1.Controls.play
End Sub
Private Sub Label1_DblClick()
If Form1.Height = 495 Then
Form1.Height = 900
Form1.Width = 8200
Label1.Height = 900
Label1.Width = 8200
Label1.FontSize = 30
Label2.Height = 900
Label2.Width = 8200
Label2.FontSize = 30
Else
Form1.Height = 495
Form1.Width = 5115
Label1.Height = 495
Label1.Width = 5115
Label1.FontSize = 15
Label2.Height = 900
Label2.Width = 8200
Label2.FontSize = 15
End If
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then
Text1.Text = 0
End If
Label1.Caption = Val(Text1.Text) * 60
Timer1.Interval = 1000
Timer1.Enabled = True
s = Val(Text1.Text) '假定这是要换算的秒数
End Sub
Private Sub Timer1_Timer()
If Text1.Text <= 0 Then
Label1.Caption = Time() & " " & Time()
Label2.Visible = False
Else
Label2.Visible = True
Label1.Caption = Val(Label1.Caption) - 1
Dim s As Long, h As Integer, m As Integer
s = Val(Label1.Caption) '要换算的秒数
h = s \ 3600
s = s Mod 3600
m = s \ 60
s = s Mod 60
Label2.Caption = Str(m) & "分" & Str(s) & "秒" & " " & Str(m) & "分" & Str(s) & "秒"
If Val(Label1.Caption) <= 0 Then
Timer1.Enabled = False
Label2.Caption = " 时间到!"
End If
End If
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
DoDrag Me
End Sub
Private Sub Label2_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
DoDrag Me
End Sub
Private Sub Label2_DblClick()
If Form1.Height = 495 Then
Form1.Height = 900
Form1.Width = 8500
Label1.Height = 900
Label1.Width = 8500
Label1.FontSize = 30
Label2.Height = 900
Label2.Width = 8500
Label2.FontSize = 30
Else
Form1.Height = 495
Form1.Width = 5115
Label1.Height = 495
Label1.Width = 5115
Label1.FontSize = 15
Label2.Height = 900
Label2.Width = 8500
Label2.FontSize = 15
End If
End Sub
