John G Duffy
May 19th, 2001, 01:48 PM
I have a Shape control on my form and I would like to copy its image and turn it into a Graphic file. Anyone know how to do this? It does not have a .hwnd property so GetWindowRect is out of the question.
John G
shree
May 19th, 2001, 07:59 PM
If you set the autoredraw property of the form to false, you can grab anything on the form (actually anything visible on the screen), controls, and all. Here's a short program that copies the shape control on the form to a picturebox. Then, you can save it using SavePicture.
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Me.AutoRedraw = False
BitBlt Picture1.hDC, 0, 0, Shape1.Width / Screen.TwipsPerPixelX, Shape1.Height / Screen.TwipsPerPixelY, Form1.hDC, Shape1.Left / Screen.TwipsPerPixelX, Shape1.Top / Screen.TwipsPerPixelY, &HCC0020
End Sub
John G Duffy
May 20th, 2001, 08:18 AM
God love you man. I was pursueing another approach of .Pset and .Point to copy from Form to PictureBox but was having trouble. Autoredraw may be my problem but I like your Bitblt method.
John G