============================================================================= SaveFileDlg()
| 5776 | // |
| 5777 | // |
| 5778 | BOOL SaveFileDlg ( HWND hwnd, LPWSTR lpstrFile, int cchFile, LPCWSTR lpstrInitialDir ) |
| 5779 | { |
| 5780 | OPENFILENAME ofn; |
| 5781 | WCHAR szNewFile[MAX_PATH]; |
| 5782 | LPWSTR oext; |
| 5783 | LPWSTR oname; |
| 5784 | WCHAR szFilter[NUMLEXERS * 1024]; |
| 5785 | WCHAR tchInitialDir[MAX_PATH] = L""; |
| 5786 | lstrcpy ( szNewFile, lpstrFile ); |
| 5787 | Style_GetOpenDlgFilterStr ( szFilter, COUNTOF ( szFilter ) ); |
| 5788 | if ( lstrlen ( lpstrInitialDir ) ) { |
| 5789 | lstrcpy ( tchInitialDir, lpstrInitialDir ); |
| 5790 | } else if ( lstrlen ( szCurFile ) ) { |
| 5791 | lstrcpy ( tchInitialDir, szCurFile ); |
| 5792 | PathRemoveFileSpec ( tchInitialDir ); |
| 5793 | } else if ( lstrlen ( tchDefaultDir ) ) { |
| 5794 | ExpandEnvironmentStrings ( tchDefaultDir, tchInitialDir, COUNTOF ( tchInitialDir ) ); |
| 5795 | if ( PathIsRelative ( tchInitialDir ) ) { |
| 5796 | WCHAR tchModule[MAX_PATH]; |
| 5797 | GetModuleFileName ( NULL, tchModule, COUNTOF ( tchModule ) ); |
| 5798 | PathRemoveFileSpec ( tchModule ); |
| 5799 | PathAppend ( tchModule, tchInitialDir ); |
| 5800 | PathCanonicalize ( tchInitialDir, tchModule ); |
| 5801 | } |
| 5802 | } else { |
| 5803 | // haccel |
| 5804 | HL_Get_last_dir ( tchInitialDir ); |
| 5805 | } |
| 5806 | ZeroMemory ( &ofn, sizeof ( OPENFILENAME ) ); |
| 5807 | ofn.lStructSize = sizeof ( OPENFILENAME ); |
| 5808 | ofn.hwndOwner = hwnd; |
| 5809 | ofn.lpstrFilter = szFilter; |
| 5810 | ofn.lpstrFile = szNewFile; |
| 5811 | ofn.lpstrInitialDir = tchInitialDir; |
| 5812 | ofn.nMaxFile = MAX_PATH; |
| 5813 | ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ | |
| 5814 | /*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT | |
| 5815 | OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST; |
| 5816 | // haccel #17 |
| 5817 | oext = PathFindExtensionW ( szCurFile ); |
| 5818 | oname = PathFindFileNameW ( szCurFile ); |
| 5819 | HL_WTrace ( "OLD EXT '%s'", oext ); |
| 5820 | HL_WTrace ( "OLD NAME '%s'", oname ); |
| 5821 | if ( 0 == lstrlen ( szCurFile ) ) { |
| 5822 | ofn.lpstrDefExt = ( lstrlen ( tchDefaultExtension ) ) ? tchDefaultExtension : NULL; |
| 5823 | } else if ( NULL == oext || lstrlen ( oext ) < 2 || 0 == lstrcmp ( oext, oname ) ) { |
| 5824 | ofn.lpstrDefExt = NULL; |
| 5825 | } else { |
| 5826 | ofn.lpstrDefExt = ( oext + 1 ); |
| 5827 | } |
| 5828 | if ( GetSaveFileName ( &ofn ) ) { |
| 5829 | lstrcpyn ( lpstrFile, szNewFile, cchFile ); |
| 5830 | return TRUE; |
| 5831 | } else { |
| 5832 | return FALSE; |
| 5833 | } |
| 5834 | } |
| 5835 | /****************************************************************************** |
no test coverage detected