summaryrefslogtreecommitdiff
path: root/NSCmpts/BackupDestProp.h
blob: 0c7e1eec0279350770487a1a0dfc5aee5e038c74 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// BackupDestProp.h : Declaration of the CBackupDestProp

#ifndef __BACKUPDESTPROP_H_
#define __BACKUPDESTPROP_H_

#include "resource.h"       // main symbols
#include "../common/cmptdata.h"
#include <contexthelp.h>

EXTERN_C const CLSID CLSID_BackupDestProp;

/////////////////////////////////////////////////////////////////////////////
// CBackupDestProp
class ATL_NO_VTABLE CBackupDestProp :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CBackupDestProp, &CLSID_BackupDestProp>,
	public IPropertyPageImpl<CBackupDestProp>,
	public CDialogImplEx,
	public CContextHelp<CBackupDestProp>
{
// Construction
public:
	CBackupDestProp() : CDialogImplEx(IDD)
	{
		m_dwTitleID = IDS_TITLEBackupDestProp;
		m_dwHelpFileID = IDS_NSHELPFILE;
		m_dwDocStringID = IDS_DOCSTRINGBackupDestProp;
	}
	~CBackupDestProp()
		{ ATLTRACE(_T("Destroying BackupDestProp\n")); }

	enum {IDD = IDD_BACKUPDEST};

DECLARE_REGISTRY_RESOURCEID(IDR_BACKUPDESTPROP)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CBackupDestProp) 
	COM_INTERFACE_ENTRY(IPropertyPage)
END_COM_MAP()

BEGIN_MSG_MAP(CBackupDestProp)
	MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
	MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
	COMMAND_ID_HANDLER(IDC_BROWSE, OnBrowse)
	CHAIN_MSG_MAP(IPropertyPageImpl<CBackupDestProp>)
	CHAIN_MSG_MAP(CContextHelp<CBackupDestProp>)
END_MSG_MAP()

BEGIN_HELP_MAP(NS_HELP_FILE)
	HELP_ID(IDC_DEST, 4004)
	HELP_ID(IDC_BROWSE, 4003)
END_HELP_MAP

// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnBrowse(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

	STDMETHOD(Apply)(void)
	{
		// Get text from Control first if poss
		if(IsWindow())
		{
			GetDlgItemText(IDC_DEST, m_sPath.get_buffer(MAX_PATH), MAX_PATH);
			m_sPath.release_buffer();
		}

		if(!m_Data.IsInitialized())
			m_Data.Initialize(m_nObjects, m_ppUnk);

		if(!m_Data.IsInitialized())
			return E_FAIL;

		m_Data.WriteString(NS_BACKUP_REG_DEST, m_sPath);
		m_bDirty = FALSE;
		return S_OK;
	}

protected:
	CPropertyBag m_Data;
	string m_sPath;
};

#endif //__BACKUPDESTPROP_H_