============================================================================= OpenFileDlg()
| 5712 | // |
| 5713 | // |
| 5714 | BOOL OpenFileDlg ( HWND hwnd, LPWSTR lpstrFile, int cchFile, LPCWSTR lpstrInitialDir ) |
| 5715 | { |
| 5716 | OPENFILENAME ofn; |
| 5717 | WCHAR szFile[MAX_PATH]; |
| 5718 | WCHAR szFilter[NUMLEXERS * 1024]; |
| 5719 | WCHAR tchInitialDir[MAX_PATH] = L""; |
| 5720 | lstrcpy ( szFile, L"" ); |
| 5721 | Style_GetOpenDlgFilterStr ( szFilter, COUNTOF ( szFilter ) ); |
| 5722 | if ( !lpstrInitialDir ) { |
| 5723 | if ( lstrlen ( szCurFile ) ) { |
| 5724 | lstrcpy ( tchInitialDir, szCurFile ); |
| 5725 | PathRemoveFileSpec ( tchInitialDir ); |
| 5726 | } else if ( lstrlen ( tchDefaultDir ) ) { |
| 5727 | ExpandEnvironmentStrings ( tchDefaultDir, tchInitialDir, COUNTOF ( tchInitialDir ) ); |
| 5728 | if ( PathIsRelative ( tchInitialDir ) ) { |
| 5729 | WCHAR tchModule[MAX_PATH]; |
| 5730 | GetModuleFileName ( NULL, tchModule, COUNTOF ( tchModule ) ); |
| 5731 | PathRemoveFileSpec ( tchModule ); |
| 5732 | PathAppend ( tchModule, tchInitialDir ); |
| 5733 | PathCanonicalize ( tchInitialDir, tchModule ); |
| 5734 | } |
| 5735 | } else { |
| 5736 | // haccel |
| 5737 | HL_Get_last_dir ( tchInitialDir ); |
| 5738 | } |
| 5739 | } |
| 5740 | ZeroMemory ( &ofn, sizeof ( OPENFILENAME ) ); |
| 5741 | ofn.lStructSize = sizeof ( OPENFILENAME ); |
| 5742 | ofn.hwndOwner = hwnd; |
| 5743 | ofn.lpstrFilter = szFilter; |
| 5744 | ofn.lpstrFile = szFile; |
| 5745 | ofn.lpstrInitialDir = ( lpstrInitialDir ) ? lpstrInitialDir : tchInitialDir; |
| 5746 | ofn.nMaxFile = COUNTOF ( szFile ); |
| 5747 | ofn.lpfnHook = HL_OFN__hook_proc; |
| 5748 | ofn.Flags = |
| 5749 | OFN_HIDEREADONLY | |
| 5750 | /* OFN_NOCHANGEDIR |*/ |
| 5751 | OFN_DONTADDTORECENT | |
| 5752 | /*OFN_PATHMUSTEXIST |*/ |
| 5753 | OFN_SHAREAWARE |
| 5754 | /*| OFN_NODEREFERENCELINKS*/; |
| 5755 | if ( b_Hl_use_prefix_in_open_dialog ) { |
| 5756 | #if 1 |
| 5757 | HL_TRACE("WIN VERSION %d" , WINVER); |
| 5758 | ofn.Flags |= ( OFN_ENABLEHOOK | OFN_EXPLORER ); |
| 5759 | #else |
| 5760 | ofn.Flags |= ( OFN_ENABLEHOOK ); |
| 5761 | #endif |
| 5762 | } else { |
| 5763 | ofn.Flags |= OFN_FILEMUSTEXIST; |
| 5764 | } |
| 5765 | ofn.lpstrDefExt = ( lstrlen ( tchDefaultExtension ) ) ? tchDefaultExtension : NULL; |
| 5766 | if ( GetOpenFileName ( &ofn ) ) { |
| 5767 | lstrcpyn ( lpstrFile, szFile, cchFile ); |
| 5768 | return TRUE; |
| 5769 | } else { |
| 5770 | return FALSE; |
| 5771 | } |
no test coverage detected