// ---------------------------------------------------------------------------
static bool gs_wxClipboardIsOpen = false;
+static int gs_htmlcfid = 0;
bool wxOpenClipboard()
{
gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0;
if ( !gs_wxClipboardIsOpen )
+ {
wxLogSysError(_("Failed to open the clipboard."));
+ }
return gs_wxClipboardIsOpen;
}
else
{
- wxLogDebug(wxT("Can not open clipboard without a main window."));
+ wxLogDebug(wxT("Cannot open clipboard without a main window."));
return false;
}
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- wxDataFormat::NativeFormat cf = dataFormat.GetFormatId();
+ wxDataFormat::NativeFormat cf = dataFormat.GetFormatId();
+ if (cf == wxDF_HTML)
+ cf = gs_htmlcfid;
if ( ::IsClipboardFormatAvailable(cf) )
{
{
wxBitmap *bitmap = (wxBitmap *)data;
- if ( bitmap && bitmap->Ok() )
+ if ( bitmap && bitmap->IsOk() )
{
wxDIB dib(*bitmap);
if ( dib.IsOk() )
char *buf = new char [400 + strlen(html)];
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"
// string when you overwrite it so you follow up with code to replace
// the 0 appended at the end with a '\r'...
char *ptr = strstr(buf, "StartHTML");
- sprintf(ptr+10, "%08u", strstr(buf, "<html>") - buf);
+ sprintf(ptr+10, "%08u", (unsigned)(strstr(buf, "<html>") - buf));
*(ptr+10+8) = '\r';
ptr = strstr(buf, "EndHTML");
- sprintf(ptr+8, "%08u", strlen(buf));
+ sprintf(ptr+8, "%08u", (unsigned)strlen(buf));
*(ptr+8+8) = '\r';
ptr = strstr(buf, "StartFragment");
- sprintf(ptr+14, "%08u", strstr(buf, "<!--StartFrag") - buf);
+ sprintf(ptr+14, "%08u", (unsigned)(strstr(buf, "<!--StartFrag") - buf));
*(ptr+14+8) = '\r';
ptr = strstr(buf, "EndFragment");
- sprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
+ sprintf(ptr+12, "%08u", (unsigned)(strstr(buf, "<!--EndFrag") - buf));
*(ptr+12+8) = '\r';
// Now you have everything in place ready to put on the
strcpy(ptr, buf);
GlobalUnlock(hText);
- handle = ::SetClipboardData(cfid, hText);
+ handle = ::SetClipboardData(gs_htmlcfid, hText);
// Free memory...
GlobalFree(hText);
bool wxClipboard::Open()
{
+ // Get clipboard id for HTML format...
+ if(!gs_htmlcfid)
+ gs_htmlcfid = RegisterClipboardFormat(wxT("HTML Format"));
+
// OLE opens clipboard for us
m_isOpened = true;
#if wxUSE_OLE_CLIPBOARD
// convert to NativeFormat Id
cf = formats[n].GetFormatId();
+ if (cf == wxDF_HTML)
+ cf = gs_htmlcfid;
// if the format is not available, try the next one
// this test includes implicit / sythetic formats
if ( !::IsClipboardFormatAvailable(cf) )