Hello, I need to make an image viewer, that would need that images are stored in a ListBox with your route is displayed on the PictureWell when selected. I can not do, any help ??
Where are the images coming from? Disk? What information do you display in the listbox?
Yes, the imagen are from the disk, and in the listbox is the url of the imagen (like: “file:///User/Documents/Picture.png” )
When the user selects a row, the Changed event fires. In that event, use the URL from the listbox to retrieve the image from disk and display it in the imagewell.
Yes, that is what i would like to do, but the problem is that i don’t know the code. You know it? Thanks in advance
What have you tried?
have a look at Xojos Example folder (a couple of ListBox example displays soe folder contents )
Thanks for all but, in the Xojo’s example folder when i go to “Load Picture List” i can´t select any image!
@Federico José D’Andrea
I would use a PopupMenu and canvas to do this to make sure you can resize the images unless you already have them sized to fit your imagewell if so then use it.
Create a Property in the WindowForm you have the popupmenu and Name it somewhat ever you want and make the Type Picture. Ex. Displayed_Pic
Add the Picture you want displayed into your project. I usually keep them in a folder “img”
Create a Case in the Change Event Handler
[code]select case me.ListIndex
case 0
Displayed_Pic = Picture1 // Picture1 and Picture2 are the names of the pictures you added to your project
//Displayed_Pic is the Property we created earlier
case 1
Displayed_Pic = Picture2
//ect…
end select
Canvas5.Invalidate //Canvas5 is the canvas you want the image to display on
[/code]
Next In the Canvas Paint event Handler we need to call and resize the image just in case its to big.
[code] Dim scaleX, scaleY, scale as Double
Dim theLeft, theTop as integer
if Displayed_Pic = nil then Displayed_Pic = Picture1 //Displayed_Pic is a property that has been added to the window
if Displayed_Pic.width = me.width and Displayed_Pic.height = me.height then //if pic is smaller than the canvas
theLeft = (me.width - Displayed_Pic.width)/2 //center the image horizontally
theTop = (me.height - Displayed_Pic.height)/2 //center the image vertically
g.DrawPicture Displayed_Pic, theLeft, theTop
else
scaleX = me.width / Displayed_Pic.width
scaleY = me.height / Displayed_Pic.height
scale = Min( scaleX, scaleY ) //choose the smaller value
theLeft = (me.width - (Displayed_Pic.widthscale))/2 //center the image horizontally
theTop = (me.height - (Displayed_Pic.heightscale))/2 //center the image vertically
g.DrawPicture Displayed_Pic, theLeft, theTop, (Displayed_Pic.width * scale), (Displayed_Pic.height * scale), 0, 0, Displayed_Pic.Width, Displayed_Pic.Height
end if
[/code]
Hope this Helps!!! If i was understanding what you were asking correctly
THANKS A LOT !! For All!! Thanks for the help! All helped me a lot