Click here to Skip to main content
15,937,127 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I set which radio button is selected when I DoModal() the dialog they are in? Presently the wrong one is selected. I think I once knew, but I no longer remember.
Posted
Updated 16-Jun-11 15:25pm
v2

1 solution

There's a couple of ways, most straight forward is...
CMyDialog::OnInitDialog()
{
  CDialog::OnInitDialog();
  CButton *button = GetDlgItem( nID ); //nID is resource ID
  button->SetCheck( BST_UNCHECKED );   //Or BST_CHECKED
}
 
Share this answer
 
Comments
mcsuman 17-Jun-11 11:21am    
Tnx, that solves my problem. But I'm puzzled as to what sets the default if I don't do it explicitly. Is it the order in the resource file?
Albert Holguin 17-Jun-11 13:48pm    
You should set your own defaults in the OnInitDialog() call... if there's a variable that's linked using the DDX_Control functions, than the default loaded will be whatever that variable indicates...
mcsuman 17-Jun-11 21:29pm    
Thank you, I think I'm getting it (I wrote a lot of Windows in C++ before 2000, but since then I've been stuck in VB, and retreading my brain is painful).
Albert Holguin 17-Jun-11 21:37pm    
I know the feeling... I forget a lot of things I've learned over the years... good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900