Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6122313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:53:03+00:00 2026-05-23T15:53:03+00:00

Language: C++ Development Environment: Microsoft Visual C++ Libraries Used: MFC Background: So I’ve created

  • 0

Language: C++

Development Environment: Microsoft Visual C++

Libraries Used: MFC

Background: So I’ve created an application that is basically a large preference dialog where the user can configure a number of pages, each with a bunch of different settings. When the user is finished, he/she has three options for saving the preferences (as XML): Save Current [page], Save These, and Save All.

I’m working with the Save These function right now. When the user chooses this option, a dialog appears with check boxes for each page, allowing them to choose which pages they wish to output. Once they choose the directory into which they wish the files to be saved, the magic happens and the XML files are written.

Problem: I have a function (UpdatePageData) that will detect which page is being displayed and update the current page’s data by calling UpdateData. I have put in a break point to watch to make sure the variables are being filled with the user’s inputted values, and everything is dandy and working correctly. However, when the program jumps from the checkbox dialog (where I call UpdatePageData) to the classes for the pages I’m saving, suddenly all of the values are wrong.

Below I’ve included some code that will help you guys understand the program flow.

NOTE: In SaveThese, I am currently just working on saving a single page…I will have it update all pages selected once I figure out the problem I’m having.


Location: Main Dialog

void CSAPrefsDialog::OnSaveThese()
  {
  int msgboxID = ::MessageBox(
      NULL,
      (LPCSTR)"Are you sure you want to save?",
      (LPCSTR)"Save These",
      MB_ICONQUESTION | MB_OKCANCEL
  );

  switch (msgboxID)
  {
      case IDCANCEL:
          break;
      case IDOK:
          UpdatePageData();
          CSaveThese m_sT;
          m_sT.DoModal();
          break;
  }
}

Location: Main Dialog

void CSAPrefsDialog::UpdatePageData() 
{
  if ((m_iCurPage >= 0) && (m_iCurPage < m_pages.GetSize()))
  {
      pageStruct *pPS = (pageStruct *)m_pages.GetAt(m_iCurPage);
      if (pPS)
      {
          ASSERT(pPS->pDlg);
          if (pPS->pDlg)
          {
              if (!pPS->pDlg->UpdateData()) // THIS WORKS. THE DATA IS UPDATED.
              {  
                  AfxMessageBox("Did not update data.");
              }
          }
      }
  }
}

Location: SaveThese Class

void CSaveThese::OnBnClickedOk()
{
  // TODO: Add your control notification handler code here
  UpdateData(TRUE); // figures out which boxes are checked for saving
  CDirDialog dir;
  CSAPrefsDialog prefsDialog;
  if(dir.DoBrowse())
  {
      prefsDialog.m_strDirectorySavePath = dir.m_strPath;
  }

      // [ other if-statements like the one below to check the check boxes ]

  }
  if(m_bST_FS)
  {
      FSC_Main m_FS;
      m_FS.Save(prefsDialog.m_strDirectorySavePath);
  }
  OnOK();
}

Location: FSC_Main Class

void FSC_Main::Save(CString dirPath)
{
  if(Validate())
  {
      dirPath += "\\FS_Config.xml";
      FILE *fp = fopen(dirPath, "w+");
      WriteXML(fp);
      fclose(fp);
  }
}

By the time it gets to WriteXML, the values have either reverted back to their initialized values (empty strings and -1 for all combo boxes), or have strange values (empty for strings, and large numbers for combo boxes).

I imagine I just have something in the wrong place. I’m just not sure why this is happening, and it’s really the biggest hurdle between me and really getting this project rolling.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:53:03+00:00Added an answer on May 23, 2026 at 3:53 pm

    Jon, Very hard to understand your code. What i understood is you have a member variable m_pages in CSAPrefsDialog dialog class which you are updating by calling UpdateData. And then you are creating a local variable CSaveThese m_sT and calling DoModal. Do you expect CSaveThese class should hold the values of m_Pages?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Language : C++ Development Environment : Microsoft Visual C++ Libraries Used : MFC Problem
I heard that C# is a rapid application development (RAD) language. Even after reading
I am very interested in mobile application development. But which language or framework is
Development Environment: Eclipse 3.7.0 Developing: Android 3.2 application for Market Place Using: aChartEngine 0.7.0
This is trouble shooting question. Our application's development environment is VS2005 C/C++, VB6 based
In the application I'm writing using a combination of development environments and languages, I
If Delphi is the primary language for my development, what is the ideal complement
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
I am planning to participate in development of a code written in C language
Hi I'm looking into iPhone development, and Objective-C is not be my preferred language.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.