Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing and loading the form again..
Message
From
24/01/2007 09:40:24
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 6
Miscellaneous
Thread ID:
01188499
Message ID:
01188641
Views:
20
>>Hi Dan thanks, well yes, I have methods in form1, and I don't put codes in the init and load.
>>
>>My problem here is, I've created images in form1 using addobject. What I want to do now with the button is to re-create all the images. Of course, when the program does the addobject again, I'll get the error that it already exists. :)
>>
>>A better question here should be, how to delete all the images created using the addobject (becoz I have other images in the form created at design time).
>>
>>Thanks! :)
>
>When you create your images, store references to each of them in a form's array property. I'm not 100% certain that
>
>store NULL to thisform.arrImages would work, so you may do instead
>
>for lnI = 1 to alen(thisform.arrImages)
>   thisform.RemoveObject(thisform.arrImages[lnI])
>next
You can be certain ;-)

The code below needs to be refined, but these are the basics
&& to add images
with m.thisform

	local i, ImageCount
	ImageCount = 5
	
	=.AddProperty('ImageCount', m.ImageCount)
	
	=.AddProperty('ImageArray[' + transf(.ImageCount) + ']')
	
	for i = 1 to .ImageCount
		
		do case
		case !.AddObject( strtran('ImageArray[?]', '?', transf(m.i)), 'Image')
		
		otherwise
			with eval('.' + strtran('ImageArray[?]', '?', transf(m.i)) )
				
				=.move(0, m.i * 50, 50, 50)
				.Visible = TRUE
			endwith
		endcase
	endfor
	

endwith

&& To remove them
with m.thisform
	local i
	
	for i = 1 to .ImageCount
		
		do case
		case !inlist(vartype(.ImageArray[m.i]), T_OBJECT)

                && There's one gotcha.
                && They cannot be removed individually, 
                &&       since their names are not ImageArray[1], ImageArray[2], ... 
                &&      but the name of each and everyone of them is ImageArray

		case !.RemoveObject('ImageArray')
			assert FALSE
		endcase
	endfor
	
	

endwith
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform