Opened 14 years ago

Closed 14 years ago

#1664 closed Bug (Fixed)

_GuiCtrlTab_GetItem() fails to retrieve item text in some cases

Reported by: PsaltyDS Owned by: Jpm
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:


Ref A:

Ref B:

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:

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
		$tBuffer = DllStructCreate("char Text[" & $iBuffer & "]")
	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)
		$iRet = _SendMessage($hWnd, $TCM_GETITEMA, $iIndex, $pMemory)
	_MemRead($tMemMap, $pMemory, $pItem, $iItem)
	_MemRead($tMemMap, $pText, $pBuffer, $iBuffer)
	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

Attachments (0)

Change History (1)

comment:1 Changed 14 years ago by Jpm

  • Milestone set to
  • Owner changed from Gary to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [5868] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Jpm.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.