DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Help, about BitBlt

  1. #1
    rex Guest

    Help, about BitBlt

    dear all,

    When I using BitBlt function to capture a picturebox contain, if any window
    over top on it, it will capture it also. any method to solve it ?

    thanks a lot,
    Rex




  2. #2
    Mike D Sutton Guest

    Re: Help, about BitBlt

    > When I using BitBlt function to capture a picturebox contain, if any
    window
    > over top on it, it will capture it also. any method to solve it ?


    Enable the AutoRedraw property of the picture box control.
    Hope this helps,

    Mike


    -- EDais --

    - Microsoft Visual Basic MVP -
    WWW: Http://EDais.earlsoft.co.uk/
    Work E-Mail: EDais@btclick.com
    Other E-Mail: Mike.Sutton@btclick.com



  3. #3
    rex Guest

    Re: Help, about BitBlt

    Mike,

    It doesn't work , but thanks anyway

    Rex

    "Mike D Sutton" <Mike.Sutton@btclick.com> wrote in message
    news:3c95fb76@10.1.10.29...
    > > When I using BitBlt function to capture a picturebox contain, if any

    > window
    > > over top on it, it will capture it also. any method to solve it ?

    >
    > Enable the AutoRedraw property of the picture box control.
    > Hope this helps,
    >
    > Mike
    >
    >
    > -- EDais --
    >
    > - Microsoft Visual Basic MVP -
    > WWW: Http://EDais.earlsoft.co.uk/
    > Work E-Mail: EDais@btclick.com
    > Other E-Mail: Mike.Sutton@btclick.com
    >
    >




  4. #4
    Mike D Sutton Guest

    Re: Help, about BitBlt

    > It doesn't work , but thanks anyway

    It does work... Add three picture box's and a command button to a form,
    then paste this code in and run it.

    '***
    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 Form_Load()
    With Picture1
    .AutoRedraw = False
    .BackColor = vbRed
    .ScaleMode = vbPixels
    .Move 0, 0, 2000, 2000
    End With

    With Picture2
    .AutoRedraw = True
    .BackColor = vbGreen
    .ScaleMode = vbPixels
    .Move 2000, 0, 2000, 2000
    End With

    With Picture3
    .AutoRedraw = True
    .ScaleMode = vbPixels
    .Move 1000, 1000, 2000, 2000
    End With

    With Command1
    .Move 3000, 2000, 1000, 1000
    .Default = True
    Form1.Width = .Left + .Width + 120
    Form1.Height = .Top + .Height + 400
    End With
    End Sub

    Private Sub Command1_Click()
    Dim StartTime As Long

    BitBlt Picture3.hDC, 0, 0, Picture1.ScaleWidth, _
    Picture1.ScaleHeight, Picture1.hDC, _
    0, 0, vbSrcCopy
    Picture3.CurrentY = 0
    Picture3.Print "Non-autoredraw"
    Picture3.Print " Notice the bottom right"
    Picture3.Print " corner is not drawn"
    Picture3.Print " properly"
    Picture3.Refresh

    StartTime = Timer

    Do: DoEvents 'Delay for 5 seconds
    Loop Until Timer > StartTime + 5

    BitBlt Picture3.hDC, 0, 0, Picture2.ScaleWidth, _
    Picture2.ScaleHeight, Picture2.hDC, _
    0, 0, vbSrcCopy
    Picture3.CurrentY = 0
    Picture3.Print "Autoredraw"
    Picture3.Print " With autoredraw, the"
    Picture3.Print " entire picture is drawn"
    Picture3.Print " properly"
    Picture3.Refresh
    End Sub
    '***

    Mike


    -- EDais --

    - Microsoft Visual Basic MVP -
    WWW: Http://EDais.earlsoft.co.uk/
    Work E-Mail: EDais@btclick.com
    Other E-Mail: Mike.Sutton@btclick.com



  5. #5
    rexyeung Guest

    Re: Help, about BitBlt

    Mike,

    Actually I using the picturebox for display the Video only, just like the
    following code


    Set Parent = picturebox1.hWnd

    mCapHwnd = capCreateCaptureWindow("RexCaptureWindow", WS_VISIBLE Or
    WS_CHILD, 0, 0, Parent.ScaleWidth, Parent.ScaleHeight, Parent.hWnd, 0)

    SetParent mCapHwnd, Parent.hWnd

    even I set the picturebox1's autoredraw property is true or set the source
    hdc of BitBlt is getdc(mCaphwnd), both not work

    Rex


    "Mike D Sutton" <Mike.Sutton@btclick.com> wrote in message
    news:3c99da91$1@10.1.10.29...
    > > It doesn't work , but thanks anyway

    >
    > It does work... Add three picture box's and a command button to a form,
    > then paste this code in and run it.
    >
    > '***
    > 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 Form_Load()
    > With Picture1
    > .AutoRedraw = False
    > .BackColor = vbRed
    > .ScaleMode = vbPixels
    > .Move 0, 0, 2000, 2000
    > End With
    >
    > With Picture2
    > .AutoRedraw = True
    > .BackColor = vbGreen
    > .ScaleMode = vbPixels
    > .Move 2000, 0, 2000, 2000
    > End With
    >
    > With Picture3
    > .AutoRedraw = True
    > .ScaleMode = vbPixels
    > .Move 1000, 1000, 2000, 2000
    > End With
    >
    > With Command1
    > .Move 3000, 2000, 1000, 1000
    > .Default = True
    > Form1.Width = .Left + .Width + 120
    > Form1.Height = .Top + .Height + 400
    > End With
    > End Sub
    >
    > Private Sub Command1_Click()
    > Dim StartTime As Long
    >
    > BitBlt Picture3.hDC, 0, 0, Picture1.ScaleWidth, _
    > Picture1.ScaleHeight, Picture1.hDC, _
    > 0, 0, vbSrcCopy
    > Picture3.CurrentY = 0
    > Picture3.Print "Non-autoredraw"
    > Picture3.Print " Notice the bottom right"
    > Picture3.Print " corner is not drawn"
    > Picture3.Print " properly"
    > Picture3.Refresh
    >
    > StartTime = Timer
    >
    > Do: DoEvents 'Delay for 5 seconds
    > Loop Until Timer > StartTime + 5
    >
    > BitBlt Picture3.hDC, 0, 0, Picture2.ScaleWidth, _
    > Picture2.ScaleHeight, Picture2.hDC, _
    > 0, 0, vbSrcCopy
    > Picture3.CurrentY = 0
    > Picture3.Print "Autoredraw"
    > Picture3.Print " With autoredraw, the"
    > Picture3.Print " entire picture is drawn"
    > Picture3.Print " properly"
    > Picture3.Refresh
    > End Sub
    > '***
    >
    > Mike
    >
    >
    > -- EDais --
    >
    > - Microsoft Visual Basic MVP -
    > WWW: Http://EDais.earlsoft.co.uk/
    > Work E-Mail: EDais@btclick.com
    > Other E-Mail: Mike.Sutton@btclick.com
    >
    >




  6. #6
    Mike D Sutton Guest

    Re: Help, about BitBlt

    > Actually I using the picturebox for display the Video only, just like the
    > following code


    <Code snipped>

    > even I set the picturebox1's autoredraw property is true or set the source
    > hdc of BitBlt is getdc(mCaphwnd), both not work


    Because you're not drawing from the picture box at all, you're drawing from
    another window entirely! Help us to help you by giving us the relevant
    information otherwise how can we possible help, we're not mind-readers..

    Mike


    -- EDais --

    - Microsoft Visual Basic MVP -
    WWW: Http://EDais.earlsoft.co.uk/
    Work E-Mail: EDais@btclick.com
    Other E-Mail: Mike.Sutton@btclick.com



  7. #7
    Sergio Commran Guest

    RE: Help, about BitBlt


    "picture1.picture = picture1.image"
    before bitblt? ;-)
    regards



  8. #8
    Mike D Sutton Guest

    Re: Help, about BitBlt

    > "picture1.picture = picture1.image"
    > before bitblt? ;-)


    What relevance does this have at all? He's not even drawing on a picture
    box?..

    Mike


    -- EDais --

    - Microsoft Visual Basic MVP -
    WWW: Http://EDais.earlsoft.co.uk/
    Work E-Mail: EDais@btclick.com
    Other E-Mail: Mike.Sutton@btclick.com



  9. #9
    rexyeung Guest

    Re: Help, about BitBlt

    So if not drawing on picturebox , bitblt can't capture from a DC?

    Rex


    "Mike D Sutton" <Mike.Sutton@btclick.com> wrote in message
    news:3c9f201f@10.1.10.29...
    > > "picture1.picture = picture1.image"
    > > before bitblt? ;-)

    >
    > What relevance does this have at all? He's not even drawing on a picture
    > box?..
    >
    > Mike
    >
    >
    > -- EDais --
    >
    > - Microsoft Visual Basic MVP -
    > WWW: Http://EDais.earlsoft.co.uk/
    > Work E-Mail: EDais@btclick.com
    > Other E-Mail: Mike.Sutton@btclick.com
    >
    >




  10. #10
    Mike D Sutton Guest

    Re: Help, about BitBlt

    > So if not drawing on picturebox , bitblt can't capture from a DC?

    ? Of course it can.. A picture box is _not_ a DC, it's just a visual
    element that can display the image contained within a device context.

    Mike


    -- EDais --

    - Microsoft Visual Basic MVP -
    WWW: Http://EDais.earlsoft.co.uk/
    Work E-Mail: EDais@btclick.com
    Other E-Mail: Mike.Sutton@btclick.com



  11. #11
    rexyeung Guest

    Re: Help, about BitBlt

    thk,

    So How to grab it only if some control over it?

    Rex

    "Mike D Sutton" <Mike.Sutton@btclick.com> wrote in message
    news:3ca060d5$1@10.1.10.29...
    > > So if not drawing on picturebox , bitblt can't capture from a DC?

    >
    > ? Of course it can.. A picture box is _not_ a DC, it's just a visual
    > element that can display the image contained within a device context.
    >
    > Mike
    >
    >
    > -- EDais --
    >
    > - Microsoft Visual Basic MVP -
    > WWW: Http://EDais.earlsoft.co.uk/
    > Work E-Mail: EDais@btclick.com
    > Other E-Mail: Mike.Sutton@btclick.com
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center