Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GIFs and Refresh() problem
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
GIFs and Refresh() problem
Miscellaneous
Thread ID:
00897827
Message ID:
00897827
Views:
48
Hi,

Just by chance we found out a problem when using GIFs, we do not know if it is a well known problem or not (a quick search in UT gave negative results). The problem is that thisform.refresh will make a GIF displayed on an image control visible, disregarding the actual value of the 'visible' property of it, even if you put the image control in a container and hide the container.

For example, this will show 3 images, the first one with just the image control, the second one we overlap the image with a shape (this works as a workaround in this case) and the third one is an image control inside a container that we make invisible:
oForm = Createobject('Form1')
oForm.Show(1)
return

oForm = Createobject('Form1')
oForm.Show(1)
return

DEFINE CLASS form1 AS form


	Top = 57
	Left = 130
	Height = 116
	Width = 355
	DoCreate = .T.
	BorderStyle = 3
	Caption = "Form1"
	WindowState = 0
	Name = "Form1"


	ADD OBJECT shpgif2 AS shape WITH ;
		Top = -2, ;
		Left = 90, ;
		Height = 97, ;
		Width = 88, ;
		BorderStyle = 0, ;
		Visible = .F., ;
		Name = "shpGif2"


	ADD OBJECT cmdexit AS commandbutton WITH ;
		Top = 82, ;
		Left = 295, ;
		Height = 32, ;
		Width = 60, ;
		Caption = "Exit", ;
		TabIndex = 5, ;
		Name = "cmdExit"


	ADD OBJECT imggif1 AS image WITH ;
		Picture = Home(4) + "gifs\morphfox.gif", ;
		Stretch = 1, ;
		Height = 97, ;
		Left = 2, ;
		Top = -2, ;
		Width = 88, ;
		Name = "imgGif1"


	ADD OBJECT cmdhideshow AS commandbutton WITH ;
		Top = 0, ;
		Left = 295, ;
		Height = 32, ;
		Width = 60, ;
		Caption = "Hide", ;
		Name = "cmdHideShow"


	ADD OBJECT cmdrefresh AS commandbutton WITH ;
		Top = 41, ;
		Left = 295, ;
		Height = 32, ;
		Width = 60, ;
		Caption = "Refresh", ;
		Name = "cmdRefresh"


	ADD OBJECT chkvisiblegif AS checkbox WITH ;
		Top = 95, ;
		Left = 2, ;
		Height = 17, ;
		Width = 93, ;
		Caption = "Visible Gif?", ;
		ControlSource = "thisform.imggif1.visible", ;
		ReadOnly = .T., ;
		Name = "chkVisibleGif"


	ADD OBJECT imggif2 AS image WITH ;
		Picture = Home(4) + "gifs\morphfox.gif", ;
		Stretch = 1, ;
		Height = 97, ;
		Left = 90, ;
		Top = -2, ;
		Width = 88, ;
		Name = "imgGif2"


	ADD OBJECT chkvisibleshp AS checkbox WITH ;
		Top = 95, ;
		Left = 92, ;
		Height = 17, ;
		Width = 114, ;
		Caption = "Visible Shp?", ;
		ControlSource = "thisform.shpGif2.visible", ;
		ReadOnly = .T., ;
		Name = "chkVisibleShp"


	ADD OBJECT ctrgif3 AS container WITH ;
		Top = -2, ;
		Left = 178, ;
		Width = 88, ;
		Height = 97, ;
		BorderWidth = 0, ;
		Name = "ctrGif3"


*!*		ADD OBJECT form1.ctrgif3.imggif3 AS image WITH ;
*!*			Picture = Home(4) + "gifs\morphfox.gif", ;
*!*			Stretch = 1, ;
*!*			Height = 97, ;
*!*			Left = 0, ;
*!*			Top = 0, ;
*!*			Width = 88, ;
*!*			Name = "imgGif3"


	ADD OBJECT chkvisiblectr AS checkbox WITH ;
		Top = 96, ;
		Left = 179, ;
		Height = 17, ;
		Width = 81, ;
		Caption = "Visible Ctr?", ;
		ControlSource = "thisform.ctrGif3.visible", ;
		ReadOnly = .T., ;
		Name = "chkVisibleCtr"


	PROCEDURE cmdexit.Click
		thisform.Release()
	ENDPROC


	PROCEDURE cmdhideshow.Click
		if this.Caption = 'Hide'
			this.Caption = 'Show'
			thisform.imgGif1.Visible = .f.
			thisform.shpGif2.Visible = .t.
			thisform.ctrGif3.Visible = .f.
		else
			this.Caption = 'Hide'
			thisform.imgGif1.Visible = .t.
			thisform.shpGif2.Visible = .f.
			thisform.ctrGif3.Visible = .t.
		endif
		thisform.chkVisibleGif.Refresh()
		thisform.chkVisibleShp.Refresh()
		thisform.chkVisibleCtr.Refresh()
	ENDPROC


	PROCEDURE cmdrefresh.Click
		thisform.Refresh
	ENDPROC

	procedure init
	
		thisform.ctrGif3.addobject('imgGif3', 'Image')
		with thisform.ctrGif3.imgGif3
			.Picture = Home(4) + "gifs\morphfox.gif"
			.Stretch = 1
			.Height = 97
			.Left = 0
			.Top = 0
			.Width = 88
			.Visible = .t.
		endwith
		thisform.shpGif2.zorder(0)
	endproc
	
ENDDEFINE
Now after running this program if you click hide, all images are hidden, but as soon as you click the refresh button, which calls thisform.refresh(), the images 1 and 3 are shown again, although their visible property remains false, as shown in the checkboxes

By the way, I do not know why the code generated by class browser does not work, I needed to change the code that is commented out and put it in the init as a quick workaround
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Next
Reply
Map
View

Click here to load this message in the networking platform