X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a5bcc4db0851bf8cd3063917511b0b17c7f9679..61f824b8198b6c916adc25f58640a22c9d523bf0:/src/msw/clipbrd.cpp diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index 842a9c94aa..cd848901bd 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -87,11 +87,11 @@ // old-style clipboard functions using Windows API // --------------------------------------------------------------------------- -static bool gs_wxClipboardIsOpen = FALSE; +static bool gs_wxClipboardIsOpen = false; bool wxOpenClipboard() { - wxCHECK_MSG( !gs_wxClipboardIsOpen, TRUE, wxT("clipboard already opened.") ); + wxCHECK_MSG( !gs_wxClipboardIsOpen, true, wxT("clipboard already opened.") ); wxWindow *win = wxTheApp->GetTopWindow(); if ( win ) @@ -107,24 +107,24 @@ bool wxOpenClipboard() { wxLogDebug(wxT("Can not open clipboard without a main window.")); - return FALSE; + return false; } } bool wxCloseClipboard() { - wxCHECK_MSG( gs_wxClipboardIsOpen, FALSE, wxT("clipboard is not opened") ); + wxCHECK_MSG( gs_wxClipboardIsOpen, false, wxT("clipboard is not opened") ); - gs_wxClipboardIsOpen = FALSE; + gs_wxClipboardIsOpen = false; if ( ::CloseClipboard() == 0 ) { wxLogSysError(_("Failed to close the clipboard.")); - return FALSE; + return false; } - return TRUE; + return true; } bool wxEmptyClipboard() @@ -133,10 +133,10 @@ bool wxEmptyClipboard() { wxLogSysError(_("Failed to empty the clipboard.")); - return FALSE; + return false; } - return TRUE; + return true; } bool wxIsClipboardOpened() @@ -151,7 +151,7 @@ bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) if ( ::IsClipboardFormatAvailable(cf) ) { // ok from the first try - return TRUE; + return true; } // for several standard formats, we can convert from some other ones too @@ -167,7 +167,7 @@ bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) #endif // wxUSE_ENH_METAFILE default: - return FALSE; + return false; } } @@ -196,7 +196,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, SelectObject(hdcSrc, old); DeleteDC(hdcMem); DeleteDC(hdcSrc); - return FALSE; + return false; } HBITMAP old1 = (HBITMAP) SelectObject(hdcMem, hBitmap); @@ -221,10 +221,13 @@ bool wxSetClipboardData(wxDataFormat dataFormat, { wxBitmap *bitmap = (wxBitmap *)data; - HGLOBAL hDIB = wxDIB::ConvertFromBitmap(GetHbitmapOf(*bitmap)); - if ( hDIB ) + if ( bitmap && bitmap->Ok() ) { - handle = ::SetClipboardData(CF_DIB, hDIB); + wxDIB dib(*bitmap); + if ( dib.IsOk() ) + { + handle = ::SetClipboardData(CF_DIB, dib.Detach()); + } } break; } @@ -271,7 +274,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, default: { wxLogError(_("Unsupported clipboard format.")); - return FALSE; + return false; } case wxDF_OEMTEXT: @@ -303,15 +306,15 @@ bool wxSetClipboardData(wxDataFormat dataFormat, case wxDF_HTML: { char* html = (char *)data; - + // Create temporary buffer for HTML header... char *buf = new char [400 + strlen(html)]; - if(!buf) return FALSE; - + if(!buf) return false; + // Get clipboard id for HTML format... static int cfid = 0; if(!cfid) cfid = RegisterClipboardFormat(wxT("HTML Format")); - + // Create a template string for the HTML header... strcpy(buf, "Version:0.9\r\n" @@ -321,7 +324,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, "EndFragment:00000000\r\n" "\r\n" "\r\n"); - + // Append the HTML... strcat(buf, html); strcat(buf, "\r\n"); @@ -330,7 +333,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, "\r\n" "\r\n" ""); - + // Now go back, calculate all the lengths, and write out the // necessary header information. Note, wsprintf() truncates the // string when you overwrite it so you follow up with code to replace @@ -338,35 +341,35 @@ bool wxSetClipboardData(wxDataFormat dataFormat, char *ptr = strstr(buf, "StartHTML"); wsprintf(ptr+10, "%08u", strstr(buf, "") - buf); *(ptr+10+8) = '\r'; - + ptr = strstr(buf, "EndHTML"); wsprintf(ptr+8, "%08u", strlen(buf)); *(ptr+8+8) = '\r'; - + ptr = strstr(buf, "StartFragment"); wsprintf(ptr+14, "%08u", strstr(buf, "