A screenshot of the screen to grasp the simple version of code

Source: Internet
Author: User
Tags socket

//---------------------------------------------------------------------------


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);


   }


}


//---------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.