|
백그라운드에서 계속해서 화면을 캡춰하는 놈인데
잘 돌다가도 마우스를 마구 움직이면 시스템시소스가 없다나요...
아무리 보아도 로직에러는 없습니다.
고수님들의 도움을 기다립니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#include <jpeg.hpp>
#pragma hdrstop
#include "cap.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
class TCaptureThread : public TThread
{
public:
void __fastcall Execute(void);
__fastcall TCaptureThread(void):TThread(true)
{};
};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TCaptureThread::Execute(void)
{
int status;
TRect rect,rect2,FullRect;
int lx,ly,sx,sy,dif;
TMemoryStream *tms=new TMemoryStream;
static int initialized =false;
Graphics::TBitmap *Bitmap;
Bitmap= new Graphics::TBitmap;
HDC dc = GetDC(0);
Graphics::TCanvas *ScreenCanvas = new Graphics::TCanvas;
ScreenCanvas->Handle=dc;
TJPEGImage *jp = new TJPEGImage();
while(1){
Bitmap->Height=Screen->Height;
Bitmap->Width=Screen->Width;
Form1->Memo1->Lines->Add("!");
rect = Rect(0,0,Screen->Width,Screen->Height);
sx=sy=0;
lx=Screen->Width;
ly=Screen->Height;
rect = Rect(0,0,lx-sx,ly-sy);
rect2 = Rect(sx,sy,lx,ly);
Bitmap->Canvas->CopyRect(rect,ScreenCanvas,rect2);
////////////////////////////////////////////
/////PART SCREEN Update
tms->Position=0;
jp->Assign(Bitmap);
jp->SaveToStream(tms);
// DataSize = tms->Position;
}//while
Form1->Memo1->Lines->Add("Cap thread end!");
delete Bitmap;
delete ScreenCanvas;
delete jp;
ReleaseDC(NULL,dc);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TCaptureThread * captureThread = new TCaptureThread;
captureThread->Priority = tpNormal; // set the priority lower than normal
captureThread->Resume(); // now run the thread
}
//---------------------------------------------------------------------------
|