Form view problem
-
Hi All, I have a FormView application,which contains some edit boxes ,combo boxes,two radio buttons(radio1 and radio2)and two buttons(button1(IDOK) and button2(IDC_BUTTON_XXX)). the two buttons have BN_CLICKED handler functions. when i select radio1, button1 will be shown to the user and button2 will be hidden. select radio2 ,button2 will be shown to the user and button1 will be hidden. my problem is that in radio2 selection,i input data in the edit boxes press ENTER key,button1's BN_CLICKED handler function getting invoked instead of button2's handler. Can anyone tell me what might be the possible reason. Thanks in Advance..
-
Hi All, I have a FormView application,which contains some edit boxes ,combo boxes,two radio buttons(radio1 and radio2)and two buttons(button1(IDOK) and button2(IDC_BUTTON_XXX)). the two buttons have BN_CLICKED handler functions. when i select radio1, button1 will be shown to the user and button2 will be hidden. select radio2 ,button2 will be shown to the user and button1 will be hidden. my problem is that in radio2 selection,i input data in the edit boxes press ENTER key,button1's BN_CLICKED handler function getting invoked instead of button2's handler. Can anyone tell me what might be the possible reason. Thanks in Advance..
This is caused by the form view's default implementation. A click on the Enter key issues a command for the form to simulate a click on it's default button, which usually is the 'OK' button. In your case, it is the button 1. To remedy this, change the button 2 to be the default button of the form, or alternatively, capture keyboard messages sent to the form and filter out those containing VK_RETURN. This prevents the form from calling the default button's BN_CLICKED handler when it receives a key press event indicating the Enter/Return key was pressed. Of course, when you filter out the keyboard messages, you can custom-call the click handler for the second button as well. To simulate a click on a button, create a WM_COMMAND message, put the HIWORD of wParam to be 'BN_CLICKED' and LOWORD to be the ID of the control. The lParam can be left alone (NULL) or can be the window handle (HWND) of the control. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.