Results 1 to 3 of 3

Thread: LoadBitmap and CreatePatternBush question

  1. #1

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Question LoadBitmap and CreatePatternBush question

    I've got a bitmap in a resource file, and a want to use it with the CreatePatternBush API.

    How do you do this?


    Thanks in advanced.

  2. #2
    jim mcnamara
    Guest
    Here's sample code from www.allapi.net - they have free software - api guide & apiviewer. Good stuff

    Code:
    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 Any) As Long
    Dim bBytes(1 To 8) As Byte
    Private Sub Form_Paint()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
    
        Dim R As RECT, mBrush As Long, hBitmap As Long
        For mBrush = 1 To 8
            bBytes(mBrush) = 123
        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

  3. #3

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Thumbs up

    Cheers jim mcnamara

Posting Permissions

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



Click Here to Expand Forum to Full Width