Solved

vb5: API Creating Device Contexts / Bitmaps

Posted on 2000-04-09
6
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…

705 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