I am trying to use a double buffer technique for drawing shapes, and I just can't seem to get it right. Can someone please help me figure this out.
Currently, this will draw a single line on a form.
I've read that double buffering the drawing surface will speed up the drawing process, which is my ultimate goal here. So, if there is another technique that is faster than this, I'd be interested in that too.
-George
"the screen with the little boxes in the window." - Moron
Currently, this will draw a single line on a form.
Code:
Option Explicit
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDc As Long) As Long
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 Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hDc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hDc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As Any) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Const PS_SOLID = 0
Private Sub Command1_Click()
Dim redPen As Long
redPen = CreatePen(PS_SOLID, 15, vbRed)
DeleteObject SelectObject(Me.hDc, redPen)
MoveToEx Me.hDc, 10, 10, 0
LineTo Me.hDc, 210, 210
Me.Refresh
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Sub
I've read that double buffering the drawing surface will speed up the drawing process, which is my ultimate goal here. So, if there is another technique that is faster than this, I'd be interested in that too.
-George
"the screen with the little boxes in the window." - Moron