Home > Software engineering >  MFC edit box number reaches a certain size will shine
MFC edit box number reaches a certain size will shine

Time:10-09

Is receiving server data, in the edit box, normal at the beginning, more words will be flashing, why ah,
 
If (resultList. The size ()==size2)
{
STD: : string w;
2. TXT FILE * fa=fopen (" ", "wb +");
The fclose (fa);
1. TXT FILE * fc=fopen (" ", "wb +");
The fclose (fc);
Size2 + +;
X=pl. The output (" 1. TXT ", resultList, errorCode);

For (int s=0; S & lt; ResultList. The size (); S++)
{
X=pl. Convert_json (resultList [s] c_str (), w, strbuffer);//json parsing
}


CFile sf.
Cstrings STR (" ");
Sf. Open (_T (" 2. TXT "), CFile: : modeRead);
DWORD size3=sf. GetLength ();
Char * resultbuf;
Resultbuf=new char [size3 + 1];
Memset (resultbuf, 0, size3 + 1);
Sf. Read (resultbuf, size3);
Int len=size3 + 1;
Int unicodeLen=: : MultiByteToWideChar (CP_UTF8,
0,
Resultbuf,
1,
NULL,
0);
Would be * pUnicode;
PUnicode=new would [unicodeLen + 1];
(unicodeLen memset (pUnicode, 0, + 1) * sizeof (would));
: : MultiByteToWideChar (CP_UTF8,
0,
Resultbuf,
1,
LPWSTR pUnicode,
UnicodeLen);
Cstrings rt.
Rt=(would be *) pUnicode;
The delete pUnicode;
The delete [] resultbuf;
Cstrings outresult;
Outresult=rt;
Int n=outresult. Remove (' ");
Outresult. Remove (' \ r \ n ');
Myedit - & gt; SetWindowText (outresult);
Myedit - & gt; LineScroll (myedit - & gt; GetLineCount ());
The InvalidateRect (NULL, NULL, true);
}

CodePudding user response:

Can try only in the old display content and new content of the rectangular area InvalidateRect
You can also try using double buffer technology
Remind: the use of any technology, full screen white and full screen black show alternately, sparkles,

CodePudding user response:

Don't use myedit - & gt; SetWindowText (outresult);

Edit. SetSel (1, 1);
Edit. ReplaceSel (pbufs) (char *);

CodePudding user response:

CodePudding user response:


Why can't use

CodePudding user response:

Edit box of double buffer will not quite, can you teach me

CodePudding user response:

myedit - & gt; SetSel (1, 1);//is your pointer

CodePudding user response:

Well, discovered, but as if it's no use, will flash, who would double buffer can teach me?

CodePudding user response:

Don't
The InvalidateRect (NULL, NULL, true);
Have a try

CodePudding user response:

I also met this problem, you direct SetWindowText will flash, can use ReplaceSel and SetSel,
If you want to use double buffer, then you have to rewrite the CEdit this class, one at a time to draw the last visible area of a string of a string,
As for the double buffering is under the temporary memdc drawing first, then a one-off drawing on the screen...
http://www.cnblogs.com/watsonlong/archive/2011/04/19/2021486.html

CodePudding user response:

You can also try RichEdit control

CodePudding user response:

Well, found the problem, it seems I have been in the timer timing to refresh
 
GetDlgItem (IDC_Timer1) - & gt; GetClientRect (& amp; The rect);
HWND HWND=myedit - & gt; GetSafeHwnd ();
The InvalidateRect (hWnd, & amp; The rect, true);

Myedit - & gt; SetWindowText (wtime2);

So that you can only refresh timer

CodePudding user response:

Why InvalidateRect (hWnd, & amp; The rect, true); ?
Myedit - & gt; SetWindowText (wtime2); They will be refresh

CodePudding user response:

 
Unsigned int __stdcall TimeThread PVOID (pM)
{
CEdit * myedit=(CEdit *) (pM);
//CrecordDlg * myedit=(CrecordDlg *) (pM);
Sec2=0;
Min2=0;
The h2=0;
Hmin2=0;
While (st==0)
{
Sleep (10);

Hmin2 + +;
If (hmin2==100) {
Hmin2=0;
Sec2 + +;
}
If (sec2==60)
{
Sec2=0;
Min2 + +;
}
If (min2==60)
{
Min2=0;
The h2 + +;
}


Wtime2. The Format (_T (" % d: % d: % d: % d \ n "), h2, min2, sec2, hmin2);
//SendMessage (0, WM_MY_MESSAGE, 0, 0);
//m_timeout=wtime2;
HWND HWND=myedit - & gt; GetSafeHwnd ();
The InvalidateRect (hWnd, & amp; The rect, true);

Myedit - & gt; SetWindowText (wtime2);



}
return 0;
}

CodePudding user response:

Threads do not interface Time Thread
(PVOID pM)Initialization time
The SetTimer (1100, 0, 0);

The code in the OnTimer

CodePudding user response:

Ontimer used, but the timing is not, sometimes also gets stuck, so finally decided to use thread,

CodePudding user response:

The message in the thread

CodePudding user response:

 
Unsigned int __stdcall TimeThread PVOID (pM)
{
CEdit * myedit=(CEdit *) (pM);
//CrecordDlg * myedit=(CrecordDlg *) (pM);
Sec2=0;
Min2=0;
The h2=0;
Hmin2=0;
While (st==0)
{
Sleep (10);

Hmin2 + +;
If (hmin2==100) {
Hmin2=0;
Sec2 + +;
}
If (sec2==60)
{
Sec2=0;
Min2 + +;
}
If (min2==60)
{
Min2=0;
The h2 + +;
}


Wtime2. The Format (_T (" % d: % d: % d: % d \ n "), h2, min2, sec2, hmin2);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related