adding a little glamor - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

adding a little glamor

Can anyone tell me how I could go about a certain process. The problem at hand is that I have a program that takes some time to finish its task so during this process I want a word on the form to blink two different colors until the process has stopped. anybody got any ideas?

-Einstein3000

Comments

  • doofusboydoofusboy Posts: 256Member
    [b][red]This message was edited by doofusboy at 2003-8-15 5:1:42[/red][/b][hr]
    : Can anyone tell me how I could go about a certain process. The problem at hand is that I have a program that takes some time to finish its task so during this process I want a word on the form to blink two different colors until the process has stopped. anybody got any ideas?
    :
    : -Einstein3000
    :
    Assuming the "word on the form" is in a Label control, just change its .ForeColor property back and forth between two colors and use a Timer control to control this process and how long it runs. You'll probably need to add a 'DoEvents' to the other task in your code to allow the timer to do its thing simultaneously.


    Label1.Forecolor = vbRed
    ....Timer pause......
    Label1.Forecolor = vbGreen
    ....Timer pause......
    etc
    etc
    etc
  • ZantosZantos Posts: 139Member
    To elaborate a little more:

    Set the Timer interval to whatever you want (in milliseconds so if you want the color to change every second you would set the value to 1000). Then make sure you set the Enabled value to False so it doesn't start running when the program starts up. When you want the label to appear and start blinking add in this code:
    [code]
    Private Sub Form_Load()
    lblWorking.ForeColor = vbRed '//makes the font red
    lblWorking.Visible = True '//makes the label visible
    tmrColorChange.Enabled = True '//starts the timer
    ..start your code
    DoEvents '//allows windows to process other actions in a loop
    '//when your code finishes, add the following
    lblWorking.Visible = False
    tmrColorChange.Enabled = False
    End Sub
    [/code]
    And the code for the timer should look something like:
    [code]
    Private Sub tmrColorChange_Timer()
    If lblWorking.ForeColor = vbRed Then
    lblWorking.ForeColor = vbGreen '//makes the font green
    Else
    lblWorking.ForeColor = vbRed '//if the font isn't red it
    '//will be changed to red
    End If
    End Sub
    [/code]
    That should do it. If you have any questions, go ahead and drop me a line.
    [code]
    [b]..:[/b] Zantos [b]:..[/b]
    [blue]Mega[/blue][red]Riot[/red] Productions
    http://www.megariot.funurl.com
    [/code]

Sign In or Register to comment.