|
|
<elmosquera@xxxxxxxxxxxxxx> wrote in message
news:f6dcc9de138e.4476c7e0@xxxxxxxxxxxxxxxxx
> Thanks you for your help, is a good idea. I like it becouse is C++ but I
want to use this apis with Qt4. Do you know how to use them (WINAPI) with
Qt4.
Not sure I understand your question. This has nothing to do
with Qt. You need to use the windows calls directly.
> I have an idea including windows.h in my application. But I don't know how
to call it.
I'm (thankfully) not an mfc/winapi expert. To trap the keyboard, you need
to create a keyboard hook and write a callback function.
Here's some code from an older borland project that I have. I found this
mostly by googling and modified it to compile. It doesn't deal directly
with ctrl alt del but is for the alt tab, etc. No guarantees
here <g>
Note that it is tested only on win2k and may not work on previous versions:
//The callback
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM
lParam)
{
BOOL fEatKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN: case WM_SYSKEYDOWN:
case WM_KEYUP: case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
fEatKeystroke =
((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0))
||
(p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN) || (p->vkCode
== VK_APPS) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000)
!= 0));
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
lParam));
}
// To use it:
if(block_keyboard)
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
(HOOKPROC)LowLevelKeyboardProc, HInstance, 0);
else
UnhookWindowsHookEx(hhkLowLevelKybd);
HTH
--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/
|
|