CreateBitmap and VB 5.0 - ??? 
Author Message
 CreateBitmap and VB 5.0 - ???

Dear Reader,

We have a VB 3.0 app that creates a monochrome bitmap to do some BitBlt
masking, and it works great. We think it also worked OK as an interim
version in VB 4.0 16-bit, but we're not sure and haven't tried to
recreate it.

Today, we're just trying to just port it to VB 5.0. All the other 32-bit
GDI calls seem to work fine, but this one returns a 0 instead of a
handle. If you have a suggestion or insight, could you please respond?

Thank you in advance!

Ilse Gayl
---



Mon, 06 Mar 2000 03:00:00 GMT  
 CreateBitmap and VB 5.0 - ???

Better post your code.  I've done the same thing (ported VB3 mono mask code
to VB5) with no problem.

Jim Deutch
MS Dev MVP


Quote:
> Dear Reader,

> We have a VB 3.0 app that creates a monochrome bitmap to do some BitBlt
> masking, and it works great. We think it also worked OK as an interim
> version in VB 4.0 16-bit, but we're not sure and haven't tried to
> recreate it.

> Today, we're just trying to just port it to VB 5.0. All the other 32-bit
> GDI calls seem to work fine, but this one returns a 0 instead of a
> handle. If you have a suggestion or insight, could you please respond?

> Thank you in advance!

> Ilse Gayl
> ---



Tue, 07 Mar 2000 03:00:00 GMT  
 CreateBitmap and VB 5.0 - ???

OK, here's code that behaves the same way:

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
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As
Long
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
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal
hObject As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As
Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

Public Sub Main()
    frmMap.Visible = True
    frmMap!picMap.Picture = LoadPicture("udd-so.bmp")
    frmMap!picMap.Visible = True
    frmMap!picMask.Visible = True

End Sub
Public Sub MakeMask()

    Dim hSrcDC As Long
    Dim hDestDC As Long
    Dim BitmapDC  As Long
    Dim hMonoBM  As Long
    Dim hOld  As Long
    Dim hwndSrc  As Long
    Dim xSrc As Long
    Dim ySrc As Long
    Dim x As Long
    Dim y As Long
    Dim planes As Long
    Dim clrs As Long
    Dim bits As Long
    Dim nWidth As Long
    Dim nHeight As Long
    Dim Rop  As Long
    Dim Success As Long

'    On Error Resume Next

    'Create a monochrome bitmap
    nWidth = 800
    nHeight = 600
    planes = 1
    clrs = 1
    BitmapDC = CreateCompatibleDC(0)
    hMonoBM = CreateBitmap(nWidth, nHeight, planes, clrs, bits)
    hOld = SelectObject(BitmapDC, hMonoBM)

    frmMap!picMask.ScaleMode = 3
    frmMap!picMap.ScaleMode = 3
    hSrcDC = frmMap!picMap.hdc
    hDestDC = BitmapDC
    xSrc = 0
    ySrc = 0
    nWidth = frmMap!picMap.ScaleWidth
    nHeight = frmMap!picMap.ScaleHeight
    x = 0
    y = 0

   'blt the  sourcemap onto the monochrome bitmap
    hSrcDC = frmMap!picMap.hdc
    hDestDC = BitmapDC
    Rop = 13369376  '&HCC0020 'SRCCOPY
    Success = BitBlt(hDestDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc,
Rop)

    'blt the monochrome bitmap into picMask

    Success = 0
    hSrcDC = BitmapDC
    hDestDC = frmMap!picMask.hdc
    Rop = 13369376 '&HCC0020 'SRCCOPY      Rop = 8913094 '&H8800C6
'SRCAND
    Success = BitBlt(hDestDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc,
Rop)

    'delete memory bitmap
    Success = SelectObject(BitmapDC, hOld)
    Success = DeleteObject(hOld)
    Success = DeleteDC(BitmapDC)
End Sub



Tue, 07 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB 5.0 Professional Ed. suddenly becomes VB 5.0 Learning Ed.

2. VB 5.0 Professional Edition Vs. VB 5.0 Enterprise Edition

3. CreateBitmap()

4. Bad DLL Calling Convention during CreateBitmap()

5. How to use CreateBitmap

6. How to use CreateBitmap?

7. Help! CreateBitMap Failure

8. CreateBitmap API

9. Help! CreateBitMap Failure

10. Help! WinAPI function CreateBitMap Failure

11. CreateBitmap API

12. Problem with CreateBitmap API

 

 
Powered by phpBB® Forum Software