Solved

vb5: API Creating Device Contexts / Bitmaps

Posted on 2000-04-09
6
193 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:ChrisK
6 Comments
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2697597
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.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2697865
These may help:

:HOWTO: Create Your Own Bitmap Object Class:
http://support.microsoft.com/support/kb/articles/Q187/5/68.ASP

"HOWTO: Capture and Print the Screen, a Form, or any Window"
http://support.microsoft.com/support/kb/articles/Q161/2/99.ASP
0
 
LVL 2

Author Comment

by:ChrisK
ID: 2698205
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 2698352
http://www.vb-helper.com/Howto/picmask.zip

Don't know if thats what youre looking for either
0
 
LVL 2

Author Comment

by:ChrisK
ID: 2698392
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.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2698399
Hello Chris, glad it pointed you in the right direction.  You can just accept my comment above as an answer if you wish.  Cheers!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now