#include once "window9.bi"

Function GetStateMenu(ByVal menu As HMENU,ByVal iNpos As Long) As Integer Export
	
	var iState=GetMenuState(menu, CInt(iNpos) , 0)
	
	If (iState And MF_CHECKED ) AndAlso (iState And MF_GRAYED ) Then
		
		Return 4
		
	ElseIf (iState And MF_CHECKED ) AndAlso (iState And MF_DISABLED ) Then
		
		Return 5
		
	ElseIf (iState And MF_CHECKED ) Then
		
		Return 3
		
	ElseIf (iState And MF_GRAYED ) Then
		
		Return 1
		
	ElseIf (iState And MF_DISABLED ) Then   
		
		Return 2
		
	ElseIf (iState = 0) then
		
		Return 0
		
	Else
		
		Return -1
		
	EndIf	
	
End Function
