Solved

vb5: API Creating Device Contexts / Bitmaps

Posted on 2000-04-09
6
194 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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