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

📄 unit1.cpp

📁 网络极速寻呼源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
*/




void __fastcall TForLover::sbSEndClick(TObject *Sender)
{
GServer1->DisConnect();
ServerEnable(false);

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

void __fastcall TForLover::sbSystemClick(TObject *Sender)
{
GServer1->ListInfo();
}
//---------------------------------------------------------------------------

void __fastcall TForLover::cbServerImidiateClick(TObject *Sender)
{
if(cbServerImidiate->Checked)
GServer1->Imidiate =true;
else
GServer1->Imidiate =false;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::sbSSaveClick(TObject *Sender)
{
sdSave->FileName ="服务.rtf";
if(GServer1->Text.Length()>0&&sdSave->Execute())
{
try
{
GServer1->Lines->SaveToFile(sdSave->FileName);
GServer1->Clear();
}
catch(...){GServer1->Lines->Add("无法保存文件!");}
}
}
//---------------------------------------------------------------------------



void __fastcall TForLover::GServer1Connecting(TObject *Sender)
{
if(cbServerConnect->Checked&&addwave)sndPlaySound((LPCSTR)addwave,SND_ASYNC|SND_MEMORY);
}
//---------------------------------------------------------------------------

void __fastcall TForLover::GServer1Leave(TObject *Sender)
{
if(cbServerLeave->Checked&&delwave)sndPlaySound((LPCSTR)delwave,SND_ASYNC|SND_MEMORY);
}
//---------------------------------------------------------------------------

void __fastcall TForLover::sbCCancelClick(TObject *Sender)
{
GClient1->Close();
sbCCancel->Enabled=false;
sbCConnect->Enabled =true;
GClient1->Lines->Add("连接操作被取消!");
Timer3->Enabled =false;
TBConnect->ImageIndex =65;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::GClient1Closed(TObject *Sender)
{
sbCConnect->Enabled =true;
GClient1->Lines->Add("连接已经被关闭!");
edCText->Enabled =false;
btCSend->Enabled =false;
sbCDisConnect->Enabled=false;
Timer3->Enabled =false;
TBConnect->ImageIndex =65;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::GClient1Connected(TObject *Sender)
{
sbCCancel->Enabled=false;
sbCDisConnect->Enabled =true;
edCText->Enabled =true;
btCSend->Enabled =true;
Timer3->Enabled =false;
TBConnect->ImageIndex =64;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::GClient1ConnectFailed(TObject *Sender)
{
sbCConnect->Enabled =true;
sbCCancel->Enabled =false;
Timer3->Enabled=false;
TBConnect->ImageIndex =65;
}
//---------------------------------------------------------------------------
void __fastcall TForLover::lbColorClick(TObject *Sender)
{
if(cdColor->Execute())
	{
		GClient1->SendColor =cdColor->Color;
		edCText->Font->Color =cdColor->Color;
		lbColor->Color =cdColor->Color;
	}

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

void __fastcall TForLover::GServer1DisConnect(TObject *Sender)
{
ServerEnable(false);
sbCloseDoor->Down =false;
}
//---------------------------------------------------------------------------



void __fastcall TForLover::ListBox1DrawItem(TWinControl *Control,
      int Index, TRect &Rect, TOwnerDrawState State)
{
/*
try
{
AnsiString asTemp=ListBox1->Items->Strings[Index];
int tid=asTemp.ToInt();
int tindex=GClient1->indexByID(tid);
if(tindex==-1)throw;
ListBox1->Canvas->FillRect(Rect);
ImageList1->Draw(ListBox1->Canvas,Rect.Left+1,Rect.Top +1,GClient1->gcu[tindex].ai.Face,true);
ListBox1->Canvas->TextOutA(Rect.Left+1,Rect.Top+34,asTemp);
ListBox1->Canvas->TextOutA(Rect.Left+1,Rect.Top+35+abs(ListBox1->Canvas->Font->Height),GClient1->gcu[tindex].ai.Name);
}
catch(...){}*/
}
//---------------------------------------------------------------------------
void __fastcall TForLover::Mini(TObject*Sender)
{
	//TODO: Add your source code here
Application->Minimize();
ShowWindow(Application->Handle,SW_HIDE);
IsMini=true;
}

void __fastcall TForLover::SpeedButton12Click(TObject *Sender)
{
//	
}
//---------------------------------------------------------------------------


/*函数名:CheckPort;
函数功能:检验文本框的内容是否为数字
参数:[in]TEdit*
返回值:为数字则返回该数字,不是数字则返回-1
*/
int TForLover::CheckPort(TEdit*ted)
{
try
{
ted->Text=ted->Text.Trim();
int iport=ted->Text.Length();
if(iport==0||iport>5)return -1;
iport=ted->Text.ToInt();
if(iport>65535||iport<=0)return -1;
return iport;
}
catch(...){}
return -1;
}


void __fastcall TForLover::SpeedButton8Click(TObject *Sender)
{
sdSave->FileName ="聊天记录.rtf";
if(GClient1->Text.Length()>0&&sdSave->Execute())
{
try
{
GClient1->Lines->SaveToFile(sdSave->FileName);
GClient1->Clear();
}
catch(...){GClient1->Lines->Add("无法保存文件!");}
}
}
//---------------------------------------------------------------------------


void __fastcall TForLover::LoverPaint(TObject *Sender)
{
//
/*AnsiString LoverWord=" 我是真的爱你 ";
int ix,iy,tx,ty,wx,wy;
wx=Lover->Canvas->TextWidth(LoverWord)+2;
wy=Lover->Canvas->TextHeight(LoverWord)+2;
tx=Lover->Width/wx;
ty=Lover->Height/wy;
ix=(Lover->Width-wx*tx)/2;
iy=(Lover->Height-wy*ty)/2;
for(int i=0;i<ty;i++)
{
 for(int j=0;j<tx;j++)
	Lover->Canvas->TextOutA(j*wx+ix+1,i*wy+iy+1,LoverWord);
} */
}
//---------------------------------------------------------------------------


void __fastcall TForLover::FormCloseQuery(TObject *Sender, bool &CanClose)
{
if(GServer1->beListen)
	{
	if(MessageBox(Handle,"服务端处于监听状态,确实要退出程序吗?","提醒",MB_YESNO|MB_ICONQUESTION)==ID_NO)
		{
		CanClose=false;
		return;
		}
	else
		GServer1->DisConnect();
	}
if(GClient1->Connected)
	{
	if(MessageBox(Handle,"客户端处于连接状态,确实要退出程序吗?","提醒",MB_YESNO|MB_ICONQUESTION)==ID_NO)
		CanClose=false;
	else
		GClient1->Close();
	}
if(IsScan)
{
 if(MessageBox(Handle,"正在进行端口扫描,确实要结束程序吗?","提醒",MB_YESNO|MB_ICONQUESTION)==ID_NO)
	CanClose=false;
 else
 	sbEndScanClick(NULL);
}
}
//---------------------------------------------------------------------------

void __fastcall TForLover::Panel3Resize(TObject *Sender)
{
int hei=Panel3->Height;
edCText->Left =24;
edCText->Top=(hei-edCText->Height)/2;
btCSend->Left =Panel3->Width -btCSend->Width-7;
btCSend->Top=(hei-btCSend->Height)/2;
edCText->Width =btCSend->Left-edCText->Left-7;
lbColor->Top=(hei-lbColor->Height)/2;
}
//---------------------------------------------------------------------------
void __fastcall TForLover::FormCreate(TObject *Sender)
{
char *temp=NULL;
char szTipText[56],
	  szCaptionText[256];
szTipText[0]=0;
szCaptionText[0]=0;
slServerAll->Clear();
HINSTANCE hInst=LoadLibrary("NetPlug.dll");
try
{
	temp=LoadWave("slist","TXT",hInst);
	if(temp==NULL){ShowMessage("初始化服务器列表失败!网上寻呼将无法使用!");}
	else
	{
	 cbServer->Items->Text=AnsiString(temp);
	}
	temp=LoadWave("server","TXT",hInst);
	if(temp==NULL){ShowMessage("装载服务器列表失败!网上寻呼将无法使用!");}
	else
	{
		slServerAll->Text =AnsiString(temp);
	int icount=slServerAll->Count;
	for(int i=0;i<icount;i++)
		slServerAll->Strings[i]=slServerAll->Strings[i].Trim();
	delete[]temp;
	temp=NULL;
	}
	temp=LoadWave("call","TXT",hInst);
	if(temp)
	{
	Memo2->Text =AnsiString(temp);
	delete[]temp;
	temp=NULL;
	}
	temp=LoadWave("server1","TXT",hInst);
	if(temp)
	{
	 GServer1->Text =AnsiString(temp);
	 delete[]temp;
	temp=NULL;
	}
	temp=LoadWave("client1","TXT",hInst);
	if(temp)
	{
	 GClient1->Text =AnsiString(temp);
	 delete[]temp;
	temp=NULL;
	}
	temp=LoadWave("scan","TXT",hInst);
	if(temp)
	{
	 Memo1->Text =AnsiString(temp);
	 delete[]temp;
	temp=NULL;
	}
	addwave=LoadWave("add","WAVE",hInst);
	delwave=LoadWave("del","WAVE",hInst);
	saywave=LoadWave("say","WAVE",hInst);
	if(hInst)
		{
		LoadString(hInst,101,szTipText,55);
		LoadString(hInst,100,szCaptionText,255);
		if(strlen(szCaptionText))Caption=AnsiString(szCaptionText);
		}
}
catch(...){if(temp)delete[]temp;}
if(hInst)FreeLibrary(hInst);
hicon[0]=LoadIcon(HInstance,"ji");
hicon[1]=LoadIcon(HInstance,"su");
hicon[2]=LoadIcon(HInstance,"xun");
hicon[3]=LoadIcon(HInstance,"zu");
Icon->Handle =hicon[3];
curIcon=0;
ZeroMemory(&notify,sizeof(notify));
notify.cbSize =sizeof(notify);
notify.hWnd =Handle;
notify.uID =1;
notify.uFlags =NIF_ICON|NIF_MESSAGE|NIF_TIP;
notify.uCallbackMessage =WM_LOVERICON;
if(strlen(szTipText))strncpy(notify.szTip,szTipText,56);
else
	strcpy(notify.szTip ,"网络时代v1.0正式版");
if(AddIcon())Timer2->Enabled =true;
acbServer->Items->Clear();
acbServer->Items->Assign(cbServer->Items);
cbServer->ItemIndex=0;
acbServer->ItemIndex=0;
cbServerClick(NULL);
/*int theight=ListBox1->Canvas->TextHeight("幼稚")*2+36;
ListBox1->ItemHeight=(theight>68)?theight:68;*/
ComboBox1->ItemIndex=2;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::ComboBox1Click(TObject *Sender)
{
DWORD process;
switch(ComboBox1->ItemIndex)
{
case 0:
process=REALTIME_PRIORITY_CLASS;break;
case 1:
process=HIGH_PRIORITY_CLASS;break;
case 2:
process=NORMAL_PRIORITY_CLASS;break;
case 3:
process=IDLE_PRIORITY_CLASS;break;
}
SetPriorityClass(GetCurrentProcess,process);
}
//---------------------------------------------------------------------------

void __fastcall TForLover::Panel6Resize(TObject *Sender)
{
//
mmWord->Width=Panel6->Width-18;
mmWord->Left =9;
Label5->Left=(Panel6->Width-Label5->Width)/2;
bbtCall->Left=(Panel6->Width-bbtCall->Left)/2;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::PaintBox1Paint(TObject *Sender)
{
/*AnsiString LoverWord=" Powered By C++Builder ";
int ix,iy,tx,ty,wx,wy;
wx=PaintBox1->Canvas->TextWidth(LoverWord)+2;
wy=PaintBox1->Canvas->TextHeight(LoverWord)+2;
tx=PaintBox1->Width/wx;
ty=PaintBox1->Height/wy;
ix=(PaintBox1->Width-wx*tx)/2;
iy=(PaintBox1->Height-wy*ty)/2;
for(int i=0;i<ty;i++)
{
 for(int j=0;j<tx;j++)
	PaintBox1->Canvas->TextOutA(j*wx+ix+1,i*wy+iy+1,LoverWord);
} */
}
//---------------------------------------------------------------------------

void __fastcall TForLover::GClient1Say(TObject *Sender)
{
if(saywave&&cbClientSay->Checked)sndPlaySound((LPCSTR)saywave,SND_ASYNC|SND_MEMORY);
}
//---------------------------------------------------------------------------

void __fastcall TForLover::ListView1Change(TObject *Sender,
      TListItem *Item, TItemChange Change)
{
try
{
kickId=Item->Caption.ToInt();
}
catch(...){kickId=0;}	
}
//---------------------------------------------------------------------------

void __fastcall TForLover::sbKickClick(TObject *Sender)
{
if(MessageBox(NULL,"真的要将其请出聊天室吗?","询问",MB_YESNO|MB_ICONQUESTION)==ID_YES)GServer1->Kick(kickId);
}
//---------------------------------------------------------------------------

void __fastcall TForLover::SpeedButton6Click(TObject *Sender)
{
GClient1->SelAttributes->Charset =GB2312_CHARSET;
GClient1->DefAttributes->Charset =GB2312_CHARSET;
}
//---------------------------------------------------------------------------



void __fastcall TForLover::rbSelectPortClick(TObject *Sender)
{
bool isChecked=rbSelectPort->Checked;
edFrom->Enabled =isChecked;
edTo->Enabled =isChecked;
lbTo->Enabled =isChecked;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::rbAllPortClick(TObject *Sender)
{
bool isChecked=!rbAllPort->Checked;
edFrom->Enabled =isChecked;
edTo->Enabled =isChecked;
lbTo->Enabled =isChecked;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::rbLocalClick(TObject *Sender)
{
edRemote->Enabled =!rbLocal->Checked;
}
//---------------------------------------------------------------------------

void __fastcall TForLover::rbRemoteClick(TObject *Sender)
{
edRemote->Enabled =rbRemote->Checked;
}
//---------------------------------------------------------------------------
/*函数名称:AddrReady;
函数功能:当目标主机地址解析完成后调用;
*/
void __fastcall TForLover::sbStartScanClick(TObject *Sender)
{
//
in_addr inaddr;
if(rbAllPort->Checked)
	{
		NowScanPort=1;
		TotalScanPort=65535;
	}
else
	{
		NowScanPort=CheckPort(edFrom);
		if(NowScanPort==-1){stbScan->Panels->Items[0]->Text ="端口号最小为1,最大为65535!";return;}
		TotalScanPort=CheckPort(edTo);
		if(TotalScanPort==-1){stbScan->Panels->Items[0]->Text ="端口号最小为1,最大为65535!";return;}
	}
try
{
if(rbLocal->Checked)
	RemoteAddr=LocalIp();

⌨️ 快捷键说明

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