summaryrefslogtreecommitdiff
path: root/NSCmpts/PromptClose.h
blob: a10c05863c17ad22dd17920af69cf11230a84105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// PromptClose.h: interface for the CPromptClose class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PROMPTCLOSE_H__5BB78C71_C041_11D3_8306_005056C1D336__INCLUDED_)
#define AFX_PROMPTCLOSE_H__5BB78C71_C041_11D3_8306_005056C1D336__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <atlwinhk.h>

template <class TBase = CWindow>
class CPromptCloseT : public CWindowImplBaseT< TBase >  
{
public:
	CPromptCloseT()
	{
		m_nIDRet = IDCANCEL;
	}

	bool CloseNext(UINT nRet)
	{
		m_nIDRet = nRet;
		_Module.AddCreateWndData(&m_thunk.cd, this);
		return HOOK_AND_SUBCLASS_NEXT() ? true : false;
	}


BEGIN_MSG_MAP(CPromptCloseT<TBase>)
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()

	DECLARE_HOOK_AND_SUBCLASS(CPromptCloseT<TBase>)

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		EndDialog(m_hWnd, m_nIDRet);
		UnsubclassWindow();
		// Hide this Dialog
		return TRUE;
	}

protected:
	UINT m_nIDRet;
};

typedef CPromptCloseT<CWindow> CPromptClose;

#endif // !defined(AFX_PROMPTCLOSE_H__5BB78C71_C041_11D3_8306_005056C1D336__INCLUDED_)