Help!- Background color of Highlighted line in RichEditView
-
Hi I am new to MFC, i have written function to highlight a perticular line in richeditview class. find the routines below. But i am not able to change the background of a line (presently in black color). i am able to change the text color. I tried with CHARFORMAT2, but its not working. So plz help me out to solve this problem void CDbgView::HighlightLine(int GLineNum) { int FirstVisibleLineNum = pSCodeView->GetRichEditCtrl( ).GetFirstVisibleLine() + 1; int LastLine = FirstVisibleLineNum + pSCodeView->GetRichEditCtrl( ).GetLineCount(); int nBegin,nEnd; nBegin = pSCodeView->GetRichEditCtrl().LineIndex(GLineNum-1); End = pSCodeView->GetRichEditCtrl().LineLength(nBegin); // Select the range of charecters. CHARRANGE cr; pSCodeView->GetRichEditCtrl().GetSel(cr); cr.cpMin = nBegin; cr.cpMax = nBegin + nEnd; pSCodeView->GetRichEditCtrl().SetSel(cr); //Change the Bk Color of the line selected /*CHARFORMAT2 cf; pSCodeView->GetRichEditCtrl().GetSelectionCharFormat(cf); cf.cbSize = 84; CHARFORMAT2* pcf = &cf; pSCodeView->SendMessage(EM_SETCHARFORMAT,(WPARAM) SCF_ALL,(LPARAM) pcf); cf.dwMask = CFM_SIZE | CFM_BACKCOLOR ; cf.dwEffects = CFE_PROTECTED | CFM_COLOR | CFM_BACKCOLOR; cf.crBackColor = RGB(0,0,255); pSCodeView->GetRichEditCtrl().SetSelectionCharFormat(cf); */ pSCodeView->UpdateWindow( ); } Thanks Irshad
-
Hi I am new to MFC, i have written function to highlight a perticular line in richeditview class. find the routines below. But i am not able to change the background of a line (presently in black color). i am able to change the text color. I tried with CHARFORMAT2, but its not working. So plz help me out to solve this problem void CDbgView::HighlightLine(int GLineNum) { int FirstVisibleLineNum = pSCodeView->GetRichEditCtrl( ).GetFirstVisibleLine() + 1; int LastLine = FirstVisibleLineNum + pSCodeView->GetRichEditCtrl( ).GetLineCount(); int nBegin,nEnd; nBegin = pSCodeView->GetRichEditCtrl().LineIndex(GLineNum-1); End = pSCodeView->GetRichEditCtrl().LineLength(nBegin); // Select the range of charecters. CHARRANGE cr; pSCodeView->GetRichEditCtrl().GetSel(cr); cr.cpMin = nBegin; cr.cpMax = nBegin + nEnd; pSCodeView->GetRichEditCtrl().SetSel(cr); //Change the Bk Color of the line selected /*CHARFORMAT2 cf; pSCodeView->GetRichEditCtrl().GetSelectionCharFormat(cf); cf.cbSize = 84; CHARFORMAT2* pcf = &cf; pSCodeView->SendMessage(EM_SETCHARFORMAT,(WPARAM) SCF_ALL,(LPARAM) pcf); cf.dwMask = CFM_SIZE | CFM_BACKCOLOR ; cf.dwEffects = CFE_PROTECTED | CFM_COLOR | CFM_BACKCOLOR; cf.crBackColor = RGB(0,0,255); pSCodeView->GetRichEditCtrl().SetSelectionCharFormat(cf); */ pSCodeView->UpdateWindow( ); } Thanks Irshad
i do it this way: void MyClass::SetBold(void) { CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD; DWORD dwSelMask = GetSelectionCharFormat(cf); if( (cf.dwMask & CFM_BOLD) & (dwSelMask & CFM_BOLD) ) { cf.dwEffects ^= CFE_BOLD; } else { cf.dwEffects |= CFE_BOLD; } cf.dwMask = CFM_BOLD; SetSelectionCharFormat(cf); }
-
i do it this way: void MyClass::SetBold(void) { CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD; DWORD dwSelMask = GetSelectionCharFormat(cf); if( (cf.dwMask & CFM_BOLD) & (dwSelMask & CFM_BOLD) ) { cf.dwEffects ^= CFE_BOLD; } else { cf.dwEffects |= CFE_BOLD; } cf.dwMask = CFM_BOLD; SetSelectionCharFormat(cf); }
thanks for reply...but i want to change the background color of hightlighted line...presently it is black... so i tried to use CHARFORMAT2...but i am not able set the size attribute & i am not able send a massage for CHARFORMAT2 regards, Irshad