Link to home
Start Free TrialLog in
Avatar of Rajeshm8484
Rajeshm8484Flag for India

asked on

How to insert a thick Line into RichEditCtrl??

Hi,

I am inserting a line into RichEditCtrl using AppendToLog() function(The defination of this function is attached as Code Snippet).......I am Calling this function as AppendToLog("______________________________________________________",RGB(24,233,170));
This call will insert a line into RichEditctrl(Which is not Thick),But i need this line to be inserted as a Very Thick Line..How can i solve this problem???
int CEncopyDlg::AppendToLog(CString str,COLORREF linecolor)
{
  int nOldLines = 0, nNewLines = 0, nScroll = 0;
  long nInsertionPoint = 0;
  CHARFORMAT cf;
  // Save number of lines before insertion of new text
  nOldLines = m_ctrlLog.GetLineCount();
  // Initialize character format structure
  cf.cbSize = sizeof(CHARFORMAT);
  cf.dwMask = CFM_COLOR;
  cf.dwEffects = 0; // To disable CFE_AUTOCOLOR
  cf.crTextColor = linecolor;
  // Set insertion point to end of text
  nInsertionPoint = m_ctrlLog.GetWindowTextLength();
  m_ctrlLog.SetSel(nInsertionPoint, -1);
  // Set the character format
  m_ctrlLog.SetSelectionCharFormat(cf);
  // Replace selection. Because we have nothing 
  // selected, this will simply insert
  // the string at the current caret position.
  m_ctrlLog.ReplaceSel(str);
  // Get new line count
  nNewLines = m_ctrlLog.GetLineCount();
  // Scroll by the number of lines just inserted
  nScroll = nNewLines - nOldLines;
  m_ctrlLog.LineScroll(nScroll);
  return 0;
}

Open in new window

Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

you have to insert a formatted paragraph with border like:

\par \brdrb\brdrs\brdrw50
Avatar of Rajeshm8484

ASKER

I did not understand,what ur trying to convey?So please explain briefly.
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Jaime,

I have tried using PARAFORMAT2 structure for inserting a Thick line into Rich Edit Control......But i did not find any differences.

The code is :

  PARAFORMAT2 format;
  format.cbSize=sizeof(PARAFORMAT2);
  format.dwMask=PFM_BORDER;
  format.wBorderWidth=9000;
  format.wBorders=0x08 | 0x900 | 0x8000;
  m_ctrlLog.SetParaFormat(format);

Hi,

PARAFORMAT2 structure with the above mentioned parameters is inserting a thick line into my RichRditControl.

ALso we can use CHARFORMAT2 structure in my Appendlog function(which is attached as code snippet) and change the parameters cf.dwMask = CFM_COLOR to cf.dwMask = CFM_COLOR|CFM_SIZE; and include cf.yheight=1000;
which also will insert a thick line ....

Thanks and Regards,
Rajesh.M
Thanks a lot jaime,it helped me a lot....Please try to give suggestions whenever i post a questions..