개발/MFC
MFC 그룹박스 테두리 색상 적용
FA1976
2017. 4. 28. 13:25
반응형
그룹박스의 테두리및 글씨를 보기 좋게....
If you want to customize the look of the standard GroupBox control then the SxGroupBox class can be most helpful for you. It provides functions for customizing the font, color, and style. Most of the work is done in the OnPaint message handler. You can easily change the OnPaint function yourself to add other effects such as rounded corners or other line styles or box styles.
You can follow these steps to use the class:
- Include the SxGroupBox.h header file in your dialog class header file.
- Use class wizard to create a control data member of type CSxGroupBox. If the CSxGroupBox type does not appear in the class wizard control type combobox then just choose CButton and then manually edit your dialog class header file and replace the CButton with CSxGroupBox.
- Add whatever commands you want to your dialog class cpp file to customize the appearance of the GroupBox.
A sample application is included that shows most of the features of SxGroupBox.
The following code snippet shows how to call some of the functions.
[In File YourDialogClass.h]
- #include "SxGroupBox.h"
- class YourDialogClass : public CDialog
- {
- ...
- // Dialog Data
- //{{AFX_DATA(YourDialogClass)
- ...
- CSxGroupBox MyGroupBox;
- ...
- //}}AFX_DATA
- ...
- }
[In File YourDialogClass.cpp]
- void YourDialogClass::YourFunction()
- {
- // create font
- CSxLogFont Arial12b(120,FW_BOLD,false,"Arial");
- // set the custom font, text color, and alignment
- MyGroupBox.SetFont( &Arial12b );
- MyGroupBox.SetTextColor( RGB(100,0,0) );
- MyGroupBox.SetTextAlign( BS_CENTER );
- // set the custom line colors, thickness, and style
- MyGroupBox.SetBoxColors( RGB(100,0,0), RGB(255,100,100) );
- MyGroupBox.SetLineThickness(2);
- MyGroupBox.SetLineStyle( BS_3D );
- }
반응형