dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] Capturing part of a Form

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Resolved [RESOLVED] Capturing part of a Form

    On a Form I have several controls of which one is a picturebox. On top of the picturebox is an UC Image Control that shows some colored lines effects. I need to copy the picture that is in the picturebox and also the colored lines that have been drawn on the UC Image Control to another Form. I can copy the picturebox and the picture that is in the UC Image Control but not the colored lines drawn on top of the UC Image Control.

    If I do this:

    Form2.UCimg1.Picture = Form1.UCimg1.Picture
    Form2.picResults.Picture = Form1.picResults.Picture

    I get both pictures but not the colored lines that were drawn on the UC Image Control.

    So it occurs to me that maybe I could simply take a snap shot of the area on the Form that is occupied by the Picturebox. I know how to capture the entire Form but not a portion of it.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Capturing part of a Form

    JMS

    This is admittedly rather crude, but, since you know how to capture the entire
    Form, maybe you could start from there.

    On the other form, add 2 controls .. PictureBox1, and PictureBox2, where PB2 is
    contained within PB1.

    PB1 will serve as a "mask" .. make it the size you eventually want to see
    PB2 will be bigger, the size of the 1st Form. Put the captured shot in this PB.

    By playing with PB2.Top and PB2.Left, you ought to be able to position PB2
    such that you only see the region that you want to see (as delimited by PB1).

    Spoo

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Capturing part of a Form

    Thanks, Spoo, but I already figured it out

    Code:
    Private Sub CapturePicture()
     Dim ControlDC As Long
     
     ControlDC = GetDC(frmHairColorSimulator.hWND)   
     
     BitBlt Picture2.hdc, _
             0, 0, _
             Picture2.Width, Picture2.Height, _
             ControlDC, _
             picResultsContainer.Left, picResultsContainer.Top, _
             SRCCOPY
            
     Picture2.Refresh
    
     Form2.picResults.Picture = Form1.Picture2.Picture
    End Sub
    I don't need to do the UC because on Form2 only the total results are needed which is on top of Form1.picResults so the BitBlt picks up both the picture and the UC overlay


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width