• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CPropertySheetExt
    Last Modify : 27 December, 2010(02:40)
    // PropertySheetExt.cpp : implementation file
    //
    
    // DATE		: March 9, 2007
    // CODER	: Kurome (aucd29@gmail.com)
    // VERSION	: 1.0
    //
    //
    
    #include "stdafx.h"
    #include "PropertySheetExt.h"
    
    // CPropertySheetExt
    
    IMPLEMENT_DYNAMIC(CPropertySheetExt, CPropertySheet)
    
    CPropertySheetExt::CPropertySheetExt()
    : CPropertySheet()
    , m_nLeftMenuWidth(150)
    , m_pFrame(NULL)
    {
    }
    
    CPropertySheetExt::CPropertySheetExt(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
    	:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
    	, m_nLeftMenuWidth(150)
    	, m_pFrame(NULL)
    {
    }
    
    CPropertySheetExt::CPropertySheetExt(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
    	:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
    	, m_nLeftMenuWidth(150)
    	, m_pFrame(NULL)
    {
    }
    
    CPropertySheetExt::~CPropertySheetExt()
    {
    	if (m_pFrame != NULL)
    	{
    		delete m_pFrame;
    	}
    }
    
    
    BEGIN_MESSAGE_MAP(CPropertySheetExt, CPropertySheet)
    END_MESSAGE_MAP()
    
    // CPropertySheetExt message handlers
    
    BOOL CPropertySheetExt::OnInitDialog()
    {
    	EnableStackedTabs(false);
    	
    	BOOL bResult = CPropertySheet::OnInitDialog();
    	
    	// 탭 컨트롤을 살포시 숨기자.
    	CTabCtrl *pTab = GetTabControl();
    	if (!IsWindow(pTab->GetSafeHwnd()))
    	{
    		ASSERT(FALSE);
    		return bResult;
    	}
    	pTab->ShowWindow(SW_HIDE);
    	pTab->EnableWindow(FALSE);
    	CString szWindowsText;
    	pTab->GetWindowText(szWindowsText);
    
    	CRect rectFrame;
    	pTab->GetWindowRect(rectFrame);
    	ScreenToClient(rectFrame);
    
    	m_pFrame = new CPropertyFrame;
    	if (!m_pFrame)
    	{
    		ASSERT(FALSE);
    		AfxThrowMemoryException();
    	}
    	m_pFrame->Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF);
    
    	const int nTreeWidth = m_nLeftMenuWidth;
    	const int nTreeSpace = 5;
    	CRect rectSheet;
    
    	// 윈도우 크기를 변경
    	GetWindowRect(rectSheet);
    	rectSheet.right += nTreeWidth;
    	SetWindowPos(NULL, -1, -1, rectSheet.Width(), rectSheet.Height(), SWP_NOZORDER|SWP_NOMOVE);
    	CenterWindow();
    
    	// 탭컨트롤에 자식폼 위치 변경
    	MoveChildWindows(nTreeWidth, 0);
    
    	CRect rectTree(rectFrame);
    	rectTree.right = rectTree.left + nTreeWidth - nTreeSpace;
    	rectTree.top  -= 3;
    
    	// 왼쪽 메뉴 관련
    	m_cstLeftMenu.SetRect(rectTree);
    	m_cstLeftMenu.Create(this);
    	SetItems();
    	m_cstLeftMenu.SetStaticControl();
    			
    	return bResult;
    }
    
    void CPropertySheetExt::MoveChildWindows(int nDx, int nDy)
    {
    	// 탭 컨트롤에 존재하는 차일드 윈도우를
    	// 오른쪽으로 이동 시킨다.
    	CWnd* pWnd = GetWindow(GW_CHILD);
    	CString m_szWindowText;
    	while (pWnd)
    	{
    		CRect rect;
    		pWnd->GetWindowRect(rect);
    		rect.OffsetRect(nDx, nDy);
    		ScreenToClient(rect);
    		pWnd->MoveWindow(rect);
    		pWnd = pWnd->GetNextWindow();
    	}
    }
    
    void CPropertySheetExt::SetItems(void)
    {
    	CTabCtrl *pTabCtrl = GetTabControl();
    	if (!IsWindow(pTabCtrl->GetSafeHwnd()))
    	{
    		ASSERT(FALSE);
    		return;
    	}
    
    	// 탭 컨트롤에 갯수를 가져오고
    	const int nPageCount = pTabCtrl->GetItemCount();
    
    	// 탭 정볼르 입력하자.
    	for (int nPage = 0; nPage < nPageCount; ++nPage)
    	{
    		// Get title and image of the page
    		CString strPagePath;
    
    		TCITEM ti;
    		ZeroMemory(&ti, sizeof(ti));
    		ti.mask = TCIF_TEXT|TCIF_IMAGE;
    		ti.cchTextMax = MAX_PATH;
    		ti.pszText = strPagePath.GetBuffer(ti.cchTextMax);
    		ASSERT(ti.pszText);
    		if (!ti.pszText)
    			return;
    
    		pTabCtrl->GetItem(nPage, &ti);
    		strPagePath.ReleaseBuffer();
    
    		if (!nPage)
    		{
    			SetFrameWindowText(ti.pszText);
    		}
    
    		m_cstLeftMenu.AddMenu(ti.pszText);		
    	}
    }
    
    void CPropertySheetExt::SetMenuWidth(int nWidth)
    {
    	m_nLeftMenuWidth = nWidth;
    }
    
    void CPropertySheetExt::SetFrameWindowText(CString szWindowText)
    {
    	m_pFrame->SetWindowText(szWindowText);
    	m_pFrame->InvalidateRectFrame();
    }
    
    #pragma once
    
    #include "PropertyFrame.h"
    #include "CustomMenu.h"
    
    // CPropertySheetExt
    
    class CPropertySheetExt : public CPropertySheet
    {
    	DECLARE_DYNAMIC(CPropertySheetExt)
    
    public:
    	CPropertySheetExt();
    	CPropertySheetExt(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    	CPropertySheetExt(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
    	virtual ~CPropertySheetExt();
    
    private:
    
    protected:
    	int m_nLeftMenuWidth;	
    	DECLARE_MESSAGE_MAP()
    public:
    	virtual BOOL OnInitDialog();
    
    private:
    	CPropertyFrame* m_pFrame;
    	CCustomMenu m_cstLeftMenu;
    	CRect m_rect;
    
    protected:
    	void MoveChildWindows(int nDx, int nDy);
    public:
    	
    	void SetItems(void);
    	void SetMenuWidth(int nWidth);
    	void SetFrameWindowText(CString szWindowText);
    };
    
    
    
    
    
    
    
    
    
    
    

    Comment


    입력하3 1498665066



    Locations of visitors to this page