#pragma once
#include "afxcmn.h"

// CWaitDlg dialog

static const UINT WM_USER_PULSE = WM_USER + 1000;

#include "resource.h"

class CWaitDlg : public CDialog
{
	DECLARE_DYNAMIC(CWaitDlg)

public:
	CWaitDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CWaitDlg();

// Dialog Data
	enum { IDD = IDD_WAIT_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	CProgressCtrl m_ctlProgress;
	afx_msg LRESULT OnPulse( WPARAM wp, LPARAM lp );
public:
	virtual BOOL OnInitDialog();
private:
	static CWaitDlg* m_pInstance;
public:
	static void Hide()
	{
		if(m_pInstance)
			m_pInstance->ShowWindow(SW_HIDE);
	};
};

class CWait
{
public:
	CWait( string sMsg, CWnd* pParent );
	~CWait();

protected:

	static DWORD CALLBACK _Thread( LPVOID pParam ){ reinterpret_cast<CWait*>(pParam)->Thread(); return 0; };

	void Thread();

private:

	CWaitDlg* m_pDlg;
	HANDLE m_hThread;
	bool m_bStop;
};
