1
프레임으로 작동하는 OCX를 만들었습니다. 구성 요소를 활성화/비활성화하고 다른 모든 컨트롤을 프레임 내부에 배치하여 비활성화 할 수 있기를 원합니다. 이것을 달성 할 수있는 방법이 있습니까?VB6 OCX 만들기 내부 모든 컨트롤 사용/사용 안 함
감사합니다.
프레임으로 작동하는 OCX를 만들었습니다. 구성 요소를 활성화/비활성화하고 다른 모든 컨트롤을 프레임 내부에 배치하여 비활성화 할 수 있기를 원합니다. 이것을 달성 할 수있는 방법이 있습니까?VB6 OCX 만들기 내부 모든 컨트롤 사용/사용 안 함
감사합니다.
나는 이것을 달성하기위한 몇 가지 유틸리티 방법을 만들었습니다. 자유롭게 사용하고 변경하십시오!
Option Explicit
Private Enum ControlProperty
PropertyEnabled
PropertyVisible
PropertyText
End Enum
Public Sub SetEnabledPropertyForAllControlsInFrame(frmForm As Form, strFrameCaption As String, Optional booValue As Boolean)
SetPropertyForAllControlsInFrame frmForm, strFrameCaption, PropertyEnabled, booValue
End Sub
Public Sub SetVisiblePropertyForAllControlsInFrame(frmForm As Form, strFrameCaption As String, Optional booValue As Boolean)
SetPropertyForAllControlsInFrame frmForm, strFrameCaption, PropertyVisible, booValue
End Sub
Public Sub ClearAllTextBoxesInFrame(frmForm As Form, strFrameCaption As String, Optional strText As String)
If IsMissing(strText) Then strText = vbNullString
SetPropertyForAllControlsInFrame frmForm, strFrameCaption, PropertyText, strText
End Sub
Public Sub ClearAllTextBoxesInForm(frmForm As Form, Optional ExceptInFrame As Frame)
Dim ctl As Control
Dim strCaption As String
If ExceptInFrame Is Nothing Then
For Each ctl In frmForm.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = vbNullString
End If
Next
Else
strCaption = ExceptInFrame.Caption
ExceptInFrame.Caption = "xdgerviye246123nvasdmnvwe8"
For Each ctl In frmForm.Controls
If TypeOf ctl Is TextBox Then
If TypeOf ctl.Container Is Frame Then
If Not ctl.Container.Caption = ExceptInFrame.Caption Then
ctl.Text = vbNullString
End If
End If
End If
Next
ExceptInFrame.Caption = strCaption
End If
End Sub
Public Sub ClearAllCheckBoxesInForm(frmForm As Form)
Dim ctl As Control
For Each ctl In frmForm.Controls
If TypeOf ctl Is CheckBox Then
ctl.Value = vbUnchecked
End If
Next
End Sub
Private Sub SetPropertyForAllControlsInFrame(frmForm As Form, strFrameCaption As String, enuControlProperty As ControlProperty, varValue As Variant)
Dim ctrl As Control
Dim ctrl2 As Control
For Each ctrl In frmForm.Controls
If ctrl.Container.Caption = strFrameCaption Then
Select Case enuControlProperty
Case ControlProperty.PropertyEnabled
ctrl.Container.Enabled = varValue
ctrl.Enabled = varValue
If TypeOf ctrl Is TextBox Then
ctrl.BackColor = IIf(varValue = True, vbWindowBackground, vbButtonFace)
End If
Case ControlProperty.PropertyVisible
ctrl.Container.Visible = varValue
ctrl.Visible = varValue
Case ControlProperty.PropertyText
ctrl.Text = varValue
End Select
If TypeOf ctrl Is Frame Then
SetPropertyForAllControlsInFrame frmForm, ctrl.Caption, enuControlProperty, varValue
End If
End If
Next
End Sub
컨테이너를 사용하지 않으면 포함 된 컨트롤이나 자식 컨트롤도 논리적으로 비활성화됩니다. 그들은 정상적으로 보일 것이지만 상호 작용할 수는 없습니다. – Deanna