IonicWind Software

IWBasic => GUI Central => Topic started by: zaphod on December 13, 2009, 11:48:06 AM

Title: Detecting checked menu
Post by: zaphod on December 13, 2009, 11:48:06 AM
Hello,
I search to detect if a menu is checked or disabled...
How to do that ??
Title: Re: Detecting checked menu
Post by: LarryMc on December 13, 2009, 02:11:40 PM
See if this helps you:

http://www.ionicwind.com/forums/index.php/topic,2110.msg21168.html#msg21168

Larry
Title: Re: Detecting checked menu
Post by: zaphod on December 14, 2009, 01:04:37 AM
Thanx Larry for reply.
Thats what i search.
But its not easy to adapt for emergence basic... ouch !

On another basic there is an order
on purebasic : GetMenuItemState
on blitzmax : menuchecked, menu enabled

I continue my search...
Title: Re: Detecting checked menu
Post by: fasecero on December 14, 2009, 03:59:07 AM
Here is a possible adaptation, not fully tested:



CONST MIIM_STATE = 1
CONST MIIM_ID = 2
CONST MIIM_SUBMENU = 4
CONST MIIM_CHECKMARKS = 8
CONST MIIM_TYPE = 16
CONST MIIM_DATA = 32
CONST MIIM_STRING = 64
CONST MIIM_BITMAP = 128
CONST MIIM_FTYPE = 256

CONST MFS_CHECKED = 8
CONST MFS_DEFAULT = 4096
CONST MFS_DISABLED = 1
CONST MFS_ENABLED = 0
CONST MFS_GRAYED = 3
CONST MFS_HILITE = 128
CONST MFS_UNCHECKED = 0
CONST MFS_UNHILITE = 0

TYPE MENUITEMINFO
DEF cbSize AS INT
DEF fMask AS INT
DEF fType AS INT
DEF fState AS INT
DEF wID AS INT
DEF hSubMenu AS INT
DEF hbmpChecked AS INT
DEF hbmpUnchecked AS INT
DEF dwItemData AS INT
DEF dwTypeData AS POINTER
DEF cch AS INT
ENDTYPE

DECLARE IMPORT, _RtlZeroMemory ALIAS RtlZeroMemory(dest AS POINTER,numBytes AS INT)
DECLARE IMPORT, _GetMenuItemInfo ALIAS GetMenuItemInfoA(hMenu AS INT,un AS INT,b AS INT,lpMenuItemInfo AS MENUITEMINFO),INT
DECLARE IMPORT, _GetMenu ALIAS GetMenu(hwnd AS INT),INT




' return: 1 enabled, 0 disabled
SUB MenuItemIsEnabled(window w, uint itemid), INT
MENUITEMINFO mii
int hmenu, state

hmenu = _GetMenu(w.hwnd)
_RtlZeroMemory(&mii, LEN(mii) )
mii.cbSize = LEN(mii)
mii.fMask = MIIM_STATE
mii.wID = itemid

IF _GetMenuItemInfo(hMenu, itemid, 0, mii) THEN
IF (mii.fState & MFS_DISABLED) = MFS_DISABLED THEN RETURN 0
IF (mii.fState & MFS_GRAYED) = MFS_GRAYED THEN RETURN 0
ENDIF
RETURN 1
ENDSUB

' return : 1 checked, 0 unchecked
SUB MenuItemIsChecked(window w, uint itemid), INT
MENUITEMINFO mii
int hmenu, state

hmenu = _GetMenu(w.hwnd)
_RtlZeroMemory(&mii, LEN(mii) )
mii.cbSize = LEN(mii)
mii.fMask = MIIM_STATE
mii.wID = itemid

IF _GetMenuItemInfo(hMenu, itemid, 0, mii) THEN
IF (mii.fState & MFS_CHECKED) = MFS_CHECKED THEN RETURN 1
ENDIF
RETURN 0
ENDSUB

Title: Re: Detecting checked menu
Post by: zaphod on December 14, 2009, 07:35:43 AM
Thanx fasecero, very good and useful for me !