I want to disable keyboard when my program Run, means that no one can use alt+F4 etc. How I can make it possible using c in window OS.
+2
A:
Pressing alt + f4 sends WM_CLOSE message. You should properly handled this message.
ralu
2010-03-09 07:40:48
How can I handle this type of messages???
Arman
2010-03-09 07:54:02
@Arman, just to note, this will only disable the keyboard in your program, not in others. Plus you can never disable CTRL+ALT+DELETE combination.
Let_Me_Be
2010-03-09 08:20:56
How to disable in c?? Any hint?
Arman
2010-03-09 08:24:16
@Arman This is normal WinAPI, just add handlers to the main message loop in your code. Its the same for C and C++.
Let_Me_Be
2010-03-09 08:27:03
+2
A:
Handle WM_SYSKEYUP , WM_SYSKEYDOWN and return 0
Here's the WndProc to handle these messages
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_KEYDOWN:
case WM_KEYUP:
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Indeera
2010-03-09 07:55:12
Win32 is a C API. When you create a sample Windows application in Visual studio, you should see the WndProc generated for you. You handle messages there like shown above.
Indeera
2010-03-09 08:28:59