[VB6] - about DC's
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: [VB6] - about DC's

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Posts
    626

    [VB6] - about DC's

    i did 1 class for working with DC's(double buffering):
    Code:
    Option Explicit
    
    Private Type DC
         handleDC As Long
         handleBMP As Long
         handleRefBMP As Long
    End Type
    
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
    Dim SourceDC As DC
    Dim lngWidth As Long
    Dim lngHeight As Long
    
    Public Sub GetImage(ByRef hdc As Long, ByRef Width As Long, ByRef Height As Long)
        SourceDC.handleDC = CreateCompatibleDC(hdc)
        SourceDC.handleBMP = CreateCompatibleBitmap(SourceDC.handleDC, Width, Height)
        SourceDC.handleRefBMP = SelectObject(SourceDC.handleDC, SourceDC.handleBMP)
        BitBlt SourceDC.handleDC, 0, 0, Width, Height, hdc, 0, 0, vbSrcCopy
        lngHeight = Height
        lngWidth = Width
    End Sub
    
    Public Sub DrawImage(ByRef hdc As Long)
        BitBlt hdc, 0, 0, lngWidth, lngHeight, SourceDC.handleDC, 0, 0, vbSrcCopy
    End Sub
    
    Private Sub Class_Terminate()
        DeleteObject SelectObject(SourceDC.handleDC, SourceDC.handleRefBMP)
        DeleteObject SourceDC.handleBMP
        DeleteDC SourceDC.handleDC
    End Sub
    why instead copy\draw the image, copy a mask image?

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [VB6] - about DC's

    It gets copied to the GPU rather than use the CPU that VB6 uses. There is video memory that can be accessed faster than pc memory, and draw it to the screen. It stores data in its buffer
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2009
    Posts
    626

    Re: [VB6] - about DC's

    Quote Originally Posted by dglienna View Post
    It gets copied to the GPU rather than use the CPU that VB6 uses. There is video memory that can be accessed faster than pc memory, and draw it to the screen. It stores data in its buffer
    what you are talking about?
    i need a double buffer faster, for avoid 1 flicker

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [VB6] - about DC's

    Look up DirectDraw. Back in the day, VB6 had a lot of great people supporting it. http://www.oocities.org/vbasicprogramming/DDTut1.htm Now, you get what's left!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Apr 2009
    Posts
    626

    Re: [VB6] - about DC's

    Quote Originally Posted by dglienna View Post
    Look up DirectDraw. Back in the day, VB6 had a lot of great people supporting it. http://www.oocities.org/vbasicprogramming/DDTut1.htm Now, you get what's left!
    i know that directx is the most used in VB6, by it's speed and power. but, for me, it's very complicate to startd
    i need a tutorial for Introdution\basics, at least for i start
    can you help me on that friend?
    thanks for all

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [VB6] - about DC's

    Not from this decade. See if you can track down an old version . VBForums.com might have some of my old stuff still around...
    http://externalweb.exhedra.com/Direc...DA_SoundFx.asp
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Apr 2009
    Posts
    626

    Re: [VB6] - about DC's

    Quote Originally Posted by dglienna View Post
    Not from this decade. See if you can track down an old version . VBForums.com might have some of my old stuff still around...
    http://externalweb.exhedra.com/Direc...DA_SoundFx.asp
    sorry.. server error

  8. #8
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [VB6] - about DC's

    Told you that. It worked fine in 2006
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Apr 2009
    Posts
    626

    Re: [VB6] - about DC's

    Quote Originally Posted by dglienna View Post
    Told you that. It worked fine in 2006
    hey... my engish isn't 100%, but i try hehehe
    can you give me another link?
    thanks

  10. #10
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: [VB6] - about DC's

    VBForums.com was the hang out back then...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Apr 2009
    Posts
    626

    Re: [VB6] - about DC's

    Quote Originally Posted by dglienna View Post
    VBForums.com was the hang out back then...
    i'm register there hehehe
    but thanks for all

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center