* 다음에 해볼 작품(?)입니다. 결과를 보시고 어떤 방법으로 해야 할지 생각해보세요
* Label을 이용한 전광판 효과 만들기 입니다
< 기능 추가 사항 >
1. 출력 문구 입력 받기
2. 임의의(사용자 입력) 크기의 전광판 생성
3. 배경, 글자색 선택 기능
4. 폰트, 글자크기 선택 기능
5. 이동 속도 사용자 입력받기
5. 다양한 효과 주기
* 2개의 폼을 사용함
* 실행하면 제어창은 안보이고 실행창만 보임
* 실핼창 더블클릭하면 실행창 종료되고 제어창 보임
<Form1 - 제어창>
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub btn_ForColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ForColor.Click
forColorDialog.ShowDialog()
btn_ForColor.BackColor = forColorDialog.Color
lbl_Preview.ForeColor = forColorDialog.Color
Private Sub btn_BackColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_BackColor.Click
backColorDialog.ShowDialog()
btn_BackColor.BackColor = backColorDialog.Color
lbl_Preview.BackColor = backColorDialog.Color
Private Sub btn_Font_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Font.Click
FontDialog1.ShowDialog()
lbl_Preview.Font = FontDialog1.Font
End Class
<Form2 - 실행창>
Public Class Form2
Dim my_x As Integer = CInt(Form1.form2_X.Text)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = Form1.TextBox1.Text
Timer1.Enabled = True
Timer1.Interval = CInt(Form1.timer_int.Text)
Me.Width = CInt(Form1.form2_X.Text)
Me.Height = CInt(Form1.form2_Y.Text)
Me.ForeColor = Form1.lbl_Preview.ForeColor
Me.BackColor = Form1.lbl_Preview.BackColor
Label1.Font = Form1.lbl_Preview.Font
Label2.Text = Timer1.Interval.ToString
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Form1.CheckBox1.Checked = False Then
my_x -= 1
Label1.Location = New Point(my_x, 50)
Else
If (my_x Mod 2) = 1 Then
Label1.Hide()
Label1.Show()
End If
If (my_x + Label1.Width) < 0 Then
my_x = Me.Width
Private Sub Form2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Form1.Show()
* 기본 동작 코드
Dim my_x As Integer = Me.Width
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 5
Label1.ForeColor = Color.Red
Me.BackColor = Color.Black
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
my_x -= 3
If (my_x + (Label1.Width)) <= 0 Then
로그인
회원가입
* 2개의 폼을 사용함
* 실행하면 제어창은 안보이고 실행창만 보임
* 실핼창 더블클릭하면 실행창 종료되고 제어창 보임
<Form1 - 제어창>
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub btn_ForColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ForColor.Click
forColorDialog.ShowDialog()
btn_ForColor.BackColor = forColorDialog.Color
lbl_Preview.ForeColor = forColorDialog.Color
End Sub
Private Sub btn_BackColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_BackColor.Click
backColorDialog.ShowDialog()
btn_BackColor.BackColor = backColorDialog.Color
lbl_Preview.BackColor = backColorDialog.Color
End Sub
Private Sub btn_Font_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Font.Click
FontDialog1.ShowDialog()
lbl_Preview.Font = FontDialog1.Font
End Sub
End Class
<Form2 - 실행창>
Public Class Form2
Dim my_x As Integer = CInt(Form1.form2_X.Text)
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = Form1.TextBox1.Text
Timer1.Enabled = True
Timer1.Interval = CInt(Form1.timer_int.Text)
Me.Width = CInt(Form1.form2_X.Text)
Me.Height = CInt(Form1.form2_Y.Text)
Me.ForeColor = Form1.lbl_Preview.ForeColor
Me.BackColor = Form1.lbl_Preview.BackColor
Label1.Font = Form1.lbl_Preview.Font
Label2.Text = Timer1.Interval.ToString
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Form1.CheckBox1.Checked = False Then
my_x -= 1
Label1.Location = New Point(my_x, 50)
Else
my_x -= 1
Label1.Location = New Point(my_x, 50)
If (my_x Mod 2) = 1 Then
Label1.Hide()
Else
Label1.Show()
End If
End If
If (my_x + Label1.Width) < 0 Then
my_x = Me.Width
End If
End Sub
Private Sub Form2_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Form1.Show()
End Sub
이 댓글을
* 기본 동작 코드
Public Class Form1
Dim my_x As Integer = Me.Width
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Interval = 5
Label1.ForeColor = Color.Red
Me.BackColor = Color.Black
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
my_x -= 3
Label1.Location = New Point(my_x, 50)
If (my_x + (Label1.Width)) <= 0 Then
my_x = Me.Width
End If
End Sub
End Class
이 댓글을