webowner47
Programmer
Hello,
I'm using the code below to capture desktop screen, but the problem is that the screenshot is taken from the MainForm, and i want to take it from the Secondary TForm instead:
this is the dynamic TForm with TImage and TTimer:
I'm using the code below to capture desktop screen, but the problem is that the screenshot is taken from the MainForm, and i want to take it from the Secondary TForm instead:
Code:
TBitmap* __fastcall TCaptureContainer::CaptureImage()
{
HDC hdcDesk;
try
{
this->bitbmp->Width = Screen->Width;
this->bitbmp->Height = Screen->Height;
hdcDesk = GetDC(GetDesktopWindow());
if ( BitBlt(this->bitbmp->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, hdcDesk, 0, 0, SRCCOPY) ) {
this->CaptureViewer->Picture->Bitmap = this->bitbmp;
}
}
__finally
{
ReleaseDC(GetDesktopWindow(), hdcDesk);
}
return this->bitbmp;
}
this is the dynamic TForm with TImage and TTimer:
Code:
__fastcall TCaptureContainer::TCaptureContainer()
{
// Capture Container
this->CaptureContainer = new TForm(NULL, 0);
this->CaptureContainer->Parent = NULL;
this->CaptureContainer->DoubleBuffered = true;
this->CaptureContainer->BorderStyle = bsSizeable;
this->CaptureContainer->Position = poScreenCenter;
this->CaptureContainer->Width = 389;
this->CaptureContainer->Height = 226;
this->CaptureContainer->Color = clBlack;
this->CaptureContainer->OnClose = this->CaptureContainerClose;
this->CaptureContainer->Show();
// Capture Viewer
this->CaptureViewer = new TImage(this->CaptureContainer);
this->CaptureViewer->Parent = this->CaptureContainer;
this->CaptureViewer->Align = alClient;
this->CaptureViewer->Center = true;
this->CaptureViewer->Show();
// Capture Streamer
this->CaptureStreamer = new TTimer(this->CaptureContainer);
this->CaptureStreamer->Interval = 1;
this->CaptureStreamer->Enabled = true;
this->CaptureStreamer->OnTimer = this->CaptureStreamerOnTimer;
// Bitmap
this->bitbmp = new TBitmap();
}