[commit] r1836 - in trunk/GME: Gme MgaUtil

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Feb 24 09:53:05 CST 2012


Author: ksmyth
Date: Fri Feb 24 09:53:05 2012
New Revision: 1836

Log:
Under Vista+, use shell FileOpenDialog for browsing directories. (SHBrowseForFolder is so terrible)

Added:
   trunk/GME/Gme/GMEVistaUtil.cpp   (contents, props changed)
Modified:
   trunk/GME/Gme/GME.vcxproj
   trunk/GME/Gme/GME.vcxproj.filters
   trunk/GME/Gme/MgaOpenDlg.cpp
   trunk/GME/Gme/NewXmlbackendProjDlg.cpp
   trunk/GME/MgaUtil/GmeDlg.cpp
   trunk/GME/MgaUtil/MgaUtil.vcxproj
   trunk/GME/MgaUtil/MgaUtil.vcxproj.filters
   trunk/GME/MgaUtil/UACUtils.cpp
   trunk/GME/MgaUtil/UACUtils.h

Modified: trunk/GME/Gme/GME.vcxproj
==============================================================================
--- trunk/GME/Gme/GME.vcxproj	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/Gme/GME.vcxproj	Fri Feb 24 09:53:05 2012	(r1836)
@@ -315,6 +315,12 @@
     <ClCompile Include="GmePrintDialog.cpp" />
     <ClCompile Include="GMESearch.cpp" />
     <ClCompile Include="GMEView.cpp" />
+    <ClCompile Include="GMEVistaUtil.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
     <ClCompile Include="GraphicsUtil.cpp" />
     <ClCompile Include="GuiMeta.cpp" />
     <ClCompile Include="GUIObject.cpp" />

Modified: trunk/GME/Gme/GME.vcxproj.filters
==============================================================================
--- trunk/GME/Gme/GME.vcxproj.filters	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/Gme/GME.vcxproj.filters	Fri Feb 24 09:53:05 2012	(r1836)
@@ -222,6 +222,9 @@
     <ClCompile Include="SyncObjsListCtrl.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="GMEVistaUtil.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="AnnotatorEventSink.rgs">

Added: trunk/GME/Gme/GMEVistaUtil.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/GME/Gme/GMEVistaUtil.cpp	Fri Feb 24 09:53:05 2012	(r1836)
@@ -0,0 +1,41 @@
+
+#define NTDDI_VERSION 0x06000000
+#define _WIN32_WINNT 0x0600
+
+#include <afxwin.h>
+#include <ShObjIdl.h>
+#include <atlcomcli.h>
+#include <atlstr.h>
+
+HRESULT VistaBrowseDirectory(CString& directory)
+{
+	CComPtr<IFileDialog> pfd;
+	HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, 
+					  NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
+	if (FAILED(hr))
+		return hr;
+
+	DWORD dwFlags;
+	hr = pfd->GetOptions(&dwFlags);
+	if (FAILED(hr))
+		return hr;
+	hr = pfd->SetOptions(dwFlags | FOS_FORCEFILESYSTEM | FOS_PICKFOLDERS);
+	if (FAILED(hr))
+		return hr;
+	hr = pfd->Show(NULL);
+	if (FAILED(hr))
+		return hr;
+
+	CComPtr<IShellItem> psiResult;
+	hr = pfd->GetResult(&psiResult);
+	if (FAILED(hr))
+		return hr;
+	PWSTR pszFilePath = NULL;
+	hr = psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
+	if (FAILED(hr))
+		return hr;
+	directory = pszFilePath;
+	CoTaskMemFree(pszFilePath);
+
+	return hr;
+}

Modified: trunk/GME/Gme/MgaOpenDlg.cpp
==============================================================================
--- trunk/GME/Gme/MgaOpenDlg.cpp	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/Gme/MgaOpenDlg.cpp	Fri Feb 24 09:53:05 2012	(r1836)
@@ -53,7 +53,7 @@
 		flag_meta = false;
 		break;
 	case NewDialog:
-		title = _T("New");
+		title = _T("New Project");
 		filemsg = _T("Create project file");
         xmlfilemsg = _T("Create multi user project");
 		flag_isopen = true;
@@ -188,6 +188,7 @@
                 }
                 else
                 {
+					// KMS: FIXME: I think this is dead code
                     // open existing multiuser project
                     BROWSEINFO bi;
 

Modified: trunk/GME/Gme/NewXmlbackendProjDlg.cpp
==============================================================================
--- trunk/GME/Gme/NewXmlbackendProjDlg.cpp	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/Gme/NewXmlbackendProjDlg.cpp	Fri Feb 24 09:53:05 2012	(r1836)
@@ -5,6 +5,8 @@
 #include "gme.h"
 #include "NewXmlbackendProjDlg.h"
 #include <direct.h>
+#include "../MgaUtil/UACUtils.h"
+
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -71,8 +73,19 @@
 /////////////////////////////////////////////////////////////////////////////
 // CNewXmlbackendProjDlg message handlers
 
+// GMEVistaUtil.cpp:
+HRESULT VistaBrowseDirectory(CString& directory);
+
 void CNewXmlbackendProjDlg::OnButtonBrowseLoc() 
 {
+	if (CUACUtils::isVistaOrLater())
+	{
+		UpdateData();
+		HRESULT hr = VistaBrowseDirectory(m_location);
+		UpdateData(FALSE);
+		return;
+	}
+
 	BROWSEINFO bi;
 
 	TCHAR szDisplayName[MAX_PATH];

Modified: trunk/GME/MgaUtil/GmeDlg.cpp
==============================================================================
--- trunk/GME/MgaUtil/GmeDlg.cpp	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/MgaUtil/GmeDlg.cpp	Fri Feb 24 09:53:05 2012	(r1836)
@@ -7,6 +7,8 @@
 #include "GmeDlg.h"
 #include "DirDialog.h"
 #include "comcat.h"
+#include "UACUtils.h"
+
 //#include "basetyps.h"
 const GUID CATID_ActiveScript = { 0xf0b7a1a1, 0x9847, 0x11cf, { 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64} };
 
@@ -114,9 +116,18 @@
 
 //AFX_MANAGE_STATE( AfxGetStaticModuleState()); 
 
+// GMEVistaUtil.cpp:
+HRESULT VistaBrowseDirectory(CString& directory);
 
 CString CGmeDlg::getDirectory( const CString& text = _T("Specify the icons directory"))
 {
+	if (CUACUtils::isVistaOrLater())
+	{
+		CString ret;
+		HRESULT hr = VistaBrowseDirectory(ret);
+		return ret;
+	}
+
 	BROWSEINFO bi;
 	TCHAR szDir[MAX_PATH];
 	CString Dir = _T("");

Modified: trunk/GME/MgaUtil/MgaUtil.vcxproj
==============================================================================
--- trunk/GME/MgaUtil/MgaUtil.vcxproj	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/MgaUtil/MgaUtil.vcxproj	Fri Feb 24 09:53:05 2012	(r1836)
@@ -267,6 +267,12 @@
     </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\Gme\GMEVistaUtil.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
     <ClCompile Include="AlterNmspDlg.cpp" />
     <ClCompile Include="AnnotationAspectList.cpp" />
     <ClCompile Include="AnnotationBrowserDlg.cpp" />

Modified: trunk/GME/MgaUtil/MgaUtil.vcxproj.filters
==============================================================================
--- trunk/GME/MgaUtil/MgaUtil.vcxproj.filters	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/MgaUtil/MgaUtil.vcxproj.filters	Fri Feb 24 09:53:05 2012	(r1836)
@@ -144,6 +144,9 @@
     <ClCompile Include="UACUtils.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\Gme\GMEVistaUtil.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <None Include="MgaUtil.def">

Modified: trunk/GME/MgaUtil/UACUtils.cpp
==============================================================================
--- trunk/GME/MgaUtil/UACUtils.cpp	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/MgaUtil/UACUtils.cpp	Fri Feb 24 09:53:05 2012	(r1836)
@@ -5,18 +5,6 @@
 #define BCM_FIRST               0x1600      // Button control messages
 #define BCM_SETSHIELD            (BCM_FIRST + 0x000C)
 
-bool CUACUtils::isVistaOrLater()
-{ 
-	OSVERSIONINFO osvi;
-
-	::ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
-    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-
-    GetVersionEx(&osvi);
-
-	return (osvi.dwMajorVersion >= 6);
-}
-
 void CUACUtils::SetShieldIcon(const CButton& button, bool on)
 {
 	/*

Modified: trunk/GME/MgaUtil/UACUtils.h
==============================================================================
--- trunk/GME/MgaUtil/UACUtils.h	Fri Feb 24 09:52:47 2012	(r1835)
+++ trunk/GME/MgaUtil/UACUtils.h	Fri Feb 24 09:53:05 2012	(r1836)
@@ -5,7 +5,16 @@
 class CUACUtils
 {
 public:
-	static bool isVistaOrLater();
+	static bool isVistaOrLater() {
+		OSVERSIONINFO osvi;
+
+		::ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+		osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+		GetVersionEx(&osvi);
+
+		return (osvi.dwMajorVersion >= 6);
+	}
 
 	template <typename T>
 	static HRESULT CreateElevatedInstance(REFCLSID classId,


More information about the gme-commit mailing list