Author : Dipen Anovadia
Date Submitted : 12/18/2005
Category : Other
Compatibility : VB 6,VB 5
This code has been accessed 3135 times.
Task : Enable/Disable control in any frame
Declarations
Code
Public Sub FrameEnabled(f As Form, fr As Frame, bEnable As Boolean, Optional bNoNestedFrame As Boolean = True)
'Variables...
Dim o As Object
Dim lhWnd As Long
On Error GoTo errFE
'Check all the objects...
For Each o In f
'Get container's hWnd...
lhWnd = o.Container.hwnd
'Verify and make enable or disable accordingly...
If lhWnd <> 0 And _
lhWnd = fr.hwnd Then
If Not (TypeOf o Is Frame And _
bNoNestedFrame) Then _
o.Enabled = bEnable
End If
Next o
Exit Sub
errFE:
'err 438, Object doesn't support this property or method.
'(As we don't know what the object is!)
If Err = 438 Then lhWnd = 0: Resume Next
MsgBox "Error " & Err & vbNewLine & vbNewLine & _
Error, vbCritical, f.Caption
Err.Clear
End Function
'Please tell me about bugs or suggestions... etc