CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2012
    Posts
    33

    Question Hi i have a form and i want to know how to save pictures to it?

    Hi, everyone i have a program that you add images to the mainform, but when you exit the program the pictures do not save how can i do this, i need to save the pictures to the mainform. i have tryed this.

    Code:
    SaveMainform
    And it dose not work, am i doing something wrong, and its under a button.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Hi i have a form and i want to know how to save pictures to it?

    What does the code inside SaveMainForm look like ?

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Hi i have a form and i want to know how to save pictures to it?

    Well basically you do not save anything to the form. What you would need to do is save to a file of some sort then read from that file to load the images when the program starts. How you should do this depends on what you are doing but for example you may just need to save the path/filename to a text file then read that text file during load and load the images that are listed in the text file.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Re: Hi i have a form and i want to know how to save pictures to it?

    Hi, everyone i have a program that you add images to the mainform, but when you exit the program the pictures do not save how can i do this, i need to save the pictures to the mainform. i have tryed this.

    Did you write anything if so please provide what you have written ? .we will give more suggestion .anyway if you want to put the picture .so that when user run the project every time picture will show at the form at runtime .if so press f4 .and go to properies window .select the path of picture in the picture property of form .it is easy without write anything .save the project .it will save picture automatically .

    Last edited by firoz.raj; August 30th, 2012 at 01:13 PM.

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Hi i have a form and i want to know how to save pictures to it?

    That only works for 1 picture per control and must be done at design time which is not what the poster appears to be asking for.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Sep 2012
    Posts
    7

    Re: Hi i have a form and i want to know how to save pictures to it?

    I agree with DataMiser about the way you load and show your image. But if you really need to do the job this way you probably will have a hard time.
    A window has a handle (hWnd). That handle could be translated to a DeviceContext's handle (hDC) using hDC=GetDC(hWnd). Find out the coordinates you want to save, use bitblt to copy your selection to a destinatino hDC (Let's say hDCdst=GetDC(Picturebox.hWnd) you created in the same window (form) or in a different window (inside or outside the same process). From that point you can use the VB SavePicture function to save you StdPicture (PictureBox.Picture) to a file.
    Good luck!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Hi i have a form and i want to know how to save pictures to it?

    I was under the impression that the poster is using picture or image controls and wants to load pictures to them at runtime then recall them when the programs is ran. This would not be that hard. I would use an INI file.
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Sep 2012
    Posts
    7

    Re: Hi i have a form and i want to know how to save pictures to it?

    mwahaha.. I guess I misunderstood the question completely. I thought an app prints images that needed to be saved

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

Featured