try this.
Code: Select all
Procedure IsXEnabled(hWnd)
mii.MENUITEMINFO
mii\cbSize=SizeOf(MENUITEMINFO)
mii\fMask=#MIIM_STATE
result=999
GetSystemMenu_(hWnd, #True)
hSysMenu=GetSystemMenu_(hWnd,#False)
Debug hSysMenu ; 374605515 (OK)
If hSysMenu
info=GetMenuItemInfo_(hSysMenu,#SC_CLOSE, 0, @mii)
Debug info ; 0 (Failure)
If info
result=Bool(mii\fState=#MFS_ENABLED)
EndIf
EndIf
ProcedureReturn result
EndProcedure
hWnd=FindWindow_(0,"Untitled - Notepad") ; "Unbenannt - Editor" "Untitled - Notepad"
If hWnd=0
Debug "Please start Notepad manually and run this code TWICE to see the problem!"
Else
Debug IsXEnabled(hWnd) ; Returns 999 on SECOND run because "info" var is 0 (failed).
EndIf
EDit: Sorry, had to change to the english version of Notepad.