mfc >> Save As problem

by PP » Wed, 26 Nov 2003 00:44:32 GMT

I'm completely new to MFC.. so please excuse my ignorance..

I used the wizard to make a simple app.. Toolbars, menus etc.

So i've got a few classes, the ones im interested in are CMapEditorApp and
CMapEditorDoc.

In CMapEditor.cpp I created all the D3D stuff, which renders my level, and
allows it to be edited. It all works fine.

The problem comes when I want to do a Save as - I have to use CMapEditorDoc
to get the filename returned by the Save As dialogue.. But I can't think of
a way of passing this name back to CMapEditorApp for it to use the save
function..

I can't just put the save function in CMapEditorDoc because the data is all
stored in a structure in mapeditor..

Hope this makes sense.. I've got myself confused.

What i want ideally is a function to get a pointer to the CMapEditorApp
class, but I dont know how because I can't find where it's defined..




mfc >> Save As problem

by PP » Wed, 26 Nov 2003 02:59:16 GMT


found the problem, i needed to typecast the pointer.





Similar Threads

1. Save File problem - A Tricky One for Me

Hi I am stuck with a problem of saving a file which is data from a text
box on a windows form.

The text of each line is data seperated by '~' for example
here is a sample file contents.

1640797~CSANCHE~DRUIZ~09/01/2004~2005~WIRE~WIRE~TRAVEL DEPOSIT~~
1640798~CSANCHE~DRUIZ~09/01/2004~2005~WIRE~WIRE~TRAVEL DEPOSIT~~
1640799~CSANCHE~DRUIZ~09/01/2004~2005~WIRE~WIRE~TRAVEL~~
1640800~CSANCHE~DRUIZ~09/01/2004~2005~WIRE~WIRE~TRAVEL DEPOSIT~~
1640801~CSANCHE~DRUIZ~09/01/2004~2005~WIRE~WIRE~TRAVEL DEPOSIT~~

I then read the data in line by line and use the String.Split function.

Here is the data creation method

FileStream fs = new FileStream(Logfile,FileMode.Create);
StreamWriter m_sw2 = new StreamWriter(fs,System.Text.Encoding.ASCII);
 // Save Data
 int i=0;
 foreach (string s in textBoxBatch.Lines)
 {
   m_sw2.WriteLine(s);
 }
 m_sw2.Flush();
 m_sw2.Close();
 fs.Close();

Even though I specify Encoding ASCII, the file created is not read in
properly.

When I use the following code to read the data back in
I keep getting a message which states this file only has 1 field.

int L=0;
string s="";
StreamReader sr = File.OpenText(fileName);
while ((s = sr.ReadLine()) != null)
{
   Temp = s.Split('~');
   L = Temp.Length;
   if (L > 5)
   {
      // Data can be processed
      Process(Temp);
   }
   else  // Data is in an invalid format. Processing stopped
   {
      MessageBox.Show(string.Format("It had only {0} field(s) ",L));
      break;
   }
}
sr.Close();

I don't know why this is happening, I have another source of data which
looks identical but it reads in the data just fine, so I believe it is
the file creation which is in question.

I would be very happy if someone out there can figure this out?

2. IIS, C# and saving Excel problem

3. TDBGrid column saving width problem

Hi guys,

I have a routine in the Ondestroy event that runs through a dbGrid and
saves the column widths so they can be read in on start up in the
OnCreate event. It all works fine except...

Normally I have assigned columns to the grid using the Columns Editor
but I wanted this latest grid to display all of the columns at run
time so I did NOT use the Columns Editor to add display columns.

However, when it is left VISUALLY empty, D5 takes the field count of
the underlying ttable and says there are 15 colums and saves the
default width of 64 pixels. In the OnCreate event the dbGrid has no
VISIBLE columns so it fires an index out of range error trying to set
the 15 columns that do not exist.

If I add a single column using the Columns Editor it all works fine
again.

Can anyone offer suggestions for Columns.Count when there are  no
visible columns assigned?

Thanks in advance for any help.


Gary C.

4. Cms save problem when try to save the html page to server - CSharp/C#

5. Invoke 'Save As' Dialog to save WebBrowser control contents

Hi,

I have a WebBrowser control displaying some formatted HTML.

I need to be able to save the formatted HTML to a file, using the
common Windows 'Save As' dialog, and preferably be able to pre-
populate the File Name for saving.

What's the easiest way to achieve this?

Cheers

Artie

6. C# and EXCEL question saving a file saving the the first column as read only - CSharp/C#

7. Datarepeater adding a save button to save data

Hi all,

Newbie here learnig C# and ASP programming
I have a webpage (aspx) that make use of a datarepeater. In the data 
repeater items I have variaus different bound items, like textboxes, 
checkboxes. Which enable the user to edit the given row.
I want to at the end, add a button to commit theses changes to the database.

Thanks
Robert


8. FileNotFound returned by Bitmap::Save() when saving to stream