CFileDialog : no prompt for wrong file extension.

hi
Priyanka here.
i am creating a CFileDialog box.my application has its exention as
..TPL. Now when i am saving a file with any other extension, like
abc.exe or abc.doc or something like this, i want the dialog should
prompt me for the wrong extension.
i did it manually. but here, the dialog is getting disappeared and i
have to open it again.
People are suggesting to append the extension after the file name(ie.
make it abc.exe.tpl).
But i dont want the user should specify any dot, in the file name,
which is considered as a part of filename.

Please help.
Thanks and regards,
Priyanka

0
12/6/2005 7:13:40 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
778 Views

Similar Articles

[PageSpeed] 26

Here is how you can fix this problem.

Inherit a class from CFileDialog (let's call it CMyFileDialog)
Then override the OnFileNameOK method. And if the extension is not the
correct one return 1 from that method (0 is filename is good, and 1 is
filename is bad)

Like this

BOOL CMyFileDialog::OnFileNameOK()
{
    //GetFileExt method does not include the '.'
    //so if m_pOFN->lpstrDefExt has the '.'  remove it
   CString DefExt = m_pOFN->lpstrDefExt;
   if (!DefExt.IsEmpty() && DefExt[0] == '.')
   {
      DefExt = DefExt.Right(DefExt.GetLength()-1);
   }

   if (GetFileExt().CompareNoCase(DefExt) == 0)
   {
      return CFileDialog::OnFileNameOK();
   }

   MessageBox("Incorrect File Extension");
   return TRUE;
}


AliR.

"priya" <priyanka.khedekar@gmail.com> wrote in message
news:1133853220.617468.131740@o13g2000cwo.googlegroups.com...
> hi
> Priyanka here.
> i am creating a CFileDialog box.my application has its exention as
> .TPL. Now when i am saving a file with any other extension, like
> abc.exe or abc.doc or something like this, i want the dialog should
> prompt me for the wrong extension.
> i did it manually. but here, the dialog is getting disappeared and i
> have to open it again.
> People are suggesting to append the extension after the file name(ie.
> make it abc.exe.tpl).
> But i dont want the user should specify any dot, in the file name,
> which is considered as a part of filename.
>
> Please help.
> Thanks and regards,
> Priyanka
>


0
AliR3470 (3235)
12/6/2005 4:04:44 PM
Reply:

Similar Artilces:

ID of CFileDialog
Hi all, i am trying to find Resource ID of CFileDialog, what number is it? i can know this? Let me know if you can help me. Thanks Duy It is not a resource in your project. The dialog is created by Windows when you call GetOpenFileName / GetSaveFileName. -- Sheng Jiang Microsoft MVP in VC++ "James Duy Trinh" <vietdoor@gmail.com> wrote in message news:eOrRoVReIHA.1212@TK2MSFTNGP05.phx.gbl... > Hi all, > > i am trying to find Resource ID of CFileDialog, what number is it? i can > know this? > > Let me know if you can help me. Thanks > > Duy > ...

USPTYPE.XML File?
Hi There- I'm trying to install Outlook XP and the install keeps looking for a USPTYPE.XML file which isn't on the CD. I think it has something to do with the outlook connector for Notes which I had installed at one point. Any idea what's going on? Thanks, nj ...

How do I record a macro which should work on multiple files ?
Hi, I'am interested in creating Macros for some job tasks of mine. I went through the Excel course of "Working with Loops" in Macros and have attained some basic information on VBA. But since I'am not an expert in it, I want to create Excel macros, using the Option " RECORD MACRO" in excel. My problem is that, I want the MACRO to (a) Copy data from 2 files into a new file. (b) Analyze this data with calculations (c) Build a graph.......basically the summary sheet and graph in a new sheet of the new file. I want to know, whether, can we do such a macro using &...

File name
Hi, Is it possible to show the Excel file name in a cell? Thanks Pilar Pilar =CELL("Filename") -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Pilar" <pilarblancom@terra.es> wrote in message news:zC95d.2633616$A6.8987406@telenews.teleline.es... > Hi, > Is it possible to show the Excel file name in a cell? > > Thanks > Pilar > > Hi see: http://www.xldynamic.com/source/xld.xlFAQ0002.html -- Regards Frank Kabel Frankfurt, Germany "Pilar" <pilarblancom@terra.es> schr...

Executing or opening a file
How does one code a procedure to open a file from within VC++, under the assumption that their system's file associations are in check? I'm guessing the execl() family is bad news. I need to open an HTML page that is created within the program when the user clicks on a menu option. This is a dialog based app if that makes any difference. I'd prefer to have it externally executed rather than within the program (so the user has all of the web browser options availble to them). Thanks. Try ShellExecuteEx(...) Regards, Peter "NoName" <anon@reply.to.group>...

Windows CE SD Card driver : IsValidFileInfo : Invalid File Info
Hi All, I am getting debug error as FATFS : IsValidFileInfo : Invalid File Info when i connect target and PB through file viewer,and copy the file to SD Card folder. It tells to search path for Volume.cpp file. c:\ymzki\private\winceos\coreos\fsd\exfat But i coundnt find it. Why It is invalid file info.What is the problem? Any file format or some.I am not getting any idea. And first time its work without any problem.When i try to load image again and try to copy files in sd card. And one more issue is the previous files which i copied get deleted or someting i cant see them in se...

Logon Prompt with CRM 4.0, Vista and IE 8
All I have this issue where I am prompted for a logon every time I open an EMail within CRM 4.0. There are at least 2 other users in the office that have this as well as one of our clients. I have Vista SP2, IE8, CRM 4.0 Update Rollup 6 (had the issue with UR5). If I uninstall IE8 the problem goes away. If I reinstall IE8 the problem comes back. I have.. added the address to the Trusted sites enabled automatic logon Turned protection mode on/off Turned UAC on/off Changed the securtiy levels to minimum security Tried WinServer2003 IE8 -- no logon prompt Tried Win7 IE8 -- no logon pr...

IXsltContextFunction args seemingly passed wrong during Invoke
I have a user-defined XPath function implemented using a custom context and the IXsltContextFunction interface. For its arguments, it accepts 3: { XPathResultType.Any, XPathResultType.Any, XPathResultType.String }. The function is called datediff, which converts the arguments to DateTimes, and gives args[0] - args[1] in the units specified by args[2] (e.g., "days", "months"). Anyhow, as an example, Let's say I have the following XML file: <root> <testnode DateVal="2008-12-05T00:00:00" TestName="Whatever" /> </root> And ...

RESCUE PST.FILE OL2000
This is a multi-part message in MIME format. ------=_NextPart_000_0025_01C49E2B.2732A7B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I need to repair/reinstall XP but want to rescue the pst.file on the = C-disk. The Hard disk is now a slave on another computer but I'm not = allowed access to DOC/RICHARD/APPL/MS/OL.=20 Is this because it had a password on the user ?? THX!! ------=_NextPart_000_0025_01C49E2B.2732A7B0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HT...

File Names
What is the name of the Sent file in Outlook. I accidently deleted it and want to retrieve it. Thanks There is no file specifically for a Sent item. All data is stored in a pst-file. Is it no longer in your Deleted Items folder? -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tips of the month: -Create your own fully customized Toolbar -Creating a Classic View in Outlook 2003 Subscribe to the newsletter to receive news and tips & tricks in your mailbox! www.sparnaaij.net (I changed my reply add...

regular expression with linq to get files from a dir
Hi, After googling and reading some pages (among http://msdn.microsoft.com/en-us/library/bb882639.aspx), i was trying to get some code running, but I have some problem with the regular expression. I would like to look for files that match a name build like this: defaulName20100223.zip Therefore I made a regular expression string: string regExpression = "("+myDefaultName+@"[0-9]{8}\.[zZ][iI][pP])"; where myDefaultName is just a string (needs to be dynamic). the fileList I will query, will look something like this: c:\\myDir1\\mydir2\\defaulName201002...

Crash using CFileDialog
Hi I am using VS6, SP6, XP-SP1 using MFC as dynamic DLL. I am having a crash when using CFileDialog. Searching net revealed that there is a bug in CFiledialog, but that was fixed in SP6. Crash occurs in destructor of CFileDialog. Can you please guide me to some quick Fix. -- Best regards Shrishail Rana Was the class used as a base class in another class? How did you initalize the CFileDialog class? Directly as ususal. The same code was working properly when MFC was used as static link library. -- Best regards Shrishail Rana CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDERE...

how do i change an image extension in incoming mail? #2
My email picture's come in with a different extension. When I try to open the image a new image software window opens up and asked to purchase it, in order to view my images. How can I change the extension on the images, and view them with one of my image editors? Thank you, Vee ...

I have opened an Excel file and I can't edit any cell
Please post any questions in the body of the message this is considered rude http://www.cpearson.com/excel/newposte.htm Are the sheets protected? -- Regards, Peo Sjoblom Tools > Protection > unprotect worksheet But you will need a password Cheers peterm "Elise0" wrote: > ...

Finding a mislabeled .jpeg file
Last year I mislabeled a .jpeg video and now I cannot find it. The extension could have been named .doc or .txt, and the file name is now unknown. Is there any way to search for .jpeg files regardless of how they may be labeled? Thank you, "Goomba" <Goomba@discussions.microsoft.com> wrote in message news:7B4D9BEA-A671-44D3-9E8B-332C751FB7B0@microsoft.com... > Last year I mislabeled a .jpeg video and now I cannot find it. The > extension > could have been named .doc or .txt, and the file name is now unknown. Is > there any way to search for .jpeg fi...

Starting Excel from file
Can anyone help? I've just started getting a problem loading excel from a file. It starts just fine from the start menu etc. and I can open files from within Excel. However, if I click on (say) an excel file icon in My Documents or on one of my saved icons on the desktop then Excel loads fine but NOT the file!! This is really frustrating as it means I have to go through the process of loading excel separately every time I wish to use it. I Use Office XP + Windows XP PRO. I have done a system restore to before the problem occurred - no luck. I have completely uninstalled Office...

CFileDialog
Windows 7 has changed the rules for the member lpstrInitialDir of CFileDialog to: 1. If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory. I want to be able to set the path to what I want not what the first time it was used was. Is there a way to do this? Thank you, Tim ...

Outlook 2000 wrong icon as attachment
When I try and attach a quickbooks file to an email in Outlook 2000, the program will attach the file, but instead of a quickbooks icon showing up, the generic windows icon shows up, and the file is unreadable on the other end. Any ideas as to why outlook isn't interpreting the attachment correctly? Thank you. ...

remove elements from xml file programmatically
i would like to remove all elements called say <CustomerID> from an xml file is there an easy way to do this programmatically. thanks for the help. Run a SelectNodes with the Following XPath //CustomerID Then check if the Parent is <> null (nothing) Move to the parent and then say RemoveChild, passing in the reference to the Child (CustomerID) Node. Joe Feser "raife" <raife@stokes.net.au> wrote in message news:079e01c39f80$174d0660$a401280a@phx.gbl... > i would like to remove all elements called say > <CustomerID> > from an xml file > is the...

Back up under Vista of changed files.
Can you tell me how to back up only those files which have changed after a certain date. All I can see is how to back up the whole disk at one time. Thanks rraybould This question really has nothing to do with Microsoft Word. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "rraybould" <rraybould@discussions.microsoft.com> wrote in message news:3566D321-1761-40B4-BB4A-6321AE8A75F9@microsoft.com... > Can you tell me how to back up only those files which have changed after a > certain date. All ...

Problem with EXCEl reading CD files
I have a new Dell Computer with Microsoft Professional XP and Office 2003. I got a CD from IRS with excel and ascii files When I try to open them I get an error message that says the file may be read only or the device may be read only or the server may not be in service. IRS uses excel 4.0. The 2003 system has to be cancelled out of. Then I moved the CD to an old 98 Office 2000 system and excel 2000 would open the files but the files that I had tried to open on the new computer were corrupted. Files I did not open on the new computer were fine. IRS has not experienced this pro...

is M04 salv different than M03 salv; If not M04 is corrupting M03 files
Does the salv utility in M04 detect and fix things that the M03 salv utility doesn't? Here is the situation: Existing M03 file passes level 1 and level 2 salv without any problems. Convert that file to M04. Run salv on the converted M04 file and there are all kinds of errors. Fix the new M04 file using salv. I can't reconcile several accounts. Not only is M04 not worth upgrading for M03 users, it screws my file up. Great job guys. Try using the one on the File-> menu instead. It's almost certainly written for 04, rather than the external one which appears to be for ea...

2007Data files?
There are several data files that my Outlook 2007 is using. I only need the default file. My question is this. When I go to Tools/Account Settings/Data Files and highlight a pst file that I do not want Outlook to use, if I click "Remove" does this just tell Outlook not to use it, or does it completely delete the file? Fred It tells Outlook not to open or use the file, it does NOT delete the data file from your system. Hal -- Hal Hostetler, CPBE Senior Engineer/MIS -- MS MVP-Print/Imaging -- WA7BGX www.kvoa.com -- KVOA Television, Tucson, AZ. Live at Hot Licks - www.badn...

Column widths get changed when another user opens my files
hello, i save an excel file on a network drive and when another user opens it the width of the columns are all changed. what's going on? How can we get stop this? thanks!!! ...

XLS File
I have downloaded a excel file for a Caravan Site Fee Calculator. I have not got Microsoft Word to use it, but I can view it with the free Microsoft Excel Viewer. I have got Openoffice, which you are able to open XLS files, so I thought I could use that. When I open the file it comes up with "Error Loading Document File Read-Error This File Is Password Protested" I have not had this problem before opening xls files this way with Openoffice ...