May 11, 2024, 03:59:13 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Detecting checked menu

Started by zaphod, December 13, 2009, 11:48:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zaphod

Hello,
I search to detect if a menu is checked or disabled...
How to do that ??

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

zaphod

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...

fasecero

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


zaphod

Thanx fasecero, very good and useful for me !