|
-
September 8th, 2004, 10:39 PM
#1
Passing a frame as a Control
I want to pass a Frame control to a sub, so that I can enable/disable all controls
that are contained on the frame, with a simple loop
I've already set the container property of each control to the Frame.
(this code not shown for simplicity)
Now I just need to loop through all the controls and enable/disable them.
I don't know how to pass the Frame as a control or object, in the actual Call.
private const CTRLS_ENABLED AS BOOLEAN = True
'caller
SetControls(frmColors, CTRLS_ENABLED)
' this call doesn't work, because it passes the Caption propertuy by default
'Private Sub SetControls(Parent As Control, CtrlState As Boolean)
'Private Sub SetControls(Parent As Object, CtrlState As Boolean)
Private Sub SetControls(Parent As Frame, CtrlState As Boolean)
Dim Ctrl As Control
On Error Resume Next
For Each Ctrl In Parent
Ctrl.Enabled = CtrlState
Next Ctrl
End Sub
Can someone help me out here ?
thanks
-
September 9th, 2004, 12:06 AM
#2
Re: Passing a frame as a Control
The easy way is to disable the frame only, which will prevent the controls on it from being accessed. However, they won't actually appear disabled. You can iterate through the form's controls collection, and disable only those which are in the frame.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
September 9th, 2004, 11:52 AM
#3
Re: Passing a frame as a Control
 Originally Posted by WizBang
The easy way is to disable the frame only, which will prevent the controls on it from being accessed. However, they won't actually appear disabled. You can iterate through the form's controls collection, and disable only those which are in the frame.
I will do that, for the future, I would still like to know how to pass a Frame, so I can iterate through it's properties.
-
September 9th, 2004, 11:56 AM
#4
Re: Passing a frame as a Control
 Originally Posted by WizBang
The easy way is to disable the frame only, which will prevent the controls on it from being accessed. However, they won't actually appear disabled. You can iterate through the form's controls collection, and disable only those which are in the frame.
When I disable the frame, the controls on it ARE disabled, but not greyed out. THat is, they don't look disabled.
Why is that ?
-
September 9th, 2004, 03:02 PM
#5
Re: Passing a frame as a Control
 Originally Posted by cappy2112
When I disable the frame, the controls on it ARE disabled, but not greyed out. THat is, they don't look disabled.
Why is that ?
Yes, that's what I said. As for why, I suppose it's just because the controls aren't actually disabled. Think of it like a form which is disabled - same effect. It's just how windows works.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
September 10th, 2004, 04:39 AM
#6
Re: Passing a frame as a Control
I think the problem lies in the declaration of the SetControls function you wrote.
Make sure you explicitly declare the parameter that accepts the frame to either Frame or Object. Not declaring the parameter will turn it into a variant, makeing it convert the variant into the default property of the frame (which is the caption), in this case a string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|