mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
clip
This commit is contained in:
parent
661cf42e00
commit
600cb73d1b
@ -88,8 +88,7 @@ static void clipboard_callback_1(void (*callback)(const wchar_t *, bool), HANDLE
|
|||||||
WNDCLASS wc = {};
|
WNDCLASS wc = {};
|
||||||
wc.lpfnWndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
wc.lpfnWndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
#ifndef WINXP
|
static auto callbackx = [](HWND hWnd)
|
||||||
if (WM_CLIPBOARDUPDATE == message)
|
|
||||||
{
|
{
|
||||||
auto data = clipboard_get_internal();
|
auto data = clipboard_get_internal();
|
||||||
auto callback_ = reinterpret_cast<decltype(callback)>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
auto callback_ = reinterpret_cast<decltype(callback)>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
||||||
@ -100,6 +99,11 @@ static void clipboard_callback_1(void (*callback)(const wchar_t *, bool), HANDLE
|
|||||||
GetWindowThreadProcessId(ohwnd, &pid);
|
GetWindowThreadProcessId(ohwnd, &pid);
|
||||||
callback_(data.value().c_str(), pid == GetCurrentProcessId());
|
callback_(data.value().c_str(), pid == GetCurrentProcessId());
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
#ifndef WINXP
|
||||||
|
if (WM_CLIPBOARDUPDATE == message)
|
||||||
|
{
|
||||||
|
callbackx(hWnd);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static HWND nextviewer;
|
static HWND nextviewer;
|
||||||
@ -125,15 +129,7 @@ static void clipboard_callback_1(void (*callback)(const wchar_t *, bool), HANDLE
|
|||||||
break;
|
break;
|
||||||
case WM_DRAWCLIPBOARD:
|
case WM_DRAWCLIPBOARD:
|
||||||
{
|
{
|
||||||
auto data = clipboard_get_internal();
|
callbackx(hWnd);
|
||||||
auto callback_ = reinterpret_cast<decltype(callback)>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
|
||||||
if (data && callback_)
|
|
||||||
{
|
|
||||||
auto ohwnd = GetClipboardOwner();
|
|
||||||
DWORD pid;
|
|
||||||
GetWindowThreadProcessId(ohwnd, &pid);
|
|
||||||
callback_(data.value().c_str(), pid == GetCurrentProcessId());
|
|
||||||
}
|
|
||||||
if (nextviewer)
|
if (nextviewer)
|
||||||
SendMessage(nextviewer, message, wParam, lParam);
|
SendMessage(nextviewer, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user