Solved

changing the application wnd title after fileopen and filesave

Posted on 2000-02-16
4
242 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
ID: 2529288
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
ID: 2529345
I should have got that ... anyway how can I remove the icon besides the title
0
 
LVL 4

Expert Comment

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

Author Comment

by:arindam042099
ID: 2532258
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
string initialization in java 11 110
abstract class with all non abstract mentods 6 76
Thin secure Windows 10 5 75
x-bar in Google Sheets 2 26
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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