2

Generally if u add any control Eg: a rich text, the left and the top portion of the control will have thick borders.But the bottom and the right side of the control do not have borders. Is there any way to add borders to all sides. The border property has only true or false option, i don't want to take off the borders but have the borders unique on all sides. Please let me know if there are any ways.

Sorry i was unable add images earlier as i didn't have enough reputations. Please note the below image where the left and top borders of the rich text box are thick but the right and the bottom part and plain. I want all sides with borders even.

enter image description here

Anyways?.

Jerry
  • 67
  • 1
  • 7
  • What type of control, and, can you provide an image that shows what you want? Most MFC controls support [owner drawing](https://msdn.microsoft.com/en-us/library/windows/desktop/bb775501(v=vs.85).aspx), so, you should be able to render it the way you want. – rrirower Jul 29 '15 at 12:16
  • I have edited and added an image now. – Jerry Jul 31 '15 at 13:11
  • Are you asking for specifically for rich edit controls, or, dialog controls in general? – rrirower Jul 31 '15 at 13:15
  • Rich text box is particularly the one that i need. There are controls that have even borders too. It will be good to know about other dialog controls as well in general which have uneven borders but rich text control is the one that i need the most. – Jerry Jul 31 '15 at 13:17

1 Answers1

0

I’ve answered a very similar (may be duplicate) question recently. You can check “Want to show colored box around Richedit control in MFC at runtime”. That question asked for a yellow colored border. To answer your question, it requires you to derive your own class from CRichEditCtrl, override OnNcPaint, and a simple modification of the sample (OnNcPaint) code I presented in that post:

CPen pen;
COLORREF color = ::GetSysColor(COLOR_3DDKSHADOW);
pen.CreatePen(PS_SOLID, 5, color);
dc.SelectObject(pen);
dc.Rectangle(&rect);

The above would result in...

enter image description here

Note: You can adjust the border color by changing the parameter of ::GetSyscolor

Community
  • 1
  • 1
rrirower
  • 4,338
  • 4
  • 27
  • 45