Click here to Skip to main content
15,896,522 members
Articles / Desktop Programming / MFC

"Browse For Folder" dialog alike with source

Rate me:
Please Sign up or sign in to vote.
4.60/5 (5 votes)
5 Sep 2001 115K   1.7K   38  
Shell interfaces in use. IShellFolder, IEnumIDList, etc.
// AppView.cpp : implementation of the CAppView class
//

#include "stdafx.h"
// exported classes
#include "BrowseForFolderDlg.h"
#include "exports.h"
//
#include "App.h"
#include "AppDoc.h"
#include "AppView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAppView

IMPLEMENT_DYNCREATE(CAppView, CView)

BEGIN_MESSAGE_MAP(CAppView, CView)
	//{{AFX_MSG_MAP(CAppView)
	ON_COMMAND(IDM_SET_FOLDER, OnSetFolder)
	ON_COMMAND(IDM_BBF_FILES, OnBbfFiles)
	ON_UPDATE_COMMAND_UI(IDM_BBF_FILES, OnUpdateBbfFiles)
	ON_COMMAND(IDM_BFF_SYS_ONLY, OnBffSysOnly)
	ON_UPDATE_COMMAND_UI(IDM_BFF_SYS_ONLY, OnUpdateBffSysOnly)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAppView construction/destruction

CAppView::CAppView():
m_bIncFiles(false),
m_bSysOnly(true)
{
	// TODO: add construction code here

}

CAppView::~CAppView()
{
}

BOOL CAppView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CAppView drawing

void CAppView::OnDraw(CDC* pDC)
{
	CAppDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	CString strMsg = "Working Directory: <";
	strMsg += m_strPath;
    strMsg += ">";

	pDC->TextOut(0, 0, strMsg);
}

/////////////////////////////////////////////////////////////////////////////
// CAppView printing

BOOL CAppView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CAppView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CAppView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CAppView diagnostics

#ifdef _DEBUG
void CAppView::AssertValid() const
{
	CView::AssertValid();
}

void CAppView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CAppDoc* CAppView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAppDoc)));
	return (CAppDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CAppView message handlers

void CAppView::OnSetFolder() 
{
  CBrowseForFolderDlg::BFFINFO info;
  memset(&info, 0, sizeof(info));
  info.m_pParent = this;
  strcpy(info.m_szTitle, "Browse For Folder");
  strcpy(info.m_szMsg, "Select the Voice Mail Folder");
  strcpy(info.m_szSelected, m_strPath);
  info.m_nFlags |= (m_bIncFiles) ? BFF_INCLUDE_FILES : info.m_nFlags;
  info.m_nFlags |= (m_bSysOnly) ? BFF_SYSTEM_ONLY : info.m_nFlags;

  CBrowseForFolderDlg dlg(&info);
  if (dlg.DoModal() == IDCANCEL)
	return;

  m_strPath = dlg.GetTreeSelectedPath();
  Invalidate();
}

void CAppView::OnBbfFiles() 
{
  m_bIncFiles = !m_bIncFiles;
}

void CAppView::OnUpdateBbfFiles(CCmdUI* pCmdUI) 
{
  pCmdUI->SetCheck(m_bIncFiles);
}

void CAppView::OnBffSysOnly() 
{
  m_bSysOnly = !m_bSysOnly;
}

void CAppView::OnUpdateBffSysOnly(CCmdUI* pCmdUI) 
{
  pCmdUI->SetCheck(m_bSysOnly);
}

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



Comments and Discussions