GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Apr-2005, 01:49
shinyhui shinyhui is offline
Awaiting Email Confirmation
 
Join Date: Feb 2005
Posts: 38
shinyhui is on a distinguished road

Problem in saving file as .txt


i'm using the CFileDialog filedialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Text Files (*.txt)|*.txt|Document Files (*.doc)|*.doc|All Files (*.*)|*.*||"), this) to limit as my DoModal() file type.. when i save a file i choose my file type as .txt but in the actual fie destination it does not appear as a .txt file it just display as a window file as type File.

Did there have any solution about this?
  #2  
Old 29-Apr-2005, 04:16
Janakiraman Janakiraman is offline
Junior Member
 
Join Date: Apr 2005
Location: Chennai - India
Posts: 47
Janakiraman is on a distinguished road
Hi,

The second parameter is for Extension of the file... it seems u have placed NULL there... it means no extension for the file..

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

Is it... OK

Best Regards,
Janakiraman
Last edited by LuciWiz : 29-Apr-2005 at 04:54. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #3  
Old 02-May-2005, 18:48
shinyhui shinyhui is offline
Awaiting Email Confirmation
 
Join Date: Feb 2005
Posts: 38
shinyhui is on a distinguished road
Quote:
Originally Posted by Janakiraman
Hi,

The second parameter is for Extension of the file... it seems u have placed NULL there... it means no extension for the file..

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

Is it... OK

Best Regards,
Janakiraman

This is my code look like CFileDialog filedialog(FALSE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Text Files (*.txt)|*.txt|Document Files (*.doc)|*.doc|All Files (*.*)|*.*||"), this);
is there anyhting need to be change?
  #4  
Old 02-May-2005, 19:23
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline
Junior Member
 
Join Date: Apr 2005
Location: Arizona
Posts: 35
Stack Overflow will become famous soon enough
Hello,

You could try this:

CPP / C++ / C Code:
char szFileName[ MAX_PATH ];

CFileDialog filedialog(FALSE, "txt", szFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
_T("Text Files (*.txt)|*.txt|Document Files (*.doc)|*.doc|All Files (*.*)|*.*||"), this);

If not you could look at the following example for answers. I just broke down the process in small steps:

CPP / C++ / C Code:
BOOL M_SaveFile(void) {
	// Local variables
	OPENFILENAME ofn;
	char szFileName[ MAX_PATH ];

	// Zero out memory
	ZeroMemory( &ofn, sizeof( ofn ) );
	// Clear out file name
	szFileName[ 0 ] = 0;
	// Set struct size
	ofn.lStructSize = sizeof( ofn );
	// Set owner
	ofn.hwndOwner = this;
	// Set filter
	ofn.lpstrFilter = "Text Files ( *.txt )\0 *.txt\0";
	// Get file name
	ofn.lpstrFile = szFileName;
	// Max file length
	ofn.nMaxFile = MAX_PATH;
	// Default extension
	ofn.lpstrDefExt = "txt";
	// Flags
	ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
}

I do hope this helps.


- Stack Overflow
__________________
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [C] / [C++] tags. Your question may have been asked before, try the search facility.
  #5  
Old 02-May-2005, 21:06
shinyhui shinyhui is offline
Awaiting Email Confirmation
 
Join Date: Feb 2005
Posts: 38
shinyhui is on a distinguished road
Thanks.. i get it already...
 
 

Recent GIDBlogFlickr uploads of IA pictures by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
Re: Programming Techniques WaltP C Programming Language 0 09-Mar-2004 23:56

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:43.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.