|
-
October 9th, 1999, 10:49 AM
#1
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
-
October 9th, 1999, 07:47 PM
#2
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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|