﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2034	_GUICtrlMenu_AppendMenu - bug when BitOr($MF_BYPOSITION, $MF_STRING) is used	Zedna	trancexx	"MSDN link to AppendMenu API
[http://msdn.microsoft.com/en-us/library/windows/desktop/ms647616%28v=vs.85%29.aspx
]

I use it this way

{{{
$Form1 = GUICreate(...)
CreateSystemMenuItem("""") ; separator
$id_about = CreateSystemMenuItem(""About"")

Func CreateSystemMenuItem($sText, $hMenu = -1)
    If $hMenu = -1 Then $hMenu = _GUICtrlMenu_GetSystemMenu($Form1, 0)

    Local $nID = GUICtrlCreateDummy()
    Local $nFlags = 0

    If $sText = """" Then $nFlags = $MF_SEPARATOR
    $nFlags = BitOr($MF_BYPOSITION, $nFlags)

    _GUICtrlMenu_AppendMenu($hMenu, $nFlags, $nID, $sText)
    Return $nID
EndFunc
}}}


On older Autoit 3.2.12.1 it was OK but on latest beta _GUICtrlMenu_AppendMenu() was changed and it doesn't work --> About system menu item is not created (separator is OK). Tested on beta 3.3.7.18.

I discovered source of problem:

{{{
Func _GUICtrlMenu_AppendMenu3($hMenu, $iFlags, $iNewItem, $pNewItem)
	Local $sType= ""ptr""
	If BitAND($iFlags, $MF_STRING) = $MF_STRING Then $sType= ""wstr"" ; --> CORRECTION
; 	If $iFlags = 0 Then $sType= ""wstr""		; $MF_STRING is equal to 0 ; --> BUG HERE
	Local $aResult = DllCall(""User32.dll"", ""bool"", ""AppendMenuW"", ""handle"", $hMenu, ""uint"", $iFlags, ""uint_ptr"", $iNewItem, $sType, $pNewItem)
	If @error Then Return SetError(@error, @extended, False)
	If $aResult[0] = 0 Then Return SetError(10, 0, False)

	_GUICtrlMenu_DrawMenuBar(_GUICtrlMenu_FindParent($hMenu))
	Return True
EndFunc   ;==>_GUICtrlMenu_AppendMenu
}}}

Instead of
If $iFlags = 0 Then $sType= ""wstr""
is needed to use
If BitAND($iFlags, $MF_STRING) = $MF_STRING Then $sType= ""wstr""

because wstr type should be used for MF_STRING no matter what other flags (MF_BYPOSITION) are used"	Bug	closed	3.3.7.22	Standard UDFs	3.3.7.18	None	Fixed		
