Sign in to follow this  
Followers 0
GaryFrost

Child windows and Listviews Bug?

5 posts in this topic

#1 ·  Posted (edited)

I believe this is a bug Using latest beta 3.1.1.61 , but want to find here 1st if it is:

first example doesn't work correctly, Child1 Window then Child2 Window is created in that order

Second example by creating Child2 Window then Child1 Window works correctly

Example 1:

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)

Dim $listview, $listview2, $Btn_MoveLeft, $Btn_MoveRight, $Btn_Exit, $msg, Const $LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1036
$Main_GUI, $Child1_GUI,$Child2_GUI
$Main_GUI = GUICreate("ListView Move Items Selected", 440, 200)

$Btn_MoveRight = GUICtrlCreateButton("-->", 175, 35, 90, 35, $BS_ICON )
GUICtrlSetImage ( $Btn_MoveRight, @SystemDir & "\progman.exe", 45, 0 )

$Btn_MoveLeft = GUICtrlCreateButton("<--", 175, 80, 90, 35, $BS_ICON )
GUICtrlSetImage ( $Btn_MoveLeft, @SystemDir & "\progman.exe", 44, 0 )

$Btn_Exit = GUICtrlCreateButton("Exit", 175, 140, 90, 25 )

;==========================================================
$Child1_GUI = GUICreate("Child1 Window",155,195,0,0,BitOR($WS_CHILD,$WS_DLGFRAME),-1,$Main_GUI)
$listview = GUICtrlCreateListView("col1|col2|col3", 5, 5, 145, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
;==========================================================

;==========================================================
$Child2_GUI = GUICreate("Child2 Window",155,195,278,0,BitOR($WS_CHILD,$WS_DLGFRAME),-1,$Main_GUI)
$listview2 = GUICtrlCreateListView("col1|col2|col3", 5, 5, 145, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
;==========================================================

GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)

GUISetState(@SW_SHOW , $Main_GUI)
GUISetState(@SW_SHOW , $Child1_GUI)
GUISetState(@SW_SHOW , $Child2_GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_MoveRight
            _GUICtrlListViewMoveSelectedItems ($listview, $listview2)
        Case $msg = $Btn_MoveLeft
            _GUICtrlListViewMoveSelectedItems ($listview2, $listview)
    EndSelect
WEnd
Exit

Func _GUICtrlListViewMoveSelectedItems($h_Source_listview, $h_Destination_listview, $s_WindowTitle = "", $s_WindowText = "")
   Local $a_indices, $i, $s_item, $control_ID
    If (_GUICtrlListViewGetSelectedCount($h_Source_listview)) Then
        If (StringLen($s_WindowTitle) == 0) Then
            $s_WindowTitle = WinGetTitle("")
        EndIf
        $a_indices = _GUICtrlListViewGetSelectedIndices($h_Source_listview, 1, $s_WindowTitle, $s_WindowText)
        For $i = 1 To $a_indices[0]
            $s_item = _GUICtrlListViewGetItemText($h_Source_listview, $a_indices[$i], -1, $s_WindowTitle, $s_WindowText)
            GUICtrlCreateListViewItem($s_item, $h_Destination_listview)
        Next
      ControlListView($s_WindowTitle, $s_WindowText, $h_Source_listview, "SelectClear")
        For $i = $a_indices[0] To 1 Step -1
            _GUICtrlListViewSetItemSelState($h_Source_listview, $a_indices[$i])
            $control_ID = GUICtrlRead($h_Source_listview)
            ConsoleWrite($control_ID & @LF)
            GUICtrlDelete($control_ID)
        Next
    EndIf
EndFunc  ;==>_GUICtrlListViewMoveSelectedItems

Example2:

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $listview2, $Btn_MoveLeft, $Btn_MoveRight, $Btn_Exit, $msg, Const $LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1036
$Main_GUI, $Child1_GUI,$Child2_GUI
$Main_GUI = GUICreate("ListView Move Items Selected", 440, 200)

$Btn_MoveRight = GUICtrlCreateButton("-->", 175, 35, 90, 35, $BS_ICON )
GUICtrlSetImage ( $Btn_MoveRight, @SystemDir & "\progman.exe", 45, 0 )

$Btn_MoveLeft = GUICtrlCreateButton("<--", 175, 80, 90, 35, $BS_ICON )
GUICtrlSetImage ( $Btn_MoveLeft, @SystemDir & "\progman.exe", 44, 0 )

$Btn_Exit = GUICtrlCreateButton("Exit", 175, 140, 90, 25 )

;==========================================================
$Child2_GUI = GUICreate("Child2 Window",155,195,278,0,BitOR($WS_CHILD,$WS_DLGFRAME),-1,$Main_GUI)
$listview2 = GUICtrlCreateListView("col1|col2|col3", 5, 5, 145, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
;==========================================================

;==========================================================
$Child1_GUI = GUICreate("Child1 Window",155,195,0,0,BitOR($WS_CHILD,$WS_DLGFRAME),-1,$Main_GUI)
$listview = GUICtrlCreateListView("col1|col2|col3", 5, 5, 145, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
;==========================================================

GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)

GUISetState(@SW_SHOW , $Main_GUI)
GUISetState(@SW_SHOW , $Child1_GUI)
GUISetState(@SW_SHOW , $Child2_GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
            ExitLoop
        Case $msg = $Btn_MoveRight
            _GUICtrlListViewMoveSelectedItems ($listview, $listview2)
        Case $msg = $Btn_MoveLeft
            _GUICtrlListViewMoveSelectedItems ($listview2, $listview)
    EndSelect
WEnd
Exit

Func _GUICtrlListViewMoveSelectedItems($h_Source_listview, $h_Destination_listview, $s_WindowTitle = "", $s_WindowText = "")
   Local $a_indices, $i, $s_item, $control_ID
    If (_GUICtrlListViewGetSelectedCount($h_Source_listview)) Then
        If (StringLen($s_WindowTitle) == 0) Then
            $s_WindowTitle = WinGetTitle("")
        EndIf
        $a_indices = _GUICtrlListViewGetSelectedIndices($h_Source_listview, 1, $s_WindowTitle, $s_WindowText)
        For $i = 1 To $a_indices[0]
            $s_item = _GUICtrlListViewGetItemText($h_Source_listview, $a_indices[$i], -1, $s_WindowTitle, $s_WindowText)
            GUICtrlCreateListViewItem($s_item, $h_Destination_listview)
        Next
      ControlListView($s_WindowTitle, $s_WindowText, $h_Source_listview, "SelectClear")
        For $i = $a_indices[0] To 1 Step -1
            _GUICtrlListViewSetItemSelState($h_Source_listview, $a_indices[$i])
            $control_ID = GUICtrlRead($h_Source_listview)
            ConsoleWrite($control_ID & @LF)
            GUICtrlDelete($control_ID)
        Next
    EndIf
EndFunc  ;==>_GUICtrlListViewMoveSelectedItems
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



Found something ...

Cause in the first sample the last current window is the Child2 the created listviewitems will be added to the right listview from Child1 but internally added to the Child2-complete-structure.

Will send it to jpm.

Thanks and regards

Holger

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