🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #714

Re: How can I transfer the content of a list

#714
From: Remy Lebeau (TeamB)
Date: Sun, 18 Nov 2007 20:24
65 lines
2566 bytes
"Bashar Termanini" <bashar-t@scs-net.org> wrote in message
news:473e9511@newsgroups.borland.com...

> Please show me a simple code how to send a TStringList
> from TIdTCPServer to the client.

    class TGetListBoxItemsSync : public TIdSync
    {
    protected:
        TListBox *fListBox;
        TStrings *fItems;
        virtual void __fastcall DoSynchronize();

    public:
        __fastcall TGetListBoxItemsSync(TListBox *ListBox, TStrings *Items);
        static void __fastcall GetItems(TListBox *ListBox, TStrings *Items);
    };

    __fastcall TGetListBoxItemsSync::TGetListBoxItemsSync(TListBox *ListBox,
TStrings *Items)
        : TIdSync()
    {
        fListBox = ListBox;
        fItems = Items;
    }

    void __fastcall TGetListBoxItemsSync::DoSynchronize()
    {
        fItems->Assign(fListBox->Items);
    }

    void __fastcall TGetListBoxItemsSync::GetItems(TListBox *ListBox,
TStrings *Items)
    {
        TGetListBoxItemsSync *Sync = new TGetListBoxItemsSync(ListBox,
Items);
        try
        {
            Sync->Synchronize();
        }
        __finally
        {
            delete Sync;
        }
    }

    void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
    {
        //...
        TStringList *Items = new TStringList;
        try
        {
            TGetListBoxItemsSync::GetItems(ListBox1, Items);
            AContext->Connection->IOHandler->Write(Items, true);
        }
        __finally
        {
            delete Items;
        }
        //...
    }


Gambit
Technical Details
Message-ID: <4740a31b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <473b5fb5@newsgroups.borland.com> <473b7069$1@newsgroups.borland.com> <473cbd6a@newsgroups.borland.com> <473e9511@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3d483e6389458d8d
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <473b5fb5@newsgroups.borland.com> <473b7069$1@newsgroups.borland.com> <473cbd6a@newsgroups.borland.com> <473e9511@newsgroups.borland.com>
Subject: Re: How can I transfer the content of a list 
Date: Sun, 18 Nov 2007 12:24:18 -0800
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.29.61
Message-ID: <4740a31b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195418395 75.83.29.61 (18 Nov 2007 12:39:55 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail