// WaitMessageDlg.cpp : 구현 파일입니다.
//

#include "stdafx.h"
#include "ConsoleApp.h"
#include "WaitMessageDlg.h"
#include ".\waitmessagedlg.h"


// CWaitMessageDlg 대화 상자입니다.

IMPLEMENT_DYNAMIC(CWaitMessageDlg, CDialog)
CWaitMessageDlg::CWaitMessageDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CWaitMessageDlg::IDD, pParent)
{
}

CWaitMessageDlg::~CWaitMessageDlg()
{
}

void CWaitMessageDlg::DoDataExchange(CDataExchange* pDX)
{
	DDX_Control(pDX, IDC_PICTURE, m_picture);
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_PROGRESS1, m_prg1);
	DDX_Control(pDX, IDC_STC, m_stc1);
	DDX_Control(pDX, IDC_STC2, m_stc2);
	DDX_Control(pDX, IDC_STC3, m_stc3);
}


BEGIN_MESSAGE_MAP(CWaitMessageDlg, CDialog)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_CANCEL_BTN, OnBnClickedCancelBtn)
END_MESSAGE_MAP()


// CWaitMessageDlg 메시지 처리기입니다.

BOOL CWaitMessageDlg::Create(UINT nIDTemplate, CWnd* pParentWnd)
{
	return CDialog::Create(nIDTemplate, pParentWnd);
}

BOOL CWaitMessageDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	if (m_picture.Load(MAKEINTRESOURCE(IDR_WAIT), _T("GIF")))
		m_picture.Draw();

	CenterWindow();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}

void CWaitMessageDlg::PostNcDestroy()
{
//	delete this;

	CDialog::PostNcDestroy();
}

BOOL CWaitMessageDlg::ShowWindow(int nCmdShow)
{
	CDialog::ShowWindow(nCmdShow);

	if (nCmdShow == SW_SHOW) {
		RedrawWindow();
		Invalidate();

		m_nTimer = (UINT)SetTimer(TIMER_ID_CHANGE, 1000, 0);
	}
	else {
		if (m_nTimer > 0)
			KillTimer(m_nTimer);
		m_nTimer = 0;
	}

	return TRUE;
}

void CWaitMessageDlg::OnTimer(UINT nIDEvent)
{
	static CString sText = "";

	if (nIDEvent == TIMER_ID_CHANGE) {
		sText += ".";
		GetDlgItem(IDC_STC)->SetWindowText(sText);
	}

	CDialog::OnTimer(nIDEvent);
}

void CWaitMessageDlg::OnBnClickedCancelBtn()
{
	switch(m_nMode)
	{
	case 0:
		PostMessage(WM_CANCEL_GETLIST,NULL,NULL);
		break;
	case 1:
		PostMessage(WM_CANCEL_MAKETREE,NULL,NULL);
		break;
	}
}
