face Posted June 27, 2014 Share Posted June 27, 2014 (edited) i have a list control that needs to show images selected from a list control items through a gui. how can i make it show images for each item selected on the list control #include <GuiConstantsEx.au3> ; GUI GUICreate("Sample GUI", 400, 400) ; PIC GUICtrlCreatePic("logo4.gif", 0, 0, 169, 68) GUICtrlCreateLabel("Image 1", 75, 1, 53, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; LIST GUICtrlCreateList("", 5, 190, 100, 90) GUICtrlSetData(-1, "Image 1|Image 2|Image 3|Image 4", "Image 1") ; GUI MESSAGE LOOP GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited June 27, 2014 by face Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 27, 2014 Moderators Share Posted June 27, 2014 face,This should give you the idea:expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <Array.au3> ; Create an array with the image titles and paths Global $aData[5][2] = [["Image 0", "Path_To_Image_0"], _ ["Image 1", "Path_To_Image_1"], _ ["Image 2", "Path_To_Image_2"], _ ["Image 3", "Path_To_Image_3"], _ ["Image 4", "Path_To_Image_4"]] $sList = "" For $i = 0 To UBound($aData) - 1 $sList &= "|" & $aData[$i][0] Next $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 200, 200) GUICtrlSetData($cList, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sSel = GUICtrlRead($cList) $iIndex = _ArraySearch($aData, $sSel) $sImagePath = $aData[$iIndex][1] ; Here we display the path - use GUICtrlSetImage to display it in a Pic control MsgBox($MB_SYSTEMMODAL, "Set image", "Path: " & $sImagePath) EndSwitch WEndPlease ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
face Posted June 27, 2014 Author Share Posted June 27, 2014 how can i make it so it shows an image when an item on the list is selected Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 27, 2014 Moderators Share Posted June 27, 2014 face,As I said in the example code:use GUICtrlSetImage to display it in a Pic controlYou have a path and a Pic control, so you have all you need to use that function to set the image into the control. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
face Posted June 28, 2014 Author Share Posted June 28, 2014 i cant seem to fix it, please help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 28, 2014 Moderators Share Posted June 28, 2014 face,Would Sir like fries with that? #include <GUIConstantsEx.au3> #include <Array.au3> ; Create an array with the image titles and paths - change the values to match the images you want to display <<<<<<<<<<<<<<<<<<<<<< Global $aData[5][2] = [["Image 0", "Path_To_Image_0"], _ ["Image 1", "Path_To_Image_1"], _ ["Image 2", "Path_To_Image_2"], _ ["Image 3", "Path_To_Image_3"], _ ["Image 4", "Path_To_Image_4"]] $sList = "" For $i = 0 To UBound($aData) - 1 $sList &= "|" & $aData[$i][0] Next $hGUI = GUICreate("Test", 500, 500) $cList = GUICtrlCreateList("", 10, 10, 200, 200) GUICtrlSetData($cList, $sList) $cPic = GUICtrlCreatePic("", 250, 10, 100, 100) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cList $sSel = GUICtrlRead($cList) $iIndex = _ArraySearch($aData, $sSel) $sImagePath = $aData[$iIndex][1] GUICtrlSetImage($cPic, $sImagePath) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now