Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: _variant_t Pin
Stuart Dootson26-May-09 0:45
professionalStuart Dootson26-May-09 0:45 
QuestionRead List values Pin
Davitor25-May-09 18:29
Davitor25-May-09 18:29 
AnswerRe: Read List values Pin
_AnsHUMAN_ 25-May-09 18:33
_AnsHUMAN_ 25-May-09 18:33 
Question[Hi! Programs CMOS Boot from USB ] Pin
tuan111125-May-09 17:24
tuan111125-May-09 17:24 
QuestionLocal symbols of a shared library Pin
sheeri manik25-May-09 14:44
sheeri manik25-May-09 14:44 
QuestionRe: Local symbols of a shared library Pin
CPallini25-May-09 20:41
mveCPallini25-May-09 20:41 
QuestionPlease help with MFC dialog Pin
Ryuk199025-May-09 12:50
Ryuk199025-May-09 12:50 
AnswerRe: Please help with MFC dialog Pin
Stuart Dootson25-May-09 14:04
professionalStuart Dootson25-May-09 14:04 
Ryuk1990 wrote:
How would you set up a member variable for a button?


For check-boxes, right-click on the control and select 'Add variable' in the context menu. Make sure the 'Control variable' box is unchecked.

The procedure for radio buttons is slightly different - see the MSDN page[^].

It seems you now have to add DDX_whatever calls into your dialog's DoDataExchange method for value variables (which is a pain in the behind - I though Visual Studio did it for you), so here are some examples:

DDX_Check(pDX, IDC_CHECK1, c1); // Checkbox - c1 is an integer, which will be 0 (unchecked) or 1 (checked)
DDX_Radio(pDX, IDC_RADIO1, values); // Radio button - IDC_RADIO1 is the first cradio button in a radio button group.
                                    //                values is an integer, which will be 0 - (# buttons in group)-1
DDX_Text(pDX, IDC_EDIT1, edit); // Text box
DDX_Text(pDX, IDC_RICHEDIT21, rich); // Rich edit box



Now, for the calculate button - for buttons like that, you add an 'OnClicked' method. The easiest way to do that is to double-click on the button in the MFC dialog editor - Visual Studio will add the handler automatically.

In the handler, the first thing to do is to call UpdateData(TRUE), to get the values of controls into your member variables. Now you can calculate a string holding your summary information, assign to to the string variable associated with your edit box and finally call UpdateData(FALSE) to push the string value into the member variable values into the controls:

void CMyDialog::OnBnClickedCalculate()
{
   UpdateData(TRUE);
   m_summaryValue = m_firstName + " " + m_secondName + ", " + m_address + whatever else you want;
   UpdateData(FALSE);
}


Hope that helps!

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Please help with MFC dialog Pin
Ryuk199025-May-09 14:29
Ryuk199025-May-09 14:29 
GeneralRe: Please help with MFC dialog Pin
Stuart Dootson25-May-09 14:33
professionalStuart Dootson25-May-09 14:33 
AnswerRe: Please help with MFC dialog Pin
Bram van Kampen26-May-09 13:59
Bram van Kampen26-May-09 13:59 
QuestionMacros. Pin
bawratri25-May-09 12:15
bawratri25-May-09 12:15 
AnswerRe: Macros. Pin
Stuart Dootson25-May-09 13:27
professionalStuart Dootson25-May-09 13:27 
GeneralRe: Macros. Pin
bawratri25-May-09 22:38
bawratri25-May-09 22:38 
QuestionMFC Networking Application. Pin
reddy0725-May-09 11:46
reddy0725-May-09 11:46 
AnswerRe: MFC Networking Application. Pin
norish26-May-09 17:50
norish26-May-09 17:50 
AnswerRe: MFC Networking Application. Pin
fanronghua26-May-09 22:32
fanronghua26-May-09 22:32 
Questionhow to connect database Pin
Supriyanka25-May-09 6:01
Supriyanka25-May-09 6:01 
QuestionRe: how to connect database Pin
David Crow25-May-09 8:33
David Crow25-May-09 8:33 
QuestionRe: how to connect database Pin
Supriyanka25-May-09 19:52
Supriyanka25-May-09 19:52 
QuestionRe: how to connect database Pin
David Crow26-May-09 3:06
David Crow26-May-09 3:06 
AnswerRe: how to connect database Pin
Hamid_RT25-May-09 19:22
Hamid_RT25-May-09 19:22 
GeneralRe: how to connect database Pin
fanronghua26-May-09 22:34
fanronghua26-May-09 22:34 
GeneralRe: how to connect database Pin
Hamid_RT27-May-09 1:22
Hamid_RT27-May-09 1:22 
QuestionMystry of C Pin
pandit8425-May-09 5:50
pandit8425-May-09 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.