Very strange behaviour of radio button...

Started by
2 comments, last by Floating 20 years, 6 months ago
Hi, I noticed a very strange thing: If a radio button has its "tab stop" option selected and is the first object (or first active object) in the tab order of the dialog, then its function "BN_CLICKED" will automatically be called when the dialog is initialized!!! If there are other radio buttons with exactly the same properties but which come after in the tab order of the dialog, their "BN_CLICKED" functions will not be called. How come? I tried with many different dialogs and it is always the same. I don''t wanna my "BN_CLICKED" function to be called when the user didn''t click the radio button!! Is this a bug or is there a good explanation for this? Meanwhile I just put a button as first object in the tab order to overcome this problem, but I am not happy with that... Thanks for your help
Advertisement
try changing the return value in your initdialog from true to false.
yep, as AP above indicated, it''s due to the response to the WM_INITDIALOG message being returned as TRUE, which tells the Dialog routine that it needs to set the focus to the first control in the tab order. if that control is a radio button, then by definition setting the focus to that radio button causes that radio button''s "clicked event" to be "fired," resulting in the BN_CLICKED message being sent.

if FALSE is returned in response to the WM_INITDIALOG message then the Dialog routine will "assume" that the DialogProc has taken care of setting the focus.
Thanks a lot APs!!!
That makes sense

This topic is closed to new replies.

Advertisement