Board index » cppbuilder » GetDC + copy multiple forms to bitmap

GetDC + copy multiple forms to bitmap

Hello,

Suppose I have a project with 2 forms (TForm1 and TForm2) which are
completely different.  I want to convert both forms to a bitmap.

I do have a function (defined in TForm1) that converts a TForm1 to a bitmap.
However, is it possible to make this function generable and pass the form
instead of defining it in both TForm1 and TForm2.  Or in other words, can I
pass the form in some way to the function GetDC???

Or does it work differently?????

void TForm1::moveFormToBitmap()
{
    Graphics::TBitmap* Bitmap = new Graphics::TBitmap();
    HDC HScreenDC = GetDC(0);
    Bitmap->Handle =
CreateCompatibleBitmap(HScreenDC,ClientWidth,ClientHeight);
    ...... and so on ....

Quote
}

Thanx in advance ...

Bob

 

Re:GetDC + copy multiple forms to bitmap


Perhaps this will help you (untested):

--- bitmapform.h ---
#ifndef BITMAP_FORM_H
#def BITMAP_FORM_H

#include <vcl.h>

void moveFormToBitmap(TCustomForm *form);

#endif

--- bitmapform.cpp ---
#include "bitmapform.h"

void moveFormToBitmap(TCustomForm *form)
{
    Graphics::TBitmap* Bitmap = new Graphics::TBitmap();
    HDC HScreenDC = GetDC(form->Handle);
    Bitmap->Handle = CreateCompatibleBitmap(HScreenDC, form->ClientWidth,
form->ClientHeight);
    // ...... and so on ....

Quote
}

Then, "Add to Project" the .cpp file, and #include the header file whever
you need the function.

Gambit

Quote
Leslie Bortels <lbort...@vub.ac.be> wrote in message

news:91smm5$k2c2@bornews.inprise.com...

Quote
> I do have a function (defined in TForm1) that converts a TForm1 to a
bitmap.
> However, is it possible to make this function generable and pass the form
> instead of defining it in both TForm1 and TForm2.  Or in other words, can
I
> pass the form in some way to the function GetDC???

Other Threads