FontDialog.HookProc(IntPtr, Int32, IntPtr, IntPtr) 메서드

정의

공용 대화 상자에 특정 기능을 추가하도록 재정의된 공용 대화 상자의 후크 프로시저를 지정합니다.

protected:
 override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam);
protected override IntPtr HookProc (IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam);
override this.HookProc : nativeint * int * nativeint * nativeint -> nativeint
Protected Overrides Function HookProc (hWnd As IntPtr, msg As Integer, wparam As IntPtr, lparam As IntPtr) As IntPtr

매개 변수

hWnd
IntPtr

nativeint

대화 상자 창에 대한 핸들입니다.

msg
Int32

받는 메시지입니다.

wparam
IntPtr

nativeint

메시지에 대한 추가 정보입니다.

lparam
IntPtr

nativeint

메시지에 대한 추가 정보입니다.

반환

IntPtr

nativeint

기본 대화 상자 프로시저가 메시지를 처리하면 0 값이고 메시지를 무시하면 0이 아닌 값입니다.

예제

다음 코드 예제에서는 메서드를 재정의하는 방법을 보여 줍니다 HookProc . 이 예제는 클래스를 상속하는 클래스로 FontDialog 구성됩니다. 클래스 재정의 HookProc 에서 예제는 특정 Windows 메시지에 대한 상수 값에 대해 메서드의 msg 매개 변수를 평가합니다. 매개 변수가 msg 지정된 상수와 같으면 이 예제에서는 메서드에 전달된 Windows 메시지를 식별하는 추적 출력을 HookProc 씁니다. 이 예제에서는 메서드가 선언된 클래스가 HookProc 클래스를 상속해야 합니다 FontDialog .

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...
   [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.
      #if defined(TRACE)
      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;
      }
      #endif
     
      // Always call the base class hook procedure.
      return FontDialog::HookProc( hWnd, msg, wParam, lParam );
   }

// 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...
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);
}
    ' 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

설명

후크 프로시저는 함수는 애플리케이션에 도달 하기 전에 이벤트를 가로챌 수 있습니다 하는 메커니즘입니다. 클래스에 CommonDialog.HookProc 대한 CommonDialog 메서드를 재정의하면 운영 체제에서 함수 재정의를 호출하여 운영 체제 메시지를 창에 게시합니다.

상속자 참고

재정의 하는 경우 HookProc(IntPtr, Int32, IntPtr, IntPtr) 파생된 클래스에서 호출 해야 기본 클래스의 HookProc(IntPtr, Int32, IntPtr, IntPtr) 메서드.

적용 대상

추가 정보