Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a button blink for about 5 seconds?

Status
Not open for further replies.

montypython1

Technical User
Jan 12, 2005
187
US
I need to make a button blink for about 5 to 10 seconds.

Any ideas?

Thanks,
Dave
 
Throw a timer control on your form where the button resides and in them timer's timer event put code to change the backcolor and/or forecolor of the button and increment a form property (or a property of the timer if you make your own timer subclass). Then just set the interval of the timer to whatever blink rate you want. When the property reaches a certain count then you can just set the interval of the timer = 0 and the property = 0 from within the timer event.

boyd.gif

SweetPotato Software Website
My Blog
 
Hi Craig,

Thank you for your suggestion.

I attempted to follow your recommendations, but did not get very far. I have done the following:

- created a timer control and placed it on the form
- opened the timer's "timer" event and was able to make the button blink, but it would not stop blinking.

Any thoughts will be appreciated.

Thanks,
Dave


 
If you're timer control is a class then create a property on it called TotalIntervals and set it to 0 as the default value. If you are just using the regular VFP base class timer, then create a property on your form called TotalIntervals and set it to 0.

Then, in the timer event increment this external counter property and use it to stop the blinking...

if you are using a timer subclass you created, then put the following in the timer event....

Code:
with this
    .TotalIntervals = .TotalIntervals + 1
  if .TotalIntervals > 20 && Change 20 to control time for blinking
    .TotalIntervals = 0
    .Interval = 0
    *!* place code to put button back to normal here (color, font, or whatever you changed to make it blink)
  else
    *!* place code to make button blink is here
  endif
endwith

...if on the other hand you are using a form property for TotalIntervals then change ".TotalIntervals" to "thisform.TotalIntervals" in the code above.

...last but not least, it might be a good idea to post your timer event code back here in this thread once you have it working so we can see if it can be improved any, and it will allow future readers of this thread to be able to implement the same functionality which is always appreciated.

boyd.gif

SweetPotato Software Website
My Blog
 
Hi Craig,

Thanks for steering me in the right direction.

I will implement your suggestions tomorrow and let you know how it turned out. Per your suggestion, I will also post the code in case future readers could benefit from your ideas.

Thank you,
Dave
 

Dave,

Just out of curiosity ... why do you want your button to blink?

I've always tried to avoid distracting visual effects, but I realise you've probably got a good reason for it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
I was just going to post the same question Mike did. There is a very good reason that blinking items are not recommended under Windows UI guidelines.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top