OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/win_util.h" | 5 #include "chrome/common/win_util.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <commdlg.h> | 9 #include <commdlg.h> |
10 #include <dwmapi.h> | 10 #include <dwmapi.h> |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 save_as.lpstrFile = file_name; | 369 save_as.lpstrFile = file_name; |
370 save_as.nMaxFile = arraysize(file_name); | 370 save_as.nMaxFile = arraysize(file_name); |
371 save_as.lpstrFileTitle = NULL; | 371 save_as.lpstrFileTitle = NULL; |
372 save_as.nMaxFileTitle = 0; | 372 save_as.nMaxFileTitle = 0; |
373 | 373 |
374 // Set up the initial directory for the dialog. | 374 // Set up the initial directory for the dialog. |
375 std::wstring directory = file_util::GetDirectoryFromPath(suggested_name); | 375 std::wstring directory = file_util::GetDirectoryFromPath(suggested_name); |
376 save_as.lpstrInitialDir = directory.c_str(); | 376 save_as.lpstrInitialDir = directory.c_str(); |
377 save_as.lpstrTitle = NULL; | 377 save_as.lpstrTitle = NULL; |
378 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | | 378 save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING | |
379 OFN_ENABLEHOOK | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; | 379 OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; |
380 save_as.lpstrDefExt = &def_ext[0]; | 380 save_as.lpstrDefExt = &def_ext[0]; |
381 save_as.lCustData = NULL; | 381 save_as.lCustData = NULL; |
382 save_as.lpfnHook = &SaveAsDialogHook; | 382 |
| 383 if (win_util::GetWinVersion() <= win_util::WINVERSION_VISTA) { |
| 384 // The save as on Windows XP and Windows Vista remembers its last position, |
| 385 // and if the screen resolution changed, it will be off screen. |
| 386 save_as.Flags |= OFN_ENABLEHOOK; |
| 387 save_as.lpfnHook = &SaveAsDialogHook; |
| 388 } |
383 | 389 |
384 // Must be NULL or 0. | 390 // Must be NULL or 0. |
385 save_as.pvReserved = NULL; | 391 save_as.pvReserved = NULL; |
386 save_as.dwReserved = 0; | 392 save_as.dwReserved = 0; |
387 | 393 |
388 if (!GetSaveFileName(&save_as)) { | 394 if (!GetSaveFileName(&save_as)) { |
389 // Zero means the dialog was closed, otherwise we had an error. | 395 // Zero means the dialog was closed, otherwise we had an error. |
390 DWORD error_code = CommDlgExtendedError(); | 396 DWORD error_code = CommDlgExtendedError(); |
391 if (error_code != 0) { | 397 if (error_code != 0) { |
392 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; | 398 NOTREACHED() << "GetSaveFileName failed with code: " << error_code; |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 851 } |
846 | 852 |
847 ChromeFont GetWindowTitleFont() { | 853 ChromeFont GetWindowTitleFont() { |
848 NONCLIENTMETRICS ncm; | 854 NONCLIENTMETRICS ncm; |
849 win_util::GetNonClientMetrics(&ncm); | 855 win_util::GetNonClientMetrics(&ncm); |
850 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 856 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
851 return ChromeFont::CreateFont(caption_font); | 857 return ChromeFont::CreateFont(caption_font); |
852 } | 858 } |
853 | 859 |
854 } // namespace win_util | 860 } // namespace win_util |
OLD | NEW |