다음을 통해 공유


Control.ControlAccessibleObject 클래스

내게 필요한 옵션 지원 응용 프로그램에서 사용할 수 있는 컨트롤에 대한 정보를 제공합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<ComVisibleAttribute(True)> _
Public Class ControlAccessibleObject
    Inherits AccessibleObject
‘사용 방법
Dim instance As ControlAccessibleObject
[ComVisibleAttribute(true)] 
public class ControlAccessibleObject : AccessibleObject
[ComVisibleAttribute(true)] 
public ref class ControlAccessibleObject : public AccessibleObject
/** @attribute ComVisibleAttribute(true) */ 
public class ControlAccessibleObject extends AccessibleObject
ComVisibleAttribute(true) 
public class ControlAccessibleObject extends AccessibleObject

설명

Windows Forms는 기본적으로 내게 필요한 옵션을 지원하며 내게 필요한 옵션 지원 클라이언트 응용 프로그램과 작업할 수 있도록 응용 프로그램에 대한 정보를 제공합니다. 내게 필요한 옵션 지원 응용 프로그램에는 화면 확대기 및 검토기 유틸리티, 음성 입력 유틸리티, 화상 키보드, 대체 입력 장치, 키보드 향상 유틸리티 등이 있습니다. 내게 필요한 옵션 지원 클라이언트 응용 프로그램에 대한 추가 정보를 제공할 수도 있습니다. 이러한 추가 정보를 제공하는 두 가지 방법은 다음과 같습니다. 기존 컨트롤에 대한 제한적인 내게 필요한 옵션 정보를 제공하려면 내게 필요한 옵션 지원 클라이언트 응용 프로그램에 보고될 해당 컨트롤의 AccessibleName, AccessibleDescription, AccessibleDefaultActionDescriptionAccessibleRole 속성 값을 설정합니다. 또한 AccessibleObject 또는 Control.ControlAccessibleObject 클래스에서 사용자 자신의 컨트롤을 파생시킨 다음 보다 많은 액세스 가능성 정보를 컨트롤에 포함하도록 작성할 수 있습니다. 예를 들어, 일반 컨트롤에서 파생되지 않는 사용자 자신의 컨트롤을 작성하거나 사용자 컨트롤 내에서 적중 테스트 같은 작업이 필요한 경우 CreateAccessibilityInstance 메서드를 호출하여 사용자 컨트롤에 대해 Control.ControlAccessibleObject를 만들어야 합니다.

참고

AccessibleObject.GetChild 메서드를 재정의하는 경우 AccessibleObject.GetChildCount 메서드도 재정의해야 합니다. AccessibilityObject 속성을 가져오거나 설정하려면 .NET Framework와 함께 설치된 Accessibility 어셈블리에 참조를 추가해야 합니다.

내게 필요한 옵션 지원 개체에 대한 자세한 내용은 MSDN Library의 Active Accessibility 단원을 참조하십시오.

예제

다음 코드 예제에서는 CheckBox 클래스에서 파생되는 CheckBox 컨트롤을 만들고 사용할 파생 클래스에 대한 사용자 지정 Control.ControlAccessibleObject를 만듭니다. 파생된 클래스인 MyCheckBox에는 기본적으로 토글 단추로 나타나도록 ButtonAppearance가 있습니다. 파생된 Control.ControlAccessibleObject 클래스인 MyCheckBoxControlAccessibleObject는 모양 차이가 고려되도록 세 가지 속성이 재정의됩니다.

Imports System
Imports System.Windows.Forms
Imports Accessibility
Imports System.Drawing

Namespace MyCustomControls
   Public Class MyCheckBox
      Inherits CheckBox
      
      Public Sub New()
         ' Make the check box appear like a toggle button.
         Me.Appearance = Appearance.Button
         ' Center the text on the button.
         Me.TextAlign = ContentAlignment.MiddleCenter
      End Sub
      
      ' Create an instance of the AccessibleObject 
      ' defined for the 'MyCheckBox' control 
      Protected Overrides Function CreateAccessibilityInstance() _
        As AccessibleObject
         Return New MyCheckBoxAccessibleObject(Me)
      End Function
   End Class
    
   ' Accessible object for use with the 'MyCheckBox' control.
   Friend Class MyCheckBoxAccessibleObject
      Inherits Control.ControlAccessibleObject
      
      Public Sub New(owner As MyCheckBox)
         MyBase.New(owner)
      End Sub
      
      Public Overrides ReadOnly Property DefaultAction() As String
         Get
            ' Return the DefaultAction based upon 
            ' the state of the control. 
            If CType(Owner, MyCheckBox).Checked Then
               Return "Toggle button up"
            Else
               Return "Toggle button down"
            End If
         End Get
      End Property
      
      Public Overrides Property Name() As String
         Get
            ' Return the Text property of the control 
            ' if the AccessibleName is null. 
            Dim accessibleName As String = Owner.AccessibleName
            If Not (accessibleName Is Nothing) Then
               Return accessibleName
            End If
            Return CType(Owner, MyCheckBox).Text
         End Get

         Set
            MyBase.Name = value
         End Set
      End Property
      
      Public Overrides ReadOnly Property Role() As AccessibleRole
         Get
            ' Since the check box appears like a button,
            ' make the Role the same as a button. 
            Return AccessibleRole.PushButton
         End Get
      End Property
   End Class
End Namespace
using System;
using System.Windows.Forms;
using Accessibility;
using System.Drawing;

namespace MyCustomControls
{
   public class MyCheckBox : CheckBox
   {
      public MyCheckBox()
      {
         // Make the check box appear like a toggle button.
         this.Appearance = Appearance.Button;
         // Center the text on the button.
         this.TextAlign = ContentAlignment.MiddleCenter;
     // Set the AccessibleDescription text.
         this.AccessibleDescription = "A toggle style button.";
      }
      
      // Create an instance of the AccessibleObject 
      // defined for the 'MyCheckBox' control
      protected override AccessibleObject CreateAccessibilityInstance() 
      {
         return new MyCheckBoxAccessibleObject(this);
      }
   }

   // Accessible object for use with the 'MyCheckBox' control.
   internal class MyCheckBoxAccessibleObject : Control.ControlAccessibleObject 
   {
      public MyCheckBoxAccessibleObject(MyCheckBox owner) : base(owner) 
      {
        
      }
               
      public override string DefaultAction 
      {
         get
         {
            // Return the DefaultAction based upon 
            // the state of the control.
            if( ((MyCheckBox)Owner).Checked )
            {
               return "Toggle button up";
            }
            else
            {
               return "Toggle button down";
            }
         }
      }

      public override string Name 
      {
         get 
         {
            // Return the Text property of the control 
            // if the AccessibleName is null.
            string name = Owner.AccessibleName;
            if (name != null) 
            {
               return name;
            }
            return ((MyCheckBox)Owner).Text;
         }
         
         set
         {
            base.Name = value;
         }
      }            
               
      public override AccessibleRole Role 
      {
         get 
         {
            // Since the check box appears like a button,
            // make the Role the same as a button.
            return AccessibleRole.PushButton;
         }
      }
   }
}
#using <Accessibility.dll>
#using <System.Drawing.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Windows::Forms;
using namespace System::Drawing;

namespace MyCustomControls
{
   public ref class MyCheckBox: public CheckBox
   {
   public:
      MyCheckBox()
      {
         // Make the check box appear like a toggle button.
         this->Appearance = ::Appearance::Button;

         // Center the text on the button.
         this->TextAlign = ContentAlignment::MiddleCenter;

         // Set the AccessibleDescription text.
         this->AccessibleDescription = "A toggle style button.";
      }

   protected:

      // Create an instance of the AccessibleObject
      // defined for the 'MyCheckBox' control
      virtual AccessibleObject^ CreateAccessibilityInstance() override;
   };

   // Accessible Object* for use with the 'MyCheckBox' control.
   private ref class MyCheckBoxAccessibleObject: public Control::ControlAccessibleObject
   {
   public:
      MyCheckBoxAccessibleObject( MyCheckBox^ owner )
         : ControlAccessibleObject( owner )
      {}

      property String^ DefaultAction 
      {
         virtual String^ get() override
         {
            // Return the DefaultAction based upon
            // the state of the control.
            if ( (dynamic_cast<MyCheckBox^>(Owner))->Checked )
            {
               return "Toggle button up";
            }
            else
            {
               return "Toggle button down";
            }
         }
      }

      property String^ Name 
      {
         virtual String^ get() override
         {
            // Return the Text property of the control
            // if the AccessibleName is 0.
            String^ name = Owner->AccessibleName;
            if ( name != nullptr )
            {
               return name;
            }

            return (dynamic_cast<MyCheckBox^>(Owner))->Text;
         }

         virtual void set( String^ value ) override
         {
            ControlAccessibleObject::Name = value;
         }
      }

      property AccessibleRole Role 
      {
         virtual AccessibleRole get() override
         {
            // Since the check box appears like a button,
            // make the Role the same as a button.
            return AccessibleRole::PushButton;
         }
      }
   };

   AccessibleObject^ MyCheckBox::CreateAccessibilityInstance()
   {
      return gcnew MyCheckBoxAccessibleObject( this );
   }
}
package MyCustomControls;
import System.*;
import System.Windows.Forms.*;
import Accessibility.*;
import System.Drawing.*;

public class MyCheckBox extends CheckBox
{
    public MyCheckBox()
    {
        // Make the check box appear like a toggle button.
        this.set_Appearance(get_Appearance().Button);
        // Center the text on the button.
        this.set_TextAlign(ContentAlignment.MiddleCenter);
        // Set the AccessibleDescription text.
        this.set_AccessibleDescription("A toggle style button.");
    } //MyCheckBox

    // Create an instance of the AccessibleObject 
    // defined for the 'MyCheckBox' control
    protected AccessibleObject CreateAccessibilityInstance()
    {
        return new MyCheckBoxAccessibleObject(this);
    } //CreateAccessibilityInstance
} //MyCheckBox

// Accessible object for use with the 'MyCheckBox' control.
class MyCheckBoxAccessibleObject extends Control.ControlAccessibleObject
{
    public MyCheckBoxAccessibleObject(MyCheckBox owner)
    {
         super(owner);
    } //MyCheckBoxAccessibleObject

    /** @property 
     */
    public String get_DefaultAction()
    {
        // Return the DefaultAction based upon 
        // the state of the control.
        if (((MyCheckBox)get_Owner()).get_Checked()) {
            return "Toggle button up";
        }
        else {
            return "Toggle button down";
        }
    } //get_DefaultAction

    /** @property 
     */
    public String get_Name()
    {
        // Return the Text property of the control 
        // if the AccessibleName is null.
        String name = get_Owner().get_AccessibleName();
        if (name != null) {
            return name;
        }
        return ((MyCheckBox)get_Owner()).get_Text();
    } //get_Name

    /** @property 
     */
    public void set_Name(String value)
    {
        super.set_Name(value);
    } //set_Name

    /** @property 
     */
    public AccessibleRole get_Role()
    {
        // Since the check box appears like a button,
        // make the Role the same as a button.
        return AccessibleRole.PushButton;
    } //get_Role
} //MyCheckBoxAccessibleObject

상속 계층 구조

System.Object
   System.MarshalByRefObject
     System.Runtime.InteropServices.StandardOleMarshalObject
       System.Windows.Forms.AccessibleObject
        System.Windows.Forms.Control.ControlAccessibleObject
           System.Windows.Forms.ButtonBase.ButtonBaseAccessibleObject
           System.Windows.Forms.DataGridView.DataGridViewAccessibleObject
           System.Windows.Forms.DateTimePicker.DateTimePickerAccessibleObject
           System.Windows.Forms.DomainUpDown.DomainUpDownAccessibleObject
           System.Windows.Forms.ToolStrip.ToolStripAccessibleObject

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Control.ControlAccessibleObject 멤버
System.Windows.Forms 네임스페이스
AccessibleObject 클래스
Control.AccessibleName 속성
Control.AccessibleDescription 속성
Control.AccessibleDefaultActionDescription 속성
Control.AccessibleRole 속성