Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using windows API BitBlt function in Delphi 2.0

360 views
Skip to first unread message

x

unread,
Jun 25, 1997, 3:00:00 AM6/25/97
to

I am using Delphi 2.0 and I am trying to copy a bitmap from one image box to
another on the same form. The copy must be done quickly.

I know this can be done quickly using Visual Basic and the BitBlt function in
the Windows API. I of course want to use the BitBlt function in Delphi 2.0.

The big question is how do I get the device context for the source and
destination image boxes? In VB there is a hook (property) called hDC which is
called like Picture1.hdc, this does not seem to work with Delphi.

What do I pass the BitBlt function when it asks for parameters hdcDest and
hdcSrc? Is it even possible to use BitBlt with Delphi?

The syntax for the BitBlt fucnction is: (from Win32 help file)

BOOL BitBlt(

HDC hdcDest, // handle of destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // x-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle of source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
DWORD dwRop // raster operation code
);


Thanks in advance,

Mark Goedert
LAN Administrator
UIC Computer Center


Heiko Lüttge

unread,
Jun 26, 1997, 3:00:00 AM6/26/97
to


x <y...@somehost.somedomain> schrieb im Beitrag
<5oro7j$2s88$2...@piglet.cc.uic.edu>...


> I am using Delphi 2.0 and I am trying to copy a bitmap from one image box
to
> another on the same form. The copy must be done quickly.
>
> I know this can be done quickly using Visual Basic and the BitBlt
function in
> the Windows API. I of course want to use the BitBlt function in Delphi
2.0.
>
> The big question is how do I get the device context for the source and
> destination image boxes? In VB there is a hook (property) called hDC
which is
> called like Picture1.hdc, this does not seem to work with Delphi.
>

There's a variable called handle for using api functions. Look at the help
file TImageBox or what component you use.

Heiko

lue...@sunpool.cs.uni-magdeburg.de

How can you I know what I want,
before I hear what I say.

Lazikas o Pontios

unread,
Jun 27, 1997, 3:00:00 AM6/27/97
to

Heiko Lüttge wrote:

> There's a variable called handle for using api functions. Look at the
> help
> file TImageBox or what component you use.
>

If you have 2 Timage components in same form you can use this :

BitBlt ( Image1.Canvas.Handle, ...Image2.Canvas.Handle,...);

this copies the contents of Image2 to image1.

Hope this helps...

Lazikas o Pontios.


David Ullrich

unread,
Jun 27, 1997, 3:00:00 AM6/27/97
to

x wrote:
>
> I am using Delphi 2.0 and I am trying to copy a bitmap from one image box to
> another on the same form. The copy must be done quickly.
>
> I know this can be done quickly using Visual Basic and the BitBlt function in
> the Windows API. I of course want to use the BitBlt function in Delphi 2.0.
>
> The big question is how do I get the device context for the source and
> destination image boxes? In VB there is a hook (property) called hDC which is
> called like Picture1.hdc, this does not seem to work with Delphi.
>
> What do I pass the BitBlt function when it asks for parameters hdcDest and
> hdcSrc? Is it even possible to use BitBlt with Delphi?

You can certainly use BitBlt in Delphi. You probably don't want
to - you can use the Delphi CopyRect function to do the same thing (if
you're missing the raster-operation paramater, you set that by setting
the CopyMode property of the destination Canvas.)

A Delphi Canvas is an encapsulation of a device context -
a Canvas's Handle property is an HDC, so ACanvas.Handle is what
you'd pass to BitBlt if you were using BitBlt directly for
some reason.

--
David Ullrich

?his ?s ?avid ?llrich's ?ig ?ile
(Someone undeleted it for me...)

0 new messages