[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting path from an image object

Posted on 2000-04-04
12
Medium Priority
?
141 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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
Course of the Month17 days, 20 hours left to enroll

831 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