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

Thread: Shape Control

  1. #1
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Shape Control

    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

  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Shape Control

    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


  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Shape Control

    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

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