简体   繁体   中英

Can we have border on all sides for a control in a dialog in a C++ MFC application?

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.

在此处输入图片说明

Anyways?.

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...

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM