@@ -173,11 +173,18 @@ static void OnItemActivate(void) {
173173 wsprintfW (g_pickerResult , L"%s\\%s" , g_pickerDir , item );
174174 }
175175
176- if (!g_pickerSaveMode ) {
177- /* In open mode, double-click/Enter on file confirms */
178- g_pickerOK = 1 ;
179- PostMessage (g_hwndPicker , WM_CLOSE , 0 , 0 );
176+ /* In save mode, confirm overwrite */
177+ if (g_pickerSaveMode ) {
178+ if (MessageBoxW (g_hwndPicker , L"File exists. Overwrite?" ,
179+ L"Confirm" , MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
180+ SetFocus (g_hwndList );
181+ return ;
182+ }
180183 }
184+
185+ /* File selected - confirm dialog */
186+ g_pickerOK = 1 ;
187+ PostMessage (g_hwndPicker , WM_CLOSE , 0 , 0 );
181188 }
182189}
183190
@@ -294,6 +301,20 @@ static LRESULT CALLBACK PickerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
294301 }
295302 }
296303
304+ /* In save mode, confirm overwrite if file exists */
305+ if (g_pickerSaveMode ) {
306+ HANDLE hTest = CreateFileW (g_pickerResult , 0 , 0 , NULL ,
307+ OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
308+ if (hTest != INVALID_HANDLE_VALUE ) {
309+ CloseHandle (hTest );
310+ if (MessageBoxW (hwnd , L"File exists. Overwrite?" ,
311+ L"Confirm" , MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
312+ SetFocus (g_hwndFilename );
313+ return 0 ;
314+ }
315+ }
316+ }
317+
297318 g_pickerOK = 1 ;
298319 }
299320 PostMessage (hwnd , WM_CLOSE , 0 , 0 );
0 commit comments