VB6 Image location testing

007bond
How do you test for the location of an image, assuming that it is in the same directory as the exe file? I have tried entering the location into a variable and testing that against Image.Picture property, but it just gives me a Type mismatch error. How do I test the image location, or do I have to use a custom image control?

paul_one
Isn't it "image.filename" or something like that...

And the directory for the opened file is something like "exe.path" or something like that... YEESH, it's been SO long since I ran VB6!!

007bond
It's App.Path, and yes I know that one. But i'll take a look into Image.Filename when I get back onto my development machine. Thanks.

007bond
checked the Object Browser for a runtime property, and there was nothing. I checked both the Image control, and the PictureBox control, and neither had a filename property. Just thinking about it now, however, I could probably set the image's location into a variable when changing it, and look at that when I go to check the location. I'll try that, but only if no one else here has any other feedback.

paul_one
So what are you trying to do exactly?

GameBoy
Computer Whizz wrote:So what are you trying to do exactly?


He wants the application to load the image from a directory, rather than have the image imported into the EXE. This way, users are able to edit the image files to make their own 'skins' as one might say.

Dunno if this is right....

picPicture.Picture = LoadPicture(App.Path + "\directory" & Index & ".jpg")


Might work.

-------------------

Edit:

hmm, just looked at something. If you're using Picture Boxes, this line of code might help:
Picture1.Picture = LoadPicture ("Filename")


I think you can probably change the parameter of ("Filename") to the image located in the same directory as the exe. I believe this will work because if it was to load a picture within the form, i think the syntax would be...
Picture1.Picture = imgPicture


But being new to this, i could be wrong. Experiment with it anyway, and see what result you get. Hope i helped :)

paul_one
There's a few days I wish I still had all my stuff installed on my PC... Now is not one of them!

Everyone should really read THIS page!
http://catb.org/~esr/faqs/smart-questions.html

It's full of a couple of hints for everyone, the people like ITID and I who over-react to stupid questons, and those who ask the questions (like Ste, 007 and again, Me).
Then again I follow the things mentioned in this page anyway - so I mainly apply to the first choice, in which I'm making leaps and bounds to be a kinder me.

EDIT::

And just to stress a point:
http://www.axeuk.com/phpBB2/viewtopic.php?t=533
This guy is posting in English as best as he can, and provides fair-ish details. He is at least trying, and it shows through even a dodgy translation!

This proves the document even more!

007bond
what exactly were we meant to read on that page. I don't have the time to read the whole thing, and a pointer would be nice.

007bond
what exactly were we meant to read on that page. I don't have the time to read the whole thing, and a pointer would be nice.

As for Ste's post, you were close, but it wasn't for skins. What I am getting a couple of friends at school to do is do button styles for me. So I have the user select a button style from a menu. Let use Green for an example. This sets a variable called btnStyle in a module to "green". Then it procedes to test for the current state of the buttons: normal, or disabled. It does this by looking at the image filename. Once it finds the right state of the button, it loads the respective image in place of the standard one. Unfortunately, there is no easy way to test the image.picture property because of the way MS made it. So, as I said above: what I might need to do is set a variable when I change the image, and test that, but there has got to be an easier way to do it, surely.

[EDIT] Just wondering, if I wanted to do a crossfading effect, I would need two MediaPlayer Controls, right?

GameBoy
a variable is apparently the best way for this. as a beginning programmer i can't tell you much, except that you're on the right tracks

007bond
I thought so.

Sorry about the double post, I pressed Submit and then thought of something else to say, and pressed Escape as quickly as I could. Obvisouly it submitted the post before I pressed Escape. I think I need my reflexes tested :D.

paul_one
OK - well then I would suggest you totally drop anything else you're doing then because you won't get far in life without reading that one single page!

Everything you have posted to this page has been along those lines, and everything you will do in the future will be along those lines.

When you check for a button state - why don't you just check for the buton state instead of checking the image? - Use the simplest route first!
So this image (you mean colour - since green is a colour) is just for an "OK" style button?

Just thought about something - you're using the "image" control as "play/stop/etc" button's aren't ya!
Check THAT to see if it's enabled or disabled then... How are you setting then enabled/disabled?

007bond
Well yeah, I am using the Image control (as I said above). Now that I think about it, I probably could use that method. Can I check for it though, or will it produce the same error that the picture property did?

GameBoy
i say Google your question, or search here:
http://www.visualbasicforum.com/

007bond
are those the VB Forums (aka vbforums.com)?

paul_one
Is clicking on the link beyond you?

GameBoy
No vbforums.com is a different site. This seems to have another URL (but same forum): http://www.xtremevbtalk.com/index.php
As you can see from the URL, Xtreme VB Talk.

007bond
no,I can click on the link, I just want to know if it is first of all, because as I said, I can't seem to sign up to VBForums.

This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums