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

📄 unit2.cpp

📁 又一个利用网上寻呼提供商的web页面来发送网上寻呼的程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#include "Unit1.h"
#include "GSocket.h"
extern in_addr LocalAddr();
extern u_long ServerToIp(char*); 
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm2::cbCFaceDrawItem(TWinControl *Control, int Index,
      TRect &Rect, TOwnerDrawState State)
{
cbCFace->Canvas->FillRect(Rect);
ForLover->ImageList1->Draw(cbCFace->Canvas,Rect.Left+3,Rect.Top,Index,true);

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


void __fastcall TForm2::FormCreate(TObject *Sender)
{
//
cbCServer->Items->Assign(ForLover->acbSName->Items);
for(int j=0;j<64;j++)
	cbCFace->Items->Add(j);
cbCFace->ItemIndex =ForLover->fi.CFace;
edCPort->Text=AnsiString(ForLover->fi.CPort);
edCPassword->Text =AnsiString(ForLover->fi.CPassword);
edCName->Text =AnsiString(ForLover->fi.CName);
edCServerAdd->Text =AnsiString(ForLover->fi.CServer);
}
//---------------------------------------------------------------------------

void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
//
strcpy(ForLover->fi.CPort,edCPort->Text.c_str());
strcpy(ForLover->fi.CPassword,edCPassword->Text.c_str());
strcpy(ForLover->fi.CName,edCName->Text.c_str());
strcpy(ForLover->fi.CServer,edCServerAdd->Text.c_str());
ForLover->fi.CFace =cbCFace->ItemIndex;
}
//---------------------------------------------------------------------------

void __fastcall TForm2::cbCServerClick(TObject *Sender)
{
//
AnsiString asTemp=cbCServer->Text.Trim();
if(asTemp.Length()==0)return;
if(asTemp==AnsiString("本地主机"))
{
 edCServerAdd->Text=inet_ntoa(LocalAddr());
 edCPort->Text =ForLover->edSPort->Text;
 edCPassword->Text =ForLover->edSPassword->Text;
}
else
{
ForLover->acbSName->ItemIndex=cbCServer->ItemIndex;
ForLover->acbSNameClick(NULL);
edCServerAdd->Text=ForLover->aedSAddress->Text;
edCPassword->Text =ForLover->aedSPassword->Text ;
edCPort->Text=ForLover->aedSPort->Text;
}
}
//---------------------------------------------------------------------------

void __fastcall TForm2::BitBtn1Click(TObject *Sender)
{
//
edCServerAdd->Text=edCServerAdd->Text.Trim();
if(edCServerAdd->Text.Length()==0)
	{
	ShowMessage("请指定主机地址!");
	this->ModalResult=(TModalResult)mrCancel;
	return;
	}
int rport=ForLover->CheckPort(edCPort);
if(rport==-1){ShowMessage("端口号必须是1-65535之间的数字");return;}
u_long rip=ServerToIp(edCServerAdd->Text.c_str());
if(rip==INADDR_NONE){ShowMessage("无效的主机地址!");return;}
wsprintf(ForLover->GClient1->pi.StrOk,"Bcbhua http://%s:%d/ HTTP1.1",edCServerAdd->Text.c_str(),rport);
ForLover->GClient1->Port=(u_short)rport;
if(ForLover->cbProxy->Checked)
{
rip=ServerToIp(ForLover->edProxyAdd->Text.c_str());
if(rip==INADDR_NONE){ShowMessage("无效的代理服务器地址!");return;}
wsprintf(ForLover->GClient1->pi.StrOk,"Bcbhua http://%s:%d/ HTTP1.1",edCServerAdd->Text.c_str(),rport);
int i=ForLover->CheckPort(ForLover->edProxyPort);
if(i==-1){MessageBox(NULL,"代理端口号必须是1-65535之间的数字!","提醒",MB_OK|MB_ICONINFORMATION);return;}
else
ForLover->GClient1->Port =(u_short)i;
//
}
edCName->Text =edCName->Text.Trim();
if(edCName->Text.Length()>14)edCName->Text =edCName->Text.SubString(1,14);
else if(edCName->Text.Length()==0)edCName->Text="幼稚";
edCPassword->Text =edCPassword->Text.Trim();
if(edCPassword->Text.Length()>14)edCPassword->Text =edCPassword->Text.SubString(1,14);
else if(edCPassword->Text.Length()==0)edCPassword->Text="NetTime";
strcpy(ForLover->GClient1->pi.Name,edCName->Text.c_str());
strcpy(ForLover->GClient1->pi.Password,edCPassword->Text.c_str());
ForLover->GClient1->ip=rip;
ForLover->GClient1->pi.Face =cbCFace->ItemIndex;
}
//---------------------------------------------------------------------------



⌨️ 快捷键说明

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