179{
181
182
183
185 HBITMAP image = NULL;
186 wchar_t imagePathWC[MAX_PATH];
187
188 MultiByteToWideChar(CP_ACP, 0, path, strlen(path)+1, imagePathWC, MAX_PATH);
189 Bitmap* bitmap = new Bitmap(imagePathWC, FALSE);
190 int imageWidth = bitmap->GetWidth();
191 int imageHeight = bitmap->GetHeight();
192 bitmap->GetHBITMAP(0, &image);
193 delete bitmap;
194
195
196
198
199 if (image == NULL)
200 {
203 }
204 else
205 {
208 }
209
210 int screenY = GetSystemMetrics(SM_YVIRTUALSCREEN);
212 int screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
214
215
216
217 RECT r;
219
221 HBITMAP bufbmp = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
224
225
226
227
229 HBRUSH brush = CreateSolidBrush(0x000000);
231 DeleteObject(brush);
232
233
234
236
237 if (image != NULL)
238 {
239
240 DeleteObject(SelectObject(buf, image));
242 StretchBlt(
cachedBackground, previewBorder, previewBorder,
PreviewItemWidth-(previewBorder*2),
PreviewItemHeight-(previewBorder*2), buf, 0, 0, imageWidth, imageHeight, SRCCOPY);
243
244
245
246
247
248
249
250
251
252 DeleteObject(image);
253 }
254 else
255 {
256
257 HFONT font = CreateFont(10, 0, 0, 0, FW_NORMAL, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Segoe UI");
260 InflateRect(&r, -previewBorder, -previewBorder);
261 DrawTextWithEffects(
cachedBackground, r, path, DT_LEFT | DT_VCENTER | DT_NOPREFIX | DT_PATH_ELLIPSIS, 0xffffff,
false, 0,
false, 0, 0, 0);
263 }
264
265 DeleteDC(buf);
266
267
268
269 if (bufbmp) DeleteObject(bufbmp);
270
271 POINT pt;
273 POINT ptSrc;
274 ptSrc.x = 0, ptSrc.y = 0;
275
276 BLENDFUNCTION bf;
277 bf.BlendOp = AC_SRC_OVER;
278 bf.BlendFlags = 0;
279 bf.AlphaFormat = AC_SRC_ALPHA;
280 bf.SourceConstantAlpha = (unsigned char)255;
281
284
285
286
287
288
289
290
291
292
293
294
295}
void DrawTextWithEffects(HDC hdc, RECT r, LPSTR text, unsigned int format, COLORREF textColor, bool outline, COLORREF outlineColor, bool shadow, COLORREF shadowColor, int shadowX, int shadowY)
Definition BBApi.cpp:3519