看到手机上有这样的程序,突然心血来潮,写了个很粗陋的类似的程序,还有很多可以改进的地方,label的autosize有些问题,还没想到更好的解决方法~

Public Class Form1Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
#Region " Windows 窗体设计器生成的代码 "

Public Sub New()Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。

Protected Overloads Overrides Sub Dispose()Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents InputPanel1 As Microsoft.WindowsCE.Forms.InputPanel

Private Sub InitializeComponent()Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.Label1 = New System.Windows.Forms.Label
Me.Timer1 = New System.Windows.Forms.Timer
Me.Panel1 = New System.Windows.Forms.Panel
Me.Label5 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.InputPanel1 = New Microsoft.WindowsCE.Forms.InputPanel
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 170.0!, System.Drawing.FontStyle.Regular)
Me.Label1.Location = New System.Drawing.Point(240, 48)
Me.Label1.Size = New System.Drawing.Size(1, 220)
'
'Timer1
'
'
'Panel1
'
Me.Panel1.Controls.Add(Me.Label5)
Me.Panel1.Controls.Add(Me.Label4)
Me.Panel1.Controls.Add(Me.RadioButton2)
Me.Panel1.Controls.Add(Me.RadioButton1)
Me.Panel1.Controls.Add(Me.Label3)
Me.Panel1.Controls.Add(Me.Label2)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.ComboBox2)
Me.Panel1.Controls.Add(Me.ComboBox1)
Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Location = New System.Drawing.Point(16, 8)
Me.Panel1.Size = New System.Drawing.Size(200, 248)
'
'Label5
'
Me.Label5.ForeColor = System.Drawing.SystemColors.GrayText
Me.Label5.Location = New System.Drawing.Point(112, 224)
Me.Label5.Size = New System.Drawing.Size(80, 16)
Me.Label5.Text = "design by xy"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(24, 110)
Me.Label4.Size = New System.Drawing.Size(32, 16)
Me.Label4.Text = "字幕"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(120, 80)
Me.RadioButton2.Size = New System.Drawing.Size(72, 18)
Me.RadioButton2.Text = "慢速"
'
'RadioButton1
'
Me.RadioButton1.Location = New System.Drawing.Point(24, 80)
Me.RadioButton1.Size = New System.Drawing.Size(64, 18)
Me.RadioButton1.Text = "快速"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(24, 48)
Me.Label3.Size = New System.Drawing.Size(56, 16)
Me.Label3.Text = "字幕色"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 16)
Me.Label2.Size = New System.Drawing.Size(56, 16)
Me.Label2.Text = "背景色"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 128)
Me.Button1.Size = New System.Drawing.Size(96, 24)
Me.Button1.Text = "开始滚动"
'
'ComboBox2
'
Me.ComboBox2.Items.Add("white")
Me.ComboBox2.Items.Add("black")
Me.ComboBox2.Items.Add("blue")
Me.ComboBox2.Items.Add("yellow")
Me.ComboBox2.Items.Add("red")
Me.ComboBox2.Items.Add("green")
Me.ComboBox2.Items.Add("cyan")
Me.ComboBox2.Items.Add("purple")
Me.ComboBox2.Items.Add("orange")
Me.ComboBox2.Location = New System.Drawing.Point(120, 48)
Me.ComboBox2.Size = New System.Drawing.Size(72, 20)
'
'ComboBox1
'
Me.ComboBox1.Items.Add("white")
Me.ComboBox1.Items.Add("black")
Me.ComboBox1.Items.Add("blue")
Me.ComboBox1.Items.Add("yellow")
Me.ComboBox1.Items.Add("red")
Me.ComboBox1.Items.Add("green")
Me.ComboBox1.Items.Add("cyan")
Me.ComboBox1.Items.Add("purple")
Me.ComboBox1.Items.Add("orange")
Me.ComboBox1.Location = New System.Drawing.Point(120, 8)
Me.ComboBox1.Size = New System.Drawing.Size(72, 20)
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(64, 104)
Me.TextBox1.Size = New System.Drawing.Size(128, 21)
Me.TextBox1.Text = ""
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(7, 300)
Me.Button2.Size = New System.Drawing.Size(40, 16)
Me.Button2.Text = "exit"
'
'Form1
'
Me.ClientSize = New System.Drawing.Size(240, 280)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Label1)
Me.Menu = Me.MainMenu1
Me.Text = "滚动的条幅"
End Sub
#End Region
Dim cout As Integer, speed As Integer

Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Panel1.Hide()
Me.WindowState = FormWindowState.Maximized
Me.FormBorderStyle = FormBorderStyle.None
Me.ControlBox = False
Me.Menu = Nothing
If TextBox1.Text = "" Then TextBox1.Text = "滚动的条幅"
Label1.Text = TextBox1.Text
For i = 1 To Label1.Text.Length
If Asc(Mid(TextBox1.Text, i, 1)) > 31 And Asc(Mid(TextBox1.Text, i, 1)) < 126 Then
cout = cout + 1
Else
cout = cout + 2
End If
Next
Label1.Width = 120 * cout
If RadioButton1.Checked = True Then
speed = 30
Else
speed = 15
End If
Timer1.Enabled = True
End Sub

Private Sub ComboBox1_SelectedIndexChanged()Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.SelectedIndex
Case 0
Me.BackColor = System.Drawing.Color.White
Case 1
Me.BackColor = System.Drawing.Color.Black
Case 2
Me.BackColor = System.Drawing.Color.Blue
Case 3
Me.BackColor = System.Drawing.Color.Yellow
Case 4
Me.BackColor = System.Drawing.Color.Red
Case 5
Me.BackColor = System.Drawing.Color.Green
Case 6
Me.BackColor = System.Drawing.Color.Cyan
Case 7
Me.BackColor = System.Drawing.Color.Purple
Case 8
Me.BackColor = System.Drawing.Color.Orange
End Select
End Sub

Private Sub ComboBox2_SelectedIndexChanged()Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Select Case ComboBox2.SelectedIndex
Case 0
Label1.ForeColor = System.Drawing.Color.White
Case 1
Label1.ForeColor = System.Drawing.Color.Black
Case 2
Label1.ForeColor = System.Drawing.Color.Blue
Case 3
Label1.ForeColor = System.Drawing.Color.Yellow
Case 4
Label1.ForeColor = System.Drawing.Color.Red
Case 5
Label1.ForeColor = System.Drawing.Color.Green
Case 6
Label1.ForeColor = System.Drawing.Color.Cyan
Case 7
Label1.ForeColor = System.Drawing.Color.Purple
Case 8
Label1.ForeColor = System.Drawing.Color.Orange
End Select
End Sub

Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RadioButton2.Checked = True
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 1
End Sub

Private Sub Timer1_Tick()Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Label1.Left > -Label1.Width Then
Label1.Left = Label1.Left - speed
Else
Label1.Left = 240
End If
End Sub

Private Sub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub TextBox1_GotFocus()Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus
InputPanel1.Enabled = True
End Sub

Private Sub TextBox1_LostFocus()Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus
InputPanel1.Enabled = False
End Sub
End Class