//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void ScreenCapture ( void )
{
RECT r ; // 声明一个块
GetWindowRect ( GetDesktopWindow () , & r ); // 获取桌面窗口将其放到 r 中 ( R 是一个块)
TCanvas * tCanvas = new TCanvas ; // 定义一个新的 canvas
tCanvas -> Handle = GetDC ( NULL ); // GetDC 函数返回的是当前窗口客户区的描述表。
Form1 -> img_paint -> Canvas -> CopyRect // 开始复制
(
Rect ( 0,0,Form1 -> img_paint ->Width, Form1 -> img_paint->Height ) , // 复制到图象控件 img1 的指定区域
tCanvas,
Rect (
Form1->Left + Form1->img_paint->Left,
Form1->Top + Form1->img_paint->Top,
Form1->Left + Form1->img_paint->Left + Form1->img_paint ->Width,
Form1->Top + Form1->img_paint->Top + Form1->img_paint->Height
)
);
//delete tCanvas ;
}
int last_left=-1;
int last_top=-1;
//---------------------------------------------------------------------------
void __fastcall TForm1::tmr1Timer(TObject *Sender)
{
static int count=0;
if(last_left!=Left || last_top!=Top)
{
count=1;
}
if(count)
{
count--;
ScreenCapture();
last_left=Left;
last_top=Top;
}
else
{
static int count2=0;
if(!((count2++)%5))
{
ScreenCapture();
}
}
/*
for(int y=0;y<128;y++)
{
for(int x=0;x<256;x++)
{
//这种方式是比较慢的,主要慢在从图片控件取点与画点上
unsigned long color1=img_paint->Canvas->Pixels[x][y];
unsigned long r1=(color1>>16)&0xff;
unsigned long g1=(color1>> 8)&0xff;
unsigned long b1=(color1>> 0)&0xff;
unsigned long color2=img_ss->Canvas->Pixels[x][y];
unsigned long r2=(color2>>16)&0xff;
unsigned long g2=(color2>> 8)&0xff;
unsigned long b2=(color2>> 0)&0xff;
unsigned long per=20;
if(y>=64)
{
per=80;
}
unsigned long r3=( r1*per + r2*(100-per) )/100;
unsigned long g3=( g1*per + g2*(100-per) )/100;
unsigned long b3=( b1*per + b2*(100-per) )/100;
unsigned long color3=(r3<<16)|(g3<<8)|(b3<<0);
img_rs->Canvas->Pixels[x][y]=TColor(color3);
}
}
*/
img_2->Left+=2;
if(img_2->Left>Width+img_2->Width)
{
img_2->Left=0-img_2->Width;
}
img_1->Left-=1;
if(img_1->Left<(0-img_1->Width))
{
img_1->Left=Width+img_1->Width;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::lbl_1Click(TObject *Sender)
{
this->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::img_paintMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
int X, int Y)
{
ReleaseCapture ();
SendMessage ( Handle,WM_SYSCOMMAND,SC_MOVE | HTCAPTION,0 );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
last_left=-1;
last_top=-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
/*
HWND hDesktop;
hDesktop=FindWindow("Progman",NULL);
if(hDesktop)
this->ParentWindow=hDesktop;
this->BringToFront();
BringWindowToTop(this->Handle);
*/
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
last_left=-1;
last_top=-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
last_left=-1;
last_top=-1;
}
//---------------------------------------------------------------------------
- 1
- 2
- 3
- 4
- 5
前往页