KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an MFC dialog in which there are two radio buttons. I have put them in a nice group, their IDCs are one after each other ( RB_LEFT, RB_RIGHT ). I want to use DDX_Radio so I can access the buttons using an integer value so in the function DoDataExchange I call : DDX_Radio(pDX, RB_LEFT, mRBLeftRight); where mRBLeftRight is a member variable of integer type. I also need to edit the buttons properties so I wanted to use a DDX_Control to map them on member variables mRBLeft and mRBRight ( CButton ): DDX_Control(pDX, RB_LEFT, mRBLeft); DDX_Control(pDX, RB_RIGHT, mRBRight); Now if I do the call to DDX_Control , whenever DoDataExchange is called, the application crashes because DDX_Control forces RB_LEFT to handle a message that DDX_Radio cannot handle. This part I understand. I decided to not use DDX_Control (removed the calls in DoDataExchange ) and just keep a pointer to my radio buttons ( CButton* ) in my classes. So in my OnInitDialog function, I do the following calls : mRBLeft= ((CButton*)GetDlgItem(RB_LEFT)); mRBRight = ((CButton*)GetDlgItem(RB_RIGHT)); Now as long as I don't use mRBLeft it's going to be fine, but if I do, bam, crash on DoDataExchange . The thing that really puzzles me is if I change my left radio button using ((CButton*)GetDlgItem(RB_LEFT)->SetCheck(true) it's going to work. Sooo what's the difference ? (I know it's a lot of hassle for little, but I just wanna understand the mechanics)
Tags (comma-separated)
Save Edits
Cancel