Solved

Getting path from an image object

Posted on 2000-04-04
12
135 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
Technology Partners: 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 42
Passing a Text Box name to a Sub 6 102
Zip Folders Using Chilkat Routines 1 77
Formula problem with Excel attachment 6 43
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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