Home > Software engineering >  Under the great god come in MFC, big data to CRichEdit controls, the cursor pointer has been in a bu
Under the great god come in MFC, big data to CRichEdit controls, the cursor pointer has been in a bu

Time:10-06

 

//the code below is in a CRichEdit control tail, additional according to new data (such as 1024 * 16 characters), automatic scrolling, vertical scrolling, after the completion of the last line in the new display,

//this code will call,

//the problem now is that the cursor pointer has been in a busy state, is actually in the Arrow and Wait to switch between two states, don't want to display a Wait state, Arrow will always want to display, the great god, the action!

CRichEditCtrl * pedCtrl=(CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT21);


CHARFORMAT cf={0};
DWORD dwFlags=GTL_NUMCHARS;

Int txtLen=pedCtrl - & gt; GetTextLengthEx (dwFlags);

NOldLines=pedCtrl - & gt; GetLineCount ();

Cf. CbSize=sizeof (cf);
Cf. DwMask=CFM_COLOR;
Cf. DwEffects=~ CFE_AUTOCOLOR;

Cf. CrTextColor=RGB (0, 0, 255);



PedCtrl - & gt; SetSel (txtLen, 1);//Set the cursor to the end of the text area and deselect everything.
PedCtrl - & gt; ReplaceSel (strMyString + (strMyString GetLength () & lt; 1? _T (" ") : _T (" \ n ")));//Inserts the when nothing is selected.

Int n1=strMyString. GetLength ();
Int n2=pedCtrl - & gt; GetTextLengthEx (dwFlags);
//the Apply formating the to the just inserted text.
PedCtrl - & gt; SetSel (txtLen pedCtrl - & gt; GetTextLengthEx (dwFlags));
PedCtrl - & gt; SetSelectionCharFormat (cf).


Long nVisible=GetNumVisibleLines (pedCtrl);
If (pedCtrl!=pedCtrl - & gt; GetFocus ())
{
PedCtrl - & gt; LineScroll (INT_MAX);
PedCtrl - & gt; LineScroll (1 - nVisible);
}

CodePudding user response:

Look at the code, the feeling is no problem,
Also didn't find cycle,

Control operation if there is a cycle, it is best to use a thread to handle, otherwise very easily jammed,

CodePudding user response:

reference 1st floor l357630798 response:
single look at the code, feel no problem,
Also didn't find cycle,

Control operation if there is a cycle, it is best to use a thread to handle, otherwise very easily jammed,

Thanks reply, may I describe not clear, to describe:

Code everything is normal, no card to death, also have no problem, I am in the outside has a single thread, often called the code, then write CRichEdit control big data, in this case, Windows is the state sets the mouse pointer to busy, this code is also one of the effects, but my request is that, don't want to let the mouse pointer display busy state, I want him to have been showing Arrow state, this is data processing is smooth, how to deal with?

CodePudding user response:

Don't write, can process the data in the thread, then PostMessage asynchronous mode to the main interface of the UI to update the data

CodePudding user response:

reference oyljerry reply: 3/f
don't write, can process the data in the thread, then PostMessage asynchronous mode to the main interface of the UI to update the data


The webmaster!
Thread on the inside is very simple, send data first, and then receive data, receiving and processing the data, call on a piece of code above, in CRichEdit control display, display, and then start sending the next frame data, logical relationship there is no problem,

Now the question is, what is not a logical reasons to cause, because every time to display the number of more, 1024 * 16 characters, whether using my way call UI function directly, or use message inform you suggest to write CRichEdit controls, I think as long as you use the code above, will result in the mouse pointer in the busy state, write data is complete, the mouse pointer back Arrow, I want to make the mouse pointer is not busy, just keep Arrow state, with the, the following function takes longer,
PedCtrl - & gt; ReplaceSel (strMyString + (strMyString GetLength () & lt; 1? _T (" ") : _T (" \ n "))),

With inside, Send a EM_REPLACESEL message, don't move,

CodePudding user response:

LockWindowUpdate ()

CodePudding user response:

Where necessary to insert a message loop?
  • Related