简体   繁体   English

如何删除字体编辑器标题栏

[英]How to remove FontEditor Titlebar

Calling out ColorEditor needs to implement IWindowsFormsEditorService and IServiceProvider.调用 ColorEditor 需要实现 IWindowsFormsEditorService 和 IServiceProvider。 The Color Dialog has a great flexibility to integrate in a DropDownForm.颜色对话框可以非常灵活地集成到 DropDownForm 中。 But FontEditor Window has build-in CloseButton and Titlebar already.但是 FontEditor Window 已经内置了 CloseButton 和 Titlebar。 Why MS implements so different things inside dialogs?为什么 MS 在对话框中实现了如此不同的东西? How to get rid of the CloseButton and Titlebar?如何摆脱关闭按钮和标题栏? Does Caling out FontEditor have to use IWindowsFormsEditorService and IServiceProvider?调出 FontEditor 是否必须使用 IWindowsFormsEditorService 和 IServiceProvider?

在此处输入图片说明

  1. Why MS implements so different things inside dialogs?为什么 MS 在对话框中实现了如此不同的东西?

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. FontEditor 只是一个弹出窗口,我现在不可能这样做。

  1. Does Caling out FontEditor have to use IWindowsFormsEditorService and IServiceProvider?调出 FontEditor 是否必须使用 IWindowsFormsEditorService 和 IServiceProvider?

I did try, it seems we we have to use both, even though IWindowsFormsEditorService is not being called actually我确实尝试过,似乎我们必须同时使用两者,即使实际上并未调用 IWindowsFormsEditorService

. .

    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;
        }
       ///.....
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM