Sign in to follow this  
Followers 0
Jester009

Listview and Tab problem

11 posts in this topic

#1 ·  Posted (edited)

Hi guys,

Can somebody please explain whats wrong with this piece of code? I tried hours without success :)

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM", 611, 371, 217, 195)
$tab = GUICtrlCreateTab(10, 10, 590, 350, $GUI_ONTOP)
$tab1 = GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("")

$tab2 = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")

$tab3=GUICtrlCreateTabitem ("Tab3")
$hListView = _GUICtrlListView_Create ($GUI,"FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
    EndSelect
WEnd

Thanks,

Jester009

Edited by Jester009

Share this post


Link to post
Share on other sites



Try this

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM", 611, 371, 217, 195)
$tab = GUICtrlCreateTab(10, 10, 590, 350, $GUI_ONTOP)
$tab1 = GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("")

$tab2 = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")

$tab3=GUICtrlCreateTabitem ("Tab3")
$hTab3 = GUICtrlGetHandle($tab3)
$hListView = GUICtrlCreateListView ("FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
    EndSelect
WEnd

_GUICtrlListView_SetExtendedListViewStyle requires a handle, but GUICtrlCreateListView returns a controlid, however it works and the help file example for _GUICtrlListView_SetExtendedListViewStyle shows the same usage.

Share this post


Link to post
Share on other sites

Jester009

Hmm... interesting problem. But i don`t understand where allow error.

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM", 611, 371, 217, 195)

$tab = GUICtrlCreateTab(10, 10, 590, 350, $TCS_FIXEDWIDTH)

$tab1 = GUICtrlCreateTabItem("Tab1")

$tab2 = GUICtrlCreateTabItem("Tab2")

$tab3=GUICtrlCreateTabitem ("Tab3")

$iListView = GUICtrlCreateListView("FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($iListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))

GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
    EndSelect
WEnd

So this work, but i`m be curious, why your example don`t work. What say a GarryFrost?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks a lot for rasim and picaxe for replying. I used GUICtrlCreateListView at first. But when I tried to delete an entry I got and error. Thats why I used _GUICtrlListView_Create.

When I use this code the delete function does not work... (with GUICtrlCreateListView)

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM1", 611, 371, 217, 195)
$tab = GUICtrlCreateTab(10, 10, 590, 350, $GUI_ONTOP)
$tab1 = GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("")

$tab2 = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")

$tab3=GUICtrlCreateTabitem ("Tab3")
$hListView = GUICtrlCreateListView ("FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
Dim $aItems[10][5]
For $iI = 0 To UBound($aItems) - 1
    $aItems[$iI][0] = "Item " & $iI
    $aItems[$iI][1] = "Item " & $iI & "-1"
    $aItems[$iI][2] = "Item " & $iI & "-2"
    $aItems[$iI][3] = "Item " & $iI & "-3"
    $aItems[$iI][4] = "Item " & $iI & "-4"
Next
_GUICtrlListView_AddArray ($hListView, $aItems)
$Button1 = GUICtrlCreateButton("Button1", 340, 320, 50, 20)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
        Case $msg = $Button1
            $i = _GUICtrlListView_GetSelectedIndices($hListView, 1)
            _GUICtrlListView_DeleteItem($hListView, $i[1])
    EndSelect
WEnd

When I use this code the delete function works. But the listview appears on all the tabs. (With _GUICtrlListView_Create)

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM1", 611, 371, 217, 195)
$tab = GUICtrlCreateTab(10, 10, 590, 350, $GUI_ONTOP)
$tab1 = GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("")

$tab2 = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")

$tab3=GUICtrlCreateTabitem ("Tab3")
$hListView = _GUICtrlListView_Create ($GUI,"FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
Dim $aItems[10][5]
For $iI = 0 To UBound($aItems) - 1
    $aItems[$iI][0] = "Item " & $iI
    $aItems[$iI][1] = "Item " & $iI & "-1"
    $aItems[$iI][2] = "Item " & $iI & "-2"
    $aItems[$iI][3] = "Item " & $iI & "-3"
    $aItems[$iI][4] = "Item " & $iI & "-4"
Next
_GUICtrlListView_AddArray ($hListView, $aItems)
$Button1 = GUICtrlCreateButton("Button1", 340, 320, 50, 20)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
        Case $msg = $Button1
            $i = _GUICtrlListView_GetSelectedIndices($hListView, 1)
            _GUICtrlListView_DeleteItem($hListView, $i[1])
    EndSelect
WEnd

Any idea why its happening??

Edited by Jester009

Share this post


Link to post
Share on other sites

When I use this code the delete function does not work... (with GUICtrlCreateListView)

#include <GUIConstants.au3>
#Include <GuiListView.au3>

$GUI = GUICreate("FORM1", 611, 371, 217, 195)
$tab = GUICtrlCreateTab(10, 10, 590, 350, $GUI_ONTOP)
$tab1 = GUICtrlCreateTabItem("Tab1")
GUICtrlCreateTabItem("")

$tab2 = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")

$tab3=GUICtrlCreateTabitem ("Tab3")
$hListView = GUICtrlCreateListView ("FIELD1|FIELD2|FIELD3|FIELD4|FIELD5", 20, 50, 570, 250, BitOR($LVS_SINGLESEL, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
Dim $aItems[10][5]
For $iI = 0 To UBound($aItems) - 1
    $aItems[$iI][0] = "Item " & $iI
    $aItems[$iI][1] = "Item " & $iI & "-1"
    $aItems[$iI][2] = "Item " & $iI & "-2"
    $aItems[$iI][3] = "Item " & $iI & "-3"
    $aItems[$iI][4] = "Item " & $iI & "-4"
Next
_GUICtrlListView_AddArray ($hListView, $aItems)
$Button1 = GUICtrlCreateButton("Button1", 340, 320, 50, 20)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            Exit
        Case $msg = $Button1
            $i = _GUICtrlListView_GetSelectedIndices($hListView, 1)
            _GUICtrlListView_DeleteItem($hListView, $i[1])
    EndSelect
WEndoÝ÷ Ø    ò×¢¶ÈZ¦§x?ªê-x]¡ë'ßÛp¢¹yÆ®±á +k*Þj×ËUìºw-ëzÛ«Ëaz'^ØêÜ¢{k¢RÂ¥xe
Úå.+-V'°ëRzWµçHØzƧte
Úå.+-V'°
é^µâ-zgîËb¢{'yçmì"Ú0²§vW­¢Ø^rí®ZºÚ"µÍØÙH  ÌÍÛÙÈH ÌÍÐ]ÛBBBIÌÍÚÛHÕRPÝÙ][J   ÌÍÚÝY]ÊB   ÌÍÚHHÑÕRPÝÝY]×ÑÙ]Ù[XÝY[XÙÊ    ÌÍÚÛJBY ÌÍÚVÌH  ÝÈ[ÑÕRPÝÝY]×Ñ[]R][J ÌÍÚÛ    ÌÍÚVÌWJ

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Thanks a lot Danny35d.

You do not know how many hours I wasted trying to figure this out...

Thanks a million

:)

Share this post


Link to post
Share on other sites

There is no GarryFrost.

The even if the UDF created listview returned a control id Autoit wouldn't treat it the same as the Built-in Listview.

There is a lot of internal code used to make the built-in controls behave as they do.


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

I have the same problem : But the listview appears on all the tabs. (With _GUICtrlListView_Create)

any idea ?

Share this post


Link to post
Share on other sites

I have the same problem : But the listview appears on all the tabs. (With _GUICtrlListView_Create)

any idea ?

Use GuiCtrlCreateListView


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

GaryFrost

There is no GarryFrost

:) Sorry, i don`t want offend you. Posted Image

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