Fold Group Box

 ´ÙÀ½ ³»¿ëÀº www.codeproject.comÀÇ Button Control ¼½¼ÇÀÇ "CGroup - A Powerful Group Control" ºÎºÐ¿¡¼­ Âü°íÇÑ ³»¿ëÀÔ´Ï´Ù.

 ±×¸²¿¡¼­ º¸´Ù½ÃÇÇ Group Box ¾È¿¡ µé¾î°¡´Â ÄÁÆ®·ÑµéÀÌ Á¢È÷´Â °ÍÀ» º¼ ¼ö ÀÖ½À´Ï´Ù. ¹°·Ð ¿É¼Ç¿¡ µû¶ó ±×·± ±â´ÉÀ» ¾ø¾Ù¼öµµ ÀÖ½À´Ï´Ù. À§ÀÇ Group Box ´Â Á¢È÷´Â ±â´ÉÀ» ¾ø¾Ø °ÍÀ̰í, ¾Æ·¡ÀÇ Group Box´Â ±× ±â´ÉÀÌ ÀÖ´Â °ÍÀÌÁÒ. ºñ±³ÇÒ ¼ö ÀÖ°Ô µÎ °³ÀÇ ±×¸²À» ³õ¾Ò½À´Ï´Ù.

   

 µ¥¸ð ÇÁ·ÎÁ§Æ®´Â ¿©±â¼­ ´Ù¿î·Îµå ¹ÞÀ¸½Ã°í..

 ´ÙÀ½°ú °°Àº ¼ø¼­·Î µû¶óÇÏ½Ã¸é µË´Ï´Ù.

1. ´ÙÀ̾ó·Î±× º£À̽º·Î »õ·Î¿î ÇÁ·ÎÁ§Æ®¸¦ ¸¸µì´Ï´Ù. ¿©±â¼­´Â ÇÁ·ÎÁ§Æ® À̸§À» GroupFolder ¶ó°í Á¤Çß½À´Ï´Ù.

2. Group.h / cpp ÆÄÀÏÀ» ÇÁ·ÎÁ§Æ®¿¡ Ãß°¡ (¼Ò½ºÆÄÀÏ ´Ù¿î·Îµå)

3. ´ÙÀ̾ó·Î±× ÅÛÇø´ À§¿¡ Group Box¸¦ ³õ½À´Ï´Ù. ±×¸®°í Å×½ºÆ® »ï¾Æ ¾Æ¹« ÄÁÆ®·ÑÀ̳ª ±× À§¿¡ ¿Ã·Á³õ½À´Ï´Ù.

À̶§ ¹Ýµå½Ã ÄÁÆ®·ÑÀÌ Group Box ¾È¿¡ ¿ÏÀüÈ÷ µé¾î°¡µµ·Ï ³õ¾Æ¾ß ÇÕ´Ï´Ù.

¸¸¾à ÄÁÆ®·ÑÀÌ Group Box¸¦ ¹þ¾î³ª¸é Group Box°¡ Á¢Èú ¶§, ±× ÄÁÆ®·ÑÀº Group Box¿¡ Æ÷ÇÔµÇÁö ¾Ê¾Æ »ç¶óÁöÁö ¾Ê½À´Ï´Ù.

4. Group Box ÀÇ ID¸¦ IDC_STATIC¿¡¼­ ´Ù¸¥ °ÍÀ¸·Î ¹Ù²ß´Ï´Ù. ¿©±â¼­´Â IDC_GROUP1 ·Î ¹Ù²Ùµµ·Ï ÇÏÁÒ

5. Class WizardÀÇ Member Variables ÅÇ¿¡¼­ Group Box (¾Õ¿¡¼­ ID¸¦ IDC_GROUP1 ·Î Á¤Çß´ø °Í) ¿¡ ¸â¹öº¯¼ö¸¦ ´ÙÀ½Ã³·³ ¿¬°áÇÕ´Ï´Ù.

6. GroupFolderDlg.h ÆÄÀÏÀÇ CButton m_Group1 ºÎºÐÀ» ´ÙÀ½Ã³·³ °íĨ´Ï´Ù.

        CButton m_Group1   ===>    CGroup m_Group1

 ±×¸®°í ÀÌ ÆÄÀÏÀÇ Á¦ÀÏ À§¿¡ ´ÙÀ½Ã³·³ Çì´õÆÄÀÏÀ» ÀÎŬ·çµå ½ÃÄÑÁÝ´Ï´Ù.

        #include "Group.h"

7. ¿©±â±îÁö ÀÛ¾÷ ÈÄ ÄÄÆÄÀÏÀ» Çϸé, ³¡ÀÔ´Ï´Ù. ±âº»ÀûÀÎ »ç¿ë¹ýÀº ¾ÆÁÖ °£´ÜÇÏÁÒ.

8. CGroup Ŭ·¡½ºÀÇ ¸â¹öÇÔ¼ö´Â OnInitDialog ÇÔ¼ö ³»¿¡¼­ ´ÙÀ½Ã³·³ »ç¿ëÇÏ¸é µË´Ï´Ù.

BOOL CGroupFolderDlg::OnInitDialog()
{
        CDialog::OnInitDialog();

        .................

        // TODO: Add extra initialization here
        m_Group1.SetBarColor(RGB(128,128,0));
        m_Group1.SetTextColor(RGB(100,200,30));
        m_Group1.SetBarHeight(20);
        m_Group1.SetFold(false);        
        
        return TRUE;  // return TRUE  unless you set the focus to a control
}

9. CGroup Ŭ·¡½ºÀÇ ¸â¹öÇÔ¼ö´Â ´ÙÀ½°ú °°½À´Ï´Ù.

// CGroup °´Ã¼ÀÇ Æ÷ÀÎÅÍ ¹Ýȯ
CGroup* GetGroupCtrl() { return this; }

// ŸÀÌÆ²¹Ù »ö±ò º¯°æ
void SetBarColor(COLORREF color) { m_barColor = color; Invalidate(); }

// ŸÀÌÆ²¹Ù ±ÛÀÚ »ö±ò º¯°æ
void SetTextColor(COLORREF color) { m_textColor = color; Invalidate(); }

// Tells the group whether it attracts other groups or not
// Attraction is vertical and descending. Any CGroup placed under the current
// CGroup will be, if they didn't disable their attraction, attracted.
void SetAttract(bool toggle = false) { m_attract = toggle; Invalidate(); }

// Group Box°¡ Á¢ÈúÁö(fold) ¾Æ´ÒÁö ¼³Á¤
void SetFold(bool toggle = true);

// Add a bitmap to the title bar and assign a color mask
// If the bitmap is bigger than the title bar, you can
// choose to resize the bar automatically.
void SetBitmap(UINT bmpID,COLORREF mask = RGB(0,0,0),bool resizeBar = false);

// Toggle to tell whether the group can be attracted
void SetAttraction(bool toggle = true) { m_IsAttracted = toggle; Invalidate(); }

// ÆùÆ® ¼³Á¤ (LOGFONT ±¸Á¶Ã¼ ¶Ç´Â °¢Á¾ º¯¼ö ÀÌ¿ë)
void SetTextFont (LOGFONT lf);
void SetTextFont (CString face,int size = 12,bool bold = true,bool italic = false,bool underline = false);

// ŸÀÌÆ²¹Ù ³ôÀÌ ¼³Á¤
void SetBarHeight(int h);

//Set whether the group will change its height or not when attracted
// (ie the bottom of the group area will remain the same, hence increasing or
// decreasing the height of the group as other groups fold above it)
void SetLastGroup(bool toggle = false) {m_last = toggle; Invalidate(); }

//Set whether the last control (lowest) in the group will have its height modified by attraction
void SetLastCtrl(bool toggle = false) {m_extendLastCtrl = toggle; Invalidate(); }

//Toggle the display of the frame for the group
void DrawGroupBorder(bool toggle = true) { m_borders = toggle; Invalidate(); }

//toggle the display the frame for the title bar
void DrawBarBorder(bool toggle = true) { m_barBorders = toggle; Invalidate(); }

- the end -