Discussion:
VCL Form inside TThread->Execute
(too old to reply)
James L. Williams
2008-06-14 08:56:46 UTC
Permalink
Hello,

I would like to create a form that exists inside a Thread. I want this so
that the forms graphics updates are handled inside of a thread.

I do something like the following:

Thread::Execute()
{
MSG msg;
TmyForm * myForm = new TmyForm(NULL);
myForm->Parent = NULL;
myForm->ParentWindow = GetDesktopWindow();
myForm->Left = 10;
myForm->Top = 10;
myForm->Width = 500;
myForm->Height = 500;
myForm->Visible = true;
while(GetMessage(msg,NULL,0,0))
{

if(Terminated) break;
TranslateMessage(&msg);
DispatchMessage(&msg);

}

delete myForm;
}

Is this a good way to do it, or is there a better way?

Thanks,


James
James
2008-06-14 18:27:43 UTC
Permalink
Also, the application that uses this thread form in not a C++
Builder application. In fact, it does not have its own support for
multi-thread, however it does allow dll calls. However, multiple threads
containing this form could me executed at the same time.

Hence, I decided to wrap up a form object into a thread and place that into
a dll. Then they can create an instance and the form runs. The reason I
need this is because in their main application they may be executing a
lengthy database query. I wanted to provide a progress bar that shows that
the application has not hung, but is retrieving data. They also want to use
this when they download files, to indicate things are going well.

Thanks,


James
Post by James L. Williams
Hello,
I would like to create a form that exists inside a Thread. I want this so
that the forms graphics updates are handled inside of a thread.
Thread::Execute()
{
MSG msg;
TmyForm * myForm = new TmyForm(NULL);
myForm->Parent = NULL;
myForm->ParentWindow = GetDesktopWindow();
myForm->Left = 10;
myForm->Top = 10;
myForm->Width = 500;
myForm->Height = 500;
myForm->Visible = true;
while(GetMessage(msg,NULL,0,0))
{
if(Terminated) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
delete myForm;
}
Is this a good way to do it, or is there a better way?
Thanks,
James
Loading...