Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

hbitmap to TImage?

Posted on 2001-07-31
6
Medium Priority
?
2,127 Views
Last Modified: 2008-02-01
I have an ActiveX component which returns a windows handle to a Bitmap.
I need to get this handle into a TImage which can be saved to a file and/or displayed as part of an image component on the background of my form.

I have been able to get a HDC to the bitmap and draw on the bitmap... but I cannot figure out how to "copy" the data into a TImage.

MyHDC := CreateCompatibleDC(0);
    // ' Selects entire bitmap to this DC
SelectObject(MyHDC, HGDIOBJ(SkinObject.hEntireBitmap));

I'm sure I'm just missing something simple.
John
0
Comment
Question by:zitt
[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 2

Expert Comment

by:bugroger
ID: 6336920
Hi zitt,


{...}
MemBitmap        := TBitmap.Create;
MemBitmap.Handle := "HBITMAP";

Image1.Width  := MemBitmap.Width;
Image1.Height := MemBitmap.Height;
Image1.Canvas.Draw(0, 0, MemBitmap);

MemBitmap.Free;
{...}

GL
 Bug

0
 
LVL 2

Expert Comment

by:bugroger
ID: 6336948
If
 MemBitmap.Handle := "HBITMAP/HDC";
does not work try this:

 MemBitmap.Handle := CreateCompatibleBitmap("HDC", "Width", "Height");

0
 
LVL 2

Expert Comment

by:bugroger
ID: 6336951
You can also try
 Image1.Picture.Bitmap.Handle := "HBitmap/HDC"
or
 Image1.Picture.Bitmap.Handle := CreateCompatibleBitmap("HDC", "Width", "Height");
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 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 6336983
Maybe simply "Image1.Picture.Bitmap.Handle := HBitmap;" ?

Regards, Madshi.
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6338821
listening :-)
0
 

Author Comment

by:zitt
ID: 6362689
Short, simple and it seems to work.
I could have swore I tried this; however, it was likely do to inconsitancies I have with the OCX control I'm using.

John
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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