phenixa
June 23rd, 2008, 07:22 AM
hi,
i am new to c++ (used to program in java and c#)
for several days i have been trying to change gui from a thread,
i searched all the internet but couldnt find anything related,
i am using Borland c++ builder 6,
here is my code
hope
you ll find a solution
DWORD WINAPI TForm1::m_check(LPVOID param)
{
DWORD status;
HANDLE m_con[2];
m_con[0] = report;
m_con[1] = hExitEvent;
while(true)
{
status = WaitForMultipleObjects(2,m_con,FALSE,INFINITE);
Sleep(10); //do not use processor 100%
switch(status)
{
case WAIT_OBJECT_0:
Form1->write(message);
break;
case WAIT_OBJECT_0 +1:
return NULL;//exit
case WAIT_FAILED:
Form1->write("wait failed");
break;
default:
Form1->write("fail");
break;
}
}
}
this part is called by a thread when a button is clicked and runs
until exitevent is set
;
void TForm1::write(AnsiString inp)
{
Edit1->Text += inp+"\n";
}
and code to modify gui
this all code doesnt gives an error but it doesnt changes anything on gui
when i put a break point on
Edit->Text
as i see text is changed but it doesnt appears at gui
i am new to c++ (used to program in java and c#)
for several days i have been trying to change gui from a thread,
i searched all the internet but couldnt find anything related,
i am using Borland c++ builder 6,
here is my code
hope
you ll find a solution
DWORD WINAPI TForm1::m_check(LPVOID param)
{
DWORD status;
HANDLE m_con[2];
m_con[0] = report;
m_con[1] = hExitEvent;
while(true)
{
status = WaitForMultipleObjects(2,m_con,FALSE,INFINITE);
Sleep(10); //do not use processor 100%
switch(status)
{
case WAIT_OBJECT_0:
Form1->write(message);
break;
case WAIT_OBJECT_0 +1:
return NULL;//exit
case WAIT_FAILED:
Form1->write("wait failed");
break;
default:
Form1->write("fail");
break;
}
}
}
this part is called by a thread when a button is clicked and runs
until exitevent is set
;
void TForm1::write(AnsiString inp)
{
Edit1->Text += inp+"\n";
}
and code to modify gui
this all code doesnt gives an error but it doesnt changes anything on gui
when i put a break point on
Edit->Text
as i see text is changed but it doesnt appears at gui