Solved

Radio Button not Checking

Posted on 2004-04-09
4
1,048 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change owner from userA to server Local Administrators 7 59
sumNumber challenge 16 110
withoutTen challenge 14 99
Way to decrease size of apk file 9 42
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

18 Experts available now in Live!

Get 1:1 Help Now