Jump to content

Timer numa form


pbreda
 Share

Recommended Posts

Public Class frmUpLoadDonwload
    Inherits Form

    Private SendF As New MySQLSender
    Private PrgBar As New ProgressBar
    Private WithEvents cmdCanc As New Button
    Private WithEvents tmrTemp As New System.Windows.Forms.Timer
    Private lblPCG As New Label

    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New frmUpLoadDonwload())
    End Sub

    Sub New()
        Height = 100
        Me.Text = "Uploading file..."
        Me.MinimizeBox = False
        Me.MaximizeBox = False
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedDialog
        Me.ControlBox = False

        With PrgBar
            .Maximum = SendF.FileSize + 1
            .Width = Me.Width - (.Left * 2) - 10
        End With
        With lblPCG
            .Top = PrgBar.Height + 5
        End With
        With tmrTemp
            .Interval = 1000
            .Enabled = True
        End With
        With cmdCanc
            .Top = (lblPCG.Height * 2) + 5
            .Left = (Me.Width \ 2) - (.Width / 2)
            .Text = "Cancel"
        End With
        Me.Controls.Add(PrgBar)
        Me.Controls.Add(lblPCG)
        Me.Controls.Add(cmdCanc)
        Me.Controls.Add(tmrTemp)
        tmrTemp.Start()
    End Sub

    Private Sub cmdCancelar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCanc.Click
        Close()
    End Sub

    Private Sub tmrTemp_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrTemp.Tick
        PrgBar.Value = SendF.BytesPrepared
        lblPCG.Text = Int(SendF.BytesPrepared / 1024) & " KByte(s) preparado(s) para enviar..."
    End Sub
End Class

Este código corresponde aquilo que quero fazer que é o seguinte: Mostrar o progresso de um download e de um upload de um ficheiro.....bem o problema é que o controlo tmrTemp que é um timer é do tipo system.windows.forms.timer porque caso contrário, ou seja, timer, dá-me um erro de conflito porque estou a usar Thread's noutra classe......como é que vou resolver isto? e como se pode deduzir eu quero fazer isto em Runtime....

Cumprimentos.......

Qualquer coisa esfrega a lampada!!!Visite Banco de Software e desfrute do software disponível xD

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.