Solved

changing the application wnd title after fileopen and filesave

Posted on 2000-02-16
4
227 Views
Last Modified: 2013-11-20
I have a drawing based application .. when drawing in the application i have the title of the window to be whatever i specify under OnInitialUpdate() now I need to save the applocation and then later be able to open the application based on the saved filename ... How do i make it do :
1. the new file name comes up like this
Draw RMS_Voltage and Pst Calculator - filename . ext as soon as i do filesave
2. when i open the saved case the application window comes up like this
Draw RMS_Voltage and Pst Calculator - filename . ext






// *******************************************************************
void CRms_VoltageView::OnInitialUpdate()
{
      CView::OnInitialUpdate();
  GetParentFrame()->SetWindowText("Draw RMS_Voltage and Pst Calculator");
      
      // TODO: Add your specialized code here and/or call the base class
      
}


// *****************************
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs
cs.style&=~FWS_ADDTOTITLE; // PREFIXTITLE - default will give untitled as text

      return CFrameWnd::PreCreateWindow(cs);
}



//********************************

// *******************************************************************************
void CRms_VoltageView::OnFileSaveAs()
{
      // TODO: Add your command handler code here


//CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL,
                //LPCTSTR lpszFileName = NULL, DWORD dwFlags =
                //OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
                //LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );

static char szFilter[] = "Data Files (*.dat)|*.dat|All Files (*.*)|*.*||";

CFileDialog SaveAsDlg(FALSE,"dat","*.dat",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, szFilter,NULL);


  if (SaveAsDlg.DoModal() == IDOK)
  {          
      ofstream outfile;
      CString filename = SaveAsDlg.GetFileName();
      outfile.open (filename,ios::out);        //  open file name given by user
      outfile.setf(ios::fixed);      

// ********* FILE STORAGE BEGINS HERE ***********

            outfile<<current_line;
            outfile<<"\n"<<m_Startvolt;
            outfile<<"\n"<<m_Tottime;
            outfile<<"\n"<<m_Period;
            outfile<<"\n"<<m_miny;
            outfile<<"\n"<<m_maxy;
            outfile<<"\n"<<CircleDraw;
            outfile<<"\n"<<Process_Started;
            outfile<<"\n"<<Pointer_PST_Value;
            outfile<<"\n"<<m_bDraw;
            outfile<<"\n"<<ScaleDraw;
            outfile<<"\n"<<CursorValue;
// array elements


         for ( j=1; j<=(current_line); j++)
       {
               outfile<<"\n"<<pline_array[j].x1_pixel;
               outfile<<"\n"<<pline_array[j].y1_pixel;
               outfile<<"\n"<<pline_array[j].x2_pixel;
               outfile<<"\n"<<pline_array[j].y2_pixel;
               outfile<<"\n"<<pline_array[j].ini_volt;
               outfile<<"\n"<<pline_array[j].ini_time;
               outfile<<"\n"<<pline_array[j].fin_volt;
               outfile<<"\n"<<pline_array[j].fin_time;
                         
         } // for ends

   outfile.close();

  } // SaveAsDlg if
 
}
// *******************************************************************************
void CRms_VoltageView::OnFileOpen()
{
      // TODO: Add your command handler code here
      
  CFileDialog OpenDlg( TRUE, "dat", "*.dat", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "*.dat", NULL );

  if (OpenDlg.DoModal() == IDOK)
  {
   CString filename = OpenDlg.GetFileName();
   ifstream inputfile(filename);       
   FileOn = 1;
   mode =1; // retreival mode of the saved case
   
// ********* FILE STORAGE BEGINS HERE ***********

            inputfile>>current_line;
            inputfile>>m_Startvolt;
            inputfile>>m_Tottime;
            inputfile>>m_Period;
            inputfile>>m_miny;
            inputfile>>m_maxy;
            inputfile>>CircleDraw;
            inputfile>>Process_Started;
            inputfile>>Pointer_PST_Value;
            inputfile>>m_bDraw;
            inputfile>>ScaleDraw;
            inputfile>>CursorValue;
          Flag = 0;

// array elements
         // These are three conditions that needs initialization
             pline_array = make_line_array(current_line); // call the function
      
         for ( j=1; j<=(current_line); j++)
       {
         inputfile>>pline_array[j].x1_pixel;
         inputfile>>pline_array[j].y1_pixel;  
         inputfile>>pline_array[j].x2_pixel;
         inputfile>>pline_array[j].y2_pixel;
         inputfile>>pline_array[j].ini_volt;
         inputfile>>pline_array[j].ini_time;
         inputfile>>pline_array[j].fin_volt;
         inputfile>>pline_array[j].fin_time;
         } // for ends


  Invalidate();         
  inputfile.close();


               ofstream fileout("out.out");

            fileout<<current_line;
            fileout<<"\n"<<m_Startvolt;
            fileout<<"\n"<<m_Tottime;
            fileout<<"\n"<<m_Period;
            fileout<<"\n"<<m_miny;
            fileout<<"\n"<<m_maxy;
            fileout<<"\n"<<CircleDraw;
            fileout<<"\n"<<Process_Started;
            fileout<<"\n"<<Pointer_PST_Value;
            fileout<<"\n"<<m_bDraw;
            fileout<<"\n"<<ScaleDraw;
            fileout<<"\n"<<CursorValue;

            // array elements

         for ( j=1; j<=(current_line); j++)
       {
               fileout<<"\n"<<pline_array[j].x1_pixel;
               fileout<<"\n"<<pline_array[j].y1_pixel;
               fileout<<"\n"<<pline_array[j].x2_pixel;
               fileout<<"\n"<<pline_array[j].y2_pixel;
               fileout<<"\n"<<pline_array[j].ini_volt;
               fileout<<"\n"<<pline_array[j].ini_time;
               fileout<<"\n"<<pline_array[j].fin_volt;
               fileout<<"\n"<<pline_array[j].fin_time;
         }
        
          fileout.close();         

   } // OpenDlg if




}
// *******************************************************************************
0
Comment
Question by:arindam042099
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
captainkirk earned 10 total points
Comment Utility
1) sounds like you want to do this in your OnFileSave() function:

CString csText = "Draw RMS_Voltage and Pst Calculator - ";
GetParentFrame()->SetWindowText(csText + filename);


2) and then do the same thing in your OnFileOpen

0
 

Author Comment

by:arindam042099
Comment Utility
I should have got that ... anyway how can I remove the icon besides the title
0
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
I'm not sure that can be done easily...give me your email and I will check on that...
0
 

Author Comment

by:arindam042099
Comment Utility
ari@ece.msstate.edu

Please look into one more problem that i am having on this code in my next posted question ....
thanks
arindam
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now