I have posted a question on other board asking for a way to disable Keybord and Mouse input on controls without using EnableWindow(HWND, FALSE) because that makes the controls grayed, which makes it hard for the user to read itīs content.

A guy answered that a good way would be to intercept the FOCUS messages and direct the focus elsewhere.

I thought that would be a great solution, but as a beginner, i couldnt code something 100% functional.

Hereīs what i have right now. The problem with this piece of code is kindda weird: It works only once, i mean, if you click over one of the controls, it does not receives the focus and the focus is sent to buttonstart (OK!). Then if you click again over any control, it receives the focus. My question is: Why the hell would this code work only for the first click?


Any help would be appreciated.

Code:
case WM_KILLFOCUS: 
if (((LOWORD(wParam))==IDC_CLEARBUTTON) || /* This are the controls that can receive focus */ 
((LOWORD(wParam))==IDC_CHECKSCROLL) || 
((LOWORD(wParam))==IDC_COPYBUTTON) || 
((LOWORD(wParam))==IDC_BUTTONSTART) || 
((LOWORD(wParam))==IDC_BUTTONSTOP) || 
((LOWORD(wParam))==IDC_BUTTONVIEWLOG) || 
((LOWORD(wParam))==IDC_BUTTONABOUT)) { 
return DefWindowProc (mainWindow, messages, wParam, lParam); 
return 0; 
} 
else { /* For the controls that cannot receive focus */ 
SetFocus(buttonstart); /*Lets set the focus elsewhere */ 
return 0; 
}