[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Getting path from an image object

Posted on 2000-04-04
12
Medium Priority
?
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 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