Menu

Diff of /MyFileBrowser.cpp [000000] .. [r101]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/MyFileBrowser.cpp
@@ -0,0 +1,109 @@
+// MyFileBrowser.cpp : implementation file
+//
+
+//#include "pch.h"
+#include "stdafx.h"
+#include "MCE.h"
+#include "afxdialogex.h"
+#include "MyFileBrowser.h"
+
+
+// MyFileBrowser dialog
+
+IMPLEMENT_DYNAMIC(MyFileBrowser, CDialogEx)
+
+MyFileBrowser::MyFileBrowser(CWnd* pParent, CString strCaption)
+	: CDialogEx(IDD_DIALOG_FILE_BROWSER, pParent)
+{
+	m_strCaption = strCaption;
+}
+
+MyFileBrowser::~MyFileBrowser()
+{
+}
+
+void MyFileBrowser::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_MFCSHELLLIST1, m_wndShellList);
+	DDX_Control(pDX, IDC_MFCSHELLTREE1, m_wbdShellTree);
+}
+
+
+BEGIN_MESSAGE_MAP(MyFileBrowser, CDialogEx)
+	ON_BN_CLICKED(IDOK, &MyFileBrowser::OnBnClickedOk)
+	//ON_NOTIFY(TVN_SELCHANGED, IDC_MFCSHELLTREE1, &MyFileBrowser::OnTvnSelchangedMfcshelltree1)
+	ON_REGISTERED_MESSAGE(AFX_WM_CHANGE_CURRENT_FOLDER, OnChangeFolder)
+END_MESSAGE_MAP()
+
+
+// MyFileBrowser message handlers
+
+
+void MyFileBrowser::OnBnClickedOk()
+{
+	// TODO: Add your control notification handler code here
+	m_filePath = "";
+	POSITION pos = m_wndShellList.GetFirstSelectedItemPosition();
+	if (pos == NULL) {
+		//nothing is selected!
+		return;
+	}
+	int iItem = m_wndShellList.GetNextSelectedItem (pos);
+	m_wndShellList.GetItemPath(m_filePath, iItem);
+
+	CDialogEx::OnOK();	
+}
+
+BOOL MyFileBrowser::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+	SetWindowText(m_strCaption);
+	
+	m_wbdShellTree.Expand(m_wbdShellTree.GetRootItem(), TVE_EXPAND);
+	m_wbdShellTree.SetRelatedList(&m_wndShellList);
+
+	LPITEMIDLIST ppidl;
+	if (SHGetSpecialFolderLocation(GetSafeHwnd(),CSIDL_BITBUCKET, &ppidl) != NOERROR)
+	{
+		return 0;
+	}
+
+	//SHChangeNotifyEntry scnIDL;
+	//scnIDL.pidl = ppidl;
+	//scnIDL.fRecursive = TRUE;
+
+	//m_ulChangeIconNotifyID = SHChangeNotifyRegister(m_hWnd, SHCNF_ACCEPT_INTERRUPTS | SHCNF_ACCEPT_NON_INTERRUPTS, SHCNE_ALLEVENTS,  UWM_CHANGE_SYSTEM_ICON, 1, &scnIDL);
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+}
+LRESULT MyFileBrowser::OnChangeFolder(WPARAM,LPARAM)
+{
+	CString strPath;
+	if (!m_wndShellList.GetCurrentFolder (strPath) &&
+		!m_wndShellList.GetCurrentFolderName (strPath))
+	{
+		strPath = _T("????");
+		return 0;
+	}
+	//LPITEMIDLIST l = m_wndShellList.GetCurrentItemIdList();
+
+	
+
+	/*
+	if (AfxGetMainWnd () != NULL)
+	{
+		((CMainFrame*) AfxGetMainWnd ())->SetCurrFolder (strPath);
+	}
+	*/
+
+	return 0;
+}
+/*
+void MyFileBrowser::OnTvnSelchangedMfcshelltree1(NMHDR* pNMHDR, LRESULT* pResult)
+{
+	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
+	// TODO: Add your control notification handler code here
+	*pResult = 0;
+}
+*/