• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CPropertyFrame
    Last Modify : 27 December, 2010(02:41)
    // PropertyFrame.cpp : implementation file
    //
    
    // DATE		: March 9, 2007
    // CODER	: Kurome (aucd29@gmail.com)
    // VERSION	: 1.0
    //
    //
    
    #include "stdafx.h"
    #include "PropertyFrame.h"
    
    
    
    // CPropertyFrame
    
    IMPLEMENT_DYNAMIC(CPropertyFrame, CWnd)
    
    CPropertyFrame::CPropertyFrame()
    : m_szWindowText(L"")
    , m_szFont(L"Tahoma")
    , m_nFontHeight(13)
    , m_bFrameSet(false)
    {
    	m_crFontColor			= RGB(73, 73, 73);
    	m_crCaptionBackground	= RGB(255, 255, 255);
    	m_crCaptionBorder		= RGB(127, 157, 185);
    	
    	LOGFONT hfont;
    	memset(&hfont, 0, sizeof(LOGFONT));
    	wcscpy_s(hfont.lfFaceName, m_szFont);
    	hfont.lfHeight = m_nFontHeight;
    	hfont.lfWeight = FW_BOLD;
    	m_Font.CreateFontIndirect(&hfont);
    }
    
    CPropertyFrame::~CPropertyFrame()
    {
    	m_Font.DeleteObject();
    }
    
    
    BEGIN_MESSAGE_MAP(CPropertyFrame, CWnd)
    ON_WM_PAINT()
    END_MESSAGE_MAP()
    
    
    
    // CPropertyFrame message handlers
    
    BOOL CPropertyFrame::Create(DWORD dwWindowStyle, const RECT &rect, CWnd *pwndParent, UINT nID)
    {
    	return CWnd::Create(
    			AfxRegisterWndClass(
    			CS_HREDRAW|CS_VREDRAW, 
    			AfxGetApp()->LoadStandardCursor(IDC_ARROW),
    			GetSysColorBrush(COLOR_3DFACE)),
    			_T("PropertyFrame"),
    			dwWindowStyle, rect, pwndParent, nID);
    }
    
    void CPropertyFrame::OnPaint()
    {
    	CPaintDC dc(this); // device context for painting
    	InitObject(&dc);
    	mDC.FillSolidRect(m_rectOut, m_crCaptionBackground);
    	mDC.FrameRect(m_rectOut, &CBrush(m_crCaptionBorder));
    	mDC.TextOut(10, 4, L"::  " + m_szWindowText);
    	dc.BitBlt(0, 0, m_rect.Width(), m_rect.Height(), &mDC, 0, 0, SRCCOPY);
    }
    
    void CPropertyFrame::SetWindowText(CString szWindowText)
    {
    	m_szWindowText = szWindowText;
    }
    
    void CPropertyFrame::InitObject(CDC* pDC)
    {
    	if (!m_bFrameSet)
    	{
    		CRect rect;
    		GetClientRect(rect);
    
    		//m_rect.SetRect(0, 0, rect.Width() - 1, 21);
    		m_rect = rect;
    		mDC.CreateCompatibleDC(pDC);
    		mBitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
    		mDC.SelectObject(&mBitmap);
    		mDC.SelectObject(&m_Font);
    		mDC.SetBkMode(TRANSPARENT);
    		mDC.SetTextColor(m_crFontColor);
    		mDC.FillSolidRect(m_rect, GetSysColor(COLOR_3DFACE));
    		
    		m_rectOut = m_rect;
    		m_rectOut.top += 1;	
    
    		m_bFrameSet = true;
    	}
    }
    
    void CPropertyFrame::InvalidateRectFrame(void)
    {
    	InvalidateRect(m_rect);
    }
    
    #pragma once
    
    #include "StaticEx.h"
    // CPropertyFrame
    
    class CPropertyFrame : public CWnd
    {
    	DECLARE_DYNAMIC(CPropertyFrame)
    
    public:
    	CPropertyFrame();
    	virtual ~CPropertyFrame();
    
    protected:
    	int m_nFontHeight;
    	bool m_bFrameSet;
    	CRect m_rect, m_rectOut;
    	CFont m_Font;
    	CString m_szWindowText;
    	CString m_szFont;	
    	COLORREF m_crFontColor;
    	COLORREF m_crCaptionBackground;
    	COLORREF m_crCaptionBorder;
    	CStaticEx m_stcCaption;
    	CDC mDC;
    	CBitmap mBitmap;
    
    	virtual void InitObject(CDC* pDC);
    
    	DECLARE_MESSAGE_MAP()
    public:
    	virtual BOOL Create(DWORD dwWindowStyle, const RECT &rect, CWnd *pwndParent, UINT nID);
    	afx_msg void OnPaint();	
    	void SetWindowText(CString szWindowText);	
    	void InvalidateRectFrame(void);
    };
    

    Comment


    입력하3 1508772081



    Locations of visitors to this page