Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am trying to set different paraformat for different text in a CRichEditCtrl

But the paraformat that i am setting at last only working. My code is

C++
void Function1()
{
// pRichEdit  - Object of the CRichEditCtrl
	PARAFORMAT para1;
	para1.dwMask = PFM_ALIGNMENT ;
	para1.wAlignment = ( WORD ) PFA_LEFT;

	pRichEdit->SetParaFormat( para1 );
	AppendData(_T("1234S"));

	PARAFORMAT para2;
	para2.dwMask = PFM_ALIGNMENT ;
	para2.wAlignment = ( WORD ) PFA_CENTER;

	pRichEdit->SetParaFormat( para2 );
	AppendData(_T("\r\n123456ffffffffffKKS"));
}

void AppendData(CString data)
{
//data - text to append with the CRichEditCtrl's text
	 int nBegin;
	 nBegin = pRichEdit->GetTextLength();
	 pRichEdit->SetSel(nBegin, nBegin);   // Select last character
	 pRichEdit->ReplaceSel(data);          // Append, move cursor to end of text
	 pRichEdit->SetSel(-1,0);             // Remove Black selection bars
	 nBegin = pRichEdit->GetTextLength(); // Get New Length
	 pRichEdit->SetSel(nBegin,nBegin);    // Cursor to End of new text	
}


In the above code all the text in the CRichEditCtrl is displaying with the PFA_CENTER and the PFA_LEFT style is not working

How can i solve this?

Thanks in Advance...
Posted
Updated 17-Apr-12 5:29am
v3
Comments
Nelek 17-Apr-12 11:29am    
Edit: Code tags added

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900