🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: indy 9 tcpclient and tcpserver

#100
From: Remy Lebeau (TeamB)
Date: Mon, 12 May 2008 16:56
87 lines
3084 bytes
"Bashar T" <bashar-t@scs-net.org> wrote in message 
news:48284026$1@newsgroups.borland.com...

> How can I show my string in a lable by using TCPServer?

    class TLabelSync : public TIdSync
    {
    private:
        TLabel *FLabel;
        AnsiString FText;

    protected
        void __fastcall DoSynchronize()
        {
            FLabel->Caption = FText;
        }

    public:
        TLabelSync(TLabel *ALabel, const AnsiString &AText)
            : TIdSync(), FLabel(ALabel), FText(AText)
        {
        }

        static void __fastcall Update(TLabel *ALabel, const AnsiString 
&AText)
        {
            TLabelSync *sync = new TLabelSync(ALabel, AText);
            try {
                sync->Synchronize();
            }
            __finally {
                delete sync;
            }
        }
    };

    void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
    {
        AnsiString Line = AThread->Connection->ReadLn();
        TLabelSync::Update(Label1, Line);
    }


Alternatively:

    class TLabelNotify : public TIdNotify
    {
    private:
        TLabel *FLabel;
        AnsiString FText;

    protected
        void __fastcall DoNotify()
        {
            FLabel->Caption = FText;
        }

    public:
        TLabelNotify(TLabel *ALabel, const AnsiString &AText)
            : TIdNotify(), FLabel(ALabel), FText(AText)
        {
        }

        static void __fastcall Update(TLabel *ALabel, const AnsiString 
&AText)
        {
            TLabelNotify *notif = new TLabelNotify(ALabel, AText);
            try {
                sync->Notify();
            }
            catch(const Exception &)
            {
                delete notif;
                throw;
            }
        }
    };

    void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
    {
        AnsiString Line = AThread->Connection->ReadLn();
        TLabelNotify::Update(Label1, Line);
    }


Gambit 
Technical Details
Message-ID: <482876d6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <48284026$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c9305a4a3715af08
X-Google-Attributes: gid11508e,domainid0,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: <48284026$1@newsgroups.borland.com>
Subject: Re: indy 9 tcpclient and tcpserver
Date: Mon, 12 May 2008 09:56:17 -0700
Lines: 89
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 207.178.157.90
Message-ID: <482876d6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1210611414 207.178.157.90 (12 May 2008 09:56:54 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail