• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CStaticExGroup
    Last Modify : 27 December, 2010(02:43)
    // DATE		: February 27, 2007
    // CODER	: Kurome (aucd29@gmail.com)
    // VERSION	: 1.0
    //
    // Require
    // ----------------------------------------------------------
    // CStaticEx
    // http://www.sarangnamu.net/basic/basic_view.php?no=2844
    //
    // NOTE : May 17, 2007
    // ----------------------------------------------------------
    // * 이건 머 -_ -; 백그라운드가 문제가 있어서.. 갱신이
    //   안되는.......... 아... 방법있다. +_+;
    //
    
    #include "StdAfx.h"
    #include "StaticExGroup.h"
    
    CStaticExGroup::CStaticExGroup(void)
    : m_nTopGap(0)
    , m_bSetGroup(false)
    , m_nTextWidth(0)
    , m_nLeftMargin(12)
    , m_nTextPadding(3)
    , m_nRoundSize(2)
    {
    	m_crFontColor = RGB(0, 70, 213);		// 퍼렁 ㅋ
    	m_crPen		  = RGB(191, 184, 191);
    
    	int PenStyle = PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE;
    	m_penGroup.CreatePen(PenStyle, 1, m_crPen);
    	m_brushGroup.CreateSolidBrush(GetSysColor(COLOR_3DFACE));
    }
    
    CStaticExGroup::~CStaticExGroup(void)
    {
    	m_penGroup.DeleteObject();
    	m_brushGroup.DeleteObject();
    }
    
    void CStaticExGroup::InitObject(CDC* pDC)
    {
    	if (!m_bSetGroup)
    	{
    		GetClientRect(m_rect);
    
    		m_nTopGap			= static_cast<int>(m_nHeight / 2.0);
    		m_rectRectagle		= m_rect;
    		m_rectRectagle.top += m_nTopGap;
    		m_rectText			= m_rect;
    		m_rectText.left	   += m_nLeftMargin;
    	}
    
    	CStaticEx::InitObject(pDC);
    
    	if (!m_bSetGroup)
    	{
    		m_bSetGroup = true;
    		mDC.SelectObject(&m_penGroup);
    		mDC.SelectObject(&m_brushGroup);
    		m_nTextWidth = mDC.GetTextExtent(m_szWindowText).cx;
    	}
    }
    
    BEGIN_MESSAGE_MAP(CStaticExGroup, CStaticEx)
    	ON_WM_PAINT()
    	ON_WM_DRAWITEM()
    	ON_WM_ERASEBKGND()
    END_MESSAGE_MAP()
    
    void CStaticExGroup::OnPaint()
    {
    	CPaintDC dc(this); // device context for painting
    	
    	InitObject(&dc);
    
    	//
    	// 선 그리기
    	//
    	mDC.MoveTo(m_nRoundSize, m_rectRectagle.top);
    	mDC.LineTo(m_nLeftMargin - m_nTextPadding, m_rectRectagle.top);
    	mDC.MoveTo(m_nTextWidth + m_nTextPadding + m_nLeftMargin, m_rectRectagle.top);
    	mDC.LineTo(m_rectRectagle.right - m_nRoundSize, m_rectRectagle.top);
    	mDC.MoveTo(m_rectRectagle.right - 1, m_rectRectagle.top + m_nRoundSize);
    	mDC.LineTo(m_rectRectagle.right - 1, m_rectRectagle.bottom - m_nRoundSize);
    	mDC.MoveTo(m_rectRectagle.right - 1 - m_nRoundSize, m_rectRectagle.bottom - 1);
    	mDC.LineTo(m_rectRectagle.left - 1 + m_nRoundSize, m_rectRectagle.bottom - 1);
    	mDC.MoveTo(m_rectRectagle.left, m_rectRectagle.bottom - 1 - m_nRoundSize);
    	mDC.LineTo(m_rectRectagle.left, m_rectRectagle.top + m_nRoundSize - 1);
    
    	//
    	// TOP | LEFT
    	//
    	mDC.SetPixel(m_rectRectagle.left + 1, m_rectRectagle.top + 2 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.left + 1, m_rectRectagle.top + 1 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.left + 2, m_rectRectagle.top + 1 , m_crPen);
    
    	//
    	// TOP | RIGHT
    	//
    	mDC.SetPixel(m_rectRectagle.right - 3, m_rectRectagle.top + 1 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.right - 2, m_rectRectagle.top + 1 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.right - 2, m_rectRectagle.top + 2 , m_crPen);
    
    	//
    	// BOTTOM | LEFT
    	//
    	mDC.SetPixel(m_rectRectagle.left + 1, m_rectRectagle.bottom - 3 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.left + 1, m_rectRectagle.bottom - 2 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.left + 2, m_rectRectagle.bottom - 2 , m_crPen);
    
    	//
    	// BOTTOM | RIGHT
    	//
    	mDC.SetPixel(m_rectRectagle.right - 3, m_rectRectagle.bottom - 2 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.right - 2, m_rectRectagle.bottom - 2 , m_crPen);
    	mDC.SetPixel(m_rectRectagle.right - 2, m_rectRectagle.bottom - 3 , m_crPen);
    
    	//
    	// 글자 넣기
    	//
    	mDC.DrawText(m_szWindowText, m_rectText, m_nAlign);
    
    	//
    	// Real DC에 그리기
    	//
    	dc.BitBlt(0, 0, m_rect.Width(), m_rect.Height(), &mDC, 0, 0, SRCCOPY);
    
    	DeleteObject();
    }
    
    void CStaticExGroup::PreSubclassWindow()
    {
    	CStaticEx::PreSubclassWindow();
    	ModifyStyle(0, BS_OWNERDRAW);
    }
    
    void CStaticExGroup::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
    {
    }
    
    BOOL CStaticExGroup::OnEraseBkgnd(CDC* pDC)
    {
    	return true;
    }
    
    #pragma once
    #include "staticex.h"
    
    class CStaticExGroup :
    	public CStaticEx
    {
    public:
    	CStaticExGroup(void);
    	~CStaticExGroup(void);
    
    protected:
    	virtual void PreSubclassWindow();
    	virtual void InitObject(CDC* pDC);
    	DECLARE_MESSAGE_MAP()
    
    protected:
    	afx_msg void OnPaint();
    	afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
    	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    
    protected:
    	int m_nTopGap, m_nTextWidth, m_nLeftMargin, m_nTextPadding;
    	int m_nRoundSize;
    	CPen m_penGroup;
    	bool m_bSetGroup;
    	CRect m_rectRectagle;
    	CBrush m_brushGroup;
    	COLORREF m_crPen;
    };
    

    Comment


    입력하3 1508772506



    Locations of visitors to this page