﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1664	_GuiCtrlTab_GetItem() fails to retrieve item text in some cases	PsaltyDS	Jpm	"Ref A:  [http://www.autoitscript.com/forum/index.php?showtopic=113952&view=findpost&p=797042]

Ref B:  [http://www.autoitscript.com/forum/index.php?showtopic=115365&view=findpost&p=805972]

In certain situations (like maybe #32770 dialogs with tabs) _GuiCtrlTab_GetItem() returns no text in $aItem[1].  This in turn causes _GuiCtrlTab_GetItemText() and _GuiCtrlTab_FindTab() to fail because they depend on it.

I proposed the following patch, but both the problem and other implications of the solution are over my head:  [http://www.autoitscript.com/forum/index.php?showtopic=113952&view=findpost&p=797412]


{{{
Func _GUICtrlTab_GetItem($hWnd, $iIndex)
	If $Debug_TAB Then __UDF_ValidateClassName($hWnd, $__TABCONSTANT_ClassName)
	If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
	Local $fUnicode = _GUICtrlTab_GetUnicodeFormat($hWnd)

	Local $iBuffer = 4096
	Local $tItem = DllStructCreate($tagTCITEM)
	Local $pItem = DllStructGetPtr($tItem)
	DllStructSetData($tItem, ""Mask"", $TCIF_ALLDATA)
	DllStructSetData($tItem, ""TextMax"", $iBuffer)
	DllStructSetData($tItem, ""StateMask"", BitOR($TCIS_HIGHLIGHTED, $TCIS_BUTTONPRESSED))
	Local $iItem = DllStructGetSize($tItem)
	Local $tBuffer
	If $fUnicode Then
		$tBuffer = DllStructCreate(""wchar Text["" & $iBuffer & ""]"")
		$iBuffer *= 2
	Else
		$tBuffer = DllStructCreate(""char Text["" & $iBuffer & ""]"")
	EndIf
	Local $pBuffer = DllStructGetPtr($tBuffer)
	Local $tMemMap
	Local $pMemory = _MemInit($hWnd, $iItem + $iBuffer, $tMemMap)


	; Start Bug patch..................................................
	;Local $pText = $pMemory + $iItem
	Local $pText = $pMemory + $iItem + 4 ; add room for 32-bit pointer
    If @AutoItX64 Then $pText += 4 ; more room for 64-bit pointer
	; End Bug patch....................................................


	DllStructSetData($tItem, ""Text"", $pText)
	_MemWrite($tMemMap, $pItem, $pMemory, $iItem)
	Local $iRet
	If $fUnicode Then
		$iRet = _SendMessage($hWnd, $TCM_GETITEMW, $iIndex, $pMemory)
	Else
		$iRet = _SendMessage($hWnd, $TCM_GETITEMA, $iIndex, $pMemory)
	EndIf
	_MemRead($tMemMap, $pMemory, $pItem, $iItem)
	_MemRead($tMemMap, $pText, $pBuffer, $iBuffer)
	_MemFree($tMemMap)
	Local $aItem[4]
	$aItem[0] = DllStructGetData($tItem, ""State"")
	$aItem[1] = DllStructGetData($tBuffer, ""Text"")
	$aItem[2] = DllStructGetData($tItem, ""Image"")
	$aItem[3] = DllStructGetData($tItem, ""Param"")
	Return SetError($iRet <> 0, 0, $aItem)
EndFunc   ;==>_GUICtrlTab_GetItem
}}}

"	Bug	closed	3.3.7.0	Standard UDFs	3.3.6.1	None	Fixed		
