Solved

changing the application wnd title after fileopen and filesave

Posted on 2000-02-16
4
250 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 146
NotAlone Challenge 20 83
Message not shown 5 49
Work with App store 7 51
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

15 Experts available now in Live!

Get 1:1 Help Now