Menu

#16 Automatically add the extension to the filename

closed
nobody
None
1
2007-10-29
2006-10-11
No

Automatically add the extension to the filename, while
saving if no extension is specified by the user.

Just add these lines before return statement in char *
FileDialog::doSaveDlg() function.
if(_ofn.nFilterIndex > 1 && strrchr(fn, '.') == NULL)
{
switch(_ofn.nFilterIndex)
{
case 2:
strcat(fn, ".c");
break;
case 3:
strcat(fn, ".cpp");
break;
case 4:
strcat(fn, ".rc");
break;
case 5:
strcat(fn, ".h");
break;
case 6:
strcat(fn, ".java");
break;
case 7:
strcat(fn, ".html");
break;
case 8:
strcat(fn, ".xml");
break;
case 9:
strcat(fn, ".php");
break;
case 10:
strcat(fn, ".ini");
break;
case 11:
strcat(fn, ".bat");
break;
case 12:
strcat(fn, ".txt");
break;
default:
break;
}
}

Discussion

  • Acheron

    Acheron - 2007-03-01

    Logged In: YES
    user_id=1149303
    Originator: NO

    I agree with this. Use normal Windows behaviour by default. If necessary add an option to settings-menu to disable automatic adding extensions.
    This is also necessary for saving session files. By default no extension is selected so if you don't have the experience you end up with lots of files without extension. Keep in mind that in newer OS's as Windows Vista it becomes harder for the average user to change file extension from the GUI. Let's keep up good practices with Microsoft guidelines!

     
  • Don HO

    Don HO - 2007-10-29
    • status: open --> closed
    • priority: 5 --> 1
     
  • Don HO

    Don HO - 2007-10-29

    Logged In: YES
    user_id=916327
    Originator: NO

    a better implementation is done in v4.5

    Don