Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Default File Name in Save As Dialog

Status
Not open for further replies.

kurtschenk

Technical User
Joined
Nov 27, 2003
Messages
2
Location
US
I am working on an SDI application where the user can enter data via a dialog box. This includes the title of the application. The title is stored in an object of the class MyDoc. The corresponding member variable is declared and initialized as follows:
CString Title;
Title = _T("My Design");
At the first time the document is saved, I would like the Save As dialog to suggest the contents of Title+".mag" as file name rather than "Untitled.mag". To achieve this I added the following line to MyDoc:
if (GetPathName() == "") SetTitle(LPCTSTR(Title));
This sets the title in the MainFrame to whatever is in Title, if the document has not been saved so far. At the first call of Save or Save As the dialog suggests the proper file name. However, it only works of the title consits of a single word otherwise it just takes the first word of the title. In the above example it asks to save the document as "My.mag" instead of "My Design.mag". Why is that and is there a better way to accomplish my goal? Thanks for any suggestions.

Kurt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top