Posted 23 November 2021, 1:46 am EST
If I have a Visual Style on a winform - like this:
this.VisualStyle = C1.Win.C1Ribbon.VisualStyle.Office2010Black;
then if I add a submenu to a system menu of the form, clicking on the item in the submenu closes the form!
If there is no VisualStyle set, it works fine. Please tell me if there is some workaround…
Here’s the code:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool AppendMenu(IntPtr hMenu, int uFlags, int uIDNewItem, string lpNewItem); [DllImport("user32.dll")] public static extern IntPtr CreatePopupMenu(); public const int MF_STRING = 0x00000000; public const int MF_POPUP = 0x00000010; protected override void OnLoad(EventArgs e) { base.OnLoad(e); Ribbon.Show(); IntPtr hSysMenu = GetSystemMenu(this.Handle, false); AppendMenu(hSysMenu, MF_STRING, 0x10005, "another menu item"); var hSubMenu = CreatePopupMenu(); AppendMenu(hSubMenu, MF_STRING, 0x10010, "submenu"); AppendMenu(hSysMenu, MF_POPUP, (int)hSubMenu, "submenu item"); }