🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
6 messages
6 total messages Started by Bashar Termanini Wed, 14 Nov 2007 20:52
How can I transfer the content of a list
#704
Author: Bashar Termanini
Date: Wed, 14 Nov 2007 20:52
2 lines
1061 bytes
How can I transfer the content of a list from TidTcpServer to idTcoClient 
(indy 10)
Re: How can I transfer the content of a list
#705
Author: Remy Lebeau (TeamB)
Date: Wed, 14 Nov 2007 21:31
11 lines
1377 bytes
"Bashar Termanini" <bashar-t@scs-net.org> wrote in message 
news:473b5fb5@newsgroups.borland.com...

> How can I transfer the content of a list from
> TidTcpServer to idTcoClient (indy 10)

What kind of list?  You need to be more specific.


Gambit 
Re: How can I transfer the content of a list
#709
Author: Bashar Termanini
Date: Thu, 15 Nov 2007 16:16
5 lines
1251 bytes
>
> What kind of list?  You need to be more specific.
I have a ListBox in the server and i want to transfer it to a ListBox in the 
client by using TidTcpServer and idTcoClient 
Re: How can I transfer the content of a list
#708
Author: Remy Lebeau (TeamB)
Date: Thu, 15 Nov 2007 21:57
21 lines
1930 bytes
"Bashar Termanini" <bashar-t@scs-net.org> wrote in message 
news:473cbd6a@newsgroups.borland.com...

> I have a ListBox in the server and i want to transfer it to a
> ListBox in the client by using TidTcpServer and idTcoClient

TIdIOHandler has methods for reading/writing TStrings objects.

Since TIdTCPServer is a threaded component, you will have to Synchronize 
with the main thread (such as with the TIdSync class) in order to safely 
access the ListBox.  Copy its contents into a TStringList and then send it 
to the client.

On the client side, if you are running TIdTCPClient in the main thread, then 
you can read the inbound data directly into the ListBox.Items property. 
Otherwise, read the data into a TStringList and then Synchronize with the 
main thread in order to update the ListBox.


Gambit 
Re: How can I transfer the content of a list
#712
Author: Bashar Termanini
Date: Sat, 17 Nov 2007 07:15
14 lines
1690 bytes
> Since TIdTCPServer is a threaded component, you will have to Synchronize 
> with the main thread (such as with the TIdSync class) in order to safely 
> access the ListBox.  Copy its contents into a TStringList and then send it 
> to the client.
>
> On the client side, if you are running TIdTCPClient in the main thread, 
> then you can read the inbound data directly into the ListBox.Items 
> property. Otherwise, read the data into a TStringList and then Synchronize 
> with the main thread in order to update the ListBox.
>
>
> Gambit
Please show me a simple code how to send a TStringList from TIdTCPServer to
the client.
Re: How can I transfer the content of a list
#714
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads