Frage

I can set the icon to a 1x1 or transparent icon but I do not like that solution because the user could still click on it.

I could do something like this if it was the mdiParents mainMenuStrip:

private void mainMenuStrip_ItemEventHandler(Object sender, ToolStripItemEventArgs e)
        {
            if (e.Item.Text == "")
            {
                e.Item.Visible = false;//This will hide any toolstrip items that do not have text... ex. the SystemMenu.
            }
        }

but the UltraToolbarsManager.Toolbars do not have this event.

setting ShowIcon to false for the mdiChild only works when the mdiChild form is not maximized.

I also tried overloading the mdiChild SizeChanged event and looping through the Tools to see if I could find the one to hide but that did not work either:

private void MdiChild_SizeChanged(object sender, EventArgs e)
        {
            Form theForm = sender as Form;
            switch (theForm.WindowState)
            {
                case FormWindowState.Maximized:
                    theForm.Icon = Icon.FromHandle(Properties.Resources.blank.GetHicon());
                        foreach (UltraToolbar ut in UltraToolbarsManager1.Toolbars)
                        {
                            if (ut.IsMainMenuBar)
                            {
                                foreach (ToolBase tb in ut.Tools)
                                {
                                    //This collection does not contain the one I want to hide.

                                    // maybe?
                                    if (tb is MdiMergePlaceholderTool)
                                    {
                                        tb.SharedProps.Visible = false;
                                    }
                                }
                            }
                        }
                    break;
            }
        }

The UltraToolbarsManager and UltraToolbar do not appear to have any events that I can handle to try and remove things that are being merged into a toolbar...

This is the exact question that I also have.. but it is not answered: http://www.infragistics.com/community/forums/t/33396.aspx

I think this is an updated link to what the other post suggests but modifying 100 forms to inherit like this is not an option for me: http://help.infragistics.com/Help/NetAdvantage/WinForms/2013.1/CLR4.0/html/Win_Creation_Filter.html

A few possibilities: - Hide the item in an OnItemAdded event. - Remove the icon from the UltraToolbar.. maybe in an OnMerge event. - An event to cancel the context menu if the icon can't be hidden/removed. - Some way to get a reference to the Icon item would be nice.

Thanks in advance for any replies.

War es hilfreich?

Lösung

Looking at the provied information, I suppose that you are using our default mode of UltraToolbarManager, because if you are using Ribbon mode then you could hide the system Icon through property ShowIcon of your MDIChild form. At that moment we didn`t implement such functionality (except for Ribbon mode) to hide your Icon or SystemMenu, so you have two possible options to solve this task. Option 1: You could use CreationFilter. For example:

public Form1()
{
    InitializeComponent();
    ultraToolbarsManager1.CreationFilter = new HideIcon();
}


class HideIcon : IUIElementCreationFilter
{
    public void AfterCreateChildElements(UIElement parent)
    {

    }

    public bool BeforeCreateChildElements(UIElement parent)
    {
        if (parent is PopupToolUIElement)
        {
            parent.Parent.ChildElements.Remove(parent);
        }
        return false;
    }
}

You could find sample in our forum thread : http://www.infragistics.com/community/forums/t/33396.aspx

Another possible approach could be if you implement:

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 RemoveMenu(IntPtr hMenu, Int32 nPosition, Int32 wFlags);

or

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern bool DestroyMenu(IntPtr menu);

By this way you could destroy your menu when maximize your MDIChild form and create again context menu when change the state of your MDIChild form using :

[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr CreatePopupMenu();

I think that the best option for you to solve this task could be if you are using CreationFilter

Let me know if you have any questions Regards

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top