• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CStaticExHor
    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
    //
    
    #include "StdAfx.h"
    #include "StaticExHor.h"
    
    CStaticExHor::CStaticExHor(void)
    : m_nMiddlePos(0)
    , m_bGetFontWidth(false)
    , m_nLeftMargin(5)
    {
    	m_crHorbar		 = RGB(157, 157, 161);
    	m_crHorbarShadow = RGB(255, 255, 255);
    	m_crFontColor	 = RGB(0, 70, 213);		// 퍼렁 ㅋ
    	
    	int PenStyle = PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE;
    	m_pen.CreatePen(PenStyle, 1, m_crHorbar); 
    	m_penShadow.CreatePen(PenStyle, 1, m_crHorbarShadow);
    }
    
    CStaticExHor::~CStaticExHor(void)
    {
    	m_pen.DeleteObject();
    	m_penShadow.DeleteObject();
    }
    
    BEGIN_MESSAGE_MAP(CStaticExHor, CStaticEx)
    	ON_WM_PAINT()
    END_MESSAGE_MAP()
    
    
    void CStaticExHor::InitObject(CDC* pDC)
    {
    	CStaticEx::InitObject(pDC);	
    
    	if (!m_bGetFontWidth)
    	{
    		m_nMiddlePos    = static_cast<int>(m_rect.Height() / 2);
    		m_nLeftMargin  += mDC.GetTextExtent(m_szWindowText).cx;
    		m_bGetFontWidth = true;
    	}
    }
    
    void CStaticExHor::OnPaint()
    {
    	CPaintDC dc(this); // device context for painting
    	
    	InitObject(&dc);
    
    	//
    	// 메모리DC 에 선을 먼저 그리고
    	//
    	mDC.MoveTo(m_nLeftMargin, m_nMiddlePos);
    	mDC.SelectObject(&m_pen);
    	mDC.LineTo(m_rect.Width(), m_nMiddlePos);
    	mDC.SelectObject(&m_penShadow);
    	mDC.MoveTo(m_nLeftMargin, m_nMiddlePos + 1);
    	mDC.LineTo(m_rect.Width() - 1, m_nMiddlePos + 1);
    	mDC.LineTo(m_rect.Width(), m_nMiddlePos - 1);
    
    	//
    	// 글자 쓰기
    	//
    	mDC.DrawText(m_szWindowText + L"  ",m_rect,m_nAlign);
    	dc.BitBlt(0, 0, m_rect.Width(), m_rect.Height(), &mDC, 0, 0, SRCCOPY);
    
    	//
    	// 배경이 되는 메모리 비트맵을 지운다.
    	//
    	DeleteObject();
    }
    
    
    #pragma once
    #include "staticex.h"
    
    class CStaticExHor :
    	public CStaticEx
    {
    public:
    	CStaticExHor(void);
    	~CStaticExHor(void);
    
    protected:
    	DECLARE_MESSAGE_MAP()
    
    protected:
    	afx_msg void OnPaint();
    
    protected:
    	int m_nMiddlePos;
    	int m_nLeftMargin;
    	CPen m_pen, m_penShadow;
    	bool m_bGetFontWidth;
    	COLORREF m_crHorbar, m_crHorbarShadow;
    
    protected:
    	virtual void InitObject(CDC* pDC);
    
    };
    

    Comment


    입력하3 1503256858



    Locations of visitors to this page