OSDN Git Service

Use bool instead of BOOL and String instead of CString and LPCTSTR
authorMarcel Gosselin <marcelgosselin@users.sourceforge.net>
Mon, 30 Jun 2008 01:45:21 +0000 (01:45 +0000)
committerMarcel Gosselin <marcelgosselin@users.sourceforge.net>
Mon, 30 Jun 2008 01:45:21 +0000 (01:45 +0000)
Src/Common/ClipBoard.cpp
Src/Common/ClipBoard.h
Src/DirView.cpp

index 3a137a7..d9b5a16 100644 (file)
 
 /**
  * @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;
 }
index 8247514..9429eef 100644 (file)
@@ -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_
index 106513c..a5215a2 100644 (file)
@@ -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());
 }
 
 /**