//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int __fastcall GetListViewIndexOf(TListView *lstV,String sCaption)
{
if(lstV==NULL)return 0;
for(int idx=0;idxItems->Count;idx++)
{
if(lstV->Items->Item[i]->Caption==sCaption)return idx;
}
return 0 ;
}
//------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket)
{
//위 GetListViewIndexOf 함수를 쓰셔야죠
int idx=GetListViewIndexOf(ListView1,Socket->RemoteAddress);
if(idx>=0)
ListView1->Items->Delete(idx);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
TListItem *item = ListView1->Items->Add();
item->Caption=Socket->RemoteAddress;
}
니라카 님이 쓰신 글 :
:
:
: //---------------------------------------------------------------------------
:
: #include
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::ServerSocket1ClientDisconnect(TObject *Sender,
: TCustomWinSocket *Socket)
: {
:
: :I=ListView1->Items->IndexOf(Socket->RemoteAddress);
: : ListView1->Items->Delete(I);
:
: }
: //---------------------------------------------------------------------------
: int __fastcall GetListViewIndexOf(TListView *lstV,String sCaption)
: {
: if(lstV==NULL)return 0;
:
: for(int idx=0;idxItems->Count;idx++)
: {
: if(lstV->Items->Item[i]->Caption==sCaption)return idx;
: }
: return 0 ;
: }
:
: ///------------------------------------------------------------------------
: void __fastcall TForm1::ServerSocket1ClientConnect(TObject *Sender,
: TCustomWinSocket *Socket)
: {
:
: TListItem *item = ListView1->Items->Add();
: item->Caption=Socket->RemoteAddress;
:
:
: }
: //---------------------------------------------------------------------------
:
:
:
:
:
:
: 이렇게했는데; 흠,,,
|