CommonDialog.HookProc メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CommonDialog.HookProc メソッドの意味・解説 

CommonDialog.HookProc メソッド

コモン ダイアログ ボックス特定の機能追加するためにオーバーライドされる、コモン ダイアログ ボックスフック プロシージャ定義します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Protected Overridable Function
 HookProc ( _
    hWnd As IntPtr, _
    msg As Integer, _
    wparam As IntPtr, _
    lparam As IntPtr _
) As IntPtr
Dim hWnd As IntPtr
Dim msg As Integer
Dim wparam As IntPtr
Dim lparam As IntPtr
Dim returnValue As IntPtr

returnValue = Me.HookProc(hWnd, msg, wparam, lparam)
protected virtual IntPtr HookProc (
    IntPtr hWnd,
    int msg,
    IntPtr wparam,
    IntPtr lparam
)
protected:
virtual IntPtr HookProc (
    IntPtr hWnd, 
    int msg, 
    IntPtr wparam, 
    IntPtr lparam
)
protected IntPtr HookProc (
    IntPtr hWnd, 
    int msg, 
    IntPtr wparam, 
    IntPtr lparam
)
protected function HookProc (
    hWnd : IntPtr, 
    msg : int, 
    wparam : IntPtr, 
    lparam : IntPtr
) : IntPtr

パラメータ

hWnd

ダイアログ ボックス ウィンドウ識別するハンドル

msg

受信しているメッセージ

wparam

メッセージについての追加情報

lparam

メッセージについての追加情報

戻り値
既定ダイアログ ボックス プロシージャメッセージ処理する場合は 0。既定ダイアログ ボックス プロシージャではメッセージ無視する場合は 0 以外。

解説解説

フック プロシージャにより、イベントアプリケーション到達する前に関数イベント認識できます。CommonDialog クラスHookProc メソッドオーバーライドすると、オペレーティング システム関数オーバーライド呼び出してオペレーティング システム メッセージウィンドウポストます。

既定では、フック プロシージャは、WM_INITDIALOG メッセージ応答してダイアログ ボックス画面中央配置します

メモメモ

このメソッドは SecurityAction.LinkDemand を使用して信頼関係のないコードからの呼び出し防ぎます。SecurityPermissionAttribute.UnmanagedCode アクセス許可は、直前呼び出し元にのみ要求されます。信頼性一部しか確認されていないコードから呼び出すことができるコード場合ユーザー入力検証せずに Marshal クラスに渡すことは避けてくださいLinkDemand メンバ使用に関する重要な制約事項については、「Demand と LinkDemand」を参照してください

このプロパティまた、SecurityAction.InheritanceDemand セキュリティ属性使用します。このメンバオーバーライドするには、派生クラスCustomPermission アクセス許可持っている必要があります

継承時の注意 継承クラスでは、コモン ダイアログ ボックス特定の機能追加するために、このメソッドオーバーライドできます派生クラスHookProcオーバーライドする場合は、基本クラスHookProc メソッド呼び出してください

使用例使用例

HookProc メソッドオーバーライドする方法次のコード例示します。この例は CommonDialog クラス継承するクラスから構成されています。また、クラスHookProc オーバーライドで、msg パラメータWindows メッセージ定数に対して評価してます。msg パラメータ指定した定数等し場合HookProc メソッド渡されWindows メッセージ識別するトレース出力書き込みますまた、この例は、HookProc メソッド宣言されているクラスCommonDialog クラス継承することを前提にしています。

    ' Defines the constants for Windows messages.

    Const WM_SETFOCUS = &H7
    Const WM_INITDIALOG = &H110
    Const WM_LBUTTONDOWN = &H201
    Const WM_RBUTTONDOWN = &H204
    Const WM_MOVE = &H3
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
    Protected Overrides Function
 HookProc(ByVal hWnd As IntPtr, ByVal
 msg As Integer, ByVal wParam As IntPtr, ByVal lParam As
 IntPtr) As IntPtr


        ' Evaluates the message parameter to determine the user action.

        Select Case msg

            Case WM_INITDIALOG
                System.Diagnostics.Trace.Write("The WM_INITDIALOG
 message was received.")
            Case WM_SETFOCUS
                System.Diagnostics.Trace.Write("The WM_SETFOCUS
 message was received.")
            Case WM_LBUTTONDOWN
                System.Diagnostics.Trace.Write("The WM_LBUTTONDOWN
 message was received.")
            Case WM_RBUTTONDOWN
                System.Diagnostics.Trace.Write("The WM_RBUTTONDOWN
 message was received.")
            Case WM_MOVE
                System.Diagnostics.Trace.Write("The WM_MOVE message
 was received.")

        End Select

        ' Always call the base class hook procedure.

        Return MyBase.HookProc(hWnd, msg, wParam,
 lParam)

    End Function
// Defines the constants for Windows messages.

const int WM_SETFOCUS = 0x0007;
const int WM_INITDIALOG = 0x0110;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_RBUTTONDOWN = 0x0204;
const int WM_MOVE = 0x0003;

// Overrides the base class hook procedure...
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name="FullTrust")] 
protected override IntPtr HookProc(IntPtr hWnd, int
 msg, IntPtr wParam, IntPtr lParam)
{

    // Evaluates the message parameter to determine the user action.

    switch(msg)
    {

        case WM_INITDIALOG:
            System.Diagnostics.Trace.Write("The WM_INITDIALOG message was received.");
            break;
        case WM_SETFOCUS:
            System.Diagnostics.Trace.Write("The WM_SETFOCUS message was received.");
            break;
        case WM_LBUTTONDOWN:
            System.Diagnostics.Trace.Write("The WM_LBUTTONDOWN message was received.");
            break;
        case WM_RBUTTONDOWN:
            System.Diagnostics.Trace.Write("The WM_RBUTTONDOWN message was received.");
            break;
        case WM_MOVE:
            System.Diagnostics.Trace.Write("The WM_MOVE message was received.");
            break;

    }

    // Always call the base class hook procedure.

    return base.HookProc(hWnd, msg, wParam,
 lParam);

}
   private:
      // Defines the constants for Windows messages.
      literal int WM_SETFOCUS = 0x0007;
      literal int WM_INITDIALOG = 0x0110;
      literal int WM_LBUTTONDOWN = 0x0201;
      literal int WM_RBUTTONDOWN = 0x0204;
      literal int WM_MOVE = 0x0003;

   protected:
      // Overrides the base class hook procedure...
//      [System::Security::Permissions::SecurityPermission(System::Security::Permissions::SecurityAction::Demand,
 Flags=SecurityPermissionFlag::UnmanagedCode)] 
      [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
 
      virtual IntPtr HookProc( IntPtr hWnd, int msg, IntPtr wParam,
 IntPtr lParam ) override
      {
         // Evaluates the message parameter to determine the user action.
         switch ( msg )
         {
            case WM_INITDIALOG:
               System::Diagnostics::Trace::Write( "The WM_INITDIALOG message
 was received." );
               break;
            case WM_SETFOCUS:
               System::Diagnostics::Trace::Write( "The WM_SETFOCUS message was
 received." );
               break;
            case WM_LBUTTONDOWN:
               System::Diagnostics::Trace::Write( "The WM_LBUTTONDOWN message
 was received." );
               break;
            case WM_RBUTTONDOWN:
               System::Diagnostics::Trace::Write( "The WM_RBUTTONDOWN message
 was received." );
               break;
            case WM_MOVE:
               System::Diagnostics::Trace::Write( "The WM_MOVE message was received."
 );
               break;
         }
         
         // Always call the base class hook procedure.
         return FontDialog::HookProc( hWnd, msg, wParam, lParam
 );
      }
    // Defines the constants for Windows messages.
    final int WM_SETFOCUS = 0x7;
    final int WM_INITDIALOG = 0x110;
    final int WM_LBUTTONDOWN = 0x201;
    final int WM_RBUTTONDOWN = 0x204;
    final int WM_MOVE = 0x3;

    // Overrides the base class hook procedure...
//    /** @attribute System.Security.Permissions.PermissionSet(System.Security.
//        Permissions.SecurityAction.Demand, Name = "FullTrust")
//     */
    /** @attribute SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)
     */
    protected IntPtr HookProc(IntPtr hWnd, int
 msg, IntPtr wParam, 
        IntPtr lParam)
    {
        // Evaluates the message parameter to determine the user action.
        switch (msg) {
            case WM_INITDIALOG :
                System.Diagnostics.Trace.Write(
                    "The WM_INITDIALOG message was received.");
                break;

            case WM_SETFOCUS :
                System.Diagnostics.Trace.Write(
                    "The WM_SETFOCUS message was received.");
                break;

            case WM_LBUTTONDOWN :
                System.Diagnostics.Trace.Write(
                    "The WM_LBUTTONDOWN message was received.");
                break;

            case WM_RBUTTONDOWN :
                System.Diagnostics.Trace.Write(
                    "The WM_RBUTTONDOWN message was received.");
                break;

            case WM_MOVE :
                System.Diagnostics.Trace.Write(
                    "The WM_MOVE message was received.");
                break;
        }

        // Always call the base class hook procedure.
        return super.HookProc(hWnd, msg, wParam, lParam);
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CommonDialog.HookProc メソッド」の関連用語

CommonDialog.HookProc メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CommonDialog.HookProc メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS