FontDialog::HookProc Method (IntPtr, Int32, IntPtr, IntPtr)
Specifies the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
protected: [SecurityPermissionAttribute(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::UnmanagedCode)] virtual IntPtr HookProc( IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam ) override
Parameters
- hWnd
-
Type:
System::IntPtr
The handle to the dialog box window.
- msg
-
Type:
System::Int32
The message being received.
- wparam
-
Type:
System::IntPtr
Additional information about the message.
- lparam
-
Type:
System::IntPtr
Additional information about the message.
Return Value
Type: System::IntPtrA zero value if the default dialog box procedure processes the message; a nonzero value if the default dialog box procedure ignores the message.
A hook procedure is a mechanism by which a function can intercept events before they reach an application. When you override the CommonDialog::HookProc method for a CommonDialog class, the operating system invokes your override of the function to post operating system messages to the window.
Notes to Inheritors:
When overriding HookProc in a derived class, be sure to call the base class's HookProc method.
The following code example demonstrates how to override the HookProc method. The example consists of a class that inherits the FontDialog class. In the class's HookProc override, the example evaluates the method's msg parameter against constant values for particular Windows messages. If the msg parameter equals the specified constant, the example writes trace output identifying the Windows message that was passed to the HookProc method. This example requires that the class in which the HookProc method is declared inherits the FontDialog class.
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 ); }
Available since 1.1