Jump to content

Recommended Posts

Posted (edited)

It's very easy to reproduce this bug. Use the help file's _GUICtrlListView_SetItem() example, and simply pass the function the actual HANDLE to the ListView control instead of the ControlID.

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView
    
    GUICreate("ListView Set Item", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    GUICtrlCreateListViewItem("Item 1", $hListView)
    GUICtrlCreateListViewItem("Item 2", $hListView)
    GUICtrlCreateListViewItem("Item 3", $hListView)

    ; Change item 2
    MsgBox(4160, "Information", "Changing item 2")
    $hListView = GUICtrlGetHandle($hListView) ; <====== NEW LINE TO REPRODUCE BUG
    _GUICtrlListView_SetItem($hListView, "New Item 2", 1)
    
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

The text is cut in half. I'm guessing a memory buffer size problem when using AutoIt Unicode?

Edited by wraithdu
Posted

I'm guessing that's a related bug then? If so, cool that it's fixed.

Is there anywhere I can get that fix, or I'll have to wait till the next beta is released?

Posted

  wraithdu said:

I'm guessing that's a related bug then? If so, cool that it's fixed.

Is there anywhere I can get that fix, or I'll have to wait till the next beta is released?

Same problem different include/function.

Posted the fix for this one at: http://www.autoitscript.com/forum/index.ph...mp;#entry521575

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

That is the version of the function I'm using (from AutoIt v3.2.12.0 final).

Can you try the example I posted in my first post? I added a GuiCtrlGetHandle line to reproduce the issue. I just run that from SciTE (F5), and get truncated text. So I think this really is a new bug.

Posted

  wraithdu said:

That is the version of the function I'm using (from AutoIt v3.2.12.0 final).

Can you try the example I posted in my first post? I added a GuiCtrlGetHandle line to reproduce the issue. I just run that from SciTE (F5), and get truncated text. So I think this really is a new bug.

Replace _GUICtrlListView_SetItemEx with the following:

Func _GUICtrlListView_SetItemEx($hWnd, ByRef $tItem)
    If $Debug_LV Then _GUICtrlListView_ValidateClassName($hWnd)
    Local $iItem, $pItem, $iBuffer, $pBuffer, $pMemory, $tMemMap, $pText, $iResult

    $pItem = DllStructGetPtr($tItem)
    If IsHWnd($hWnd) Then
        $iItem = DllStructGetSize($tItem)
        $iBuffer = DllStructGetData($tItem, "TextMax")
        If @AutoItUnicode Then $iBuffer *= 2
        $pBuffer = DllStructGetData($tItem, "Text")
        $pMemory = _MemInit($hWnd, $iItem + $iBuffer, $tMemMap)
        $pText = $pMemory + $iItem
        DllStructSetData($tItem, "Text", $pText)
        _MemWrite($tMemMap, $pItem, $pMemory, $iItem)
        If $pBuffer <> 0 Then _MemWrite($tMemMap, $pBuffer, $pText, $iBuffer)
        If @AutoItUnicode Then
            $iResult = _SendMessage($hWnd, $LVM_SETITEMW, 0, $pMemory, 0, "wparam", "ptr")
        Else
            $iResult = _SendMessage($hWnd, $LVM_SETITEMA, 0, $pMemory, 0, "wparam", "ptr")
        EndIf
        _MemFree($tMemMap)
    Else
        If @AutoItUnicode Then
            $iResult = GUICtrlSendMsg($hWnd, $LVM_SETITEMW, 0, $pItem)
        Else
            $iResult = GUICtrlSendMsg($hWnd, $LVM_SETITEMA, 0, $pItem)
        EndIf
    EndIf
    Return $iResult <> 0
EndFunc   ;==>_GUICtrlListView_SetItemEx

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

Thanks, that's got it!

Actually, that was my first fix, except I did it in the SetItem() func, not the SetItemEx() func. When I saw that SetItem() called SetItemEx(), I wasn't sure where the correct place to fix it was.

Thanks again!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...