Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing forms from a thread

Status
Not open for further replies.

nicknw

Programmer
Dec 6, 2002
2
0
0
GB
Borland C++ Builder 5.0
Project contains Form1 and Form2
Form1 contains a button

When the Form1 is created (on run) a thread is spawned using:

_beginthread(WorkTask, 4096, (void *) this);

When Form1's button is clicked the following code is called:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
stuff_to_do = true;
}

The WorkTask is as follows:

void WorkTask(void *obj)
{
while(true)
{
Sleep (1);
if(stuff_to_do)
{
Form2->Show();
stuff_to_do = false;
}
}
}

So, basically, what I want is that when Form1's button is clicked,
Form2 is displayed (I know this seems messy, but in the wider project,
this is a good way to go. We will have a main form, which will
receive data via serial and ethernet links, and control the displaing
of sub-forms, or windows, representing appropriate data and
functionality).

This all works fine as long as Form2 contains no edit boxes, buttons,
or any control with which you can interact. If an edit box, etc., is
on Form2, then the application simply freezes, with Form2 in focus.

Any ideas or help apreciated,

Nick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top