• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    CDialogExThin
    Last Modify : 27 December, 2010(02:37)
    // DialogExThin.cpp : implementation file
    //
    
    // DATE		: March 12, 2007
    // CODER	: Kurome (aucd29@gmail.com)
    //
    //
    // -------------------------------------------------------
    // REQUIRE
    // -------------------------------------------------------
    // CImageLoader
    // http://www.sarangnamu.net/basic/basic_view.php?no=2839
    //
    // CParserXML
    // http://www.sarangnamu.net/basic/basic_view.php?no=550
    //
    // -------------------------------------------------------
    // NOTE : March 12, 2007
    // -------------------------------------------------------
    // * 프레임이 없는 다이얼로그를 쉽게 만들어 보도록 하기
    //   위해서 만든다.
    // * 백그라운드 이미지를 넣을 수 있다.
    // * 이미지 크기로 자동으로 윈도우가 조절된다.
    // * ESC로 윈도우가 종료되는 걸 막을 수 있다.
    //
    
    #include "stdafx.h"
    #include "dlgThinFrame.h"
    #include "DialogExThin.h"
    
    
    // CDialogExThin dialog
    
    IMPLEMENT_DYNAMIC(CDialogExThin, CDialog)
    
    CDialogExThin::CDialogExThin(CWnd* pParent /*=NULL*/)
    : CDialog(CDialogExThin::IDD, pParent)
    , m_bPan(true)
    , m_pBitmap(NULL)
    , m_bDialogThinLoad(false)
    , m_bESCClose(true)
    , m_bResize(true)
    {
    
    }
    
    CDialogExThin::CDialogExThin(UINT nID, CWnd* pParent)
    : CDialog(nID, pParent)
    , m_bPan(true)
    , m_pBitmap(NULL)
    , m_bDialogThinLoad(false)
    , m_bESCClose(true)
    , m_bResize(true)
    {
    
    }
    
    CDialogExThin::~CDialogExThin()
    {
    	if (m_pBitmap)
    	{
    		m_pBitmap->DeleteObject();
    	}
    }
    
    BEGIN_MESSAGE_MAP(CDialogExThin, CDialog)
    	ON_WM_PAINT()
    END_MESSAGE_MAP()
    
    
    // CDialogExThin message handlers
    
    BOOL CDialogExThin::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	// 윈도우에 프레임을 제거 해주자.
    	GetClientRect(m_rect);
    	ClientToScreen(m_rect);
    	ModifyStyleEx(WS_EX_DLGMODALFRAME|WS_EX_WINDOWEDGE, 0);
    	ModifyStyle(DS_MODALFRAME|WS_DLGFRAME|WS_CAPTION, 0);
    	MoveWindow(m_rect);
    
    	return TRUE;  // return TRUE unless you set the focus to a control
    	// EXCEPTION: OCX Property Pages should return FALSE
    }
    
    LRESULT CDialogExThin::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
    	if (m_bPan)
    	{
    		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);
    }
    
    void CDialogExThin::OnPaint()
    {
    	CPaintDC dc(this); // device context for painting
    	
    	if (m_pBitmap)
    	{
    		InitObject(&dc);
    		dc.BitBlt(0, 0, m_rect.Width(), m_rect.Height(), &mDC, 0, 0, SRCCOPY);
    	}
    }
    
    void CDialogExThin::InitObject(CDC* pDC)
    {
    	if (!m_bDialogThinLoad)
    	{
    		mDC.CreateCompatibleDC(pDC);
    		mDC.SelectObject(m_pBitmap);
    
    		BITMAP bm;
    		m_pBitmap->GetObject(sizeof(BITMAP), &bm);
    		mDC.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &mDC, 0, 0, SRCCOPY);
    
    		if (m_bResize)
    		{
    			// 이미지 사이즈로 윈도우를 변경하자.
    			m_rect.right  = m_rect.left + bm.bmWidth;
    			m_rect.bottom = m_rect.top + bm.bmHeight;
    			MoveWindow(m_rect);
    			CenterWindow();
    		}
    
    		m_bDialogThinLoad = true;
    	}
    }
    
    void CDialogExThin::SetBitmap(CString m_szName)
    {
    	m_pBitmap = FindBitmap(m_szName);
    }
    
    void CDialogExThin::OnCancel()
    {
    	if (m_bESCClose)
    	{
    		__super::OnCancel();
    	}
    }
    
    void CDialogExThin::OnOK()
    {
    	if (m_bESCClose)
    	{
    		__super::OnOK();
    	}
    }
    
    void CDialogExThin::SetPan(bool bPan)
    {
    	m_bPan = bPan;
    }
    
    void CDialogExThin::SetESCClose(bool bClose)
    {
    	m_bESCClose = bClose;
    }
    
    void CDialogExThin::SetResize(bool bResize)
    {
    	m_bResize = bResize;
    }
    
    #pragma once
    
    #include <winuser.h>
    #include "ImageLoader.h"
    
    // CDialogExThin dialog
    
    class CDialogExThin : public CDialog, public CImageLoader
    {
    	DECLARE_DYNAMIC(CDialogExThin)
    
    public:
    	CDialogExThin(CWnd* pParent = NULL);   // standard constructor
    	CDialogExThin(UINT nID, CWnd* pParent);   // standard constructor
    	virtual ~CDialogExThin();
    
    // Dialog Data
    	enum { IDD = NULL };
    
    	DECLARE_MESSAGE_MAP()
    	virtual BOOL OnInitDialog();
    
    protected:
    	CDC mDC;
    	bool m_bPan, m_bDialogThinLoad, m_bESCClose;
    	bool m_bResize;
    	CRect m_rect;
    	CBitmap* m_pBitmap;
    
    	virtual void OnOK();
    	virtual void OnCancel();	
    	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
    public:
    	afx_msg void OnPaint();
    	virtual void InitObject(CDC* pDC);
    	void SetBitmap(CString m_szName);
    	void SetPan(bool bPan);
    	void SetESCClose(bool bClose);
    	void SetResize(bool bResize);
    };
    

    Comment


    입력하3 1508772208



    Locations of visitors to this page