13#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
24 DWORD dwProcessID = 0;
25 GetWindowThreadProcessId(hWnd, &dwProcessID);
27 if (dwProcessID != (DWORD)lParam)
30 if (GetParent(hWnd) ==
nullptr)
42 DWORD dwProcessID = 0;
43 GetWindowThreadProcessId(hWnd, &dwProcessID);
45 if (dwProcessID != GetCurrentProcessId())
48 if (GetWindowLongPtr(hWnd, GWLP_HINSTANCE) == lParam)
58 WindowsClipboardHandler::WindowsClipboardHandler()
62 void WindowsClipboardHandler::initialise()
66 GetModuleFileName(0, (LPCH)&buf, MAX_PATH);
68 HINSTANCE instance = GetModuleHandle(buf);
70 EnumChildWindows(GetDesktopWindow(), (WNDENUMPROC)
EnumWindowProc, (LPARAM)instance);
77 void WindowsClipboardHandler::shutdown()
83 void WindowsClipboardHandler::handleClipboardChanged(
const std::string& _type,
const std::string& _data)
88 size_t size = (mPutTextInClipboard.size() + 1) * 2;
90 if (OpenClipboard((HWND)mHwnd))
93 HGLOBAL hgBuffer = GlobalAlloc(GMEM_DDESHARE, size);
94 wchar_t* chBuffer = hgBuffer ? (
wchar_t*)GlobalLock(hgBuffer) : nullptr;
97 memcpy(chBuffer, mPutTextInClipboard.asWStr_c_str(), size);
98 GlobalUnlock(hgBuffer);
99 SetClipboardData(CF_UNICODETEXT, hgBuffer);
106 void WindowsClipboardHandler::handleClipboardRequested(
const std::string& _type, std::string& _data)
112 if (OpenClipboard((HWND)mHwnd))
114 HANDLE hData = GetClipboardData(CF_UNICODETEXT);
115 wchar_t* chBuffer = hData ? (
wchar_t*)GlobalLock(hData) : nullptr;
124 if (mPutTextInClipboard != buff)
128 _data = text.asUTF8();
delegates::CMultiDelegate2< const std::string &, std::string & > eventClipboardRequested
delegates::CMultiDelegate2< const std::string &, const std::string & > eventClipboardChanged
static ClipboardManager & getInstance()
static UString getOnlyText(const UString &_text)
static UString toTagsString(const UString &_text)
BOOL CALLBACK EnumChildWindowProc(HWND hWnd, LPARAM lParam)
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
BOOL CALLBACK EnumWindowProc(HWND hWnd, LPARAM lParam)