PDA

View Full Version : load a picture from list box


rooholah
04-19-2006, 02:24 AM
Hi...
I create a listbox that search a folder for *.jpg.I want to open picture in my project when i chose one from list box.

--This is my codes

LB = "ListBox1";
tSelected = ListBox.GetSelected(LB);
if tSelected then

sFolderToOpen = ListBox.GetItemData(LB, tSelected[1]);
tFiles = File.Find(sFolderToOpen, "1.JPG", false, false, nil);
-- I dont khnow what i my must put in ?
Image.Load("Image1", ? );


Please help me

fossil
04-19-2006, 10:24 AM
I found this exempel in AMS 6.0 Help


--Disable listbox Updating
ListBox.SetUpdate("ListBox1", false);

--Get the desired folder to browse
folder = Dialog.FolderBrowse("Open Folder", "C:\\");

--populate tables with all the .jpg and .png files
file_jpg = File.Find(folder, "*.jpg", false, false, nil);
file_png = File.Find(folder, "*.png", false, false, nil);

images = {file_jpg, file_png};

--do the following for each file:
for k in images do --loops through the different image types
for j,file_path in images[k] do --loops through each image file
--add the item to the listbox, with the name visible and path as data
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
end

--Allow the listbox to display the updated content
ListBox.SetUpdate("ListBox1", true);



Insert the following code into the On Select event for ListBox1 :

selected = ListBox.GetSelected("ListBox1");
for j,k in selected do
Image.Load("Image1", ListBox.GetItemData("ListBox1", k));
end

rooholah
04-19-2006, 05:28 PM
Thanks but it doesnt work

sara2006
04-20-2006, 06:07 AM
i have a simple

azmanar
04-20-2006, 10:16 AM
Thanks but it doesnt work

Hi Rooholah,

Try this one at : http://www.indigorose.com/forums/showpost.php?p=81167&postcount=87