CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Urgent !!! How to Save a Image Drawn on a Picturebox Using hDc

    How to Save a Image Drawn on a Picturebox Using hDc / DrawIconEx to a file

    Sterla


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Urgent !!! How to Save a Image Drawn on a Picturebox Using hDc

    When drawing in the Image on the Picturebox, set the AutoRedraw property to True, this will copy the HDC Image to the Image of the Picturebox, you can then use Picture1 = Picture1.Image to make the Image a Persistent Graphic, allowing it to be Saved/Manipulated from the Picturebox.

    Here's an example..

    private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (byval hInst as Long, byval lpIconPath as string, lpiIcon as Long) as Long
    private Declare Function DrawIcon Lib "user32" (byval hdc as Long, byval x as Long, byval y as Long, byval hIcon as Long) as Long

    private Sub Command1_Click()
    Dim lIcon as Long
    on error GoTo LoadError
    With CommonDialog1
    .Filter = "All Files|*.*"
    .CancelError = true
    .ShowOpen
    lIcon = ExtractAssociatedIcon(App.hInstance, .FileName, -1)
    Caption = lIcon
    Picture1.AutoRedraw = true
    Call DrawIcon(Picture1.hdc, 0, 0, lIcon)
    Picture1 = Picture1.Image
    SavePicture Picture1, "C:\Image.bmp"
    End With
    LoadError:
    End Sub




    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

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