I have posted a question last week asking for a way to disable Keybord and Mouse input on controls without using EnableWindow(HWND, FALSE) because that makes them grayed, which makes it hard to read its 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.
Heres 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: the focus is sent to buttonstart. Then if you click 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.
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;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, are you capturing the focus and not releasing it somehow on the other controls? If you wish to have your control accessible through tab key, simple us WS_TABSTOP in its style in the dialog resource (I am assuming you are doing it through that way).
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have posted a question last week asking for a way to disable Keybord and Mouse input on controls without using EnableWindow(HWND, FALSE) because that makes them grayed, which makes it hard to read its 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.
Heres 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: the focus is sent to buttonstart. Then if you click 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.
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;
}
Hmm, are you capturing the focus and not releasing it somehow on the other controls? If you wish to have your control accessible through tab key, simple us WS_TABSTOP in its style in the dialog resource (I am assuming you are doing it through that way).
Kip