Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC Radio buttons

Status
Not open for further replies.

EGDEric

Programmer
Aug 19, 2003
16
CA
I was using this book called: "Teach yourself visual C++ 6 in 21 days". It's a hands on tutorial for MFC. I used it, and had to stop cuz I was stuck. It told me to make an event handler for the dialog that would handle any change in the currently selected radio button.

This is the event handler:

Never mind the code within it, just know that its supposed to do that when the user clicks on a radio button.

void CGraphicsDlg: nRSelection()
{
//Synchronize the data
UpdateData(TRUE);
//Repaint the second dialog
m_dlgPaint.Invalidate();
}

I was doubtful, but I tried it anyway. It doesn't work. All event handlers I've used from the book up till now have been "attached" to messages using the class wizard. I've looked in the message maps, but there's no WM_RSELECTION message. What am I to do?
 
I do not know message WM_RSELECTION. You should add a handler for WM_COMMAND.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Using a message map
Code:
BEGIN_MESSAGE_MAP(CNumericPage, CPropertyPage)
	//{{AFX_MSG_MAP(CNumericPage)
...
...
	ON_BN_CLICKED(IDC_RADIO_EQ_POP, OnRadioEqPop)
	ON_BN_CLICKED(IDC_RADIO_EQ_RANGE, OnRadioEqRange)
...
...
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

you could use the following to check whether the button has just been selected or clicked on again

Code:
void CNumericPage::OnRadioEqRange() 
{
	int i = m_nRangeOrPopulation;
	UpdateData();
	if (i==m_nRangeOrPopulation)
		return;
	AfxMessageBox("I have been selected");
}
( m_nRangeOrPopulation is the variable attached to the radio buttons & NumericPage is just the class I was using :))


Go not to cats for advice for they will just walk over the keyboard
 
I barely understood any of that, its probably too advanced for me at this point. Nevertheless, I'll be sure to refer to your thing later when I get back to it. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top