MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / LoadBackgroundFile

Method LoadBackgroundFile

src/ConEmu/Background.cpp:1228–1286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226}
1227
1228bool 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;

Callers 6

OnComboBoxMethod · 0.45
OnEditChangedMethod · 0.45
PostCreateMethod · 0.45
OnBtn_BgImageEnableMethod · 0.45
OnBtn_BgImageChooseMethod · 0.45

Calls 7

isMainThreadFunction · 0.85
CreateSolidImageFunction · 0.85
ExpandEnvStrFunction · 0.85
LoadImageExFunction · 0.85
GetColorRefFunction · 0.70
swprintf_cFunction · 0.50
IsEmptyMethod · 0.45

Tested by

no test coverage detected