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

Frame question

Status
Not open for further replies.

savok

Technical User
Jan 11, 2001
303
AT
I have a frame and on it i put a few text boxes, cmd buttons etc... problem is when I put them on the frame it will not let me enable, disable or do anything else with these text boxes or cmd buttons when i run the program.
when i remove them from the frame everything is just fine.
I am assuming the program does nto see them for some reason when they are on the frame.

Why does it do this and what can i do to get around it?

thanks
 
Hi,
Is your frame's ENABLED property set to TRUE? If it isn't then all controls that are in the frame cannot be accessed at least not by clicking etc. If it is set to true then check your controls' enabled property...one or all of them may have been disabled.

Have a goodpone!
BK
 
Enable And Disable All Controls In A Frame

This example will show you how to enable and disable all controls in a frame. It's useful if you need to disable and enable several controls together. Just insert them to the same frame, and use the code below.

Preparations
Insert 1 Frame (named Frame1) and 2 Command Buttons (named Command1 and Command2) to your form.
Insert some controls to the frame (buttons, text boxes, whatever you want).
When you will press the first button, All the controls in the frame will be disabled, And
when you will press the second button, all the controls will be enabled.

Form Code

Public Sub EnableFrame(InFrame As Frame, ByVal Flag As Boolean)
Dim Contrl As Control
'some controls don't have the Container.Name property, so instead of
'stopping the application with an error message, we ignore them.
On Error Resume Next
'enable or disable the frame that passed as parameter.
InFrame.Enabled = Flag
'passing over all controls
For Each Contrl In InFrame.Parent.Controls
'if the control is found in the frame
If (Contrl.Container.Name = InFrame.Name) Then
'if the control is a frame, and it's not the frame that passed as parameter, i.e.
'other frame that found inside our frame, recursively run this sub with this frame,
'to enable or disable all the controls in it.
If (TypeOf Contrl Is Frame) And Not (Contrl.Name = InFrame.Name) Then
EnableFrame Contrl, Flag
Else
'enable or disable the control
If Not (TypeOf Contrl Is Menu) Then Contrl.Enabled = Flag
End If
End If
Next
End Sub

Private Sub Command1_Click()
EnableFrame Frame1, False
End Sub

Private Sub Command2_Click()
EnableFrame Frame1, True
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top