Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Commit 306c54d

Browse files
committed
Add several menu-related methods
Closes #437
1 parent 63daa40 commit 306c54d

13 files changed

+634
-22
lines changed

src/User32.Tests/User32Facts.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.IO;
77
using System.Linq;
8+
using System.Runtime.InteropServices;
89
using System.Threading;
910
using PInvoke;
1011
using Xunit;
@@ -147,4 +148,13 @@ public void SetWindowLongPtr_Test()
147148
}
148149
}
149150
}
151+
152+
[Fact]
153+
public void MENUBARINFO_MarshalSizeAsExpected()
154+
{
155+
MENUBARINFO info = default;
156+
int expectedSize = IntPtr.Size == 4 ? 0x20 : 0x30;
157+
Assert.Equal(expectedSize, Marshal.SizeOf(info));
158+
Assert.Equal(expectedSize, MENUBARINFO.Create().cbSize);
159+
}
150160
}

src/User32/PublicAPI.Shipped.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ PInvoke.User32.MENUITEMINFO.MENUITEMINFO() -> void
276276
PInvoke.User32.MENUITEMINFO.cbSize -> int
277277
PInvoke.User32.MENUITEMINFO.cch -> int
278278
PInvoke.User32.MENUITEMINFO.dwItemData -> System.IntPtr
279-
PInvoke.User32.MENUITEMINFO.dwTypeData -> string
279+
PInvoke.User32.MENUITEMINFO.dwTypeData -> char*
280280
PInvoke.User32.MENUITEMINFO.fMask -> PInvoke.User32.MenuMembersMask
281281
PInvoke.User32.MENUITEMINFO.fState -> PInvoke.User32.MenuItemState
282282
PInvoke.User32.MENUITEMINFO.fType -> PInvoke.User32.MenuItemType
@@ -1884,7 +1884,7 @@ static extern PInvoke.User32.GetCursorPos(out PInvoke.POINT lpPoint) -> bool
18841884
static extern PInvoke.User32.GetDesktopWindow() -> System.IntPtr
18851885
static extern PInvoke.User32.GetForegroundWindow() -> System.IntPtr
18861886
static extern PInvoke.User32.GetKeyState(int nVirtKey) -> short
1887-
static extern PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, ref PInvoke.User32.MENUITEMINFO lpmii) -> bool
1887+
static extern PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO* lpmii) -> bool
18881888
static extern PInvoke.User32.GetMessage(PInvoke.User32.MSG* lpMsg, System.IntPtr hWnd, PInvoke.User32.WindowMessage wMsgFilterMin, PInvoke.User32.WindowMessage wMsgFilterMax) -> int
18891889
static extern PInvoke.User32.GetMonitorInfo(System.IntPtr hMonitor, PInvoke.User32.MONITORINFO* lpmi) -> bool
18901890
static extern PInvoke.User32.GetMonitorInfoEx(System.IntPtr hMonitor, PInvoke.User32.MONITORINFOEX* lpmi) -> bool
@@ -1957,7 +1957,7 @@ static extern PInvoke.User32.SetCapture(System.IntPtr hWnd) -> System.IntPtr
19571957
static extern PInvoke.User32.SetClipboardData(int uFormat, void* hMem) -> void*
19581958
static extern PInvoke.User32.SetCursorPos(int X, int Y) -> bool
19591959
static extern PInvoke.User32.SetForegroundWindow(System.IntPtr hWnd) -> bool
1960-
static extern PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, ref PInvoke.User32.MENUITEMINFO lpmii) -> bool
1960+
static extern PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO* lpmii) -> bool
19611961
static extern PInvoke.User32.SetParent(System.IntPtr hWndChild, System.IntPtr hWndNewParent) -> System.IntPtr
19621962
static extern PInvoke.User32.SetProcessDPIAware() -> bool
19631963
static extern PInvoke.User32.SetProcessWindowStation(PInvoke.User32.SafeWindowStationHandle hWinSta) -> bool

src/User32/PublicAPI.Unshipped.txt

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ PInvoke.User32.DPI_HOSTING_BEHAVIOR
4343
PInvoke.User32.DPI_HOSTING_BEHAVIOR.DPI_HOSTING_BEHAVIOR_DEFAULT = 0 -> PInvoke.User32.DPI_HOSTING_BEHAVIOR
4444
PInvoke.User32.DPI_HOSTING_BEHAVIOR.DPI_HOSTING_BEHAVIOR_INVALID = -1 -> PInvoke.User32.DPI_HOSTING_BEHAVIOR
4545
PInvoke.User32.DPI_HOSTING_BEHAVIOR.DPI_HOSTING_BEHAVIOR_MIXED = 1 -> PInvoke.User32.DPI_HOSTING_BEHAVIOR
46+
PInvoke.User32.GetMenuDefaultItemFlags
47+
PInvoke.User32.GetMenuDefaultItemFlags.GMDI_GOINTOPOPUPS = 2 -> PInvoke.User32.GetMenuDefaultItemFlags
48+
PInvoke.User32.GetMenuDefaultItemFlags.GMDI_USEDISABLED = 1 -> PInvoke.User32.GetMenuDefaultItemFlags
49+
PInvoke.User32.GetMenuStateFlags
50+
PInvoke.User32.GetMenuStateFlags.MF_BYCOMMAND = 0 -> PInvoke.User32.GetMenuStateFlags
51+
PInvoke.User32.GetMenuStateFlags.MF_BYPOSITION = 1024 -> PInvoke.User32.GetMenuStateFlags
4652
PInvoke.User32.GetNextWindowCommands
4753
PInvoke.User32.GetNextWindowCommands.GW_HWNDNEXT = 2 -> PInvoke.User32.GetNextWindowCommands
4854
PInvoke.User32.GetNextWindowCommands.GW_HWNDPREV = 3 -> PInvoke.User32.GetNextWindowCommands
@@ -68,6 +74,46 @@ PInvoke.User32.LoadImageFlags.LR_LOADTRANSPARENT = 32 -> PInvoke.User32.LoadImag
6874
PInvoke.User32.LoadImageFlags.LR_MONOCHROME = 1 -> PInvoke.User32.LoadImageFlags
6975
PInvoke.User32.LoadImageFlags.LR_SHARED = 32768 -> PInvoke.User32.LoadImageFlags
7076
PInvoke.User32.LoadImageFlags.LR_VGACOLOR = 128 -> PInvoke.User32.LoadImageFlags
77+
PInvoke.User32.MENUBARINFO
78+
PInvoke.User32.MENUBARINFO.MENUBARINFO() -> void
79+
PInvoke.User32.MENUBARINFO.cbSize -> int
80+
PInvoke.User32.MENUBARINFO.fBarFocused.get -> bool
81+
PInvoke.User32.MENUBARINFO.fBarFocused.set -> void
82+
PInvoke.User32.MENUBARINFO.fFocused.get -> bool
83+
PInvoke.User32.MENUBARINFO.fFocused.set -> void
84+
PInvoke.User32.MENUBARINFO.hMenu -> System.IntPtr
85+
PInvoke.User32.MENUBARINFO.hwndMenu -> System.IntPtr
86+
PInvoke.User32.MENUBARINFO.rcBar -> PInvoke.RECT
87+
PInvoke.User32.MENUINFO
88+
PInvoke.User32.MENUINFO.Create() -> PInvoke.User32.MENUINFO
89+
PInvoke.User32.MENUINFO.MENUINFO() -> void
90+
PInvoke.User32.MENUINFO.cbSize -> int
91+
PInvoke.User32.MENUINFO.cyMax -> uint
92+
PInvoke.User32.MENUINFO.dwContextHelpID -> uint
93+
PInvoke.User32.MENUINFO.dwMenuData -> System.UIntPtr
94+
PInvoke.User32.MENUINFO.dwStyle -> PInvoke.User32.MenuInfoStyle
95+
PInvoke.User32.MENUINFO.fMask -> PInvoke.User32.MenuInfoMask
96+
PInvoke.User32.MENUINFO.hbrBack -> System.IntPtr
97+
PInvoke.User32.MENUITEMINFO.dwTypeData_IntPtr.get -> System.IntPtr
98+
PInvoke.User32.MENUITEMINFO.dwTypeData_IntPtr.set -> void
99+
PInvoke.User32.MenuInfoMask
100+
PInvoke.User32.MenuInfoMask.MIM_APPLYTOSUBMENUS = 2147483648 -> PInvoke.User32.MenuInfoMask
101+
PInvoke.User32.MenuInfoMask.MIM_BACKGROUND = 2 -> PInvoke.User32.MenuInfoMask
102+
PInvoke.User32.MenuInfoMask.MIM_HELPID = 4 -> PInvoke.User32.MenuInfoMask
103+
PInvoke.User32.MenuInfoMask.MIM_MAXHEIGHT = 1 -> PInvoke.User32.MenuInfoMask
104+
PInvoke.User32.MenuInfoMask.MIM_MENUDATA = 8 -> PInvoke.User32.MenuInfoMask
105+
PInvoke.User32.MenuInfoMask.MIM_STYLE = 16 -> PInvoke.User32.MenuInfoMask
106+
PInvoke.User32.MenuInfoStyle
107+
PInvoke.User32.MenuInfoStyle.MNS_AUTODISMISS = 268435456 -> PInvoke.User32.MenuInfoStyle
108+
PInvoke.User32.MenuInfoStyle.MNS_CHECKORBMP = 67108864 -> PInvoke.User32.MenuInfoStyle
109+
PInvoke.User32.MenuInfoStyle.MNS_DRAGDROP = 536870912 -> PInvoke.User32.MenuInfoStyle
110+
PInvoke.User32.MenuInfoStyle.MNS_MODELESS = 1073741824 -> PInvoke.User32.MenuInfoStyle
111+
PInvoke.User32.MenuInfoStyle.MNS_NOCHECK = 2147483648 -> PInvoke.User32.MenuInfoStyle
112+
PInvoke.User32.MenuInfoStyle.MNS_NOTIFYBYPOS = 134217728 -> PInvoke.User32.MenuInfoStyle
113+
PInvoke.User32.MenuObject
114+
PInvoke.User32.MenuObject.OBJID_CLIENT = 4294967292 -> PInvoke.User32.MenuObject
115+
PInvoke.User32.MenuObject.OBJID_MENU = 4294967293 -> PInvoke.User32.MenuObject
116+
PInvoke.User32.MenuObject.OBJID_SYSMENU = 4294967295 -> PInvoke.User32.MenuObject
71117
PInvoke.User32.SafeCursorHandle
72118
PInvoke.User32.SafeCursorHandle.SafeCursorHandle() -> void
73119
PInvoke.User32.SafeCursorHandle.SafeCursorHandle(System.IntPtr preexistingHandle, bool ownsHandle = true) -> void
@@ -107,11 +153,21 @@ static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, sh
107153
static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, short lpClassName, string lpWindowName, PInvoke.User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInstance, void* lpParam) -> System.IntPtr
108154
static PInvoke.User32.GetCursorInfo(System.IntPtr pci) -> bool
109155
static PInvoke.User32.GetCursorInfo(out PInvoke.User32.CURSORINFO pci) -> bool
156+
static PInvoke.User32.GetMenuBarInfo(System.IntPtr hwnd, PInvoke.User32.MenuObject idObject, int idItem, System.IntPtr pmbi) -> bool
157+
static PInvoke.User32.GetMenuInfo(System.IntPtr hMenu, System.IntPtr lpMenuInfo) -> bool
158+
static PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, System.IntPtr lpmii) -> bool
159+
static PInvoke.User32.GetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, ref PInvoke.User32.MENUITEMINFO lpmii) -> bool
160+
static PInvoke.User32.GetMenuItemRect(System.IntPtr hWnd, System.IntPtr hMenu, uint uItem, System.IntPtr lprcItem) -> bool
161+
static PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, System.IntPtr lpString, int cchMax, PInvoke.User32.GetMenuStateFlags flags) -> int
162+
static PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, char[] lpString, int cchMax, PInvoke.User32.GetMenuStateFlags flags) -> int
110163
static PInvoke.User32.GetNextWindow(System.IntPtr hWnd, PInvoke.User32.GetNextWindowCommands wCmd) -> System.IntPtr
111164
static PInvoke.User32.LoadCursor(System.IntPtr hInstance, System.IntPtr lpCursorName) -> PInvoke.User32.SafeCursorHandle
112165
static PInvoke.User32.LoadCursor(System.IntPtr hInstance, char[] lpCursorName) -> PInvoke.User32.SafeCursorHandle
113166
static PInvoke.User32.LoadImage(System.IntPtr hInst, System.IntPtr name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
114167
static PInvoke.User32.LoadImage(System.IntPtr hInst, char[] name, PInvoke.User32.ImageType type, int cx, int cy, PInvoke.User32.LoadImageFlags fuLoad) -> System.IntPtr
168+
static PInvoke.User32.MENUBARINFO.Create() -> PInvoke.User32.MENUBARINFO
169+
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, PInvoke.User32.MENUITEMINFO lpmii) -> bool
170+
static PInvoke.User32.SetMenuItemInfo(System.IntPtr hMenu, uint uItem, bool fByPosition, System.IntPtr lpmii) -> bool
115171
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, System.IntPtr dwNewLong) -> System.IntPtr
116172
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, void* dwNewLong) -> void*
117173
static PInvoke.User32.SystemParametersInfoForDpi(PInvoke.User32.SystemParametersInfoAction uiAction, int uiParam, System.IntPtr pvParam, PInvoke.User32.SystemParametersInfoFlags fWinIni, int dpi) -> bool
@@ -130,6 +186,18 @@ static extern PInvoke.User32.GetDialogDpiChangeBehavior(System.IntPtr hDlg) -> P
130186
static extern PInvoke.User32.GetDpiForSystem() -> int
131187
static extern PInvoke.User32.GetDpiForWindow(System.IntPtr hwnd) -> int
132188
static extern PInvoke.User32.GetDpiFromDpiAwarenessContext(System.IntPtr dpiAwarenessContext) -> int
189+
static extern PInvoke.User32.GetMenu(System.IntPtr hWnd) -> System.IntPtr
190+
static extern PInvoke.User32.GetMenuBarInfo(System.IntPtr hwnd, PInvoke.User32.MenuObject idObject, int idItem, PInvoke.User32.MENUBARINFO* pmbi) -> bool
191+
static extern PInvoke.User32.GetMenuCheckMarkDimensions() -> int
192+
static extern PInvoke.User32.GetMenuContextHelpId(System.IntPtr hMenu) -> uint
193+
static extern PInvoke.User32.GetMenuDefaultItem(System.IntPtr hMenu, uint fByPos, PInvoke.User32.GetMenuDefaultItemFlags gmdiFlags) -> uint
194+
static extern PInvoke.User32.GetMenuInfo(System.IntPtr hMenu, PInvoke.User32.MENUINFO* lpMenuInfo) -> bool
195+
static extern PInvoke.User32.GetMenuItemCount(System.IntPtr hMenu) -> int
196+
static extern PInvoke.User32.GetMenuItemId(System.IntPtr hMenu, int nPos) -> uint
197+
static extern PInvoke.User32.GetMenuItemRect(System.IntPtr hWnd, System.IntPtr hMenu, uint uItem, PInvoke.RECT* lprcItem) -> bool
198+
static extern PInvoke.User32.GetMenuState(System.IntPtr hMenu, uint uId, PInvoke.User32.GetMenuStateFlags uFlags) -> uint
199+
static extern PInvoke.User32.GetMenuString(System.IntPtr hMenu, uint uIDItem, char* lpString, int cchMax, PInvoke.User32.GetMenuStateFlags flags) -> int
200+
static extern PInvoke.User32.GetSubMenu(System.IntPtr hMenu, int nPos) -> System.IntPtr
133201
static extern PInvoke.User32.GetSystemDpiForProcess(PInvoke.Kernel32.SafeObjectHandle hProcess) -> int
134202
static extern PInvoke.User32.GetSystemMetricsForDpi(int nIndex, int dpi) -> int
135203
static extern PInvoke.User32.GetThreadDpiAwarenessContext() -> System.IntPtr
@@ -146,6 +214,7 @@ static extern PInvoke.User32.SetCursor(PInvoke.User32.SafeCursorHandle hCursor)
146214
static extern PInvoke.User32.SetDialogControlDpiChangeBehavior(System.IntPtr hwnd, PInvoke.User32.DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS mask, PInvoke.User32.DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS values) -> bool
147215
static extern PInvoke.User32.SetDialogDpiChangeBehavior(System.IntPtr hDlg, PInvoke.User32.DIALOG_DPI_CHANGE_BEHAVIORS mask, PInvoke.User32.DIALOG_DPI_CHANGE_BEHAVIORS values) -> bool
148216
static extern PInvoke.User32.SetLastErrorEx(uint dwErrCode, uint dwType) -> void
217+
static extern PInvoke.User32.SetMenuContextHelpId(System.IntPtr hMenu, uint helpId) -> uint
149218
static extern PInvoke.User32.SetProcessDpiAwarenessContext(System.IntPtr dpiAWarenessContext) -> bool
150219
static extern PInvoke.User32.SetThreadDpiAwarenessContext(System.IntPtr dpiContext) -> System.IntPtr
151220
static extern PInvoke.User32.SetThreadDpiHostingBehavior(PInvoke.User32.DPI_HOSTING_BEHAVIOR dpiHostingBehavior) -> PInvoke.User32.DPI_HOSTING_BEHAVIOR
@@ -157,4 +226,4 @@ static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE -> System
157226
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 -> System.IntPtr
158227
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_SYSTEM_AWARE -> System.IntPtr
159228
static readonly PInvoke.User32.DPI_AWARENESS_CONTEXT_UNAWARE -> System.IntPtr
160-
static readonly PInvoke.User32.SafeCursorHandle.Null -> PInvoke.User32.SafeCursorHandle
229+
static readonly PInvoke.User32.SafeCursorHandle.Null -> PInvoke.User32.SafeCursorHandle
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) All contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace PInvoke
5+
{
6+
using System;
7+
8+
/// <content>
9+
/// Contains the <see cref="GetMenuDefaultItemFlags"/> nested type.
10+
/// </content>
11+
public partial class User32
12+
{
13+
/// <summary>
14+
/// Flags to be passed into the <see cref="GetMenuDefaultItem(IntPtr, uint, GetMenuDefaultItemFlags)"/> method.
15+
/// </summary>
16+
[Flags]
17+
public enum GetMenuDefaultItemFlags
18+
{
19+
/// <summary>
20+
/// The function is to return a default item, even if it is disabled. By default, the function skips disabled or grayed items.
21+
/// </summary>
22+
GMDI_USEDISABLED = 0x0001,
23+
24+
/// <summary>
25+
/// If the default item is one that opens a submenu, the function is to search recursively in the corresponding submenu. If the submenu has no default item, the return value identifies the item that opens the submenu. By default, the function returns the first default item on the specified menu, regardless of whether it is an item that opens a submenu.
26+
/// </summary>
27+
GMDI_GOINTOPOPUPS = 0x0002,
28+
}
29+
}
30+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) All contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace PInvoke
5+
{
6+
/// <content>
7+
/// Contains the <see cref="GetMenuStateFlags"/> nested type.
8+
/// </content>
9+
public partial class User32
10+
{
11+
/// <summary>Flags passed to the <see cref="GetMenuStateFlags"/> method.</summary>
12+
public enum GetMenuStateFlags
13+
{
14+
/// <summary>
15+
/// Indicates that the uId parameter gives the identifier of the menu item.
16+
/// The <see cref="MF_BYCOMMAND"/> flag is the default if neither the <see cref="MF_BYCOMMAND"/> nor <see cref="MF_BYPOSITION"/> flag is specified.
17+
/// </summary>
18+
MF_BYCOMMAND = MenuItemFlags.MF_BYCOMMAND,
19+
20+
/// <summary>
21+
/// Indicates that the uId parameter gives the zero-based relative position of the menu item.
22+
/// </summary>
23+
MF_BYPOSITION = MenuItemFlags.MF_BYPOSITION,
24+
}
25+
}
26+
}

src/User32/User32+MENUBARINFO.cs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) All contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
namespace PInvoke
5+
{
6+
using System;
7+
using System.Runtime.InteropServices;
8+
9+
#pragma warning disable SA1300 // Naming matches .h file
10+
#pragma warning disable SA1303 // Const field names must begin with upper-case letter
11+
#pragma warning disable SA1623 // Docs match Microsoft published text.
12+
13+
/// <content>
14+
/// Contains the <see cref="MENUBARINFO"/> nested type.
15+
/// </content>
16+
public partial class User32
17+
{
18+
/// <summary>
19+
/// Contains menu bar information.
20+
/// </summary>
21+
public struct MENUBARINFO
22+
{
23+
/// <summary>
24+
/// The size of the structure, in bytes. The caller must set this to sizeof(MENUBARINFO).
25+
/// </summary>
26+
public int cbSize;
27+
28+
/// <summary>
29+
/// The coordinates of the menu bar, popup menu, or menu item.
30+
/// </summary>
31+
public RECT rcBar;
32+
33+
/// <summary>
34+
/// A handle to the menu bar or popup menu.
35+
/// </summary>
36+
public IntPtr hMenu;
37+
38+
/// <summary>
39+
/// A handle to the submenu.
40+
/// </summary>
41+
public IntPtr hwndMenu;
42+
43+
private const int fFocusedMask = 1 << 0;
44+
45+
private const int fBarFocusedMask = 1 << 1;
46+
47+
/// <summary>
48+
/// The integer sized location where <see cref="fBarFocused"/> and <see cref="fFocused"/> are stored as bit flags.
49+
/// </summary>
50+
private int flags;
51+
52+
/// <summary>
53+
/// If the menu bar or popup menu has the focus, this member is TRUE. Otherwise, the member is FALSE.
54+
/// </summary>
55+
public bool fBarFocused
56+
{
57+
get => (this.flags & fBarFocusedMask) == fBarFocusedMask;
58+
set
59+
{
60+
if (value)
61+
{
62+
this.flags |= fBarFocusedMask;
63+
}
64+
else
65+
{
66+
this.flags &= ~fBarFocusedMask;
67+
}
68+
}
69+
}
70+
71+
/// <summary>
72+
/// If the menu item has the focus, this member is TRUE. Otherwise, the member is FALSE.
73+
/// </summary>
74+
public bool fFocused
75+
{
76+
get => (this.flags & fFocusedMask) == fFocusedMask;
77+
set
78+
{
79+
if (value)
80+
{
81+
this.flags |= fFocusedMask;
82+
}
83+
else
84+
{
85+
this.flags &= ~fFocusedMask;
86+
}
87+
}
88+
}
89+
90+
/// <summary>
91+
/// Initializes a new instance of the <see cref="MENUBARINFO"/> struct
92+
/// with the <see cref="cbSize"/> preset as required.
93+
/// </summary>
94+
/// <returns>The newly initialized instance.</returns>
95+
public static MENUBARINFO Create()
96+
{
97+
var result = default(MENUBARINFO);
98+
result.cbSize = Marshal.SizeOf(result);
99+
return result;
100+
}
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)