I'm afraid I already know the answer to this question, but hey, it never hurts to ask right?
I have an application where several images are loaded as properties of control(s) at design time and / or at runtime. Ones that are loaded at runtime are loaded via Commondialog and the filename is stored in an parallel array to the image object array so I can keep the file names for subsequent loads, however if the image is loaded at design time via the property panel I can't programatically get the filename. The long pointer of course does me no good once the instance of the object expires.
I was hoping there was an API call that would retrieve the filename and possibly other file information from the initialized Picture Object. Anyone have any 'pointers' (No pun intended)
Imagery that is loaded at design time on a form or a form's control is stored as bitmap ressources in the file .frx which accompanies the code file .frm of a form. You have no later access to the filename, because you don't need. The image data will be compiled into the exe file.
You better load the initial images at program start if you require them to be changeable files.
Thanks. That was pretty much the conclusion I had come to. I have another workaround but I just don't like it as much.
My Situation is this. I have developed a custom control that has 5 different Image properties. For the most part, once the images are set at design time thats it, most new instances of the control will use the same 5 images. However, in order to simplify matters for myself, I'm writing my property values out to an INI file so that the next time I fire up VB, pop the control on a form it grabs the last used settings, including the image file names, sets the variables and voila' I'm in business without having to reconfigure the control. It all works great, BUT. I've done this by use of a property page that uses contains a Common Dialog box, the image property fields are on the property page. They also appear in the Property Panel in VB, but since I'm loading string values instead of Picture Objects, the Property Panel just has text fields. If I use Get/Set instead of Get/Let and use StdPicture types instead of String Types, I get the nice little Select Image dialog straight from the Property Panel. But as you can imagine, there's no way for me to Write that value to an INI file. So it's either stick with the Property Page or reconfigure the control each time I use a new instance of it. I know this sounds a little Petty, it just bugs me that I can't have my cake and eat it too.
If a reconfiguration of your control does not mean to completely replace all of the images by other image files, you can consider of putting all possible images int an image list and make a selection machanism within your control, to selct the images according to configuration information. So NONE of the possible mages are in files anymore. All imagery is contained within the control.
Yes, I had considered that option as well, but in the particular case I'm developing the control for, there is the likelihood of a dozen or more instances of the control on a single form, and potentially up to 32 instances, and the image list with images loaded would create a lot of additional overhead, not to mention redundancy. The property page actually works out pretty nicely, I just don't like the text fields in the Property Panel.
What I've done in the past, is to set the Picture property to use a PropertyPage. Then, that PropertyPage has the filename field, and a browse button to locate the file. So it's basically using your own custom dialog to get the picture, allowing you to also get the filename. From there, your code can save the filename, and/or create an StdPicture object. The control's property works the same from code as it does without the PropertyPage association. You can also create Friend or Public properties so the control can get the filename in addition to the StdPicture object.
Make the PropertyPage association by opening the control, and selecting "Procedure Attributes..." from the Tools menu.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?