Modify

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: 3.3.7.0 Component: Standard UDFs
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

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

Attachments (0)

Change History (1)

comment:1 Changed 14 years ago by Jpm

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

Fixed by revision [5868] in version: 3.3.7.0

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

Action
as closed The owner will remain Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.