CommonDialog 類別

定義

指定用來在螢幕上顯示對話方塊的基底類別 (Base Class) 。

public ref class CommonDialog abstract : System::ComponentModel::Component
public abstract class CommonDialog : System.ComponentModel.Component
type CommonDialog = class
    inherit Component
Public MustInherit Class CommonDialog
Inherits Component
繼承
衍生

範例

下列程式碼範例會 ColorDialog 使用 的 實作 CommonDialog ,並說明如何建立及顯示對話方塊。 這個範例會要求從現有表單內呼叫 方法,該表單上有 , TextBoxButton 放在它上。

private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      ColorDialog^ MyDialog = gcnew ColorDialog;
      // Keeps the user from selecting a custom color.
      MyDialog->AllowFullOpen = false;
      // Allows the user to get help. (The default is false.)
      MyDialog->ShowHelp = true;
      // Sets the initial color select to the current text color.
      MyDialog->Color = textBox1->ForeColor;
      
      // Update the text box color if the user clicks OK 
      if ( MyDialog->ShowDialog() == ::System::Windows::Forms::DialogResult::OK )
      {
         textBox1->ForeColor = MyDialog->Color;
      }
   }
private void button1_Click(object sender, System.EventArgs e)
 {
    ColorDialog MyDialog = new ColorDialog();
    // Keeps the user from selecting a custom color.
    MyDialog.AllowFullOpen = false ;
    // Allows the user to get help. (The default is false.)
    MyDialog.ShowHelp = true ;
    // Sets the initial color select to the current text color.
    MyDialog.Color = textBox1.ForeColor ;
    
    // Update the text box color if the user clicks OK 
    if (MyDialog.ShowDialog() == DialogResult.OK)
        textBox1.ForeColor =  MyDialog.Color;
 }
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyDialog As New ColorDialog()
    ' Keeps the user from selecting a custom color.
    MyDialog.AllowFullOpen = False
    ' Allows the user to get help. (The default is false.)
    MyDialog.ShowHelp = True
    ' Sets the initial color select to the current text color,
    MyDialog.Color = TextBox1.ForeColor

    ' Update the text box color if the user clicks OK 
    If (MyDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then
        TextBox1.ForeColor = MyDialog.Color
    End If
End Sub

備註

若要實 RunDialog 作繼承的類別,請叫用 ShowDialog 來建立特定的通用對話方塊。 繼承的類別可以選擇性地覆寫 HookProc 以實作特定的對話方塊勾點功能。

建構函式

CommonDialog()

初始化 CommonDialog 類別的新執行個體。

屬性

CanRaiseEvents

取得值,指出元件是否能引發事件。

(繼承來源 Component)
Container

取得包含 IContainerComponent

(繼承來源 Component)
DesignMode

取得值,指出 Component 目前是否處於設計模式。

(繼承來源 Component)
Events

取得附加在這個 Component 上的事件處理常式清單。

(繼承來源 Component)
Site

取得或設定 ComponentISite

(繼承來源 Component)
Tag

取得或設定包含控制項相關資料的物件。

方法

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 Component 所使用的所有資源。

(繼承來源 Component)
Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Component)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。

(繼承來源 Component)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
HookProc(IntPtr, Int32, IntPtr, IntPtr)

定義為了將特定功能加入通用對話方塊中而覆寫的通用對話方塊攔截程序。

InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
OnHelpRequest(EventArgs)

引發 HelpRequest 事件。

OwnerWndProc(IntPtr, Int32, IntPtr, IntPtr)

定義為了將特定功能加入通用對話方塊中而覆寫的主控視窗 (Owner Window) 程序。

Reset()

在衍生類別中覆寫時,重設通用對話方塊的屬性為其預設值。

RunDialog(IntPtr)

在衍生類別中覆寫時,指定通用對話方塊。

ShowDialog()

以預設的擁有人來執行通用對話方塊。

ShowDialog(IWin32Window)

以指定的擁有人來執行通用對話方塊。

ToString()

傳回任何包含 Component 名稱的 String。 不應覆寫此方法。

(繼承來源 Component)

事件

Disposed

Dispose() 方法的呼叫處置元件時,就會發生。

(繼承來源 Component)
HelpRequest

發生於使用者按一下通用對話方塊上的 [說明] 按鈕時。

適用於