Home > Software engineering >  A thread of problem
A thread of problem

Time:10-10

I write a program, want to give an edit box in the thread continuously add content, when the program has been unusually
Exceptions are conflict while reading position 0 x134

CLOL_TestDlg * test;
UINT __cdecl ThreadProc (LPVOID lpParameter)
{
Cstrings STR.
for (int i=0; i <10; I++)
{
The test - & gt; M_EditTest=STR;
The test - & gt; M_EditTest. The Format (_T (" % d) "+ STR, I);
The test - & gt; The UpdateData (FALSE);
Sleep (1000);
}
return 0;
}

Ask friends to help take a look at,

CodePudding user response:

Thread cannot directly manipulate the UI, PostMessage to the main thread in the thread, handled by the main thread

CodePudding user response:

String constants can not directly use + to connect
 test - & gt; M_EditTest. The Format (_T (" % d ")/* + STR */, I); 

CodePudding user response:

DLG dialog object, want to be in again each time you use it for instance, you had problems with that as a global variable can take DLG instance as the incoming thread function parameters

CodePudding user response:

The test - & gt; The UpdateData (FALSE); The remove

A custom message
PostMessage to dialog
MyMessage ()
{
//the UpdateData ();
}

CodePudding user response:

1 and 2 floor together is the right answer
  • Related