/// <include file='doc\FontDialog.uex' path='docs/doc[@for="FontDialog.HookProc"]/*' /> /// <devdoc> /// <para> /// Specifies the common dialog box hook procedure that is overridden to add /// specific functionality to a common dialog box. /// </para> /// </devdoc> protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) { switch (msg) { case NativeMethods.WM_COMMAND: if ((int)wparam == 0x402) { NativeMethods.LOGFONT lf = new NativeMethods.LOGFONT(); UnsafeNativeMethods.SendMessage(new HandleRef(null, hWnd), NativeMethods.WM_CHOOSEFONT_GETLOGFONT, 0, lf); UpdateFont(lf); int index = (int)UnsafeNativeMethods.SendDlgItemMessage(new HandleRef(null, hWnd), 0x473, NativeMethods.CB_GETCURSEL, IntPtr.Zero, IntPtr.Zero); if (index != NativeMethods.CB_ERR) { UpdateColor((int)UnsafeNativeMethods.SendDlgItemMessage(new HandleRef(null, hWnd), 0x473, NativeMethods.CB_GETITEMDATA, (IntPtr)index, IntPtr.Zero)); } if (NativeWindow.WndProcShouldBeDebuggable) { OnApply(EventArgs.Empty); } else { try { OnApply(EventArgs.Empty); } catch (Exception e) { Application.OnThreadException(e); } } } break; case NativeMethods.WM_INITDIALOG: if (!showColor) { IntPtr hWndCtl = UnsafeNativeMethods.GetDlgItem(new HandleRef(null, hWnd), NativeMethods.cmb4); SafeNativeMethods.ShowWindow(new HandleRef(null, hWndCtl), NativeMethods.SW_HIDE); hWndCtl = UnsafeNativeMethods.GetDlgItem(new HandleRef(null, hWnd), NativeMethods.stc4); SafeNativeMethods.ShowWindow(new HandleRef(null, hWndCtl), NativeMethods.SW_HIDE); } break; } return(base.HookProc(hWnd, msg, wparam, lparam)); }