Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disabling a container
Message
 
To
31/01/2002 10:45:08
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00613278
Message ID:
00615050
Views:
27
Well, as luck would have it, I had the same need today with a container, so I broke down and did it the hard way. Not sure how it would work with a grid, you would probably have to add the dynamicBackColor code from elsewhere in this thread.

It wasn't as hard as I thought, took less than an hour. I originaly thought you would need to recurse through all the objects but thanks to the magic of OOP, it wasn't neccessary. :)

Here it is:

Add the following props to the base container class:
.disableChildren
.origDisabledChildren
.enabled_assign
Add the following code to the .enabled_assign method:
Lparameters vNewVal
*To do: Modify this routine for the Assign method

With This
	If m.vNewVal
		** We are enabling
		If .disableChildren
			** This will change the enabled state of all the 
			** child controls. You can disabled this behaviour 
			** by setting the .DisableChildren property to .F.

			** Enabled everything first
			For Each oControl In .Controls
				If PemStatus(oControl, "Enabled", 5)
					oControl.Enabled = .T.
				Endif
			Next

			** Disable any of the stored kids.
			If .origDisabledControls[1] = .T.
				Local j
				For m.j = 2 To Alen(.origDisabledControls)
					.origDisabledControls[m.j].Enabled = .F.
				Next
			Endif

		Endif

	Else
		** We are disabling
		If .disableChildren

			** spin through the kids and build an array of any
			** that are disabled.
			Local oControl, i
			m.i = 1
			Dimension .origDisabledControls[1]

			** The first element of the is a flag to determine
			** if the array is empty
			.origDisabledControls = .F.
			For Each oControl In .Controls
				If PemStatus(oControl, "Enabled", 5)
					If Not oControl.Enabled
						.origDisabledControls[1] = .T.
						Dimension .origDisabledControls[ Alen(.origDisabledControls) + 1 ]
						m.i = m.i + 1
						.origDisabledControls[m.i] = oControl
					Endif
				Endif
			Next

			** Ok, now just changed the enabled status of the kids
			For Each oControl In .Controls
				If PemStatus(oControl, "Enabled", 5)
					oControl.Enabled = .F.
				Endif
			Next

		EndIf
		
	Endif

	.Enabled = m.vNewVal
Endwith
>> ...
>>The cheezy lamo way :)
>>slap a shape over the whole control with a label in the middle that says "Not Available".
>
>Thanks; I was considering something similar: ....Visible = .F. Well, I'll have to think about it. Probably I will decide what to do, from case to case.
>
>Hilmar.
Roi
'MCP' Visual FoxPro

In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!
Previous
Reply
Map
View

Click here to load this message in the networking platform