Solved

Getting path from an image object

Posted on 2000-04-04
12
134 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
ID: 2683338
Do you mean a path within you're application or a variable path?
0
 

Expert Comment

by:philjh
ID: 2683357
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
ID: 2683541
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Expert Comment

by:riduce
ID: 2683599
Why do you need the path
0
 

Expert Comment

by:philjh
ID: 2683621
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
ID: 2683628
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
 
LVL 1

Expert Comment

by:riduce
ID: 2683650
Why do you need the path
0
 
LVL 7

Expert Comment

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

Expert Comment

by:Erick37
ID: 2684894
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
ID: 2685657
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
ID: 2685658
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
ID: 2689043
This isn't exactly what I wanted but I will try to work with it. Thanks anyway.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

770 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