• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CColorRoundDialog
    Last Modify : 27 December, 2010(02:20)
    // ColorRoundDialog.cpp : implementation file
    //
    
    // DATE		: May 09, 2007
    // CODER	: Kurome (ccd@apsat.co.kr)
    // URL		: http://www.apsat.co.kr
    //
    // VERSION	: 1.0
    //
    // Copyright Asia pasific satellite industries Co., Ltd.
    //
    
    // ---------------------------------------------------------------
    // REQUIRE
    // ---------------------------------------------------------------
    // * CButtonEx
    // * CMemDC
    // * CWndShadow
    //
    
    // ----------------------------------------------------------------
    // NOTE
    // ----------------------------------------------------------------
    // * 메시지 창을 손쉽게 만들기 위해서 DIALOG를 상속 받은 CLASS
    // * 이 클래스를 상속받아서 사용하면된다.
    // * 추가적으로 생성하려고 한다면은 색상값을 변수로 받는 것...
    //
    
    #include "stdafx.h"
    #include "Main Unit Manager.h"
    #include "ColorRoundDialog.h"
    #include "MemDC.h"
    
    // CColorRoundDialog dialog
    
    IMPLEMENT_DYNAMIC(CColorRoundDialog, CDialog)
    
    CColorRoundDialog::CColorRoundDialog(CWnd* pParent /*=NULL*/)
    	: CDialog(CColorRoundDialog::IDD, pParent)
    	, nDialogWidth(280)
    	, nDialogHeight(200)
    {
    }
    
    CColorRoundDialog::CColorRoundDialog(UINT nID, CWnd* pParent)
    : CDialog(nID, pParent)
    , nDialogWidth(280)
    , nDialogHeight(200)
    {
    }
    
    CColorRoundDialog::~CColorRoundDialog()
    {
    	delete m_pCloseButton;
    }
    
    void CColorRoundDialog::DoDataExchange(CDataExchange* pDX)
    {
    	CDialog::DoDataExchange(pDX);
    }
    
    
    BEGIN_MESSAGE_MAP(CColorRoundDialog, CDialog)
    	ON_WM_PAINT()
    	ON_WM_ERASEBKGND()
    END_MESSAGE_MAP()
    
    
    // CColorRoundDialog message handlers
    
    LRESULT CColorRoundDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
    	LRESULT nHit;
    
    	switch(message)
    	{
    	case WM_NCHITTEST:
    		nHit = DefWindowProc(message, wParam, lParam);
    		switch(nHit)
    		{
    		case HTCLIENT:
    			nHit = HTCAPTION;
    			break;
    		}
    		return nHit;
    	}
    
    	return CDialog::WindowProc(message, wParam, lParam);
    }
    
    BOOL CColorRoundDialog::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	// 윈도우에 프레임을 제거 해주자.
    	ModifyStyleEx(WS_EX_DLGMODALFRAME|WS_EX_WINDOWEDGE, 0);
    	ModifyStyle(DS_MODALFRAME|WS_DLGFRAME|WS_CAPTION, 0);
    	GetClientRect(m_rect);
    	//ClientToScreen(m_rect);
    
    	int cxFullScreen = GetSystemMetrics(SM_CXFULLSCREEN);
    	int cyFullScreen = GetSystemMetrics(SM_CYFULLSCREEN);
    
    	// 여기 수정.
    	//
    	if (cxFullScreen < (m_ptCurrent.x + nDialogWidth))
    	{
    		m_ptCurrent.x -= (nDialogWidth+25 - (cxFullScreen - m_ptCurrent.x));
    	}
    
    	if (cyFullScreen <  (m_ptCurrent.y + nDialogHeight))
    	{
    		m_ptCurrent.y -= (nDialogHeight+15 - (cyFullScreen - m_ptCurrent.y));
    	}
    
    	//MoveWindow(m_ptCurrent.x, m_ptCurrent.y + 20, nDialogWidth, nDialogHeight);	
    
    	CRgn rgn;
    	rgn.CreateRoundRectRgn(0, 0, m_rect.right+1, m_rect.bottom+1, 10, 10);
    	SetWindowRgn(rgn, true);
    	
    	CWndShadow::Initialize(AfxGetInstanceHandle());
    	WndShadow.Create(GetSafeHwnd());
    
    	m_pCloseButton = new CButtonEx();
    	m_pCloseButton->Create(L"", WS_CHILD, CRect(m_rect.right - 18, 5, m_rect.right - 10, 30), this, 1);
    	m_pCloseButton->SetLoadImage(g_imgplus.FindImageData(L"CloseButton"));
    	m_pCloseButton->ShowWindow(true);
    	
    
    	return TRUE;  // return TRUE unless you set the focus to a control
    	// EXCEPTION: OCX Property Pages should return FALSE
    }
    
    void CColorRoundDialog::OnPaint()
    {
    	CPaintDC dc(this); // device context for painting
    	
    	CPen myPen, * pOldPen;
    	CBrush myBrush, * pOldBrush;
    	CMemDC mDC(&dc, &m_rect);
    
    	myPen.CreatePen(PS_SOLID, 1, 0X00612D0B);	
    	myBrush.CreateSolidBrush(0X00E4A77D);
    
    	pOldPen	  = mDC.SelectObject(&myPen);	
    	pOldBrush = mDC.SelectObject(&myBrush);
    	//mDC.FillSolidRect(&m_rect, 0X00E4A77D);
    	mDC.RoundRect(m_rect, CPoint(10, 10));
    
    	mDC.SelectObject(pOldPen);	
    	mDC.SelectObject(pOldBrush);
    
    	myPen.DeleteObject();
    	myBrush.DeleteObject();
    }
    
    BOOL CColorRoundDialog::OnEraseBkgnd(CDC* pDC)
    {
    	return TRUE; //CDialog::OnEraseBkgnd(pDC);
    }
    
    // header
    
    #pragma once
    
    #include "WndShadow.h"
    #include "ButtonEx.h"
    
    // CColorRoundDialog dialog
    //typedef BOOL (WINAPI* FN_ANIMATE_WINDOW)(HWND,DWORD,DWORD);
    
    class CColorRoundDialog : public CDialog
    {
    	DECLARE_DYNAMIC(CColorRoundDialog)
    
    public:
    	CColorRoundDialog(CWnd* pParent = NULL);   // standard constructor
    	CColorRoundDialog(UINT nID, CWnd* pParent);   // standard constructor
    	virtual ~CColorRoundDialog();
    
    // Dialog Data
    	enum { IDD = NULL };
    
    protected:
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    
    	DECLARE_MESSAGE_MAP()
    	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
    	CRect m_rect;	
    	HBRUSH m_hBrush;
    	int nDialogWidth, nDialogHeight;
    	CPoint m_ptCurrent;
    	CWndShadow WndShadow;
    	virtual BOOL OnInitDialog();
    	afx_msg void OnPaint();
    	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    	CButtonEx* m_pCloseButton;
    
    public:
    	void SetCurrentPos(int x, int y);
    };
    
    
    DOWNLOAD : snap.png
    Filesize : 17.4Kb

    Comment


    입력하3 1503256815



    Locations of visitors to this page