Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / MFC

CDirectoryChangeWatcher - ReadDirectoryChangesW all wrapped up

Rate me:
Please Sign up or sign in to vote.
4.92/5 (114 votes)
11 May 2002 2.1M   39.4K   365  
This class wraps up ReadDirectoryChangesW.
/* 
DESCRIPTION:
	CFolderDialog  - Folder Selection Dialog Class

NOTES:
	Copyright(C) Armen Hakobyan, 2002
	mailto:armenh@cit.am
	
VERSION HISTORY:
	24 Mar 2002 - First release
*/

#pragma once

class CFolderDialog : public CCommonDialog
{
	DECLARE_DYNAMIC(CFolderDialog)

public:
	explicit CFolderDialog(LPCTSTR lpszTitle = NULL, 
			 LPCTSTR lpszFolderName = NULL, CWnd* pParentWnd = NULL,
			 UINT uFlags = BIF_RETURNONLYFSDIRS);
	virtual ~CFolderDialog();

public:
	virtual int		DoModal(void);
	
public:	
	AFX_INLINE LPCTSTR	GetFolderPath(void) const;
	AFX_INLINE LPCTSTR	GetFolderDisplayName(void) const;
	AFX_INLINE int		GetFolderImageIndex(void) const;	
	AFX_INLINE BOOL		SetSelectedFolder(LPCTSTR lpszPath);

	AFX_INLINE BROWSEINFO&		 GetBI(void);
	AFX_INLINE const BROWSEINFO& GetBI(void) const;
	
protected:	
	BROWSEINFO	m_bi;
	TCHAR		m_szFolderPath[MAX_PATH];
	TCHAR		m_szSelectedPath[MAX_PATH];
	TCHAR		m_szFolderDisplayName[MAX_PATH];

protected:
	DECLARE_MESSAGE_MAP()
	
	virtual void OnInitialized(void);
	virtual int	 OnValidateFailed(LPCTSTR lpstrFolderPath);
	virtual void OnSelChanged(LPITEMIDLIST /*pItemIDList*/);

protected:
	AFX_INLINE void EnableOK(BOOL bEnable = TRUE);
	AFX_INLINE void SetSelection(LPITEMIDLIST pItemIDList);
	AFX_INLINE void SetSelection(LPCTSTR lpszFolderPath);
	AFX_INLINE void SetStatusText(LPCTSTR lpszText);
	
private:
	HWND m_hWnd; // used only in the callback function
	static INT CALLBACK BrowseCallbackProc(
		HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
};

AFX_INLINE BOOL CFolderDialog::SetSelectedFolder(LPCTSTR lpszPath)
	{ ASSERT (lpszPath != NULL);
		return (lstrcpy(m_szSelectedPath, lpszPath) != NULL); }

AFX_INLINE BROWSEINFO& CFolderDialog::GetBI(void)
	{ return m_bi; }

AFX_INLINE const BROWSEINFO& CFolderDialog::GetBI(void) const
	{ return m_bi; }

// filled after a call to DoModal

AFX_INLINE LPCTSTR CFolderDialog::GetFolderPath(void) const
	{ return m_szFolderPath; }

AFX_INLINE LPCTSTR CFolderDialog::GetFolderDisplayName(void) const
	{ return m_szFolderDisplayName; }

AFX_INLINE int CFolderDialog::GetFolderImageIndex(void) const
	{ return m_bi.iImage; }

// Commands - valid to call only from handlers

AFX_INLINE void CFolderDialog::EnableOK(BOOL bEnable /*TRUE*/)
	{ ASSERT(m_hWnd != NULL); 
		::SendMessage(m_hWnd, BFFM_ENABLEOK, bEnable, 0L);}

AFX_INLINE void CFolderDialog::SetSelection(LPITEMIDLIST pItemIDList)
	{ ASSERT(m_hWnd != NULL); 
		::SendMessage(m_hWnd, BFFM_SETSELECTION, FALSE, (LPARAM)pItemIDList); }

AFX_INLINE void CFolderDialog::SetSelection(LPCTSTR lpszFolderPath)
	{ ASSERT(m_hWnd != NULL);
		::SendMessage(m_hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpszFolderPath); }

AFX_INLINE void CFolderDialog::SetStatusText(LPCTSTR lpszText)
	{ ASSERT(m_hWnd != NULL);
		::SendMessage(m_hWnd, BFFM_SETSTATUSTEXT, 0L, (LPARAM)lpszText);}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions