How to remove FontEditor Titlebar

38 Views Asked by At

Calling out ColorEditor needs to implement IWindowsFormsEditorService and IServiceProvider. The Color Dialog has a great flexibility to integrate in a DropDownForm. But FontEditor Window has build-in CloseButton and Titlebar already. Why MS implements so different things inside dialogs? How to get rid of the CloseButton and Titlebar? Does Caling out FontEditor have to use IWindowsFormsEditorService and IServiceProvider?

enter image description here

1

There are 1 best solutions below

0
On
  1. Why MS implements so different things inside dialogs?

I haven't yet checked the reflected code. I am not interesting in it. I just like complains.

  1. How to get rid of the CloseButton and Titlebar?

FontEditor is just a popup window, it is impossible for me to do so at this moment.

  1. Does Caling out FontEditor have to use IWindowsFormsEditorService and IServiceProvider?

I did try, it seems we we have to use both, even though IWindowsFormsEditorService is not being called actually

.

    private void btnFont_Click(object sender, EventArgs e)
    {
        Point location = base.PointToScreen(new Point(btnFont.Bounds.Location.X, btnFont.Bounds.Location.Y + btnFont.Bounds.Height));
        DropDownManager myFontDialog = new DropDownManager(btnFont, new Rectangle(location, new Size(0, 0)), false, false, "Please choose...");                     
        object objectValue = new FontEditor().EditValue(myFontDialog, previousChoosenFont);
        if (objectValue != null)
        {
            previousChoosenFont = (Font)objectValue;
        }
        btnFont.Font = previousChoosenFont;
    }

   internal class DropDownManager : IWindowsFormsEditorService, IServiceProvider, IDisposable
    {
       ///......
       void IWindowsFormsEditorService.CloseDropDown()
        {
            throw new NotSupportedException();
        }

        void IWindowsFormsEditorService.DropDownControl(Control dropDownControl)
        {            
            throw new NotSupportedException();
        }

        DialogResult IWindowsFormsEditorService.ShowDialog(Form dialog)
        {
            throw new NotSupportedException();
        }

        object IServiceProvider.GetService(Type serviceType)
        {
            object result = null;
            if (serviceType.Equals(typeof(IWindowsFormsEditorService)))
            {
                result = this;
            }
            return result;
        }
       ///.....
}