windowsvisual-c++mfcsave-dialog

How to prevent the Overwrite Prompt while saving in custome IFileDialoge - VC++


I don't want to display any overwrite prompt while user enter the file name which is already exist in my custom IFileDialog.

I have already gone throw IFileDialog::SetOptions method but it dint solve my problem.

FOS_OVERWRITEPROMPT (0x00000002) : When saving a file, prompt before overwriting an existing file of the same name. This is a default value for the Save dialog.

IS there any flag which help me out from this issue..?? Or is there any other way to prevent the overwrite prompt while saving the file.

Please help me. Many thanks in advance..:)


Solution

  •     HRESULT hr;
        DWORD dwFlags = 0;
    
    //pDlg is your IFileSaveDialog
        hr = pDlg->GetOptions ( &dwFlags );
        if( dwFlags & FOS_OVERWRITEPROMPT )
        {
            dwFlags = dwFlags & ( ~FOS_OVERWRITEPROMPT);
            hr = pDlg->SetOptions ( dwFlags );
        }