|
Post by deaconjim on Dec 4, 2019 9:57:34 GMT -5
I would like to show the item picture when opening up the detail record. How can I do this?
|
|
|
Post by wexhammer on Dec 4, 2019 10:10:42 GMT -5
Perhaps use a string to record the file path of the bmp. Then when you click on the record get the bmp to show in a graphics box.
|
|
|
Post by deaconjim on Dec 4, 2019 10:30:54 GMT -5
I have the idea of the string for the file path, but how do I get the bmp to show in a graphics box? I am new to this.
|
|
|
Post by mknarr on Dec 4, 2019 10:49:36 GMT -5
Here is how I do it. Basically you need a graphic box in your window. Your pictures should be in a folder of it's own and you need to know how many pictures there are. The pictures can be smaller than the graphic box but not larger. First I put all the picture names in a ListBox to make the search easier. I forgot this line first. To be more precise for the next person you also need somewhere
dim info$(10, 10)
Dim Listbox(10)
files DefaultDir$+"\"+FOLDER$+" Pictures","*.bmp",info$(
LastPicture=val(info$(0,0)) 'This is the number of pictures. if LastPicture>0 then 'If there are no pictures. redim ListBox$(LastPicture) for x=1 to LastPicture ListBox$(x)=info$(x,0) 'This puts each name in the list box and it contains the .bmp next sort ListBox$(, 1,LastPicture 'Sort the names in alphabetical order. end if
Next select the item from the list box. My code looks like this. #breedlist.lb1, "selection? breed$" 'The breed$ does not contain the .bmp Then I call a sub routine that will place the picture in the graphic box. call PlacePicture breed$, LastPicture LastPicture is the number of pictures in your folder. Here is the subroutine. sub PlacePicture brdname$, lastpic 'Place breed pictures. #breedlist.grb1, "cls; fill buttonface" 'Clear the graphic box first because there is still a picture in it. I use the window color. for x=1 to lastpic 'lastpic is the number of pictures a$=upper$(upto$(ListBox$(x),".")) 'Do the search in upper case so you find the right picture in the ListBox without the .bmp if upper$(brdname$)=a$ then exit for 'Once you find the right picture exit the loop next if x>lastpic then 'No picture found. 'In case the picture isn't found. loadbmp "picture", DefaultDir$+"\bmp\"+"No Picture.bmp" 'This is bmp that says "No Picture Found". else 'Picture found. loadbmp "picture", DefaultDir$+"\"+FOLDER$+" Pictures\"+brdname$+".bmp" 'Now load the right picture. end if #breedlist.grb1, "drawbmp picture 0, 0; flush" 'Put it in the graphic box. unloadbmp "picture" 'Then unload the picture for the next one. It will stay in the graphic box until it is cleared. end sub
|
|
|
Post by deaconjim on Dec 4, 2019 13:59:24 GMT -5
Thank you for the info, I will play around with it.
|
|
|
Post by mknarr on Dec 4, 2019 14:09:03 GMT -5
See the line in red I forgot in my original post. It is to look in the picture folder to see how many pictures are in that folder.
|
|
|
Post by deaconjim on Dec 4, 2019 14:24:43 GMT -5
I created a folder with .bmp files and ran the code, but it gives me an error stating it is not a multi-dimensional array. When I change it to single, it gives an "isEmpty" not understood. I am evidently doing something wrong.
|
|
|
Post by Chris Iverson on Dec 4, 2019 14:48:25 GMT -5
You need to dimension the array before using it.
dim info$(10, 10)
Put that somewhere before you first use the info$() array(most likely before the FILES statement).
FILES will resize the array if needed, but you need to create it, first.
|
|
|
Post by mknarr on Dec 4, 2019 18:00:01 GMT -5
Sorry Chris. I knew it needed that but didn't think to post it.
|
|
|
Post by Chris Iverson on Dec 4, 2019 19:47:00 GMT -5
Don't worry about it. God only knows how many times I've forgotten something simple in something I've posted for others here. In one of my most recent posts you'll find I edited it because I left something out
|
|