{
UINT fsModifiers, vk;
PHOT_KEY pHotKey, *pLink;
HWNDhWnd;
INT iRet = 1;
WARN("DefWndSetHotKey wParam 0x%x\n", wParam);
// A hot key cannot be associated with a child window.if (pWnd->style & WS_CHILD)
return 0;
// VK_ESCAPE, VK_SPACE, and VK_TAB are invalid hot keys.if (LOWORD(wParam) == VK_ESCAPE ||
LOWORD(wParam) == VK_SPACE ||
LOWORD(wParam) == VK_TAB)
{
return -1;
}
vk = LOWORD(wParam);
fsModifiers = HIWORD(wParam);
hWnd = UserHMGetHandle(pWnd);
if (wParam)
{
pHotKey = gphkFirst;
while (pHotKey)
{
if (pHotKey->fsModifiers == fsModifiers &&
pHotKey->vk == vk &&
pHotKey->id == IDHK_REACTOS)
{
if (pHotKey->hWnd != hWnd)
iRet = 2; // Another window already has the same hot key.break;
}
/* Move to the next entry */
pHotKey = pHotKey->pNext;
}
}
pHotKey = gphkFirst;
pLink = &gphkFirst;
while (pHotKey)
{
if (pHotKey->hWnd == hWnd &&
pHotKey->id == IDHK_REACTOS)
{
/* This window has already hotkey registered */break;
}
/* Move to the next entry */
pLink = &pHotKey->pNext;
pHotKey = pHotKey->pNext;
}
if (wParam)
{
if (!pHotKey)
{
/* Create new hotkey */
pHotKey = ExAllocatePoolWithTag(PagedPool, sizeof(HOT_KEY), USERTAG_HOTKEY);
if (pHotKey == NULL)
return 0;
pHotKey->hWnd = hWnd;
pHotKey->id = IDHK_REACTOS; // Don't care, these hot keys are unrelated to the hot keys set by RegisterHotKey
pHotKey->pNext = gphkFirst;
gphkFirst = pHotKey;
}
/* A window can only have one hot key. If the window already has a hot key associated with it, the new hot key replaces the old one. */
pHotKey->pThread = NULL;
pHotKey->fsModifiers = fsModifiers;
pHotKey->vk = vk;
}
elseif (pHotKey)
{
/* Remove hotkey */
*pLink = pHotKey->pNext;
ExFreePoolWithTag(pHotKey, USERTAG_HOTKEY);
}
return iRet;
}
Generated on Mon May 28 2012 06:11:48 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.