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

How to show picture just like behavior of NO WAIT?

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
My program is actually finished, but need to do some enhancing… in my app, everytime an id number is inputed, a picture is shown… and i put a little animation using coordinates… my question is, is there a way that a picture is shown just like a behavior of NOWAIT? That processes continues even picture is not yet done showing? ( my picture slowly shows up as animation) thanks in advance…
 
If you are using an animated GIF, then there should be no problem. Your app should be able to continue to process keystrokes and mouse clicks while the animation is in progress.

If you are not using an animated GIF, please explain in more detail how you are doing the animation.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike... i have this excerpt from my app...
Code:
 lcFile = "C:\InfoWave 2021\Pictures\"+ ALLTRIM(this.Parent.text1.value) + ".jpg"
 		 			*lcFile = "D:\Program Files\SCMS Info Wave\Pictures\"+ ALLTRIM(this.Parent.text1.value) + ".jpg"
				
					IF FILE( lcFile , 1 )
					
    					this.Parent.image1.picture = lcFile
    					this.parent.image1.visible = .t.
    				
						FOR lnI = 1 to 160
 							this.parent.image1.Height = lnI
 							this.parent.image1.Width = lnI
 							Sleep(1)
						ENDFOR

						FOR lnI = 160 to 0 STEP -16
					 		this.parent.image1.Height = lnI
 							this.parent.image1.Width = lnI
 							sleep(1)
						ENDFOR 
					
						lcFile = "D:\Program Files\SCMS Info Wave\Img\scms logo3.jpg"
						this.Parent.image1.picture = lcfile 
					
						FOR lnI = 10 to 160 STEP 10
 							this.parent.image1.Height = lnI
 							this.parent.image1.Width = lnI
 							Sleep(1)
						ENDFOR 
						
						taym = 0
						
						DO WHILE taym <> 50000
							taym = taym + 1
						ENDDO
						
						this.Parent.image1.Visible = .T.
What it does it slowly show the complte picture.... but my problem is, it has to finish the picture to be fully shown before proceeding to the next code... What i intend to do is, process continues evern if the picture is still not finish showing up.. Thanks Mike....
 
As far as I am aware asynchronous code to do this is impossible in VFP as all the code is "sequential" Ie you have to wait till this is complete before doing anything else - as you have found out.

so, you need to ask yourself "Do I really NEED to animate it and pay the performance penalty ? "

Sometimes just because you can do something doesn't necessarily mean that you should.

This sort of thing can be done with .Net applications, as these can be multi-threaded - but that's not straightforward and doesn't help you here at all i'm afraid

Colin

 
Colin is right. VFP code is asynchronous, which means it has to finish one task before it can start another.

That said, it is possible for the user to interrupt a task, for example by pressing a key or clicking on a button. To do that, you need to put DOEVENTS inside your loops. Each time VFP comes to DOEVENTS, it will pause and look for an event (a keystroke or click) to execute. However, this approach will greatly slow down your code, and is not completely reliable (in my experience).

A possible solution would be to use an animated GIF, as I mentioned above. I explained how to do that in thread184-1818143. But that's not an ideal solution easier.

A much better approach would be to do as Colin suggested: do without the animation completely. Not only does it add no functionality to your app, it is a feature that many users are likely to find irritating - I know I would.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top