Thread View: borland.public.cppbuilder.internet.socket
4 messages
4 total messages
Started by sez
Sun, 18 Jun 2006 10:34
CreateMDIChild When Indy Client Connects
Author: sez
Date: Sun, 18 Jun 2006 10:34
Date: Sun, 18 Jun 2006 10:34
11 lines
1154 bytes
1154 bytes
Hello,
How to create a new mdi child window on the server, when a client connects?
This code stopped the connection and didn't create a window.
void __fastcall TMainForm::IdTCPServer1Connect(TIdPeerThread *AThread)
{
CreateMDIChild("New Window");
}
Regards,
Sezgin
Re: CreateMDIChild When Indy Client Connects
Author: sez
Date: Sun, 18 Jun 2006 21:35
Date: Sun, 18 Jun 2006 21:35
2 lines
1051 bytes
1051 bytes
I think I must use "Synchronize" in order to get around this problem. I'm currently searching google groups but it seems no example.
Re: CreateMDIChild When Indy Client Connects
Author: sez
Date: Sun, 18 Jun 2006 21:53
Date: Sun, 18 Jun 2006 21:53
13 lines
1255 bytes
1255 bytes
I found the solution:
void __fastcall TMainForm::Test(void)
{
CreateMDIChild("New Window");
}
void __fastcall TMainForm::IdTCPServer1Connect(TIdPeerThread *AThread)
{
AThread->Synchronize(Test);
}
Re: CreateMDIChild When Indy Client Connects
Author: 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
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