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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i added to a form an image, it is possible to make it blink every 10 seconds vfp 9.0 sp 2

Status
Not open for further replies.
Jan 20, 2007
237
US
Hi guys
Here still learning some tricks
i have inserted in vfp 9.0 form an image file type is png, it is a dollar sign, i would like to make blink or appears and disappears every 10 seconds, can anyone point to accomplish it thanks a lot.
 
You could drop a timer control on the form, set the Interval to 10000 and then in the Timer Method, put something like this
Code:
IF thisform.image1.Visible = .T.
	thisform.image1.Visible = .F.
ELSE
	thisform.image1.Visible = .T.
ENDIF

Ed
 
You can do it in one line of code



[pre]thisform.image1.Visible = !(thisform.image1.Visible)[/pre]

With regards
 
It won't change state while VFP is doing anything though.

The timer doesn't support multi-threading.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Back to the old blinking (spinning) label?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Another option is to convert your PNG to an animated GIF. Any decent image / icon editor should allow you to do that. You would set the frame rate to ten seconds, and have two planes: one with the dollar sign and the other completely blank. Use that as the picture in your image control. And that's all you need to do. No additional coding is necessary.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike

Would an animated GIF continue to animate if VFP was busy, or would that be like the timer solution - it would stop?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi,

From my personal experience I can tell it will stop when the CPU is very, very busy; the image will come to a still image.

Regards,

Gerrit
 
You can simply test yourself, it's easy to keep VFP busy waiting with a While loop.

Code:
_screen.AddObject("label1","label")
_screen.label1.caption = "blink"

_screen.AddObject("image1","image")
_screen.image1.top = 30
_screen.image1.picture = Addbs(Home())+"Graphics\Gifs\morphfox.gif"

_screen.AddObject("image2","image")
_screen.image2.top = 150
_screen.image2.picture = Addbs(Home())+"Graphics\Gifs\morphfox.gif"
_screen.image2.visible = .t.

_screen.AddObject("timer1","blinktimer")

Wait window '' timeout 5

* keeping VFP busy waiting for a keypress - no timer event happens
Do While Inkey()=0
EndDo 

Define Class blinktimer as Timer
   Interval = 500

   Procedure Timer()
      _screen.label1.visible = not _screen.label1.visible
      _screen.image1.visible = not _screen.image1.visible
   EndProc 
EndDefine

The mmorphfox.gif animation continues to work even after 5 seconds, when the code enters the while loop. You only see the morph in the lower image2 continue, the blinking by timer stops.

But the computer needs to be very busy overall or you only have a single core CPU, then this will also stop GIFs from animating.

Bye, Olaf.

Olaf Doschke Software Engineering
 

Would an animated GIF continue to animate if VFP was busy, or would that be like the timer solution - it would stop?

In my experience, yes. I have sometimes used one when performing a time-consuming search. It might slow down very slightly when VFP is very busy, but it does continue to animate. And the slower the frame rate, the less noticeable is the slow-down.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
sounds good to me

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Yes, it seems the OS (WinAPI) is taking car of the GIF animation, VFP here makes use of gdiplus, as far as I know, and so the image control displaying images just inherits what the gdiplus library does with them, including PNG and GIIF transparency (two different concepts) and GIF animation.

There is a downside to this, as it does show activity and suggests progress, even when VFP really would be choked into an endless loop not getting out. But you can argue for it in that a timer would often be a too early indicator of VFP being stuck, while it's just busy executing SQL.

At least one situation got a lot better, if a thread is stuck, that usually only affects one CPU core and single core CPUs have become rare. It's not just XP and later Windows versions, that got more stable, it's mainly multiple cores that removed the threat of a single core being stuck, now the OS can kill processes from cores using other cores, The OS - I think - will run its major process control loop doing multithreading and multiprocessing with the cores on multiple cores itself, this isn't just one OS process with one thread on one core and this also isn't a mechanism running in total separation on each core, so cores can control each other, too, at least in kernal mode code. (If you don't know, OS code usually has some more privileges in the CPU doing things no normal process is capable to do in kernal mode, which includes directly writing into memory of any process and likely also assigning cores to processes or vice versa).

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top