18 Mayıs 2011 Çarşamba

ARKA PLAN RENGİ SÜREKLİ DEĞİŞEN FORM


- Önce şekildeki gibi 2 buton ve 1 tane Timer eklenir.
        - Forma bir kez tıklanıp genelikle sağ tarafta yer alan Properties penceresine gelinir ve aşağıdaki özellikleri yazıldığı gibi değiştirilir:

FormBorderStyle    =    None
StartPosition           =    CenterScreen

       - ÇIKIŞ butonuna çift tıklanır, açılan kod alanına sarı ile işaretli yer yazılır:


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

        - Açılan kod sayfasına timerda kullanacağımız bir sayı değişkeni tanımlanır:

     Dim a As Integer

       - "SÜREKLİ DEĞİŞEN ARKA PLAN RENGİ" yazan butona çift tıklanıp açılan kod sayfasına aşağıdaki kodlar yazılır:

     Private Sub arka_plan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles arka_plan.Click
        arka_plan.Enabled = False 
        a = 0
        Timer1.Interval = 1000
        Timer1.Start() 
     End Sub

       - Eklenen Timera çift tıklanarak açılan kod sayfasına aşağıdaki kodlar yazılır:




     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        a = a + 1
        If a = 1 Then
            Me.BackColor = Color.Aqua
        End If
        If a = 3 Then
            Me.BackColor = Color.BlanchedAlmond
        End If
        If a = 5 Then
            Me.BackColor = Color.ForestGreen
        End If
        If a = 7 Then
            Me.BackColor = Color.MediumOrchid
        End If
        If a = 9 Then
            Me.BackColor = Color.YellowGreen
        End If
        If a = 11 Then
            Me.BackColor = Color.Turquoise
            a = 0
        End If
     End Sub


----------------------------------------------------------------------------------

Public Class Form1
    Dim a As Integer
    Private Sub cikis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cikis.Click
        Me.Close()
    End Sub

    Private Sub arka_plan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles arka_plan.Click
        arka_plan.Enabled = False
        a = 0
        Timer1.Interval = 1000
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        a = a + 1
        If a = 1 Then
            Me.BackColor = Color.Aqua
        End If
        If a = 3 Then
            Me.BackColor = Color.BlanchedAlmond
        End If
        If a = 5 Then
            Me.BackColor = Color.ForestGreen
        End If
        If a = 7 Then
            Me.BackColor = Color.MediumOrchid
        End If
        If a = 9 Then
            Me.BackColor = Color.YellowGreen
        End If
        If a = 11 Then
            Me.BackColor = Color.Turquoise
            a = 0
        End If
    End Sub
End Class


Hiç yorum yok:

Yorum Gönder

Hürriyet