-
I got a picture box that changes the picture it displays from time to time in the program. I use the load picture method. Now I don't really have problems it's just that how can I prevent users from editing or deleting the pictures that the picture box uses? I just want to prevent them from tampering with the look of the program. Is using several picture boxed and showing and hiding them more pratical and efficient?
What do you guys think?
-
If you don't have many pictures, having a PictureBox for each one on the form and hiding/showing them as needed will work. If you have more than what would be efficient to show, use an ImageList object. Then you can get by with a single PictureBox. In the Project menu, select Components (or press control+T), and select Microsoft Common Controls 5.0. I use Win95, and that's the control set with ImageList. In higher Win versions, I think it might be 6.0. Stick one in, and then in the Custom part on the Properties window, add the pictures into the control. Then in the event that triggers a new picture, do this:
Code:
Picture1.Picture = ImageList1.ListImages(Index).Picture
If you had 5 bitmaps loaded into it, Index would be from 1-5. You can also specify a key (just a string) for each image, and then you can use "key" instead of an index in the () to refer to a particular picture in the ImageList.
-
Hey great! Thanks Kaverin! That should solve the efficiency problem, but one question though, with the imagelist object do I still need the images if I transfer the program to another computer?
What's the naming convention of imagelists? Just want to practice using standard naming conventions :)
Again, thanks for the help!
[Edited by gin on 10-14-2000 at 03:52 AM]
-
No, you do not need the original files. Once you load the images into the ImageList, they are stored in memory.
-
You're welcome. I'm not sure what the convention is for naming them. When I started using conventions, it was back when VB4 had just come out, and I don't think this control even existed. :) But since an Image control is img, and a ListBox is lst, I use either imglst, or ilst.
-
I'm not sure what naming conventions are, but if it's what I think it is (the prefix of the object name?) then...
I used to use "il", but I just started using "iml" or "ilt" because the prefixes are usually 3 letters long.
[Edited by Sc0rp on 10-14-2000 at 11:22 AM]
-
Thanks
Thanks again!
I just used the iml hope other programmers who look at trhe code will understand :)