]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed some bugs in new code (CanPaste, GetSelection)
authorJulian Smart <julian@anthemion.co.uk>
Tue, 6 Apr 1999 20:26:41 +0000 (20:26 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 6 Apr 1999 20:26:41 +0000 (20:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/textctrl.cpp

index d08a18f0286ab4f512ece930c72f12b0446cf93e..2642a90de4ce474234585cb93fc6cda1cf3616a9 100644 (file)
@@ -747,8 +747,24 @@ bool wxTextCtrl::CanCut() const
 
 bool wxTextCtrl::CanPaste() const
 {
-    int dataFormat = 0; // 0 == any format
-    return (::SendMessage( (HWND) GetHWND(), EM_CANPASTE, (WPARAM) (UINT) dataFormat, 0) != 0);
+#if wxUSE_RICHEDIT
+    if (m_isRich)
+    {
+        int dataFormat = 0; // 0 == any format
+        return (::SendMessage( (HWND) GetHWND(), EM_CANPASTE, (WPARAM) (UINT) dataFormat, 0) != 0);
+    }
+#endif
+    if (!IsEditable())
+        return FALSE;
+
+    // Standard edit control: check for straight text on clipboard
+    bool isTextAvailable = FALSE;
+    if (::OpenClipboard((HWND) wxTheApp->GetTopWindow()->GetHWND()))
+    {
+        isTextAvailable = (::IsClipboardFormatAvailable(CF_TEXT) != 0);
+        ::CloseClipboard();
+    }
+    return isTextAvailable;
 }
 
 // Undo/redo
@@ -796,8 +812,8 @@ void wxTextCtrl::GetSelection(long* from, long* to) const
     }
 #endif
     DWORD dwStart, dwEnd;
-    WPARAM wParam = (WPARAM) (DWORD*) dwStart; // receives starting position
-    LPARAM lParam = (LPARAM) (DWORD*) dwEnd;   // receives ending position
+    WPARAM wParam = (WPARAM) (DWORD*) dwStart; // receives starting position
+    LPARAM lParam = (LPARAM) (DWORD*) dwEnd;   // receives ending position
 
     ::SendMessage((HWND) GetHWND(), EM_GETSEL, wParam, lParam);