/// <summary>
    /// When overridden in a derived class, specifies a common dialog box.
    /// </summary>
    /// <returns>
    /// true if the dialog box was successfully run; otherwise, false.
    /// </returns>
    /// <param name="hwndOwner">A value that represents the window handle of the owner window for the common dialog box. </param>
    protected override bool RunDialog(IntPtr hwndOwner)
    {
      NativeMethods.LOGFONT lf;
      NativeMethods.CHOOSEFONT cf;
      IntPtr plf;
      bool result;
      int minSize;
      int maxSize;
      bool showColor;

      lf = new NativeMethods.LOGFONT();

      this.Font.ToLogFont(lf);

      plf = Marshal.AllocHGlobal(Marshal.SizeOf(lf));
      Marshal.StructureToPtr(lf, plf, false);

      showColor = this.ShowColor || this.ShowEffects;

      cf = new NativeMethods.CHOOSEFONT();
      cf.lStructSize = Marshal.SizeOf(typeof(NativeMethods.CHOOSEFONT));
      cf.Flags = this.GetFlags();
      cf.hwndOwner = hwndOwner;
      cf.lpfnHook = this.HookProc;

      minSize = this.MinSize;
      maxSize = this.MaxSize;
      if (minSize > 0 || maxSize > 0)
      {
        cf.nSizeMin = minSize;
        cf.nSizeMax = maxSize > 0 ? maxSize : int.MaxValue;
      }

      cf.rgbColors = ColorTranslator.ToWin32(showColor ? this.Color : Color.Black);

      cf.lpLogFont = plf;

      try
      {
        result = NativeMethods.ChooseFont(ref cf);

        if (result)
        {
          // create a managed font from the updated LOGFONT
          lf = (NativeMethods.LOGFONT)Marshal.PtrToStructure(plf, typeof(NativeMethods.LOGFONT));
          if (!string.IsNullOrEmpty(lf.lfFaceName))
          {
            this.UpdateFont(lf);
          }

          // and update the color
          if (showColor)
          {
            this.UpdateColor(cf.rgbColors);
          }
        }
      }
      finally
      {
        // always be freein' allocated memory!
        Marshal.FreeHGlobal(plf);
      }

      return result;
    }
 public static extern bool ChooseFont([In][Out] NativeMethods.CHOOSEFONT cf);