Public Class MsgBox
Private Sub MessageBox_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Timer1.Interval = 30000 '设置执行间隔(30秒)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Me.Close() '计时器自动关闭提示窗口
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MsgBox
Inherits System.Windows.Forms.Form
'Form 重写 Dispose,以清理组件列表.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它.
'不要使用代码编辑器修改它.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TextBox1.Location = New System.Drawing.Point(13, 13)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ReadOnly = True
Me.TextBox1.Size = New System.Drawing.Size(259, 138)
Me.TextBox1.TabIndex = 1
Me.TextBox1.TabStop = False
'
'Timer1
'
'
'MsgBox
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 161)
Me.Controls.Add(Me.TextBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "MsgBox"
Me.ShowIcon = False
Me.Text = "提示"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Timer1 As System.Windows.Forms.Timer
End Class
全局代码3
Public Class MyForm
#Region "提示框"
Shared Sub MsgBox(ByVal Text As String, Optional ByVal title As String = Nothing, Optional ByVal sj As Boolean = False)
Dim Frm As New MsgBox
Frm.Text = iif(title Is Nothing,Frm.Text,title) '设置窗口标题
Frm.TextBox1.Text = Text '设置窗口文本内容
Dim Width As Integer = System.Windows.Forms.SystemInformation.WorkingArea.Width '获取屏幕的宽度
Dim Height As Integer = System.Windows.Forms.SystemInformation.WorkingArea.Height '获取屏幕的高度
If IO.File.Exists(ProjectPath & "Images\Logo.ico") = True Then '如果找到该文件的话
Dim ico As New Icon(ProjectPath & "Images\Logo.ico", 16, 16) '设置窗口的图标
Frm.Icon = ico
End If
Frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual
Dim StartPoint As New System.Drawing.Point
StartPoint.X = Width - Frm.Width
StartPoint.Y = Height - 10
Frm.Location = StartPoint
Frm.Show()
If IO.File.Exists(ProjectPath & "Wav\MsgBox.wav") = True Then '如果找到音频文件的话,播放该文件
My.Computer.Audio.Play(ProjectPath & "Wav\MsgBox.wav")
End If
For i As Integer = 1 To Frm.Height Step 2
Frm.SetBounds(Width - Frm.Width, Height - i, Frm.Width, Frm.Height)
Next
If sj = True Then
Frm.Timer1.Enabled = True
End If
End Sub
#End Region
End Class