Jump to content
Resiak1811

[Solved] _GUICtrlListView_AddArray with icon

Recommended Posts

Resiak1811
Posted (edited)

hi, (sorry for my english, I'm french so..)

normally i can find a solution by myself or with other example on the forum by not for this part..

I start coding with Autoit, 5 years ago and that is the second time i ask something here.. not so bad :)

my script have 4800+ lines of code so I will post the minimum:

I have a GUI with a listview (15 columns and a random number of rows) with a SQL Db,

each line start with a (green or red icon) with a number, the icon change depending on the Status in column 11 (Online or Offline state):

GUICtrlCreateGroup("Race List", 515, 5, 450, 710)
$racelist = GUICtrlCreateListView("1|2|3|4|5|6|7|8|9|10|Status|12|13|14|15", 520, 20, 440, 690, -1)
_GUICtrlListView_SetColumnWidth($racelist, 0, 50)
_GUICtrlListView_SetColumnWidth($racelist, 1, 50)
UICtrlListView_SetColumnWidth($racelist, 2, 80)
_GUICtrlListView_SetColumnWidth($racelist, 3, 90)
_GUICtrlListView_SetColumnWidth($racelist, 4, 80)
_GUICtrlListView_SetColumnWidth($racelist, 5, 90)
_GUICtrlListView_SetColumnWidth($racelist, 6, 140)
_GUICtrlListView_SetColumnWidth($racelist, 7, 40)
_GUICtrlListView_SetColumnWidth($racelist, 8, 50)
_GUICtrlListView_SetColumnWidth($racelist, 9, 60)
_GUICtrlListView_SetColumnWidth($racelist, 10, 50)
_GUICtrlListView_SetColumnWidth($racelist, 11, 40)
_GUICtrlListView_SetColumnWidth($racelist, 12, 55)
_GUICtrlListView_SetColumnWidth($racelist, 13, 55)
_GUICtrlListView_SetColumnWidth($racelist, 14, 100)
ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($racelist)))
_GUICtrlListView_SetExtendedListViewStyle($racelist, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hImage = _GUIImageList_Create(16, 16, 5)
            _GUICtrlListView_SetImageList($racelist, $hImage, 1)

            _SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)
            For $i = 1 To $iRows
                If $aResult[$i][11] = "Online" Then
                    $aIcon = _GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
                Else
                    $aIcon = _GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
                EndIf

                _SQLite_GetTable(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][3] & "' AND Sections.ID = '" & $aResult[$i][4] & "' ;", $aQuery, $iRows, $iColumns)
                _SQLite_GetTable(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][5] & "' AND Sections.ID = '" & $aResult[$i][6] & "' ;", $bQuery, $iRows, $iColumns)

                $GetItemCount = _GUICtrlListView_GetItemCount($racelist) + 9999
                $iIndex = _GUICtrlListView_AddItem($racelist, $aResult[$i][1], $aIcon, $GetItemCount)
                _GUICtrlListView_AddSubItem($racelist, $iIndex, $aResult[$i][2], 1)
                _GUICtrlListView_AddSubItem($racelist, $iIndex, $aQuery[3], 2)
                _GUICtrlListView_AddSubItem($racelist, $iIndex, $aQuery[4], 3)
                _GUICtrlListView_AddSubItem($racelist, $iIndex, $bQuery[3], 4)
                _GUICtrlListView_AddSubItem($racelist, $iIndex, $bQuery[4], 5)

                For $x = 7 To $iColumns - 1
                    _GUICtrlListView_AddSubItem($racelist, $iIndex, $aResult[$i][$x], $x - 1)
                Next
            Next

good_but_slow.jpg.97b03bcbcf0684b32df1f236d124acd8.jpgas you can see in the picture.... my code work fine but .. with 200+ rows it take something like 3-4 seconds to add all the line in the listview

(and take more and more time to load with more rows.) I try many things and i found this solution :

$hImage = _GUIImageList_Create(16, 16, 5)
            _GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
            _GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
            _GUICtrlListView_SetImageList($racelist, $hImage, 1)

            _SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)
            Local $aItems[$iRows][$iColumns], $aRows, $aColumns, $bRows, $bColumns

            For $i = 1 To UBound($aItems) - 1
                _SQLite_GetTable(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][3] & "' AND Sections.ID = '" & $aResult[$i][4] & "' ;", $aQuery, $aRows, $aColumns)
                _SQLite_GetTable(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][5] & "' AND Sections.ID = '" & $aResult[$i][6] & "' ;", $bQuery, $bRows, $bColumns)

                $aItems[$i][0] = $aResult[$i][1]
                $aItems[$i][1] = $aResult[$i][2]
                $aItems[$i][2] = $aQuery[3]
                $aItems[$i][3] = $aQuery[4]
                $aItems[$i][4] = $bQuery[3]
                $aItems[$i][5] = $bQuery[4]

                For $x = 7 To $iColumns - 1
                    $aItems[$i][$x - 1] = $aResult[$i][$x]
                Next
            Next
            _GUICtrlListView_AddArray($racelist, $aItems)

With the "_GUICtrlListView_AddArray" it load my 200+ lines in 0.2-0.3 seconds YOUHOO..... But :(

1st problem with code #2: it read the status of the 1st row (column 11) and add the same icon to the other rows,

I can't find a way to read each line, choose the icon, create the array and "_GUICtrlListView_AddArray", any idea ?

2nd problem with code #2: (code #1) start on the 1st row (just under the column title) but

code #2 start on the 2nd row... i can't start on the 1st row and I don't know why!?

If i remove the "- 1" from For $i = 1 To UBound($aItems) - 1

i get a array error.

 

I know you guys are amazing and maybe you will find a way to do it :)

thank you.

 

good_but_slow.jpg

Edited by Resiak1811

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)

1) try 

For $i = 0 To UBound($aItems) - 1


2)

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

_SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)
Local $aItems[$iRows][$iColumns]

For $i = 0 To UBound($aItems) - 1
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][3] & "' ;", $aQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][4] & "' ;", $bQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][5] & "' ;", $cQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][6] & "' ;", $dQuery)

    $aItems[$i][0] = $aResult[$i][1]
    $aItems[$i][1] = $aResult[$i][2]
    $aItems[$i][2] = $aQuery[0]
    $aItems[$i][3] = $bQuery[0]
    $aItems[$i][4] = $cQuery[0]
    $aItems[$i][5] = $dQuery[0]

    For $x = 7 To $iColumns - 1
        $aItems[$i][$x - 1] = $aResult[$i][$x]
    Next

    $tmp = ''
    For $y = 0 To $iColumns - 1
        $tmp &= $aItems[$i][$y] & '|'
    Next
    $tmp = StringTrimRight($tmp,1)

    If $aResult[$i][11] == "Online" Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i+1 ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

;~ _GUICtrlListView_AddArray($racelist, $aItems)

 

Edited by Zedna
added 2)

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)

3) try to optimize SQL queries inside LOOP: less amount of SQL calls, something like this:

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

_SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)
Local $aItems[$iRows][$iColumns]

For $i = 0 To UBound($aItems) - 1
;~  _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where Sites.ID = '" & $aResult[$i][3] & "' ;", $aQuery)
;~  _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where Sections.ID = '" & $aResult[$i][4] & "' ;", $bQuery)
    _SQLite_QuerySingleRow(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][3] & "' AND Sections.ID = '" & $aResult[$i][4] & "' ;", $aQuery)

;~  _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][5] & "' ;", $cQuery)
;~  _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][6] & "' ;", $dQuery)
    _SQLite_QuerySingleRow(-1, "SELECT Sites.SiteName, Sections.SectionName FROM Sites,Sections Where Sites.ID = '" & $aResult[$i][5] & "' AND Sections.ID = '" & $aResult[$i][6] & "' ;", $bQuery)

    $aItems[$i][0] = $aResult[$i][1]
    $aItems[$i][1] = $aResult[$i][2]
    $aItems[$i][2] = $aQuery[0]
    $aItems[$i][3] = $aQuery[1]
    $aItems[$i][4] = $bQuery[0]
    $aItems[$i][5] = $bQuery[1]

    For $x = 7 To $iColumns - 1
        $aItems[$i][$x - 1] = $aResult[$i][$x]
    Next

    $tmp = ''
    For $y = 0 To $iColumns - 1
        $tmp &= $aItems[$i][$y] & '|'
    Next
    $tmp = StringTrimRight($tmp,1)

    If $aResult[$i][11] = "Online" Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i+1 ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

 

EDIT:

And don't forget to tell me how FAST is my solution ;-)

Note: it will be VERY FAST!

Edited by Zedna

Share this post


Link to post
Share on other sites
Resiak1811
Posted (edited)

thank you Zedna, i will try that tonight (i'm currently at work)

Edited by Resiak1811

Share this post


Link to post
Share on other sites
Resiak1811
Posted (edited)

hi again, I tried but it does not work

if i copy&paste your code :

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$aItems[$i][3] = $aQuery[1]
$aItems[$i][3] = ^ ERROR

 

if i put back my sql code (the 4 SELECT) ... everything is loading but still no icon in 1st column :/

by the way, thank for the hint for the SQL (I started learning SQL 1 month ago)

(ok i figured a way for the SQL... using _SQLite_GetTable instead of _SQLite_QuerySingleRow)

--------------------

by the way, don't be mad at me :

my code take 4sec. to load (with all the icon)

your code take 2sec (with only 1 icon on the 1st row)...

but nothing seem to be faster than _GUICtrlListView_AddArray (but no icon at all) :(

Edited by Resiak1811

Share this post


Link to post
Share on other sites
Zedna

Problem was here

DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i+1 ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

Correct is

DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

 

changed $i+1 to $i on second line

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)

Here is WORKING small testing/reproducing script not depended on SQL data:

shows icons in ListView items

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("GUI", 800, 600, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
$racelist = GUICtrlCreateListView("1|2", 10, 10, 780, 580, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT)) ; $LVS_EX_DOUBLEBUFFER
GUISetState(@SW_SHOW)

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16,16,4,1,2)
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

For $i = 0 To 9

    If Mod($i,2) = 0 Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    $tmp = 'row ' & $i & ' col 1|row ' & $i & ' col 2'

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

GUICtrlSendMsg($racelist, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg($racelist, $LVM_SETCOLUMNWIDTH, 1, 100)

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

Edited by Zedna

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)

Here is version working with icons compiled into EXE as resources (must be compiled from Scite4AutoIt3 with AutoIt3Wrapper)

So no external icons are needed, only EXE file :-)

note: position of first added icon in EXE differ on versions of AutoIt, mine is for AutoIt 3.2.12.1 which I use

use ResHacker to see which icons are in compiled AutoIt script implicitly to see which is correct index of yours added icons ...

#AutoIt3Wrapper_run_obfuscator=y
#Obfuscator_parameters=/so /om
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_useupx=y
#AutoIt3Wrapper_Res_Icon_Add=green.ico
#AutoIt3Wrapper_Res_Icon_Add=red.ico

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("GUI", 800, 600, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
$racelist = GUICtrlCreateListView("1|2", 10, 10, 780, 580, BitOR($LVS_REPORT,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_FULLROWSELECT)) ; $LVS_EX_DOUBLEBUFFER
GUISetState(@SW_SHOW)

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16,16,4,1,2)
_GUIImageList_AddIcon($hImage, @ScriptFullPath, 4 ) ; green --> index depended on version of AutoIt
_GUIImageList_AddIcon($hImage, @ScriptFullPath, 5 ) ; red
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

For $i = 0 To 9

    If Mod($i,2) = 0 Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    $tmp = 'row ' & $i & ' col 1|row ' & $i & ' col 2'

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

GUICtrlSendMsg($racelist, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg($racelist, $LVM_SETCOLUMNWIDTH, 1, 100)

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

Edited by Zedna

Share this post


Link to post
Share on other sites
Zedna
16 hours ago, Resiak1811 said:

by the way, don't be mad at me :

my code take 4sec. to load (with all the icon)

your code take 2sec (with only 1 icon on the 1st row)...

but nothing seem to be faster than _GUICtrlListView_AddArray (but no icon at all) :(

 

You are wrong.

Native GUICtrlCreateListViewItem() is faster than  UDF version _GUICtrlListView_Addtem() + _GUICtrlListView_AddSubItem() even if you optimize UDF's functions for speed.

Really. Beleive me!

I'm sure because I did optimizations tests many years ago already.

Share this post


Link to post
Share on other sites
Resiak1811

wow, thank you !!

and after doing more test ... yep its faster, thank you so much :)

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)

I'm glad I could help :-)

This original code could be even little more optimized for speed:

original:

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

_SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)
Local $aItems[$iRows][$iColumns]

For $i = 0 To UBound($aItems) - 1
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][3] & "' ;", $aQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][4] & "' ;", $bQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][5] & "' ;", $cQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][6] & "' ;", $dQuery)

    $aItems[$i][0] = $aResult[$i][1]
    $aItems[$i][1] = $aResult[$i][2]
    $aItems[$i][2] = $aQuery[0]
    $aItems[$i][3] = $bQuery[0]
    $aItems[$i][4] = $cQuery[0]
    $aItems[$i][5] = $dQuery[0]

    For $x = 7 To $iColumns - 1
        $aItems[$i][$x - 1] = $aResult[$i][$x]
    Next

    $tmp = ''
    For $y = 0 To $iColumns - 1
        $tmp &= $aItems[$i][$y] & '|'
    Next
    $tmp = StringTrimRight($tmp,1)

    If $aResult[$i][11] == "Online" Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

;~ _GUICtrlListView_AddArray($racelist, $aItems)

 

optimized: $aItems[] not needed:

$tLVITEM = DllStructCreate( $tagLVITEM )
$pLVITEM = DllStructGetPtr( $tLVITEM )
DllStructSetData( $tLVITEM, "Mask", $LVIF_IMAGE ) ; Icon (or image)
DllStructSetData( $tLVITEM, "SubItem", 0 )        ; First column

$hImage = _GUIImageList_Create(16, 16, 5)
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\green.ico')
_GUIImageList_AddIcon($hImage, @ScriptDir & '\Includes\red.ico')
_GUICtrlListView_SetImageList($racelist, $hImage, 1)

_SQLite_GetTable2d(-1, "SELECT * FROM Races ;", $aResult, $iRows, $iColumns)

For $i = 0 To $iRows - 1
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][3] & "' ;", $aQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][4] & "' ;", $bQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SiteName FROM Sites Where ID = '" & $aResult[$i][5] & "' ;", $cQuery)
    _SQLite_QuerySingleRow(-1, "SELECT SectionName FROM Sections Where ID = '" & $aResult[$i][6] & "' ;", $dQuery)

    $tmp = $aResult[$i][1] & '|' & $aResult[$i][2] & '|' & $aQuery[0] & '|' & $bQuery[0] & '|' & $cQuery[0] & '|' & $dQuery[0]

    For $x = 7 To $iColumns - 1
        $tmp &= '|' & $aResult[$i][$x]
    Next

    If $aResult[$i][11] == "Online" Then
        $iIconIndex = 0
    Else
        $iIconIndex = 1
    EndIf

    GUICtrlCreateListViewItem($tmp, $racelist)

    DllStructSetData( $tLVITEM, "Image", $iIconIndex ) ; icon index
    DllStructSetData( $tLVITEM, "Item", $i ) ; Row
    GUICtrlSendMsg($racelist, $LVM_SETITEMW, 0, $pLVITEM ) ; Add icon
Next

 

Edited by Zedna

Share this post


Link to post
Share on other sites
Resiak1811

nice...  thank you for your answer...

i'm on this problem since monday lol

i hope i will be good as you one day :)

Share this post


Link to post
Share on other sites
Resiak1811

for some reason... when i keep

For $i = 0 To $iRows - 1

i see on my 1st row (2first column) my "SQL table name"

and if i change the 0 to 1 : For $i = 1 To $iRows - 1

the row is Ok but i lost my icon :/

any idea ?

Share this post


Link to post
Share on other sites
Resiak1811

PERFECT :)) thank

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

×