Article View: borland.public.cppbuilder.internet.socket
Article #2304Re: CreateMDIChild When Indy Client Connects
From: Remy Lebeau (TeamB)
Date: Mon, 19 Jun 2006 02:14
Date: Mon, 19 Jun 2006 02:14
54 lines
2261 bytes
2261 bytes
"sez" <www@sezginserin.com> wrote in message
news:44952c31$1@newsgroups.borland.com...
> How to create a new mdi child window on the server, when a client
connects?
Since TIdTCPServer is a multi-threaded component, and the OnConnect event
(and any other event handler with a TIdPeerThread parameter) is triggered in
the context of worker threads, you must Synchronize() access with the main
thread in order to access the GUI in a safe manner.
For example:
void __fastcall TMainForm::CreateMDIChild()
{
CreateMDIChild("New Window");
}
void __fastcall TMainForm::IdTCPServer1Connect(TIdPeerThread *AThread)
{
AThread->Synchronize((TThreadMethod) &CreateMDIChild);
}
Or:
class TCreateMDISync : public TIdSync
{
public:
__fastcall TCreateMDISync(TIdBaseThread *AThread)
: TIdSync(AThread)
{
}
virtual void __fastcall DoSynchronize()
{
MainForm->CreateMDIChild("New Window");
}
};
void __fastcall TMainForm::IdTCPServer1Connect(TIdPeerThread *AThread)
{
TCreateMDISync *Sync = new TCreateMDISync(AThread);
try
{
Sync->Synchronize();
}
__finally {
delete Sync;
}
}
Gambit
Technical Details
Message-ID:
<449608b7$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44952c31$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,918ee641c4820931 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <44952c31$1@newsgroups.borland.com> Subject: Re: CreateMDIChild When Indy Client Connects Date: Sun, 18 Jun 2006 19:14:01 -0700 Lines: 56 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: 68.69.17.41 Message-ID: <449608b7$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1150683319 68.69.17.41 (18 Jun 2006 19:15:19 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail