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

Disabling components inside of a frame

Status
Not open for further replies.

EagleTempest

Technical User
Joined
Jun 15, 2004
Messages
125
Location
CA
VB6

Hello, easy there an easy way to disable all components inside of a frame? Disabling the frame results in the inside components still looking enabled. I'm wondering if For Each would help me.

For example I have a frame called fraSpecifications with a few textboxes and a combo box inside.
 
Public Sub EnableDisable(frm as Object, bEnable as Boolean)
' Enable or Disable
Dim ctl as Object
For Each ctl In Me.Controls
On error resume next
if ctl.Container is frm then
ctl.Enabed = bEnable
End if
On error goto 0
Next
End Sub

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
I posted a similar question a while ago. While John's solution works, it assumes that all the controls within the frame are either all enabled or all disabled to begin with.

It may be the case that within the frame there is a mixture of enabled and disabled controls, in which case 'enabling' the frame would also enable any disabled controls. It's not a toggle, in other words.

It's surprising that disabling a frame doesn't redraw the controls within to look disabled, as happens elsewhere in Windows.

To achieve a robust solution, upon diabling the frame you'd have to first make a note of whether each control within the frame is disabled or enabled, then disable each control (as in John's example). To re-enable the frame, rather than setting everything to Enabled=True you'd apply the stored Enabled settings.

But it's a mystery why Windows doesn't do it for you...!


- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Maybe what we need is someone to make a subclass of the frame component or just a new, better frame component.
 
Well done for volunteering, EagleTempest. We look forward to hearing about your results and seeing your solution posted here!
[smile]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top