Solved

Radio Button not Checking

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 123
ffmpeg - "rtsp://...... Operation not permitted" 4 80
lucky13 challenge 11 144
Problem to App 4 82
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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 …
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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