Fixed issue #2507: Support keyboard shortcuts in yes/no prompts
[TortoiseGit.git] / src / Utils / MiscUI / IconBitmapUtils.h
blob85fe040dfab8ec33c2269bcc2bdcae21793f2ac8
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009, 2011, 2014 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include <Uxtheme.h>
21 #include <GdiPlus.h>
23 typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow);
24 typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc);
25 typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);
28 /**
29 * \ingroup utils
30 * provides helper functions for converting icons to bitmaps
32 class IconBitmapUtils
34 public:
35 IconBitmapUtils(void);
36 ~IconBitmapUtils(void);
38 HBITMAP IconToBitmap(HINSTANCE hInst, UINT uIcon);
39 HBITMAP IconToBitmapPARGB32(HICON hIcon);
40 HBITMAP IconToBitmapPARGB32(HINSTANCE hInst, UINT uIcon);
41 HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp) const;
42 HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon);
43 bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow) const;
44 HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow) const;
47 private:
48 HMODULE hUxTheme;
49 std::map<UINT, HBITMAP> bitmaps;
51 FN_GetBufferedPaintBits pfnGetBufferedPaintBits;
52 FN_BeginBufferedPaint pfnBeginBufferedPaint;
53 FN_EndBufferedPaint pfnEndBufferedPaint;