From 8215f84b5cff86bbde09f31a5e1f8e1d96025e07 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 31 Jul 2001 21:30:30 +0000 Subject: [PATCH] Fixed "Failed to set clipboard data. (error 1418: thread does not have a clipboard open.)" error when using wxTextCtrl::Replace git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/textctrl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index caa8d82fe0..e83cf09c9a 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -690,10 +690,13 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) SendMessage(hWnd, WM_CUT, (WPARAM)0, (LPARAM)0); // Now replace with 'value', by pasting. - wxSetClipboardData(wxDF_TEXT, (wxObject *) (const wxChar *)value, 0, 0); + if (wxOpenClipboard()) { + wxSetClipboardData(wxDF_TEXT, (wxObject *) (const wxChar *)value, 0, 0); + wxCloseClipboard(); - // Paste into edit control - SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L); + // Paste into edit control + SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L); + } #else wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0."); #endif -- 2.50.0