Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How To Use Secondary TForm As Screenshot Capture Area?

How To Use Secondary TForm As Screenshot Capture Area?

How To Use Secondary TForm As Screenshot Capture Area?

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 --> Builder

TBitmap* __fastcall TCaptureContainer::CaptureImage()
    HDC hdcDesk;
		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;
		ReleaseDC(GetDesktopWindow(), hdcDesk);
	return this->bitbmp;

this is the dynamic TForm with TImage and TTimer:

CODE --> Builder

__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;
	// Capture Viewer
	this->CaptureViewer = new TImage(this->CaptureContainer);
	this->CaptureViewer->Parent = this->CaptureContainer;
	this->CaptureViewer->Align  = alClient;
	this->CaptureViewer->Center = true;
	// 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();

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close