Board index » cppbuilder » using BitBlt

using BitBlt


2008-03-06 10:16:19 PM
cppbuilder70
Hello all.
I want to paint a bitmp to a form using BitBlt, i have to success in
creating form and image DC.
Here is the code i am using.
HDC hdcDest,hdcSrc;
hdcDest = GetDC(this->Canvas->Handle); //<--returning NULL
if(hdcDest != NULL)
{
Graphics::TBitmap *Graphic;
Graphic = new Graphics::TBitmap;
Graphic->LoadFromFile("c:\\canvas.bmp");
hdcSrc = GetDC(Graphic->Canvas->Handle); //<--returning NULL
if(hdcSrc == NULL)
ShowMessage("Image DC Not Created");
}
else
ShowMessage("Form DC not created.");
Any help greatly appreciated
Regards
SA
 
 

Re:using BitBlt

Hi bar
bar says:
Quote
Hello all.

I want to paint a bitmp to a form using BitBlt, i have to success in
creating form and image DC.
Here is the code i am using.

Graphics::TBitmap *Graphic;
Graphic = new Graphics::TBitmap;
Graphic->LoadFromFile("c:\\canvas.bmp");
BitBlt(Canvas->Handle, 0, 0,
Graphic->Width,
Graphic->Height,
Graphic->Canvas->Handle,
0, 0, SRCCOPY);
This should copy Your image to the Form Canvas at position 0, 0
GetDC works on a window handle not on a DC handle.
Kind regards
Asger
 

Re:using BitBlt

 

{smallsort}

Re:using BitBlt

Thank you Asger
Regards
SA
 

Re:using BitBlt

"bar" < XXXX@XXXXX.COM >wrote in message
Quote
hdcDest = GetDC(this->Canvas->Handle); //<--returning NULL
GetDC() expects an HWND, not an HDC:
hdcDest = GetDC(this->Handle);
Quote
hdcSrc = GetDC(Graphic->Canvas->Handle); //<--returning NULL
Use the Canvas->Handle as-is:
hdcSrc = Graphic->Canvas->Handle;
Gambit