Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetBkColor (Or: How Do I Create a Coloured Bitmap DC)

Status
Not open for further replies.

RMS001

Programmer
Nov 12, 2002
45
CA
Hi - Perhaps this has been answered before, but I couldn't find a solution in a thread search...

I am trying to create a bitmap in memory to blit another bitmap onto.
The memory bitmap needs to have its back colour set to match a transparent colour in the source image.

Does anyone know how to create a memory bitmap DC using a specific colour.

This is not working:

Dim hBitmap As Long
Dim DC As Long

DC = CreateCompatibleDC(0&)

hBitmap = CreateCompatibleBitmap(DC, 500, 500)

SelectObject DC, hBitmap

SetBkMode DC, OPAQUE
SetBkColor DC, vbRed

SetStretchBltMode Picture1.hdc, STRETCH_HALFTONE

Call StretchBlt(Picture1.hdc, 0, 0, 200, 200, _
DC, 0, 0, 500, 500, SRCCOPY)

I would like this to add a 200x200 red rectangle to the picturebox. (If I can get this to work, I will blit my transparent image onto the DC before the final StretchBlt'ing is done).

Thanks, - Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top