user32/msgbox: Use a windows hook to trap Ctrl+C

This commit is contained in:
Alistair Leslie-Hughes 2024-03-06 20:21:36 +11:00
parent 375ff622d1
commit 083102cd83

View file

@ -394,6 +394,22 @@ static void MSGBOX_CopyToClipbaord( HWND hwnd )
free(text);
}
HHOOK msghook_handle;
LRESULT CALLBACK msg_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
{
MSG *msg = (MSG *)lParam;
if (nCode == MSGF_DIALOGBOX && msg->message == WM_KEYUP)
{
if ( (msg->wParam == 'C' || msg->wParam == 'c') && (NtUserGetKeyState(VK_CONTROL) & 0x8000))
{
MSGBOX_CopyToClipbaord(GetParent(msg->hwnd));
}
}
return NtUserCallNextHookEx(msghook_handle, nCode, wParam, lParam);
}
/**************************************************************************
* MSGBOX_DlgProc
*
@ -409,6 +425,7 @@ static INT_PTR CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
SetWindowContextHelpId(hwnd, mbp->dwContextHelpId);
MSGBOX_OnInit(hwnd, mbp);
SetPropA(hwnd, "WINE_MSGBOX_HELPCALLBACK", mbp->lpfnMsgBoxCallback);
msghook_handle = SetWindowsHookExA(WH_MSGFILTER, msg_hook_proc, NULL, GetCurrentThreadId());
break;
}
@ -416,6 +433,10 @@ static INT_PTR CALLBACK MSGBOX_DlgProc( HWND hwnd, UINT message,
MSGBOX_CopyToClipbaord(hwnd);
break;
case WM_DESTROY:
NtUserUnhookWindowsHookEx(msghook_handle);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{