Jump to content

bitmpa in listview questions


Recommended Posts

hi guy i look , about  bitmap in  help file

but not  understund  so much

how  is possible  insert a foto bitmap (not color)  only in first  column ???  (in all row ??)

have  some example for study ??' thankz  so much

Link to comment
Share on other sites

Here's a small example using icons:

#cs ------------------------------------------------------------------------------

    AutoIt Version: 3.3.6.1
    Author:                        AutoBert:    http://www.autoit.de/index.php?page=Thread&postID=187402#post187402

    Skriptbeispiel für den Umgang mit    GUICtrlCreateListView, _GUICtrlListView_AddColumn, _GUICtrlListView_AddItem,
                                        _GUICtrlListView_AddSubItem, _GUICtrlListView_SetImageList, _GUIImageList_AddIcon, _GUIImageList_GetImageCount
#ce -------------------------------------------------------------------------------------------------------------------------
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <File.au3>

Opt('MustDeclareVars', 1)

Global $hGui, $listview, $hListview, $hImage, $b, $iCount,$iWidth = @DesktopWidth, $iHeight = @DesktopHeight -80
Global $Combo, $Progress, $Label,$aFile, $sDLLName, $Msg, $sTitel = "Icon-Übersicht "
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$hGui = GUICreate($sTitel & $sDLLName, $iWidth, $iHeight, 0, 0)
$Combo = GUICtrlCreateCombo("", 2, 2, 120)
$Progress = GUICtrlCreateProgress(125, 2, $iWidth -137,25)
;$Label = GUICtrlCreateLabel("TEST",330,2,200)
$aFile = _FileListToArray(@SystemDir, "*.DLL")

$listview = GUICtrlCreateListView("", 2, 42, $iWidth-4, $iHeight - 44, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
$hListview = ControlGetHandle($hGui, "", $listview)
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
For $i = 1 To 8
    ; Fügt die Spalten hinzu
    _GUICtrlListView_AddColumn($listview, "Spalte " & $i, 120)
Next
GUISetState()
For $i = 1 To $aFile[0]
    If _LoadIcons($aFile[$i]) > 0 Then GUICtrlSetData($Combo, $aFile[$i])
    GUICtrlSetData($Progress, 100- ($i / $aFile[0] * 100))
    ;GUICtrlSetData($Label,$i & " / " & $aFile[0])
Next
GUICtrlSetData($Combo, "shell32.dll", "shell32.dll")
_showIcons("shell32.dll")


While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            $sDLLName = GUICtrlRead($Combo)
            _showIcons($sDLLName)
    EndSwitch
WEnd

Func _showIcons($sDLLName)
    Local $iSpalten, $iZeilen, $iBilder
    _GUICtrlListView_DeleteAllItems($hListview)
    $iCount = _LoadIcons($sDLLName)
    WinSetTitle($hGui,"",$sTitel & $sDLLName)
    ;ConsoleWrite($sDLLName & " " & $iCount & @CRLF)
    _GUICtrlListView_SetImageList($listview, $hImage, 1)


    $iBilder = -1
    For $iZeilen = 1 To Int(($iCount - 1) / 8) + 1
        $iBilder += 1
        ; Fügt die Items hinzu
        _GUICtrlListView_AddItem($listview, "Bild: " & $iBilder, $iBilder)
        For $iSpalten = 1 To 7
            $iBilder += 1
            ; fügt die SubItems hinzu
            _GUICtrlListView_AddSubItem($listview, $iZeilen - 1, "Bild: " & $iBilder, $iSpalten, $iBilder)
        Next
    Next
EndFunc   ;==>_showIcons

Func _LoadIcons($sDLLName)
    Local $iCount, $iBilder, $iError
    Static $iGesamt
    _GUIImageList_Destroy($hImage)

    ; Lädt die Bilder
    $hImage = _GUIImageList_Create(32, 32, 5, 3, 128, 256)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\" & $sDLLName, 0,True)
    $iBilder = 1
    Do
        $iError = _GUIImageList_AddIcon($hImage, @SystemDir & "\" & $sDLLName, $iBilder,True)
        $iBilder += 1
    Until $iError <= 0
    $iCount = _GUIImageList_GetImageCount($hImage)
    $iGesamt += $iCount
    if $iCount <> 0 Then ConsoleWrite($sDLLName & " " & $iCount & " " & $iGesamt & @CRLF)
    Return $iCount
EndFunc   ;==>_LoadIcons

for BMP's you must use _GUIImageList_AddBitmap.  Have also a look in heflfile and read about: _GUICtrlListView_SetImageList. I think using images wich have all same format, there's no problem

Link to comment
Share on other sites

start  with  some  simple example 

in this  example  have  bmp  only in first colums

how  is possible  insert a .bmp  also in second columns ??

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("ImageList AddBitmap", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 32)
    _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Green.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Blue.bmp")
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)
    _GUICtrlListView_AddColumn($idListview, "Items2", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

hi guy i have a  big problem with the  bitmap

i  have created  a script when  run it  the  bitmap  load correctly in listview  in first colum  and  after  load  also  in second and  3   why ????

this is a part of script  , sorry if  i dont  pastt all script  but  is  very large

unc _Siti_web()
    _Boom() ; cancella tutto quello che trova su la  gui

    $SITIWEB_Tab1 = GUICtrlCreateTab(1, 2, 1690, 765)
    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    $SITIWEB_TabSheet1 = GUICtrlCreateTabItem($GUI_Lang[101]) ; tab eBay
    $SITIWEB_Button7 = GUICtrlCreateButton("", 6, 28, 41, 39, $BS_ICON)
    GUICtrlSetImage(-1, $DLL_LOCATE, -89)
    $SITIWEB_Button8 = GUICtrlCreateButton("", 49, 28, 41, 39, $BS_ICON)
    GUICtrlSetImage(-1, $DLL_LOCATE, -89)

    _Inizializza_eBay_Param()

    Local $sDefault_Log = IniRead($sDefault_eBay_login, "log_eBay_default_user", "Key1", "Default Value") ; user
    _GUICtrlStatusBar_SetParts($StatusBar1, $aParts)
    _GUICtrlStatusBar_SetText($StatusBar1, "eBay Login Default: " & $sDefault_Log, 1)
    _GUICtrlStatusBar_SetIcon($StatusBar1, 1, _WinAPI_ExtractIcon($DLL_LOCATE, 87))

    $SITIWEB_Group3 = GUICtrlCreateGroup($GUI_Lang[117], 5, 70, 1682, 297)

    Local $sTxtXmlResult = _eBay_list_Product()
    ;Local $bo = _ListView_OK("", 8, 86, 1675, 274, "Item ID_150_Nome Prodotto_360_Qt._50_Formato_100_Prezzo C.S._100_Prezzo Asta_100_Prezzo Spedizione_100_Proposta d'acquisto_100_Data Apertura_100_Tempo Chiusura_100_Url Site_350")
    Global $bo = GUICtrlCreateListView("", 8, 86, 1675, 274)
    _GUICtrlListView_SetExtendedListViewStyle($bo, BitOR($LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES)) ; questa stringa fa la griglia stile excel

 _GUICtrlListView_AddColumn($bo, "Column 1", 110)
    _GUICtrlListView_AddColumn($bo, "Column 2", 110)
    _GUICtrlListView_AddColumn($bo, "Column 3", 110)
 _GUICtrlListView_AddColumn($bo, "Column 1", 110)
    _GUICtrlListView_AddColumn($bo, "Column 2", 110)
    _GUICtrlListView_AddColumn($bo, "Column 3", 110)
 _GUICtrlListView_AddColumn($bo, "Column 1", 110)
    _GUICtrlListView_AddColumn($bo, "Column 2", 110)
    _GUICtrlListView_AddColumn($bo, "Column 3", 110)
_GUICtrlListView_AddColumn($bo, "Column 1", 110)
    _GUICtrlListView_AddColumn($bo, "Column 2", 110)
    _GUICtrlListView_AddColumn($bo, "Column 3", 110)

    ;GUIRegisterMsg($WM_NOTIFY, "ordina_listview") ; funzione per ordinare le listview modificate

    Local $Count = 0
    Local $C = 0
    Local $cicle = (UBound($sTxtXmlResult)) / 12

    Local $h_Image = _GUIImageList_Create(32, 32)
    Do

        _GUICtrlListView_AddItem($bo, $sTxtXmlResult[$C], $Count)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 1, 1)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 2, 2)
        $C += 1
        If $sTxtXmlResult[$C] = "FixedPriceItem" Then
            $sTxtXmlResult[$C] = "Compralo Subito"
        EndIf
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 3, 3)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 4, 4)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 5, 5)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 6, 6)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 7, 7)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 8, 8)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 9, 9)
        $C += 1
        _GUICtrlListView_AddSubItem($bo, $Count, $sTxtXmlResult[$C], 10, 10)
        $C += 1

        Local $sFilePath = (@TempDir & "\" & $C & ".jpg")
        Local $hDownload = InetGet($sTxtXmlResult[$C], $sFilePath, $INET_FORCERELOAD)

        _GDIPlus_Startup()
        Local $hImage = _GDIPlus_ImageLoadFromFile($sFilePath)
        Local $sCLSID = _GDIPlus_EncodersGetCLSID("BMP")
        _GDIPlus_ImageSaveToFileEx($hImage, @TempDir & "\" & $C & ".bmp", $sCLSID)
        _GDIPlus_Shutdown()

        _GUIImageList_AddBitmap($h_Image, @TempDir & "\" & $C & ".bmp")
        _GUICtrlListView_SetImageList($bo, $h_Image, 1)

        $C += 1
        $Count += 1
    Until $Count = ($cicle)




    $SITIWEB_TabSheet2 = GUICtrlCreateTabItem($GUI_Lang[100]) ; tab Configurazione
    ;GUICtrlSetState(-1,$GUI_SHOW)
    ;GUICtrlCreateTabItem("")
    $SITIWEB_Group1 = GUICtrlCreateGroup($GUI_Lang[102], 1273, 27, 412, 353); Registrazione
    $SITIWEB_Label4 = GUICtrlCreateLabel("eBay Site", 1542, 124, 49, 17)
    $SITIWEB_Combo2 = GUICtrlCreateCombo("eBay Italia", 1538, 145, 137, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData($SITIWEB_Combo2, "eBay Australia|eBay Austria|eBay Belgium|eBay Belgium (French)|eBay Canada (English)|" & _
            "eBay Canada (French)|eBay French|eBay Germany|eBay Hong Kong|eBay India|eBay Ireland|eBay Netherlands|eBay Singapore|" & _
            "eBay Spain|eBay Switaerland|eBay UK|eBay United States|eBay Poland|eBay Philippines|eBay Malaysia|eBay Motors", "eBay Italia")
    $SITIWEB_Button1 = GUICtrlCreateButton("Registrazione con mail", 1586, 285, 91, 85, $BS_ICON) ; Registrazione con mail
    GUICtrlSetImage(-1, @ScriptDir & "\WEB-SITE\eBay\icon\multy.ico", -1)
    $SITIWEB_Button3 = GUICtrlCreateButton("Registrazione solo eBay", 1586, 175, 91, 85, $BS_ICON); Registrazione solo eBay
    GUICtrlSetImage(-1, @ScriptDir & "\WEB-SITE\eBay\icon\Chrisbanks2-Cold-Fusion-Hd-Ebay.ico", -1)
    $SITIWEB_Button2 = GUICtrlCreateButton("Registrazione solo mail", 1482, 176, 91, 86, $BS_ICON); Registrazione solo mail
    GUICtrlSetImage(-1, @ScriptDir & "\WEB-SITE\eBay\icon\index.ico", -1)
    $SITIWEB_Checkbox1 = GUICtrlCreateCheckbox($GUI_Lang[106], 1471, 72, 65, 17); Id list
    $SITIWEB_Checkbox2 = GUICtrlCreateCheckbox($GUI_Lang[107], 1471, 50, 97, 17); Utente standard
    $SITIWEB_Button4 = GUICtrlCreateButton($GUI_Lang[108], 1604, 51, 75, 21) ; Registra
    $SITIWEB_Button5 = GUICtrlCreateButton($GUI_Lang[100], 1605, 84, 75, 21) ;Configura
    $SITIWEB_Button6 = GUICtrlCreateButton("Registrazione solo paypal", 1482, 286, 91, 85, $BS_ICON) ; Registrazione solo Paypal
    GUICtrlSetImage(-1, @ScriptDir & "\WEB-SITE\eBay\icon\Uiconstock-E-Commerce-Paypal.ico", -1)
    $SITIWEB_List1 = GUICtrlCreateListView("", 1279, 53, 185, 318, $LVS_SORTASCENDING)
    _GUICtrlListView_SetExtendedListViewStyle($SITIWEB_List1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES)) ; questa stringa fa la griglia stile excel
    _GUICtrlListView_AddColumn($SITIWEB_List1, $GUI_Lang[103], 180) ; Utente fake

    Local $aFakeUser = _FileListToArray(@ScriptDir & "\WEB-SITE\eBay\utenti")

    For $i = 1 To $aFakeUser[0]
        If $aFakeUser[$i] = "." Or $aFakeUser[$i] = ".." Then
        Else
            Local $Exist = FileExists(@ScriptDir & "\WEB-SITE\eBay\utenti\" & $aFakeUser[$i] & "\utente_eBay_Login.ini")
            If $Exist = 1 Then
                ;       Local $hImage = _GUIImageList_Create(16, 16, 5, 3)
                ;       _GUIImageList_AddIcon($hImage, $DLL_LOCATE, 93)
                ;       _GUICtrlListView_SetImageList($SITIWEB_List1, $hImage, 1)
                ;       _GUICtrlListView_AddItem($SITIWEB_List1, $aFakeUser[$i], $i)

                ; Load images
                Local $hImage = _GUIImageList_Create(16, 16, 5, 3)
                _GUIImageList_AddIcon($hImage, $DLL_LOCATE, 92)
                _GUICtrlListView_SetImageList($SITIWEB_List1, $hImage, 1)

                ; Add items
                ;_GUICtrlListView_AddItem($SITIWEB_List1, "Row 1: Col 1", 0)
                _GUICtrlListView_AddItem($SITIWEB_List1, $aFakeUser[$i], 0)
            Else
                _GUICtrlListView_AddItem($SITIWEB_List1, $aFakeUser[$i], $i)
            EndIf

        EndIf
    Next
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $SITIWEB_Group2 = GUICtrlCreateGroup($GUI_Lang[111], 1272, 380, 413, 92) ; parametrei ebay
    $SITIWEB_Input1 = GUICtrlCreateInput("", 1281, 418, 111, 21)
    $SITIWEB_Label1 = GUICtrlCreateLabel($GUI_Lang[41], 1283, 401, 36, 17) ; login
    $SITIWEB_Label2 = GUICtrlCreateLabel($GUI_Lang[42], 1398, 401, 50, 17) ; password
    $SITIWEB_Input2 = GUICtrlCreateInput("", 1396, 418, 112, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    $SITIWEB_Button9 = GUICtrlCreateButton($GUI_Lang[25], 1281, 445, 43, 21) ; setta
    $SITIWEB_Combo1 = GUICtrlCreateCombo("eBay Italia", 1533, 418, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData($SITIWEB_Combo1, "eBay Australia|eBay Austria|eBay Belgium|eBay Belgium (French)|eBay Canada (English)|" & _
            "eBay Canada (French)|eBay French|eBay Germany|eBay Hong Kong|eBay India|eBay Ireland|eBay Netherlands|eBay Singapore|" & _
            "eBay Spain|eBay Switaerland|eBay UK|eBay United States|eBay Poland|eBay Philippines|eBay Malaysia|eBay Motors", "eBay Italia")
    $SITIWEB_Label3 = GUICtrlCreateLabel($GUI_Lang[112], 1536, 400, 49, 17) ; eBay site
    ;$SITIWEB_Button10 = GUICtrlCreateButton($GUI_Lang[113], 1330, 445, 65, 21) ; Use default
    $SITIWEB_Button11 = GUICtrlCreateButton($GUI_Lang[20], 1401, 445, 65, 21) ; Carica
    GUICtrlCreateGroup("", -99, -99, 1, 1)

    GUICtrlCreateTabItem("")


    GUISetState(@SW_SHOW)

    ;configura eBay
    GUICtrlSetOnEvent($SITIWEB_Button2, "_Reg_only_mail")
    GUICtrlSetOnEvent($SITIWEB_Button4, "_Registra_utente")
    GUICtrlSetOnEvent($SITIWEB_Button3, "_Reg_Only_eBay")
    GUICtrlSetOnEvent($SITIWEB_Button6, "_Reg_Only_Paypal")
    GUICtrlSetOnEvent($SITIWEB_Button1, "_Reg_All_PayeBayMail")
    GUICtrlSetOnEvent($SITIWEB_Button5, "_Conf_Fake_User")
    GUICtrlSetOnEvent($SITIWEB_Button9, "_Setta_eBay_User_Login")
    GUICtrlSetOnEvent($SITIWEB_Button11, "_Carica_Fake_Login_eBay") ; bottone carica
    ; eBay

    ;GUICtrlSetOnEvent($SITIWEB_Button6, "_New_Item")

EndFunc   ;==>_Siti_web

 

Link to comment
Share on other sites

What seems to be the problem? Your script sets an image to every column in the _AddSubItem lines, if that's not what you wanted, then you need to remove the parameter that does that.

Also, you're adding images to the image list AFTER you're trying to use them, you need to create and load the imagelist prior to creating the listview items that will be using it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
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
 Share

  • Recently Browsing   0 members

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