From 33e4338a04a3486b051bb8f2bb9c6df924230699 Mon Sep 17 00:00:00 2001 From: Marcel Gosselin Date: Mon, 30 Jun 2008 01:45:21 +0000 Subject: [PATCH] Use bool instead of BOOL and String instead of CString and LPCTSTR --- Src/Common/ClipBoard.cpp | 24 ++++++++++++------------ Src/Common/ClipBoard.h | 8 +++++--- Src/DirView.cpp | 8 ++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Src/Common/ClipBoard.cpp b/Src/Common/ClipBoard.cpp index 3a137a790..d9b5a16ab 100644 --- a/Src/Common/ClipBoard.cpp +++ b/Src/Common/ClipBoard.cpp @@ -11,25 +11,25 @@ /** * @brief Copies string to clipboard. - * @param [in] pszText Text to copy to clipboard. + * @param [in] text Text to copy to clipboard. * @param [in] currentWindowHandle Handle to current window. * @return TRUE if text copying succeeds, FALSE otherwise. */ -BOOL PutToClipboard(LPCTSTR pszText, HWND currentWindowHandle) +bool PutToClipboard(const String & text, HWND currentWindowHandle) { - if (pszText == NULL || _tcslen(pszText) == 0) - return FALSE; + if (text.empty()) + return false; CWaitCursor wc; - BOOL bOK = FALSE; + bool bOK = false; if (OpenClipboard(currentWindowHandle)) { EmptyClipboard(); - HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (_tcslen(pszText)+1) * sizeof(TCHAR)); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (text.length()+1) * sizeof(TCHAR)); if (hData != NULL) { LPTSTR pszData = (LPTSTR)::GlobalLock(hData); - _tcscpy(pszData, pszText); + _tcscpy(pszData, text.c_str()); GlobalUnlock(hData); UINT fmt = GetClipTcharTextFormat(); bOK = SetClipboardData(fmt, hData) != NULL; @@ -45,9 +45,9 @@ BOOL PutToClipboard(LPCTSTR pszText, HWND currentWindowHandle) * @param [in] currentWindowHandle Handle to current window. * @return TRUE if retrieving the clipboard text succeeds, FALSE otherwise. */ -BOOL GetFromClipboard(CString & text, HWND currentWindowHandle) +bool GetFromClipboard(String & text, HWND currentWindowHandle) { - BOOL bSuccess = FALSE; + bool bSuccess = false; if (OpenClipboard(currentWindowHandle)) { UINT fmt = GetClipTcharTextFormat(); @@ -59,7 +59,7 @@ BOOL GetFromClipboard(CString & text, HWND currentWindowHandle) { text = pszData; GlobalUnlock(hData); - bSuccess = TRUE; + bSuccess = true; } } CloseClipboard(); @@ -71,8 +71,8 @@ BOOL GetFromClipboard(CString & text, HWND currentWindowHandle) * @brief Checks if the clipboard allows Unicode format. * @return TRUE if Unicode is supported, FALSE otherwise. */ -BOOL TextInClipboard() +bool TextInClipboard() { UINT fmt = GetClipTcharTextFormat(); - return IsClipboardFormatAvailable(fmt); + return IsClipboardFormatAvailable(fmt) != FALSE; } diff --git a/Src/Common/ClipBoard.h b/Src/Common/ClipBoard.h index 8247514e5..9429eefbf 100644 --- a/Src/Common/ClipBoard.h +++ b/Src/Common/ClipBoard.h @@ -9,8 +9,10 @@ #ifndef _CLIPBOARD_H_ #define _CLIPBOARD_H_ -BOOL PutToClipboard(LPCTSTR pszText, HWND currentWindowHandle); -BOOL GetFromClipboard(CString & text, HWND currentWindowHandle); -BOOL TextInClipboard(); +#include "UnicodeString.h" + +bool PutToClipboard(const String & text, HWND currentWindowHandle); +bool GetFromClipboard(String & text, HWND currentWindowHandle); +bool TextInClipboard(); #endif // _CLIPBOARD_H_ diff --git a/Src/DirView.cpp b/Src/DirView.cpp index 106513cda..a5215a273 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -2736,7 +2736,7 @@ void CDirView::OnCopyLeftPathnames() strPaths += _T("\r\n"); } } - PutToClipboard(strPaths.c_str(), AfxGetMainWnd()->GetSafeHwnd()); + PutToClipboard(strPaths, AfxGetMainWnd()->GetSafeHwnd()); } /** @@ -2761,7 +2761,7 @@ void CDirView::OnCopyRightPathnames() strPaths += _T("\r\n"); } } - PutToClipboard(strPaths.c_str(), AfxGetMainWnd()->GetSafeHwnd()); + PutToClipboard(strPaths, AfxGetMainWnd()->GetSafeHwnd()); } /** @@ -2796,7 +2796,7 @@ void CDirView::OnCopyBothPathnames() strPaths += _T("\r\n"); } } - PutToClipboard(strPaths.c_str(), AfxGetMainWnd()->GetSafeHwnd()); + PutToClipboard(strPaths, AfxGetMainWnd()->GetSafeHwnd()); } /** @@ -2816,7 +2816,7 @@ void CDirView::OnCopyFilenames() strPaths += _T("\r\n"); } } - PutToClipboard(strPaths.c_str(), AfxGetMainWnd()->GetSafeHwnd()); + PutToClipboard(strPaths, AfxGetMainWnd()->GetSafeHwnd()); } /** -- 2.11.0