Solved

Getting path from an image object

Posted on 2000-04-04
12
132 Views
Last Modified: 2010-05-02
How can I get the path of a picture on the disk that is in a certain Image object.
Ie. I have an image object with a picture assigned to it. How can i find out the path to that picture on my hard disk
0
Comment
Question by:adinas
  • 3
  • 3
  • 2
  • +3
12 Comments
 
LVL 1

Expert Comment

by:riduce
Comment Utility
Do you mean a path within you're application or a variable path?
0
 

Expert Comment

by:philjh
Comment Utility
I think you cannot. When the picture is first put in the control via the picture property it pulls the binary data from the file and stores its own copy. Hence , the creation of frx's etc.There is then no maintained connection to the original file unless the information was stored somewhere at the time.
0
 
LVL 1

Author Comment

by:adinas
Comment Utility
To riduce: I am talking about a path to a file. the file doesn't not move around

To philjh: Is there an object that can contain a picture and also its path
0
 
LVL 1

Expert Comment

by:riduce
Comment Utility
Why do you need the path
0
 

Expert Comment

by:philjh
Comment Utility
I don't know of one but you could try creating your own Activex control with the image conrol as a constituent and persisting the path in its own propbag.
0
 
LVL 1

Author Comment

by:adinas
Comment Utility
I am using a componet by a third party company. in order to use some of their methods I need to pass the path to the picture.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

by:riduce
Comment Utility
Why do you need the path
0
 
LVL 7

Expert Comment

by:Vbmaster
Comment Utility
You could use the Tag property to hold the path name.
0
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
Why not just store the path in a local or global variable?

Option Explicit

Private sPicPath As String

Private Sub Command1_Click()
    'Use the path somewhere else
    MsgBox sPicPath
End Sub

Private Sub Form_Load()
    'Load the picture at runtime
    sPicPath = "c:\test.bmp"
    Picture1.Picture = LoadPicture(sPicPath)
End Sub
0
 
LVL 1

Expert Comment

by:j3877
Comment Utility
I've looked through the API - there is NO API CALL FOR IT: If there is no API call for something, then it is impossible to do. (duuh!)


When an image is loaded, basically, that image is given a "process id" (it's a little different, but fundamentally the same) - this is just a number, that the control uses, and by extracting something from the number, it then gets the path of the image (or perhaps the image is loaded into memory already...), but anyway, there is probably a way of using about 1,000,000 API calls to do it, but the method below works fine:



Public Function LoadPictureB(Filename as string, ApplyTo as Picturebox) as long

on error goto ErrorHandler
ApplyTo.tag = Filename
ApplyTo.picture = loadpicture(Filename)

'Now, the function has succeded, return an all ok:
LoadPictureB = 0
Exit Function

ErrorHandler:
'Do whatever err loop u want here:
select case err.number
'...
case else
    msgbox "Error encountered while loading the image """ & Filename & """. Please check and retry",vbcritical,"Error Occurred"
end select
LoadPictureB = err.number
'You don't need the return, but it looks nicer, and u mite want to see if an error occurred...
End Function




'The above code should work fine - it's basically just a simpler way of the code above.
0
 
LVL 1

Accepted Solution

by:
j3877 earned 50 total points
Comment Utility
I've looked through the API - there is NO API CALL FOR IT: If there is no API call for something, then it is impossible to do. (duuh!)


When an image is loaded, basically, that image is given a "process id" (it's a little different, but fundamentally the same) - this is just a number, that the control uses, and by extracting something from the number, it then gets the path of the image (or perhaps the image is loaded into memory already...), but anyway, there is probably a way of using about 1,000,000 API calls to do it, but the method below works fine:



Public Function LoadPictureB(Filename as string, ApplyTo as Picturebox) as long

on error goto ErrorHandler
ApplyTo.tag = Filename
ApplyTo.picture = loadpicture(Filename)

'Now, the function has succeded, return an all ok:
LoadPictureB = 0
Exit Function

ErrorHandler:
'Do whatever err loop u want here:
select case err.number
'...
case else
    msgbox "Error encountered while loading the image """ & Filename & """. Please check and retry",vbcritical,"Error Occurred"
end select
LoadPictureB = err.number
'You don't need the return, but it looks nicer, and u mite want to see if an error occurred...
End Function




'The above code should work fine - it's basically just a simpler way of the code above.
0
 
LVL 1

Author Comment

by:adinas
Comment Utility
This isn't exactly what I wanted but I will try to work with it. Thanks anyway.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now