|
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "App.h"
// exported classes
#include "BrowseForFolderDlg.h"
#include "exports.h"
//
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(IDM_SET_FOLDER, OnSetFolder)
ON_COMMAND(IDM_BBF_FILES, OnBbfFiles)
ON_COMMAND(IDM_BFF_SYS_ONLY, OnBffSysOnly)
ON_UPDATE_COMMAND_UI(IDM_BBF_FILES, OnUpdateBbfFiles)
ON_UPDATE_COMMAND_UI(IDM_BFF_SYS_ONLY, OnUpdateBffSysOnly)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame():
m_bIncFiles(false),
m_bSysOnly(true),
m_pidlSelected(0)
{
// get the "Network" pidl
IMalloc* pAlloc;
LPITEMIDLIST pidl;
SHGetMalloc(&pAlloc);
SHGetSpecialFolderLocation(0, CSIDL_NETWORK, &pidl);
m_pidlMainPath = pidl;
pAlloc->Release();
}
CMainFrame::~CMainFrame()
{
SHFree(m_pidlMainPath);
SHFree(m_pidlSelected);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::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");
info.m_pidlRoot = m_pidlMainPath;
info.m_pidlSelected = m_pidlSelected;
info.m_nFlags |= BFF_IDL_ROOT | BFF_IDL_SELECTED;
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;
// release memory for the previous default
SHFree(m_pidlSelected);
// allocate and copy newly selected
m_pidlSelected = dlg.GetTreeSelectedFullIdl();
m_wndStatusBar.SetPaneText(0, dlg.GetTreeSelectedPath());
}
void CMainFrame::OnBbfFiles()
{
m_bIncFiles = !m_bIncFiles;
}
void CMainFrame::OnBffSysOnly()
{
m_bSysOnly = !m_bSysOnly;
}
void CMainFrame::OnUpdateBbfFiles(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bIncFiles);
}
void CMainFrame::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.
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