Index: SVN/SVNDataObject.cpp
===================================================================
--- SVN/SVNDataObject.cpp	(revision 18429)
+++ SVN/SVNDataObject.cpp	(working copy)
@@ -375,7 +375,7 @@
 		for (int i=0;i<m_svnPaths.GetCount();i++)
 		{
 			CString str = m_svnPaths[i].GetWinPathString();
-			wcscpy_s(pCurrentFilename, str.GetLength()+1, str.GetBuffer());
+			wcscpy_s(pCurrentFilename, str.GetLength()+1, (LPCWSTR)str);
 			pCurrentFilename += str.GetLength();
 			*pCurrentFilename = '\0'; // separator between file names
 			pCurrentFilename++;
Index: TortoiseMerge/FilePatchesDlg.cpp
===================================================================
--- TortoiseMerge/FilePatchesDlg.cpp	(revision 18429)
+++ TortoiseMerge/FilePatchesDlg.cpp	(working copy)
@@ -85,14 +85,9 @@
 	}
 	else
 	{
-		CString title;
-		title.LoadString(IDS_PATCH_TITLE);
-		title += _T("  ") + m_sPath;
 		CRect rect;
 		GetClientRect(&rect);
-		PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), rect.Width());
-		title.ReleaseBuffer();
-		SetWindowText(title);
+		SetTitleWithPath(rect.Width());
 		if (m_sPath.Right(1).Compare(_T("\\"))==0)
 			m_sPath = m_sPath.Left(m_sPath.GetLength()-1);
 
@@ -191,12 +186,7 @@
 		GetDlgItem(IDC_FILELIST)->MoveWindow(rect.left, rect.top, cx, cy);
 		m_cFileList.SetColumnWidth(0, cx);
 	}
-	CString title;
-	title.LoadString(IDS_PATCH_TITLE);
-	title += _T("  ") + m_sPath;
-	PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), cx);
-	title.ReleaseBuffer();
-	SetWindowText(title);
+	SetTitleWithPath(cx);
 }
 
 void CFilePatchesDlg::OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult)
@@ -412,3 +402,13 @@
 {
 	return;
 }
+
+void CFilePatchesDlg::SetTitleWithPath(int width)
+{
+	CString title;
+	title.LoadString(IDS_PATCH_TITLE);
+	title += _T("  ") + m_sPath;
+	PathCompactPath(GetDC()->m_hDC, title.GetBuffer(), width);
+	title.ReleaseBuffer();
+	SetWindowText(title);
+}
Index: TortoiseMerge/FilePatchesDlg.h
===================================================================
--- TortoiseMerge/FilePatchesDlg.h	(revision 18429)
+++ TortoiseMerge/FilePatchesDlg.h	(working copy)
@@ -107,4 +107,5 @@
 	DECLARE_MESSAGE_MAP()
 
 	CString GetFullPath(int nIndex);
+	void SetTitleWithPath(int width);
 };
Index: Utils/MiscUI/PathEdit.cpp
===================================================================
--- Utils/MiscUI/PathEdit.cpp	(revision 18429)
+++ Utils/MiscUI/PathEdit.cpp	(working copy)
@@ -21,7 +21,6 @@
 #include "PathEdit.h"
 #include "StringUtils.h"
 
-
 // CPathEdit
 
 IMPLEMENT_DYNAMIC(CPathEdit, CEdit)
@@ -34,12 +33,9 @@
 {
 }
 
-
 BEGIN_MESSAGE_MAP(CPathEdit, CEdit)
 END_MESSAGE_MAP()
 
-
-
 // CPathEdit message handlers
 
 LRESULT CPathEdit::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
@@ -51,21 +47,8 @@
 	{
 	case WM_SIZE:
 		{
-			CRect rect;
-			GetClientRect(&rect);
-			rect.right -= 5;	// assume a border size of 5 pixels
 			CString path = m_sRealText;
-
-			CDC * pDC = GetDC();
-			if (pDC)
-			{
-				CFont * pFont = pDC->SelectObject(GetFont());
-				PathCompactPath(pDC->m_hDC, path.GetBuffer(), rect.Width());
-				pDC->SelectObject(pFont);
-				ReleaseDC(pDC);
-			}
-			path.ReleaseBuffer();
-			path.Replace('\\', '/');
+			FitPathToWidth(path);
 			m_bInternalCall = true;
 			CEdit::SendMessage(WM_SETTEXT, 0, (LPARAM)(LPCTSTR)path);
 			m_bInternalCall = false;
@@ -75,22 +58,8 @@
 	case WM_SETTEXT:
 		{
 			m_sRealText = (LPCTSTR)lParam;
-
-			CRect rect;
-			GetClientRect(&rect);
-			rect.right -= 5;	// assume a border size of 5 pixels
 			CString path = m_sRealText;
-
-			CDC * pDC = GetDC();
-			if (pDC)
-			{
-				CFont * pFont = pDC->SelectObject(GetFont());
-				PathCompactPath(pDC->m_hDC, path.GetBuffer(), rect.Width());
-				pDC->SelectObject(pFont);
-				ReleaseDC(pDC);
-			}
-			path.ReleaseBuffer();
-			path.Replace('\\', '/');
+			FitPathToWidth(path);
 			lParam = (LPARAM)(LPCTSTR)path;
 			LRESULT ret = CEdit::DefWindowProc(message, wParam, lParam);
 			return ret;
@@ -118,3 +87,21 @@
 
 	return CEdit::DefWindowProc(message, wParam, lParam);
 }
+
+void CPathEdit::FitPathToWidth(CString& path)
+{
+	CRect rect;
+	GetClientRect(&rect);
+	rect.right -= 5;	// assume a border size of 5 pixels
+	
+	CDC * pDC = GetDC();
+	if (pDC)
+	{
+		CFont* previousFont = pDC->SelectObject(GetFont());
+		PathCompactPath(pDC->m_hDC, path.GetBuffer(), rect.Width());
+		path.ReleaseBuffer();
+		pDC->SelectObject(previousFont);
+		ReleaseDC(pDC);
+	}
+	path.Replace('\\', '/');
+}
Index: Utils/MiscUI/PathEdit.h
===================================================================
--- Utils/MiscUI/PathEdit.h	(revision 18429)
+++ Utils/MiscUI/PathEdit.h	(working copy)
@@ -43,6 +43,5 @@
 private:
 	CString		m_sRealText;
 	bool		m_bInternalCall;
+	void FitPathToWidth(CString& path);
 };
-
-
