//Unit1.cpp
語法:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <clipbrd.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HDC DC;
WindowState = wsMinimized;
DC = GetDC(0);
Image1->Width=Screen->Width;
Image1->Height=Screen->Height;
BitBlt(Image1->Canvas->Handle, 0, 0, Screen->Width, Screen->Height, DC, 0, 0, SRCCOPY);
Image1->Refresh();
ReleaseDC(0, DC);
WindowState = wsNormal;
Button2->Enabled=true;
Button3->Enabled=true;}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Clipboard()->Assign(Image1->Picture->Bitmap);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (SavePictureDialog1->Execute())
Image1->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
PS:粗體部分需自行KeyIn