Created
September 3, 2014 14:55
-
-
Save MarioLiebisch/aaa5eb7b9e62eac4c086 to your computer and use it in GitHub Desktop.
Snippet from a custom SFML extension for direct clipboard access.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////// | |
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