System.Windows.Forms.CommonDialog.HookProc Method

Defines the common dialog box hook procedure that is overridden to add specific functionality to a common dialog box.

Syntax

protected virtual IntPtr HookProc (IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)

Parameters

hWnd
The handle to the dialog box window.
msg
The message being received.
wparam
Additional information about the message.
lparam
Additional information about the message.

Returns

A zero value if the default dialog box procedure processes the message; a nonzero value if the default dialog box procedure ignores the message.

Remarks

A hook procedure is a mechanism by which a function can intercept events before they reach an application. When you override the CommonDialog.HookProc(IntPtr, int, IntPtr, IntPtr) method for a System.Windows.Forms.CommonDialog class, the operating system invokes your override of the function to post operating system messages to the window.

By default, the hook procedure centers the dialog box on the screen in response to a WM_INITDIALOG message.

Note:

This method uses System.Security.Permissions.SecurityAction.LinkDemand to prevent it from being called from untrusted code; only the immediate caller is required to have System.Security.Permissions.SecurityPermissionAttribute.UnmanagedCode permission. If your code can be called from partially trusted code, do not pass user input to System.Runtime.InteropServices.Marshal class methods without validation. For important limitations on using the LinkDemand member, see [<topic://cpcondemandvslinkdemand>].

This property also uses the System.Security.Permissions.SecurityAction.InheritanceDemand security attribute; to override this member, the derived class must have the CustomPermission permission.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0