Results 1 to 3 of 3

Thread: getting filename from form1.picture

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    You can display a picture on a form (.bmp, .jpg, etc.) using form's .Picture property. But how can I retrieve the filename of that picture file that has been assinged to a form?

    Thanks for your help.
    Thanks

    Tomexx.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    You can't... because it doesn't exist.


    When you select the image to be displayed in a picture property it makes a "copy" of the file and loads it internally to be stored within the application.

    If the file happened to be a gif or a jpg it also converts it to bmp format losing the transparency (it gets it back by mapping the MaskColor to the base color of the gif transparency however).


    The only way to know the filename is to actually use "LoadPicture" within your code to load the image directly and at that time you could use the Tag field to store the name of the file you just loaded.

  3. #3
    Addicted Member jcouture100's Avatar
    Join Date
    Aug 1999
    Posts
    141
    There is probably a better way to do it, but I've used this method... If using a common dialog control to retrieve and assign a specific picture file to a picture box control, then also save the common dialog "FileName" property to the PictureBox.Tag property. Then simply refer to the Picture box tag property to retrieve the filename whenever you need it. If the picture is something you assign via code, then set the picture box tag property to the same file name at the same time.

    Not a perfect solution, but it should work.
    JC

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width