Solved

Radio Button not Checking

Posted on 2004-04-09
4
1,056 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
ID: 10792018
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
ID: 10792103
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
ID: 10792246
@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
ID: 10799652
Ok, turns out that there was something stuffed up in my resource.h file. I will just split the points.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
Expand to include initial dialog with two choices. 9 80
sumNumber challenge 16 137
scoreUp challenge 14 63
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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