//---------------------------------------------------------------------------
bool __fastcall tmainform::getscreen (GRAPHICS::TBITMAP * mybmp, bool drawcur)
{
int Curx,cury;
HDC DC;
Tcanvas * Mycan;
Trect R;
Tpoint Drawpos;
Ticon * mycursor;
HWND HLD;
DWORD ThreadID;
Tpoint MP;
Ticoninfo *piconinfo;
//Mybmp=new graphics::tbitmap ();
mycan=new Tcanvas ();
DC=GETWINDOWDC (0);
Try
{
mycan->handle=dc;
R=rect (0,0,screen->width,screen->height);
mybmp->width=r.right;
mybmp->height=r.bottom;
Mybmp->canvas->copyrect (R,MYCAN,R);
}
catch (...)
{
ReleaseDC (0,DC);
return false;
}
ReleaseDC (0,DC);
mycan->handle=0;
Delete Mycan;
return true;
}
void __fastcall Tmainform::startbtnclick (tobject *sender)
{
if (!connected)
{
ssocket->port=portedit->text.tointdef (8887);
ssocket->active=true;
connected=true;
startbtn->caption= "Stop";
}
Else
{
ssocket->active=false;
Connected=false;
startbtn->caption= "Start";
}
}
//---------------------------------------------------------------------------
void __fastcall Tmainform::exitbtnclick (tobject *sender)
{
if (connect)
ssocket->active=false;
Close ();
}
//---------------------------------------------------------------------------
void __fastcall tmainform::ssocketclientread (tobject *sender,
tcustomwinsocket *socket)
{
ansistring s,s1;
Graphics::tbitmap * mybmp;
//Tjpegimage *JP = new Tjpegimage ();
tjpegimage * myjpg;
S=socket->receivetext ();
if (s== "cap")
{
try{
mystream=new Tmemorystream ();
mybmp=new Graphics::tbitmap ();
myjpg=new tjpegimage ();
Getscreen (Mybmp,false);
myjpg->assign (mybmp);
Myjpg->compressionquality=qualityedit->text.tointdef (10);
Myjpg->savetostream (MyStream);
myjpg->savetofile ("c:\\123.jpg");
}
__finally
{
Delete myjpg;
Delete mybmp;
}
mystream->position=0;
s1=inttostr (mystream->size);
Socket->sendtext (S1);
}
if (s== "ready")
{
mystream->position=0;
Socket->sendstream (MyStream);
}
}
//---------------------------------------------------------------------------