Wednesday, April 29, 2009

Pattern Brush

'Pattern Brush

Private Type
RECT
   
Left As Long
   
Top As Long
   
Right As Long
   
Bottom As Long
End Type


Private Declare Function CreatePatternBrush Lib "gdi32" _
(ByVal hBitmap
As Long) As Long

Private Declare Function FillRect Lib "user32" _
(ByVal hdc
As Long, lpRect As RECT, ByVal hBrush
As Long) As Long

Private Declare Function SetRect Lib "user32" _
(lpRect
As RECT,
ByVal X1 As Long,
ByVal Y1 As Long, _

ByVal X2 As Long,
ByVal Y2 As Long)
As Long
Private Declare Function
DeleteObject Lib "gdi32" _
(ByVal hObject
As Long) As Long

Private Declare Function CreateBitmap Lib "gdi32" _
(ByVal nWidth
As Long, ByVal nHeight
As Long, _
ByVal nPlanes
As Long, ByVal nBitCount
As Long, lpBits As Integer) As Long


Dim bBytes(1 To 8)
As Integer

Private Sub Form_Paint()

Dim R As RECT, mBrush
As Long, hBitmap As Long


For mBrush = 1 To 8
Step 2
bBytes(mBrush) = 170    
'170 = 10101010
bBytes(mBrush + 1) = 85
'85 = 01010101
Next


'Create a memory bitmap
hBitmap = CreateBitmap(8, 8, 1, 1, bBytes(1))

'Create the pattern brush
mBrush = CreatePatternBrush(hBitmap)
SetRect R, 0, 0, Me.ScaleWidth, Me.ScaleHeight

'Fill the form
FillRect Me.hdc, R, mBrush

'Clean up
DeleteObject mBrush
DeleteObject hBitmap

End Sub
 

No comments:

Post a Comment