|
|
Screen Capture: 1. Open Borland C++ Builder. 2. Place a Button on the form. 3. Place an Image on the form 4. Double click the button. 5. Type the following red code in the Button1Click function: //This is what the Button1Click function should look like: void __fastcall TForm1::Button1Click(TObject *Sender) { HDC dc = GetDC(0); Graphics::TCanvas *ScrCanvas = new Graphics::TCanvas; ScrCanvas->Handle = dc; Image1->Picture->Bitmap->Width = Screen->Width; Image1->Picture->Bitmap->Height= Screen->Height; TRect rt = Rect(0,0,Screen->Width, Screen->Height); Image1->Picture->Bitmap->Canvas->CopyRect(rt, ScrCanvas, rt); Form1->WindowState = wsMaximized; Image1->Align = alClient; delete ScrCanvas; ReleaseDC(NULL,dc); } //--------------------------------------------------------------------------- 6. Run the program, click the Button1. Form1 will resize and display the captered screen. You could add a timer and hide Form1 before each capture so that the desktop or top window is being captured and not Form1. |