首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

BCB中,Undefined symbol 'ListUserName'有关问题啊

2012-02-23 
BCB中,Undefined symbol ListUserName问题啊!/---------------------------------------#include vcl.h

BCB中,Undefined symbol 'ListUserName'问题啊!
/---------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
  : TForm(Owner)
{
  ServerSocket1->Port=50; // 监听端口
  ServerSocket1->Active=true; //初始化为打开
  m_iClientNum=0; // 默认连接数为0
  m_sIsName="NA";
  m_sIsChat="CT";
  m_sPart="#";
  m_sIsCommand="CO";
  m_sTo="ALL";
}
//---------------------------------------

void __fastcall TMainForm::ServerSocket1Accept(TObject *Sender,
  TCustomWinSocket *Socket)
{ //当客户端连接时,在状态栏显示连接数
  AnsiString sClientNum;
  m_iClientNum++;
  sClientNum.sprintf("有%d台客户连接",ServerSocket1->Socket->ActiveConnections);
  StatusBar1->Panels->Items[1]->Text="连接成功!"; //发送一个信息给客户机

  StatusBar1->Panels->Items[0]->Text=sClientNum; // 在Panel的第一个框输出连接的客户机
  ListUserAddr->Items->Add(Socket->RemoteAddress); //把客户机的IP在ListUserAddr中输出
}
//---------------------------------------

void __fastcall TMainForm::ServerSocket1ClientRead(TObject *Sender,
  TCustomWinSocket *Socket)
{
  AnsiString sTemp;
  AnsiString sPre;
  AnsiString sWelcome;
  sTemp=Socket->ReceiveText();
  sPre=sTemp.SubString(1,2);
  if(sPre==m_sIsName)
  {
  AnsiString sName;
  sName=sTemp.SubString(3,sTemp.Length()-2);
  ListUserName->Items->Add(sName);
  for(int i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
  {
  for(int j=0;j<ListUserName->Items->Count;j++)
  {
  AnsiString sName;
  sName=ListUserName->Items->Strings[j];
  ServerSocket1->Socket->Connections[i]->SendText(sName);
  Sleep(10);
  }
  sWelcome=m_sIsChat+m_sPart;
  sWelcome+=AnsiString("大家欢迎(")+sName+AnsiString(") :) 的光临!( 服务器说:)");
  ServerSocket1->Socket->Connections[i]->SendText(sWelcome);
  }

  }
  if(sPre==m_sIsChat)
  {
  AnsiString sTo,sChat;
  int iPos;
  iPos=sTemp.Pos(m_sPart);
  sTo=sTemp.SubString(3,iPos-3);
  sChat=m_sIsChat+sTemp.SubString(iPos,sTemp.Length()-iPos+1);
  if(sTo==AnsiString("ALL") )
  for(int i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
  ServerSocket1->Socket->Connections[i]->SendText(sChat);
  if(sTo!=AnsiString("ALL") )
  {
  int iIndex=ListUserName->Items->IndexOf(sTo);
  ServerSocket1->Socket->Connections[iIndex]->SendText(sChat);
  }
  }
}
//---------------------------------------

void __fastcall TMainForm::ServerSocket1ClientDisconnect(TObject *Sender,
  TCustomWinSocket *Socket)


{
  AnsiString sTemp;
  sTemp.sprintf("%s断开连接!",Socket->RemoteAddress);
  StatusBar1->Panels->Items[1]->Text=sTemp;
  int iIndex;
  iIndex=ListUserAddr->Items->IndexOf(Socket->RemoteAddress);
  ListUserAddr->Items->Delete(iIndex);
  ListUserName->Items->Delete(iIndex);  
}
//---------------------------------------

void __fastcall TMainForm::ServerSocket1ClientError(TObject *Sender,
  TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{
  ErrorCode=0;
}
//---------------------------------------

void __fastcall TMainForm::LisUserNameClick(TObject *Sender)
{
  m_sTo=ListUserName->Items->Strings[ListUserName->ItemIndex];
  Label4->Caption=AnsiString("向")+m_sTo+AnsiString("发信息!");
}
//---------------------------------------

void __fastcall TMainForm::EdtSendKeyDown(TObject *Sender, WORD &Key,
  TShiftState Shift)
{
  if(Key==VK_RETURN)
  {
  AnsiString sTemp;
  sTemp=m_sIsChat+m_sPart+EdtSend->Text+AnsiString("(服务器说:)");
  if(m_sTo==AnsiString("ALL") )
  for(int i=0;i<ServerSocket1->Socket->ActiveConnections;i++)
  ServerSocket1->Socket->Connections[i]->SendText(sTemp);
  if(m_sTo!=AnsiString("ALL") )
  {
  int iIndex=ListUserName->Items->IndexOf(m_sTo);
  ServerSocket1->Socket->Connections[iIndex]->SendText(sTemp);
  }
  EdtSend->Clear();

  }
}
//---------------------------------------
我写到这里就不能编译了,老是抛出Undefined symbol‘ListUserName’这个错误!
我是BCB新手!请问下,出现这种错误,我该怎么去查!
谢谢!

[解决办法]
不是告诉你了不识别标示ListUserName吗?看看定义了没有?如果定义了作用域有没有问题?

热点排行