| 3182 | } |
| 3183 | |
| 3184 | bool CSettings::LoadBackgroundFile(LPCWSTR inPath, bool abShowErrors) |
| 3185 | { |
| 3186 | bool lRes = false; |
| 3187 | |
| 3188 | #ifdef APPDISTINCTBACKGROUND |
| 3189 | CBackgroundInfo* pNew = CBackgroundInfo::CreateBackgroundObject(inPath, abShowErrors); |
| 3190 | SafeRelease(mp_BgInfo); |
| 3191 | mp_BgInfo = pNew; |
| 3192 | lRes = (mp_BgInfo != nullptr); |
| 3193 | #else |
| 3194 | //_ASSERTE(isMainThread()); |
| 3195 | if (!inPath || _tcslen(inPath)>=MAX_PATH) |
| 3196 | { |
| 3197 | if (abShowErrors) |
| 3198 | MBoxA(L"Invalid 'inPath' in Settings::LoadImageFrom"); |
| 3199 | |
| 3200 | return false; |
| 3201 | } |
| 3202 | |
| 3203 | _ASSERTE(isMainThread()); |
| 3204 | BY_HANDLE_FILE_INFORMATION inf = {0}; |
| 3205 | BITMAPFILEHEADER* pBkImgData = nullptr; |
| 3206 | |
| 3207 | if (wcspbrk(inPath, L"%\\.") == nullptr) |
| 3208 | { |
| 3209 | // May be "Solid color" |
| 3210 | COLORREF clr = (COLORREF)-1; |
| 3211 | if (::GetColorRef(inPath, &clr)) |
| 3212 | { |
| 3213 | pBkImgData = CreateSolidImage(clr, 128, 128); |
| 3214 | } |
| 3215 | } |
| 3216 | |
| 3217 | if (!pBkImgData) |
| 3218 | { |
| 3219 | TCHAR exPath[MAX_PATH + 2]; |
| 3220 | |
| 3221 | if (!ExpandEnvironmentStrings(inPath, exPath, MAX_PATH)) |
| 3222 | { |
| 3223 | if (abShowErrors) |
| 3224 | { |
| 3225 | wchar_t szError[MAX_PATH*2]; |
| 3226 | DWORD dwErr = GetLastError(); |
| 3227 | swprintf_c(szError, L"Can't expand environment strings:\r\n%s\r\nError code=0x%08X\r\nImage loading failed", |
| 3228 | inPath, dwErr); |
| 3229 | MBoxA(szError); |
| 3230 | } |
| 3231 | |
| 3232 | return false; |
| 3233 | } |
| 3234 | |
| 3235 | pBkImgData = LoadImageEx(exPath, inf); |
| 3236 | } |
| 3237 | |
| 3238 | if (pBkImgData) |
| 3239 | { |
| 3240 | ftBgModified = inf.ftLastWriteTime; |
| 3241 | nBgModifiedTick = GetTickCount(); |
no test coverage detected