Skip to content

Instantly share code, notes, and snippets.

@MarioLiebisch
Created September 3, 2014 14:55
Show Gist options
  • Save MarioLiebisch/aaa5eb7b9e62eac4c086 to your computer and use it in GitHub Desktop.
Save MarioLiebisch/aaa5eb7b9e62eac4c086 to your computer and use it in GitHub Desktop.
Snippet from a custom SFML extension for direct clipboard access.
////////////////////////////////////////////////////////////
ClipboardImpl& ClipboardImpl::operator >> (sf::String& data)
{
data = "";
if (!OpenClipboard(NULL))
return *this;
if (IsClipboardFormatAvailable(CF_UNICODETEXT))
{
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
Uint16 *pStart = static_cast<Uint16*>(GlobalLock(hData));
Uint16 *pEnd = pStart;
for (; *pEnd; ++pEnd);
data = String::fromUtf16(pStart, pEnd);
GlobalUnlock(hData);
}
CloseClipboard();
return *this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment