Sign in to follow this  
Followers 0
CatchFish

Something interesting with GuiCtrlCreateListViewItem()

3 posts in this topic

Just see the example:

#include <GUIConstants.au3>
#include <GuiListView.au3>
;Generated with Form Designer preview
$Form1 = GUICreate("AForm1", 531, 225, -1, -1)
$ListView1 = GUICtrlCreateListView("Col01|Col02", 16, 16, 281, 193)
_GUICtrlListViewSetColumnWidth(-1, 0, 120)
_GUICtrlListViewSetColumnWidth(-1, 1, 120)
$Button1 = GUICtrlCreateButton("GuiCtrlCreateListViewItem() +", 312, 16, 201, 25)
$Button2 = GUICtrlCreateButton("_GUICtrlListViewInsertItem() +", 312, 48, 201, 25)
$Button3 = GUICtrlCreateButton("Clear All", 312, 80, 201, 25)
$Label1 = GUICtrlCreateLabel("After you", 312, 144, 200, 17, $SS_CENTER)
$Button4 = GUICtrlCreateButton("Open a new form", 312, 160, 201, 25)
$Label2 = GUICtrlCreateLabel("...Button1 is NOT functioning.", 312, 192, 200, 17, $SS_CENTER)
GUISetState(@SW_SHOW)
Dim $Timer = -1
Dim $Form2
While 1
    If $Timer <> -1 And TimerDiff($Timer) > 2000 Then
        GUISetState(@SW_ENABLE, $Form1)
        GUIDelete($Form2)
    EndIf
    $msg = GuiGetMsg()
    Select
    Case $msg = $Button1
        GUICtrlCreateListViewItem('Button1|GuiCtrlCreateListViewItem', $ListView1)
    Case $msg = $Button2
        _GUICtrlListViewInsertItem($ListView1, _GUICtrlListViewGetItemCount($ListView1), 'Button2|_GuiCtrlListViewInsertItem')
    Case $msg = $Button3
        _GUICtrlListViewDeleteAllItems($ListView1)
    Case $msg = $Button4
        $Form2 = GUICreate("AForm2", 320, 200, -1, -1)
        $Label3 = GUICtrlCreateLabel("...Will be closed in 2 seconds...", 0, 90, 320, 17, $SS_CENTER)
        GUISetState(@SW_SHOW, $Form2)
        GUISetState(@SW_DISABLE, $Form1)
        $Timer = TimerInit()
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

...and the image:

(AutoIt v3.1.1.87)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not a bug, see code below.

#include <GUIConstants.au3>
#include <GuiListView.au3>
;Generated with Form Designer preview
$Form1 = GUICreate("AForm1", 531, 225, -1, -1)
$ListView1 = GUICtrlCreateListView("Col01|Col02", 16, 16, 281, 193)
_GUICtrlListViewSetColumnWidth (-1, 0, 120)
_GUICtrlListViewSetColumnWidth (-1, 1, 120)
$Button1 = GUICtrlCreateButton("GuiCtrlCreateListViewItem() +", 312, 16, 201, 25)
$Button2 = GUICtrlCreateButton("_GUICtrlListViewInsertItem() +", 312, 48, 201, 25)
$Button3 = GUICtrlCreateButton("Clear All", 312, 80, 201, 25)
$Label1 = GUICtrlCreateLabel("After you", 312, 144, 200, 17, $SS_CENTER)
$Button4 = GUICtrlCreateButton("Open a new form", 312, 160, 201, 25)
$Label2 = GUICtrlCreateLabel("...Button1 is NOT functioning.", 312, 192, 200, 17, $SS_CENTER)
GUISetState(@SW_SHOW)
Dim $Timer = -1
Dim $Form2
While 1
    If $Timer <> - 1 And TimerDiff($Timer) > 2000 Then
        GUISetState(@SW_ENABLE, $Form1)
        GUIDelete($Form2)
    ;*************************************
    ; Added the following line
        $Timer = -1
    EndIf
    $msg = GUIGetMsg()
    Select
        Case $msg = $Button1
            GUICtrlCreateListViewItem('Button1|GuiCtrlCreateListViewItem', $ListView1)
        Case $msg = $Button2
            _GUICtrlListViewInsertItem ($ListView1, _GUICtrlListViewGetItemCount ($ListView1), 'Button2|_GuiCtrlListViewInsertItem')
        Case $msg = $Button3
            _GUICtrlListViewDeleteAllItems ($ListView1)
        Case $msg = $Button4
            $Form2 = GUICreate("AForm2", 320, 200, -1, -1)
            $Label3 = GUICtrlCreateLabel("...Will be closed in 2 seconds...", 0, 90, 320, 17, $SS_CENTER)
            GUISetState(@SW_SHOW, $Form2)
            GUISetState(@SW_DISABLE, $Form1)
            $Timer = TimerInit()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

Thanks a lot, gafrost. I've been perplexed by this issue for days.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0