Solved

Radio Button not Checking

Posted on 2004-04-09
4
1,045 Views
Last Modified: 2013-11-20
Hi, I am a newbie C programmer and am pulling my hair out on this simple problem.

I have 2 radio buttons "IDC_TargetMD" & "IDC_TargetSC" in group "IDC_STATIC"

Both buttons have the "Auto" property checked and "IDC_TargetSC" has the "Group" Property checked.

When "TargetChoice" equals 2, the mesage box pops and the "IDC_TargetSC"is selected.
When "TargetChoice" does not equal 2, the mesage box pops but no check boxes are selected!!!!!!!

if (TargetChoice==2)
{
      MessageBox(plugin.hwndParent,"SC", "SC",MB_OK);
      CheckRadioButton(hwndDlg, IDC_TargetMD, IDC_TargetSC, IDC_TargetSC);
}
else
{
      MessageBox(plugin.hwndParent,"MD", "MD",MB_OK);
      CheckRadioButton(hwndDlg, IDC_TargetMD, IDC_TargetSC, IDC_TargetMD);
}

HEELLLLPPPP ... going bald :D
(Working in Visual Sudio C++ 6.0)
0
Comment
Question by:Peter-Pan
  • 2
4 Comments
 
LVL 14

Assisted Solution

by:wayside
wayside earned 25 total points
Comment Utility
Check the error code from CheckRadioButton:

BOOL worked = CheckRadioButton(hwndDlg, IDC_TargetMD, IDC_TargetSC, IDC_TargetMD);;

if (worked == FALSE) {
  DWORD errcode = GetLastError();
}

Are you handling the events generated when you check a button? I believe when the button is checked programatically the button fires another event that tells you it's been checked. Perhaps in handling this event you are doing something to cause the button to become unchecked. It's hard to say without seeing more code.
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 25 total points
Comment Utility
IDC_STATIC is not a group. Group is number of controls arranged by tab order. First control in group has "Group" checked, all other have "Group" unchecked. Check whether IDC_TargetMD and IDC_TargetSC have consequent tab order number (see Layout - Tab Order menu command).
0
 
LVL 1

Author Comment

by:Peter-Pan
Comment Utility
@wayside -> I tried your code and "worked" was TRUE

@AlexFM -> I meant that "IDC_STATIC" was the "Group box" control that they are sitting in.

My Dialog box has 5 elements (TabOrder):
Button - IDOK(1)
Button - IDCANCEL(2)
Group Box - IDC_STATIC(3)
RadioButton - IDC_TargetMD(4)
RadioButton - IDC_TargetSC(5)

Only IDC_TargetMD has "Group" checked.
0
 
LVL 1

Author Comment

by:Peter-Pan
Comment Utility
Ok, turns out that there was something stuffed up in my resource.h file. I will just split the points.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now