| 1226 | } |
| 1227 | |
| 1228 | bool CBackgroundInfo::LoadBackgroundFile(bool abShowErrors) |
| 1229 | { |
| 1230 | // Пустой путь - значит БЕЗ обоев |
| 1231 | if (!*ms_BgImage) |
| 1232 | { |
| 1233 | return true; |
| 1234 | } |
| 1235 | |
| 1236 | //_ASSERTE(isMainThread()); |
| 1237 | |
| 1238 | _ASSERTE(isMainThread()); |
| 1239 | bool lRes = false; |
| 1240 | BY_HANDLE_FILE_INFORMATION inf = {0}; |
| 1241 | BITMAPFILEHEADER* pBkImgData = nullptr; |
| 1242 | |
| 1243 | if (wcspbrk(ms_BgImage, L"%\\.") == nullptr) |
| 1244 | { |
| 1245 | // May be "Solid color" |
| 1246 | COLORREF clr = (COLORREF)-1; |
| 1247 | if (GetColorRef(ms_BgImage, &clr)) |
| 1248 | { |
| 1249 | pBkImgData = CreateSolidImage(clr, 128, 128); |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | if (!pBkImgData) |
| 1254 | { |
| 1255 | const CEStr exPath = ExpandEnvStr(ms_BgImage); |
| 1256 | |
| 1257 | if (exPath.IsEmpty()) |
| 1258 | { |
| 1259 | if (abShowErrors) |
| 1260 | { |
| 1261 | wchar_t szError[MAX_PATH * 2] = L""; |
| 1262 | const DWORD dwErr = GetLastError(); |
| 1263 | swprintf_c(szError, L"Can't expand environment strings:\r\n%s\r\nError code=0x%08X\r\nImage loading failed", |
| 1264 | ms_BgImage, dwErr); |
| 1265 | MBoxA(szError); |
| 1266 | } |
| 1267 | return false; |
| 1268 | } |
| 1269 | |
| 1270 | pBkImgData = LoadImageEx(exPath, inf); |
| 1271 | } |
| 1272 | |
| 1273 | if (pBkImgData) |
| 1274 | { |
| 1275 | ftBgModified = inf.ftLastWriteTime; |
| 1276 | nBgModifiedTick = GetTickCount(); |
| 1277 | //NeedBackgroundUpdate(); |
| 1278 | //MSectionLock SBG; SBG.Lock(&mcs_BgImgData); |
| 1279 | SafeFree(mp_BgImgData); |
| 1280 | mb_IsBackgroundImageValid = true; |
| 1281 | mp_BgImgData = pBkImgData; |
| 1282 | lRes = true; |
| 1283 | } |
| 1284 | |
| 1285 | return lRes; |
no test coverage detected