Solved

hbitmap to TImage?

Posted on 2001-07-31
6
2,044 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
Technology Partners: 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 50 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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