vb5: API Creating Device Contexts / Bitmaps

I've either reached something vb can't do or I'm doing it incorrectly.  I want to be able to create a bitmap in memory and bitblt ONTO that bitmap as well as from it.

CreateCompatibleDC and CreateCompatibleBitmap is what I've used so far with no success.
Who is Participating?
AzraSoundConnect With a Mentor Commented:

Don't know if thats what youre looking for either
You've presumably used CreateCompatibleDC() to create a DC, then selected the bitmap created with CreateCompatibleBitmap() into the DC before the blit? (A code sample of what you're trying would have been nice...). The most obvious error I can think of is: you might be calling CreateCompatibleBitmap() with the DC you get from CreateCompatibleDC() as a parameter. A memory DC is created by default with a 1x1 pixel monochrome bitmap, so CreateCompatibleBitmap() will return the same thing when you try it. Make sure you're calling CreateCompatibleBitmap() with the screen DC.
These may help:

:HOWTO: Create Your Own Bitmap Object Class:

"HOWTO: Capture and Print the Screen, a Form, or any Window"
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

ChrisKAuthor Commented:
Sorry...forgot my code :)

Erick these examples don't do what I'm trying to do.  Loading a bitmap from the hd into a memory allocation works....I want to bitblt onto one.  Example Picture1 is on the form...a real object.  Picture2 is only resident in memory.  I need to be able to bitblt picture1's contents to picture2 and visa versa.

tempdc = CreateCompatibleDC(map.hdc)
CreateCompatibleBitmap tempdc, 400, 400
BitBlt tempdc, 0, 0, 400, 400, map.hdc, 0, 0, vbSrcCopy

map.hdc is a picture box on the form.  So I presumed I was creating another dc with it's attributes.  Specified the size with CreateCompatibleBitmap, then bitblt to it....but I get nothing.
ChrisKAuthor Commented:
azra, submit as the answer.  I was able to figure out what was wrong from that example.

I lacked SelectObject.  Apparently I have to have that before I try to bitblt.
Hello Chris, glad it pointed you in the right direction.  You can just accept my comment above as an answer if you wish.  Cheers!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.