개발/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:

  1. Include the SxGroupBox.h header file in your dialog class header file.
  2. 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.  
  3. 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]

    1. #include "SxGroupBox.h"
    2.  
    3. class YourDialogClass : public CDialog
    4. {
    5. ...
    6. // Dialog Data
    7. //{{AFX_DATA(YourDialogClass)
    8. ...
    9. CSxGroupBox MyGroupBox;
    10. ...
    11. //}}AFX_DATA
    12. ...
    13. }

[In File YourDialogClass.cpp]

    1. void YourDialogClass::YourFunction()
    2. {
    3. // create font
    4. CSxLogFont Arial12b(120,FW_BOLD,false,"Arial");
    5. // set the custom font, text color, and alignment
    6. MyGroupBox.SetFont( &Arial12b );
    7. MyGroupBox.SetTextColor( RGB(100,0,0) );
    8. MyGroupBox.SetTextAlign( BS_CENTER );
    9. // set the custom line colors, thickness, and style
    10. MyGroupBox.SetBoxColors( RGB(100,0,0), RGB(255,100,100) );
    11. MyGroupBox.SetLineThickness(2);
    12. MyGroupBox.SetLineStyle( BS_3D );
    13. }



'개발 > MFC' 카테고리의 다른 글

[스크랩]실시간 그래프  (1) 2017.06.20
Warning C4996  (0) 2017.04.28
MFC 타이틀바 없앤뒤 이동하기  (0) 2017.04.28
MFC 타이틀바 없애기  (0) 2017.04.28
MFC 테두리 없애기  (0) 2017.04.28
MFC 다이얼로그 접기 펴기  (0) 2017.04.24
MFC 에디트 컨트롤 색상  (0) 2017.04.21
MFC 윈도우 스타일 적용  (0) 2017.04.21