[v2.1+] Menu: Get CheckState

Propose new features and changes
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

[v2.1+] Menu: Get CheckState

Post by jNizM » 21 Oct 2021, 05:27

ToggleCheck Method from Menu should return Check state (0 / 1)

Atm I do:

Code: Select all

TrayFunc(ItemName, ItemPos, *)
{
	TrayMain.ToggleCheck(ItemName)
	CheckState := MenuCheckState(TrayMain.Handle, ItemPos))
}

MenuCheckState(Handle, Item)
{
	static MF_BYPOSITION := 0x00000400
	static MF_CHECKED    := 0x00000008

	MenuState := DllCall("user32\GetMenuState", "Ptr", Handle, "UInt", Item - 1, "UInt", MF_BYPOSITION, "UInt")
	if (MenuState = -1)
		return -1
	return !!(MenuState & MF_CHECKED)
}

ref:
https://lexikos.github.io/v2/docs/objects/Menu.htm#ToggleCheck
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmenustate
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: [v2.1] Menu: Get CheckState

Post by jNizM » 22 Nov 2022, 04:20

renovation / resumption for v2.1
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

Post Reply

Return to “Wish List”