18 #error atlgdi.h requires atlapp.h to be included first 31 #endif // _INC_WINDOWSX 34 #if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) 35 #pragma comment(lib, "msimg32.lib") 36 #endif // !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) 37 #if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 38 #pragma comment(lib, "opengl32.lib") 39 #endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 81 inline LPBITMAPINFOHEADER AtlGetBitmapResourceInfo(HMODULE hModule,
ATL::_U_STRINGorID image)
83 HRSRC hResource = ::FindResource(hModule, image.m_lpstr, RT_BITMAP);
84 ATLASSERT(hResource != NULL);
85 HGLOBAL hGlobal = ::LoadResource(hModule, hResource);
86 ATLASSERT(hGlobal != NULL);
87 LPBITMAPINFOHEADER pBitmapInfoHeader = (LPBITMAPINFOHEADER)::LockResource(hGlobal);
88 ATLASSERT(pBitmapInfoHeader != NULL);
89 return pBitmapInfoHeader;
92 inline WORD AtlGetBitmapResourceBitsPerPixel(HMODULE hModule,
ATL::_U_STRINGorID image)
94 LPBITMAPINFOHEADER pBitmapInfoHeader = AtlGetBitmapResourceInfo(hModule, image);
95 ATLASSERT(pBitmapInfoHeader != NULL);
96 return pBitmapInfoHeader->biBitCount;
101 return AtlGetBitmapResourceBitsPerPixel(ModuleHelper::GetResourceInstance(), image);
113 return (AtlGetBitmapResourceBitsPerPixel(image) == 32);
120 template <
bool t_bManaged>
128 CPenT(HPEN hPen = NULL) : m_hPen(hPen)
133 if(t_bManaged && m_hPen != NULL)
143 void Attach(HPEN hPen)
145 if(t_bManaged && m_hPen != NULL && m_hPen != hPen)
146 ::DeleteObject(m_hPen);
157 operator HPEN()
const {
return m_hPen; }
159 bool IsNull()
const {
return (m_hPen == NULL); }
162 HPEN CreatePen(
int nPenStyle,
int nWidth, COLORREF crColor)
164 ATLASSERT(m_hPen == NULL);
165 m_hPen = ::CreatePen(nPenStyle, nWidth, crColor);
170 HPEN CreatePen(
int nPenStyle,
int nWidth,
const LOGBRUSH* pLogBrush,
int nStyleCount = 0,
const DWORD* lpStyle = NULL)
172 ATLASSERT(m_hPen == NULL);
173 m_hPen = ::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle);
176 #endif // !_WIN32_WCE 178 HPEN CreatePenIndirect(LPLOGPEN lpLogPen)
180 ATLASSERT(m_hPen == NULL);
181 m_hPen = ::CreatePenIndirect(lpLogPen);
187 ATLASSERT(m_hPen != NULL);
188 BOOL bRet = ::DeleteObject(m_hPen);
195 int GetLogPen(LOGPEN* pLogPen)
const 197 ATLASSERT(m_hPen != NULL);
198 return ::GetObject(m_hPen,
sizeof(LOGPEN), pLogPen);
201 bool GetLogPen(LOGPEN& LogPen)
const 203 ATLASSERT(m_hPen != NULL);
204 return (::GetObject(m_hPen,
sizeof(LOGPEN), &LogPen) ==
sizeof(LOGPEN));
208 int GetExtLogPen(EXTLOGPEN* pLogPen)
const 210 ATLASSERT(m_hPen != NULL);
211 return ::GetObject(m_hPen,
sizeof(EXTLOGPEN), pLogPen);
214 bool GetExtLogPen(EXTLOGPEN& ExtLogPen)
const 216 ATLASSERT(m_hPen != NULL);
217 return (::GetObject(m_hPen,
sizeof(EXTLOGPEN), &ExtLogPen) ==
sizeof(EXTLOGPEN));
219 #endif // !_WIN32_WCE 229 template <
bool t_bManaged>
237 CBrushT(HBRUSH hBrush = NULL) : m_hBrush(hBrush)
242 if(t_bManaged && m_hBrush != NULL)
252 void Attach(HBRUSH hBrush)
254 if(t_bManaged && m_hBrush != NULL && m_hBrush != hBrush)
255 ::DeleteObject(m_hBrush);
261 HBRUSH hBrush = m_hBrush;
266 operator HBRUSH()
const {
return m_hBrush; }
268 bool IsNull()
const {
return (m_hBrush == NULL); }
271 HBRUSH CreateSolidBrush(COLORREF crColor)
273 ATLASSERT(m_hBrush == NULL);
274 m_hBrush = ::CreateSolidBrush(crColor);
279 HBRUSH CreateHatchBrush(
int nIndex, COLORREF crColor)
281 ATLASSERT(m_hBrush == NULL);
282 m_hBrush = ::CreateHatchBrush(nIndex, crColor);
285 #endif // !_WIN32_WCE 287 #if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 288 HBRUSH CreateBrushIndirect(
const LOGBRUSH* lpLogBrush)
290 ATLASSERT(m_hBrush == NULL);
292 m_hBrush = ::CreateBrushIndirect(lpLogBrush);
294 m_hBrush = ATL::CreateBrushIndirect(lpLogBrush);
298 #endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 300 HBRUSH CreatePatternBrush(HBITMAP hBitmap)
302 ATLASSERT(m_hBrush == NULL);
303 m_hBrush = ::CreatePatternBrush(hBitmap);
307 HBRUSH CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage)
309 ATLASSERT(hPackedDIB != NULL);
310 const void* lpPackedDIB = GlobalLock(hPackedDIB);
311 ATLASSERT(lpPackedDIB != NULL);
312 m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage);
313 GlobalUnlock(hPackedDIB);
317 HBRUSH CreateDIBPatternBrush(
const void* lpPackedDIB, UINT nUsage)
319 ATLASSERT(m_hBrush == NULL);
320 m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage);
324 HBRUSH CreateSysColorBrush(
int nIndex)
326 ATLASSERT(m_hBrush == NULL);
327 m_hBrush = ::GetSysColorBrush(nIndex);
333 ATLASSERT(m_hBrush != NULL);
334 BOOL bRet = ::DeleteObject(m_hBrush);
341 int GetLogBrush(LOGBRUSH* pLogBrush)
const 343 ATLASSERT(m_hBrush != NULL);
344 return ::GetObject(m_hBrush,
sizeof(LOGBRUSH), pLogBrush);
347 bool GetLogBrush(LOGBRUSH& LogBrush)
const 349 ATLASSERT(m_hBrush != NULL);
350 return (::GetObject(m_hBrush,
sizeof(LOGBRUSH), &LogBrush) ==
sizeof(LOGBRUSH));
366 memset(
this, 0,
sizeof(LOGFONT));
376 ATLASSERT(::GetObjectType(hFont) == OBJ_FONT);
377 ::GetObject(hFont,
sizeof(LOGFONT), (LOGFONT*)
this);
380 HFONT CreateFontIndirect()
382 return ::CreateFontIndirect(
this);
392 return (lfWeight >= FW_BOLD);
395 void MakeBolder(
int iScale = 1)
397 lfWeight += FW_BOLD * iScale;
400 void MakeLarger(
int iScale)
408 void SetHeight(LONG nPointSize, HDC hDC = NULL)
410 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
412 lfHeight = -::MulDiv(nPointSize, ::GetDeviceCaps(hDC1, LOGPIXELSY), 72);
414 ::ReleaseDC(NULL, hDC1);
417 LONG GetHeight(HDC hDC = NULL)
const 419 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
421 LONG nPointSize = ::MulDiv(-lfHeight, 72, ::GetDeviceCaps(hDC1, LOGPIXELSY));
423 ::ReleaseDC(NULL, hDC1);
428 LONG GetDeciPointHeight(HDC hDC = NULL)
const 430 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
432 POINT ptOrg = { 0, 0 };
433 ::DPtoLP(hDC1, &ptOrg, 1);
435 pt.y = abs(lfHeight) + ptOrg.y;
436 ::LPtoDP(hDC1, &pt,1);
437 LONG nDeciPoint = ::MulDiv(pt.y, 720, ::GetDeviceCaps(hDC1, LOGPIXELSY));
440 LONG nDeciPoint = ::MulDiv(abs(lfHeight), 720, ::GetDeviceCaps(hDC1, LOGPIXELSY));
443 ::ReleaseDC(NULL, hDC1);
448 void SetHeightFromDeciPoint(LONG nDeciPtHeight, HDC hDC = NULL)
450 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
453 pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720);
454 ::DPtoLP(hDC1, &pt, 1);
455 POINT ptOrg = { 0, 0 };
456 ::DPtoLP(hDC1, &ptOrg, 1);
457 lfHeight = -abs(pt.y - ptOrg.y);
460 lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720));
463 ::ReleaseDC(NULL, hDC1);
467 void SetCaptionFont()
469 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
470 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
471 Copy(&ncm.lfCaptionFont);
476 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
477 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
478 Copy(&ncm.lfMenuFont);
483 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
484 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
485 Copy(&ncm.lfStatusFont);
488 void SetMessageBoxFont()
490 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
491 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
492 Copy(&ncm.lfMessageFont);
494 #endif // !_WIN32_WCE 496 void Copy(
const LOGFONT* pLogFont)
498 ATLASSERT(pLogFont != NULL);
499 *(LOGFONT*)
this = *pLogFont;
508 CLogFont& operator =(
const LOGFONT& src)
516 ATLASSERT(::GetObjectType(hFont) == OBJ_FONT);
517 ::GetObject(hFont,
sizeof(LOGFONT), (LOGFONT*)
this);
521 bool operator ==(
const LOGFONT& logfont)
const 523 return(logfont.lfHeight == lfHeight &&
524 logfont.lfWidth == lfWidth &&
525 logfont.lfEscapement == lfEscapement &&
526 logfont.lfOrientation == lfOrientation &&
527 logfont.lfWeight == lfWeight &&
528 logfont.lfItalic == lfItalic &&
529 logfont.lfUnderline == lfUnderline &&
530 logfont.lfStrikeOut == lfStrikeOut &&
531 logfont.lfCharSet == lfCharSet &&
532 logfont.lfOutPrecision == lfOutPrecision &&
533 logfont.lfClipPrecision == lfClipPrecision &&
534 logfont.lfQuality == lfQuality &&
535 logfont.lfPitchAndFamily == lfPitchAndFamily &&
536 lstrcmp(logfont.lfFaceName, lfFaceName) == 0);
541 template <
bool t_bManaged>
549 CFontT(HFONT hFont = NULL) : m_hFont(hFont)
554 if(t_bManaged && m_hFont != NULL)
564 void Attach(HFONT hFont)
566 if(t_bManaged && m_hFont != NULL && m_hFont != hFont)
567 ::DeleteObject(m_hFont);
573 HFONT hFont = m_hFont;
578 operator HFONT()
const {
return m_hFont; }
580 bool IsNull()
const {
return (m_hFont == NULL); }
583 HFONT CreateFontIndirect(
const LOGFONT* lpLogFont)
585 ATLASSERT(m_hFont == NULL);
586 m_hFont = ::CreateFontIndirect(lpLogFont);
590 #if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) 591 HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex)
593 ATLASSERT(m_hFont == NULL);
594 m_hFont = ::CreateFontIndirectEx(penumlfex);
597 #endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) 599 #if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 600 HFONT CreateFont(
int nHeight,
int nWidth,
int nEscapement,
601 int nOrientation,
int nWeight, BYTE bItalic, BYTE bUnderline,
602 BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
603 BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
604 LPCTSTR lpszFacename)
606 ATLASSERT(m_hFont == NULL);
608 m_hFont = ::CreateFont(nHeight, nWidth, nEscapement,
609 nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
610 nCharSet, nOutPrecision, nClipPrecision, nQuality,
611 nPitchAndFamily, lpszFacename);
613 m_hFont = ATL::CreateFont(nHeight, nWidth, nEscapement,
614 nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
615 nCharSet, nOutPrecision, nClipPrecision, nQuality,
616 nPitchAndFamily, lpszFacename);
620 #endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 622 HFONT CreatePointFont(
int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL,
bool bBold =
false,
bool bItalic =
false)
624 LOGFONT logFont = { 0 };
625 logFont.lfCharSet = DEFAULT_CHARSET;
626 logFont.lfHeight = nPointSize;
627 SecureHelper::strncpy_x(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE);
630 logFont.lfWeight = FW_BOLD;
632 logFont.lfItalic = (BYTE)TRUE;
634 return CreatePointFontIndirect(&logFont, hDC);
637 HFONT CreatePointFontIndirect(
const LOGFONT* lpLogFont, HDC hDC = NULL)
639 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
642 LOGFONT logFont = *lpLogFont;
645 pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720);
646 ::DPtoLP(hDC1, &pt, 1);
647 POINT ptOrg = { 0, 0 };
648 ::DPtoLP(hDC1, &ptOrg, 1);
649 logFont.lfHeight = -abs(pt.y - ptOrg.y);
652 logFont.lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720));
656 ::ReleaseDC(NULL, hDC1);
658 return CreateFontIndirect(&logFont);
663 ATLASSERT(m_hFont != NULL);
664 BOOL bRet = ::DeleteObject(m_hFont);
671 int GetLogFont(LOGFONT* pLogFont)
const 673 ATLASSERT(m_hFont != NULL);
674 return ::GetObject(m_hFont,
sizeof(LOGFONT), pLogFont);
677 bool GetLogFont(LOGFONT& LogFont)
const 679 ATLASSERT(m_hFont != NULL);
680 return (::GetObject(m_hFont,
sizeof(LOGFONT), &LogFont) ==
sizeof(LOGFONT));
691 template <
bool t_bManaged>
699 CBitmapT(HBITMAP hBitmap = NULL) : m_hBitmap(hBitmap)
704 if(t_bManaged && m_hBitmap != NULL)
714 void Attach(HBITMAP hBitmap)
716 if(t_bManaged && m_hBitmap != NULL&& m_hBitmap != hBitmap)
717 ::DeleteObject(m_hBitmap);
723 HBITMAP hBitmap = m_hBitmap;
728 operator HBITMAP()
const {
return m_hBitmap; }
730 bool IsNull()
const {
return (m_hBitmap == NULL); }
735 ATLASSERT(m_hBitmap == NULL);
736 m_hBitmap = ::LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr);
740 HBITMAP LoadOEMBitmap(UINT nIDBitmap)
742 ATLASSERT(m_hBitmap == NULL);
743 m_hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(nIDBitmap));
748 HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL,
int nMapSize = 0)
750 ATLASSERT(m_hBitmap == NULL);
751 m_hBitmap = ::CreateMappedBitmap(ModuleHelper::GetResourceInstance(), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize);
754 #endif // !_WIN32_WCE 756 HBITMAP CreateBitmap(
int nWidth,
int nHeight, UINT nPlanes, UINT nBitsPerPixel,
const void* lpBits)
758 ATLASSERT(m_hBitmap == NULL);
759 m_hBitmap = ::CreateBitmap(nWidth, nHeight, nPlanes, nBitsPerPixel, lpBits);
764 HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap)
766 ATLASSERT(m_hBitmap == NULL);
767 m_hBitmap = ::CreateBitmapIndirect(lpBitmap);
770 #endif // !_WIN32_WCE 772 HBITMAP CreateCompatibleBitmap(HDC hDC,
int nWidth,
int nHeight)
774 ATLASSERT(m_hBitmap == NULL);
775 m_hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight);
780 HBITMAP CreateDiscardableBitmap(HDC hDC,
int nWidth,
int nHeight)
782 ATLASSERT(m_hBitmap == NULL);
783 m_hBitmap = ::CreateDiscardableBitmap(hDC, nWidth, nHeight);
786 #endif // !_WIN32_WCE 790 ATLASSERT(m_hBitmap != NULL);
791 BOOL bRet = ::DeleteObject(m_hBitmap);
798 int GetBitmap(BITMAP* pBitMap)
const 800 ATLASSERT(m_hBitmap != NULL);
801 return ::GetObject(m_hBitmap,
sizeof(BITMAP), pBitMap);
804 bool GetBitmap(BITMAP& bm)
const 806 ATLASSERT(m_hBitmap != NULL);
807 return (::GetObject(m_hBitmap,
sizeof(BITMAP), &bm) ==
sizeof(BITMAP));
810 bool GetSize(SIZE& size)
const 812 ATLASSERT(m_hBitmap != NULL);
816 size.cx = bm.bmWidth;
817 size.cy = bm.bmHeight;
822 DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits)
const 824 ATLASSERT(m_hBitmap != NULL);
825 return ::GetBitmapBits(m_hBitmap, dwCount, lpBits);
827 #endif // !_WIN32_WCE 829 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 830 DWORD SetBitmapBits(DWORD dwCount,
const void* lpBits)
832 ATLASSERT(m_hBitmap != NULL);
833 return ::SetBitmapBits(m_hBitmap, dwCount, lpBits);
835 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 838 BOOL GetBitmapDimension(LPSIZE lpSize)
const 840 ATLASSERT(m_hBitmap != NULL);
841 return ::GetBitmapDimensionEx(m_hBitmap, lpSize);
844 BOOL SetBitmapDimension(
int nWidth,
int nHeight, LPSIZE lpSize = NULL)
846 ATLASSERT(m_hBitmap != NULL);
847 return ::SetBitmapDimensionEx(m_hBitmap, nWidth, nHeight, lpSize);
851 HBITMAP CreateDIBitmap(HDC hDC, CONST BITMAPINFOHEADER* lpbmih, DWORD dwInit, CONST VOID* lpbInit, CONST BITMAPINFO* lpbmi, UINT uColorUse)
853 ATLASSERT(m_hBitmap == NULL);
854 m_hBitmap = ::CreateDIBitmap(hDC, lpbmih, dwInit, lpbInit, lpbmi, uColorUse);
857 #endif // !_WIN32_WCE 859 HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse, VOID** ppvBits, HANDLE hSection, DWORD dwOffset)
861 ATLASSERT(m_hBitmap == NULL);
862 m_hBitmap = ::CreateDIBSection(hDC, lpbmi, uColorUse, ppvBits, hSection, dwOffset);
867 int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse)
const 869 ATLASSERT(m_hBitmap != NULL);
870 return ::GetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
873 int SetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse)
875 ATLASSERT(m_hBitmap != NULL);
876 return ::SetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
878 #endif // !_WIN32_WCE 888 template <
bool t_bManaged>
896 CPaletteT(HPALETTE hPalette = NULL) : m_hPalette(hPalette)
901 if(t_bManaged && m_hPalette != NULL)
911 void Attach(HPALETTE hPalette)
913 if(t_bManaged && m_hPalette != NULL && m_hPalette != hPalette)
914 ::DeleteObject(m_hPalette);
915 m_hPalette = hPalette;
920 HPALETTE hPalette = m_hPalette;
925 operator HPALETTE()
const {
return m_hPalette; }
927 bool IsNull()
const {
return (m_hPalette == NULL); }
930 HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)
932 ATLASSERT(m_hPalette == NULL);
933 m_hPalette = ::CreatePalette(lpLogPalette);
938 HPALETTE CreateHalftonePalette(HDC hDC)
940 ATLASSERT(m_hPalette == NULL);
941 ATLASSERT(hDC != NULL);
942 m_hPalette = ::CreateHalftonePalette(hDC);
945 #endif // !_WIN32_WCE 949 ATLASSERT(m_hPalette != NULL);
950 BOOL bRet = ::DeleteObject(m_hPalette);
957 int GetEntryCount()
const 959 ATLASSERT(m_hPalette != NULL);
961 ::GetObject(m_hPalette,
sizeof(WORD), &nEntries);
962 return (
int)nEntries;
965 UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
const 967 ATLASSERT(m_hPalette != NULL);
968 return ::GetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
971 UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
973 ATLASSERT(m_hPalette != NULL);
974 return ::SetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
979 void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
981 ATLASSERT(m_hPalette != NULL);
982 ::AnimatePalette(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
985 BOOL ResizePalette(UINT nNumEntries)
987 ATLASSERT(m_hPalette != NULL);
988 return ::ResizePalette(m_hPalette, nNumEntries);
990 #endif // !_WIN32_WCE 992 UINT GetNearestPaletteIndex(COLORREF crColor)
const 994 ATLASSERT(m_hPalette != NULL);
995 return ::GetNearestPaletteIndex(m_hPalette, crColor);
1006 template <
bool t_bManaged>
1014 CRgnT(HRGN hRgn = NULL) : m_hRgn(hRgn)
1019 if(t_bManaged && m_hRgn != NULL)
1029 void Attach(HRGN hRgn)
1031 if(t_bManaged && m_hRgn != NULL && m_hRgn != hRgn)
1032 ::DeleteObject(m_hRgn);
1043 operator HRGN()
const {
return m_hRgn; }
1045 bool IsNull()
const {
return (m_hRgn == NULL); }
1048 HRGN CreateRectRgn(
int x1,
int y1,
int x2,
int y2)
1050 ATLASSERT(m_hRgn == NULL);
1051 m_hRgn = ::CreateRectRgn(x1, y1, x2, y2);
1055 HRGN CreateRectRgnIndirect(LPCRECT lpRect)
1057 ATLASSERT(m_hRgn == NULL);
1058 m_hRgn = ::CreateRectRgnIndirect(lpRect);
1063 HRGN CreateEllipticRgn(
int x1,
int y1,
int x2,
int y2)
1065 ATLASSERT(m_hRgn == NULL);
1066 m_hRgn = ::CreateEllipticRgn(x1, y1, x2, y2);
1070 HRGN CreateEllipticRgnIndirect(LPCRECT lpRect)
1072 ATLASSERT(m_hRgn == NULL);
1073 m_hRgn = ::CreateEllipticRgnIndirect(lpRect);
1077 HRGN CreatePolygonRgn(LPPOINT lpPoints,
int nCount,
int nMode)
1079 ATLASSERT(m_hRgn == NULL);
1080 m_hRgn = ::CreatePolygonRgn(lpPoints, nCount, nMode);
1084 HRGN CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
int nCount,
int nPolyFillMode)
1086 ATLASSERT(m_hRgn == NULL);
1087 m_hRgn = ::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode);
1091 HRGN CreateRoundRectRgn(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
1093 ATLASSERT(m_hRgn == NULL);
1094 m_hRgn = ::CreateRoundRectRgn(x1, y1, x2, y2, x3, y3);
1098 HRGN CreateFromPath(HDC hDC)
1100 ATLASSERT(m_hRgn == NULL);
1101 ATLASSERT(hDC != NULL);
1102 m_hRgn = ::PathToRegion(hDC);
1106 HRGN CreateFromData(
const XFORM* lpXForm,
int nCount,
const RGNDATA* pRgnData)
1108 ATLASSERT(m_hRgn == NULL);
1109 m_hRgn = ::ExtCreateRegion(lpXForm, nCount, pRgnData);
1112 #endif // !_WIN32_WCE 1116 ATLASSERT(m_hRgn != NULL);
1117 BOOL bRet = ::DeleteObject(m_hRgn);
1124 void SetRectRgn(
int x1,
int y1,
int x2,
int y2)
1126 ATLASSERT(m_hRgn != NULL);
1127 ::SetRectRgn(m_hRgn, x1, y1, x2, y2);
1130 void SetRectRgn(LPCRECT lpRect)
1132 ATLASSERT(m_hRgn != NULL);
1133 ::SetRectRgn(m_hRgn, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1136 int CombineRgn(HRGN hRgnSrc1, HRGN hRgnSrc2,
int nCombineMode)
1138 ATLASSERT(m_hRgn != NULL);
1139 return ::CombineRgn(m_hRgn, hRgnSrc1, hRgnSrc2, nCombineMode);
1142 int CombineRgn(HRGN hRgnSrc,
int nCombineMode)
1144 ATLASSERT(m_hRgn != NULL);
1145 return ::CombineRgn(m_hRgn, m_hRgn, hRgnSrc, nCombineMode);
1148 int CopyRgn(HRGN hRgnSrc)
1150 ATLASSERT(m_hRgn != NULL);
1151 return ::CombineRgn(m_hRgn, hRgnSrc, NULL, RGN_COPY);
1154 BOOL EqualRgn(HRGN hRgn)
const 1156 ATLASSERT(m_hRgn != NULL);
1157 return ::EqualRgn(m_hRgn, hRgn);
1160 int OffsetRgn(
int x,
int y)
1162 ATLASSERT(m_hRgn != NULL);
1163 return ::OffsetRgn(m_hRgn, x, y);
1166 int OffsetRgn(POINT point)
1168 ATLASSERT(m_hRgn != NULL);
1169 return ::OffsetRgn(m_hRgn, point.x, point.y);
1172 int GetRgnBox(LPRECT lpRect)
const 1174 ATLASSERT(m_hRgn != NULL);
1175 return ::GetRgnBox(m_hRgn, lpRect);
1178 BOOL PtInRegion(
int x,
int y)
const 1180 ATLASSERT(m_hRgn != NULL);
1181 return ::PtInRegion(m_hRgn, x, y);
1184 BOOL PtInRegion(POINT point)
const 1186 ATLASSERT(m_hRgn != NULL);
1187 return ::PtInRegion(m_hRgn, point.x, point.y);
1190 BOOL RectInRegion(LPCRECT lpRect)
const 1192 ATLASSERT(m_hRgn != NULL);
1193 return ::RectInRegion(m_hRgn, lpRect);
1196 int GetRegionData(LPRGNDATA lpRgnData,
int nDataSize)
const 1198 ATLASSERT(m_hRgn != NULL);
1199 return (
int)::GetRegionData(m_hRgn, nDataSize, lpRgnData);
1210 template <
bool t_bManaged>
1218 CDCT(HDC hDC = NULL) : m_hDC(hDC)
1224 if(t_bManaged && m_hDC != NULL)
1225 ::DeleteDC(Detach());
1234 void Attach(HDC hDC)
1236 if(t_bManaged && m_hDC != NULL && m_hDC != hDC)
1248 operator HDC()
const {
return m_hDC; }
1250 bool IsNull()
const {
return (m_hDC == NULL); }
1254 HWND WindowFromDC()
const 1256 ATLASSERT(m_hDC != NULL);
1257 return ::WindowFromDC(m_hDC);
1259 #endif // !_WIN32_WCE 1261 CPenHandle GetCurrentPen()
const 1263 ATLASSERT(m_hDC != NULL);
1264 return CPenHandle((HPEN)::GetCurrentObject(m_hDC, OBJ_PEN));
1267 CBrushHandle GetCurrentBrush()
const 1269 ATLASSERT(m_hDC != NULL);
1270 return CBrushHandle((HBRUSH)::GetCurrentObject(m_hDC, OBJ_BRUSH));
1273 CPaletteHandle GetCurrentPalette()
const 1275 ATLASSERT(m_hDC != NULL);
1276 return CPaletteHandle((HPALETTE)::GetCurrentObject(m_hDC, OBJ_PAL));
1279 CFontHandle GetCurrentFont()
const 1281 ATLASSERT(m_hDC != NULL);
1282 return CFontHandle((HFONT)::GetCurrentObject(m_hDC, OBJ_FONT));
1285 CBitmapHandle GetCurrentBitmap()
const 1287 ATLASSERT(m_hDC != NULL);
1288 return CBitmapHandle((HBITMAP)::GetCurrentObject(m_hDC, OBJ_BITMAP));
1291 HDC CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput,
const DEVMODE* lpInitData)
1293 ATLASSERT(m_hDC == NULL);
1294 m_hDC = ::CreateDC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData);
1298 HDC CreateCompatibleDC(HDC hDC = NULL)
1300 ATLASSERT(m_hDC == NULL);
1301 m_hDC = ::CreateCompatibleDC(hDC);
1309 BOOL bRet = ::DeleteDC(m_hDC);
1318 ATLASSERT(m_hDC != NULL);
1319 return ::SaveDC(m_hDC);
1322 BOOL RestoreDC(
int nSavedDC)
1324 ATLASSERT(m_hDC != NULL);
1325 return ::RestoreDC(m_hDC, nSavedDC);
1328 int GetDeviceCaps(
int nIndex)
const 1330 ATLASSERT(m_hDC != NULL);
1331 return ::GetDeviceCaps(m_hDC, nIndex);
1335 UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags)
1337 ATLASSERT(m_hDC != NULL);
1338 return ::SetBoundsRect(m_hDC, lpRectBounds, flags);
1341 UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags)
const 1343 ATLASSERT(m_hDC != NULL);
1344 return ::GetBoundsRect(m_hDC, lpRectBounds, flags);
1347 BOOL ResetDC(
const DEVMODE* lpDevMode)
1349 ATLASSERT(m_hDC != NULL);
1350 return ::ResetDC(m_hDC, lpDevMode) != NULL;
1354 BOOL GetBrushOrg(LPPOINT lpPoint)
const 1356 ATLASSERT(m_hDC != NULL);
1357 return ::GetBrushOrgEx(m_hDC, lpPoint);
1359 #endif // !_WIN32_WCE 1361 BOOL SetBrushOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1363 ATLASSERT(m_hDC != NULL);
1364 return ::SetBrushOrgEx(m_hDC, x, y, lpPoint);
1367 BOOL SetBrushOrg(POINT point, LPPOINT lpPointRet = NULL)
1369 ATLASSERT(m_hDC != NULL);
1370 return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet);
1374 int EnumObjects(
int nObjectType,
int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData)
1376 ATLASSERT(m_hDC != NULL);
1378 return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, lpData);
1380 return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData);
1383 #endif // !_WIN32_WCE 1386 HPEN SelectPen(HPEN hPen)
1388 ATLASSERT(m_hDC != NULL);
1390 ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN || ::GetObjectType(hPen) == OBJ_EXTPEN);
1391 #else // CE specific 1392 ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN);
1393 #endif // _WIN32_WCE 1394 return (HPEN)::SelectObject(m_hDC, hPen);
1397 HBRUSH SelectBrush(HBRUSH hBrush)
1399 ATLASSERT(m_hDC != NULL);
1400 ATLASSERT(hBrush == NULL || ::GetObjectType(hBrush) == OBJ_BRUSH);
1401 return (HBRUSH)::SelectObject(m_hDC, hBrush);
1404 HFONT SelectFont(HFONT hFont)
1406 ATLASSERT(m_hDC != NULL);
1407 ATLASSERT(hFont == NULL || ::GetObjectType(hFont) == OBJ_FONT);
1408 return (HFONT)::SelectObject(m_hDC, hFont);
1411 HBITMAP SelectBitmap(HBITMAP hBitmap)
1413 ATLASSERT(m_hDC != NULL);
1414 ATLASSERT(hBitmap == NULL || ::GetObjectType(hBitmap) == OBJ_BITMAP);
1415 return (HBITMAP)::SelectObject(m_hDC, hBitmap);
1418 int SelectRgn(HRGN hRgn)
1420 ATLASSERT(m_hDC != NULL);
1421 ATLASSERT(hRgn == NULL || ::GetObjectType(hRgn) == OBJ_REGION);
1422 return PtrToInt(::SelectObject(m_hDC, hRgn));
1426 HPEN SelectStockPen(
int nPen)
1428 ATLASSERT(m_hDC != NULL);
1429 #if (_WIN32_WINNT >= 0x0500) 1430 ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN);
1432 ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN);
1433 #endif // !(_WIN32_WINNT >= 0x0500) 1434 return SelectPen((HPEN)::GetStockObject(nPen));
1437 HBRUSH SelectStockBrush(
int nBrush)
1439 #if (_WIN32_WINNT >= 0x0500) 1440 ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH);
1442 ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH);
1443 #endif // !(_WIN32_WINNT >= 0x0500) 1444 return SelectBrush((HBRUSH)::GetStockObject(nBrush));
1447 HFONT SelectStockFont(
int nFont)
1450 ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT);
1451 #else // CE specific 1452 ATLASSERT(nFont == SYSTEM_FONT);
1453 #endif // _WIN32_WCE 1454 return SelectFont((HFONT)::GetStockObject(nFont));
1457 HPALETTE SelectStockPalette(
int nPalette, BOOL bForceBackground)
1459 ATLASSERT(nPalette == DEFAULT_PALETTE);
1460 return SelectPalette((HPALETTE)::GetStockObject(nPalette), bForceBackground);
1464 COLORREF GetNearestColor(COLORREF crColor)
const 1466 ATLASSERT(m_hDC != NULL);
1467 return ::GetNearestColor(m_hDC, crColor);
1470 HPALETTE SelectPalette(HPALETTE hPalette, BOOL bForceBackground)
1472 ATLASSERT(m_hDC != NULL);
1474 return ::SelectPalette(m_hDC, hPalette, bForceBackground);
1477 UINT RealizePalette()
1479 ATLASSERT(m_hDC != NULL);
1480 return ::RealizePalette(m_hDC);
1486 ATLASSERT(m_hDC != NULL);
1487 ::UpdateColors(m_hDC);
1489 #endif // !_WIN32_WCE 1492 COLORREF GetBkColor()
const 1494 ATLASSERT(m_hDC != NULL);
1495 return ::GetBkColor(m_hDC);
1498 int GetBkMode()
const 1500 ATLASSERT(m_hDC != NULL);
1501 return ::GetBkMode(m_hDC);
1505 int GetPolyFillMode()
const 1507 ATLASSERT(m_hDC != NULL);
1508 return ::GetPolyFillMode(m_hDC);
1513 ATLASSERT(m_hDC != NULL);
1514 return ::GetROP2(m_hDC);
1517 int GetStretchBltMode()
const 1519 ATLASSERT(m_hDC != NULL);
1520 return ::GetStretchBltMode(m_hDC);
1522 #endif // !_WIN32_WCE 1524 COLORREF GetTextColor()
const 1526 ATLASSERT(m_hDC != NULL);
1527 return ::GetTextColor(m_hDC);
1530 COLORREF SetBkColor(COLORREF crColor)
1532 ATLASSERT(m_hDC != NULL);
1533 return ::SetBkColor(m_hDC, crColor);
1536 int SetBkMode(
int nBkMode)
1538 ATLASSERT(m_hDC != NULL);
1539 return ::SetBkMode(m_hDC, nBkMode);
1543 int SetPolyFillMode(
int nPolyFillMode)
1545 ATLASSERT(m_hDC != NULL);
1546 return ::SetPolyFillMode(m_hDC, nPolyFillMode);
1548 #endif // !_WIN32_WCE 1550 int SetROP2(
int nDrawMode)
1552 ATLASSERT(m_hDC != NULL);
1553 return ::SetROP2(m_hDC, nDrawMode);
1557 int SetStretchBltMode(
int nStretchMode)
1559 ATLASSERT(m_hDC != NULL);
1560 return ::SetStretchBltMode(m_hDC, nStretchMode);
1562 #endif // !_WIN32_WCE 1564 COLORREF SetTextColor(COLORREF crColor)
1566 ATLASSERT(m_hDC != NULL);
1567 return ::SetTextColor(m_hDC, crColor);
1571 BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust)
const 1573 ATLASSERT(m_hDC != NULL);
1574 return ::GetColorAdjustment(m_hDC, lpColorAdjust);
1577 BOOL SetColorAdjustment(
const COLORADJUSTMENT* lpColorAdjust)
1579 ATLASSERT(m_hDC != NULL);
1580 return ::SetColorAdjustment(m_hDC, lpColorAdjust);
1584 int GetMapMode()
const 1586 ATLASSERT(m_hDC != NULL);
1587 return ::GetMapMode(m_hDC);
1590 BOOL GetViewportOrg(LPPOINT lpPoint)
const 1592 ATLASSERT(m_hDC != NULL);
1593 return ::GetViewportOrgEx(m_hDC, lpPoint);
1596 int SetMapMode(
int nMapMode)
1598 ATLASSERT(m_hDC != NULL);
1599 return ::SetMapMode(m_hDC, nMapMode);
1601 #endif // !_WIN32_WCE 1604 BOOL SetViewportOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1606 ATLASSERT(m_hDC != NULL);
1607 return ::SetViewportOrgEx(m_hDC, x, y, lpPoint);
1610 BOOL SetViewportOrg(POINT point, LPPOINT lpPointRet = NULL)
1612 ATLASSERT(m_hDC != NULL);
1613 return SetViewportOrg(point.x, point.y, lpPointRet);
1617 BOOL OffsetViewportOrg(
int nWidth,
int nHeight, LPPOINT lpPoint = NULL)
1619 ATLASSERT(m_hDC != NULL);
1620 return ::OffsetViewportOrgEx(m_hDC, nWidth, nHeight, lpPoint);
1624 BOOL GetViewportExt(LPSIZE lpSize)
const 1626 ATLASSERT(m_hDC != NULL);
1627 return ::GetViewportExtEx(m_hDC, lpSize);
1630 BOOL SetViewportExt(
int x,
int y, LPSIZE lpSize = NULL)
1632 ATLASSERT(m_hDC != NULL);
1633 return ::SetViewportExtEx(m_hDC, x, y, lpSize);
1636 BOOL SetViewportExt(SIZE size, LPSIZE lpSizeRet = NULL)
1638 ATLASSERT(m_hDC != NULL);
1639 return SetViewportExt(size.cx, size.cy, lpSizeRet);
1642 BOOL ScaleViewportExt(
int xNum,
int xDenom,
int yNum,
int yDenom, LPSIZE lpSize = NULL)
1644 ATLASSERT(m_hDC != NULL);
1645 return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
1647 #endif // !_WIN32_WCE 1651 BOOL GetWindowOrg(LPPOINT lpPoint)
const 1653 ATLASSERT(m_hDC != NULL);
1654 return ::GetWindowOrgEx(m_hDC, lpPoint);
1657 BOOL SetWindowOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1659 ATLASSERT(m_hDC != NULL);
1660 return ::SetWindowOrgEx(m_hDC, x, y, lpPoint);
1663 BOOL SetWindowOrg(POINT point, LPPOINT lpPointRet = NULL)
1665 ATLASSERT(m_hDC != NULL);
1666 return SetWindowOrg(point.x, point.y, lpPointRet);
1669 BOOL OffsetWindowOrg(
int nWidth,
int nHeight, LPPOINT lpPoint = NULL)
1671 ATLASSERT(m_hDC != NULL);
1672 return ::OffsetWindowOrgEx(m_hDC, nWidth, nHeight, lpPoint);
1676 BOOL GetWindowExt(LPSIZE lpSize)
const 1678 ATLASSERT(m_hDC != NULL);
1679 return ::GetWindowExtEx(m_hDC, lpSize);
1682 BOOL SetWindowExt(
int x,
int y, LPSIZE lpSize = NULL)
1684 ATLASSERT(m_hDC != NULL);
1685 return ::SetWindowExtEx(m_hDC, x, y, lpSize);
1688 BOOL SetWindowExt(SIZE size, LPSIZE lpSizeRet = NULL)
1690 ATLASSERT(m_hDC != NULL);
1691 return SetWindowExt(size.cx, size.cy, lpSizeRet);
1694 BOOL ScaleWindowExt(
int xNum,
int xDenom,
int yNum,
int yDenom, LPSIZE lpSize = NULL)
1696 ATLASSERT(m_hDC != NULL);
1697 return ::ScaleWindowExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
1701 BOOL DPtoLP(LPPOINT lpPoints,
int nCount = 1)
const 1703 ATLASSERT(m_hDC != NULL);
1704 return ::DPtoLP(m_hDC, lpPoints, nCount);
1707 BOOL DPtoLP(LPRECT lpRect)
const 1709 ATLASSERT(m_hDC != NULL);
1710 return ::DPtoLP(m_hDC, (LPPOINT)lpRect, 2);
1713 BOOL DPtoLP(LPSIZE lpSize)
const 1715 SIZE sizeWinExt = { 0, 0 };
1716 if(!GetWindowExt(&sizeWinExt))
1718 SIZE sizeVpExt = { 0, 0 };
1719 if(!GetViewportExt(&sizeVpExt))
1721 lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx));
1722 lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeWinExt.cy), abs(sizeVpExt.cy));
1726 BOOL LPtoDP(LPPOINT lpPoints,
int nCount = 1)
const 1728 ATLASSERT(m_hDC != NULL);
1729 return ::LPtoDP(m_hDC, lpPoints, nCount);
1732 BOOL LPtoDP(LPRECT lpRect)
const 1734 ATLASSERT(m_hDC != NULL);
1735 return ::LPtoDP(m_hDC, (LPPOINT)lpRect, 2);
1738 BOOL LPtoDP(LPSIZE lpSize)
const 1740 SIZE sizeWinExt = { 0, 0 };
1741 if(!GetWindowExt(&sizeWinExt))
1743 SIZE sizeVpExt = { 0, 0 };
1744 if(!GetViewportExt(&sizeVpExt))
1746 lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx));
1747 lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeVpExt.cy), abs(sizeWinExt.cy));
1752 #define HIMETRIC_INCH 2540 // HIMETRIC units per inch 1754 void DPtoHIMETRIC(LPSIZE lpSize)
const 1756 ATLASSERT(m_hDC != NULL);
1758 if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
1761 ((
CDCHandle*)
this)->SetMapMode(MM_HIMETRIC);
1763 ((
CDCHandle*)
this)->SetMapMode(nMapMode);
1768 int cxPerInch = GetDeviceCaps(LOGPIXELSX);
1769 int cyPerInch = GetDeviceCaps(LOGPIXELSY);
1770 ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
1771 lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch);
1772 lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch);
1776 void HIMETRICtoDP(LPSIZE lpSize)
const 1778 ATLASSERT(m_hDC != NULL);
1780 if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
1783 ((
CDCHandle*)
this)->SetMapMode(MM_HIMETRIC);
1785 ((
CDCHandle*)
this)->SetMapMode(nMapMode);
1790 int cxPerInch = GetDeviceCaps(LOGPIXELSX);
1791 int cyPerInch = GetDeviceCaps(LOGPIXELSY);
1792 ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
1793 lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH);
1794 lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH);
1798 void LPtoHIMETRIC(LPSIZE lpSize)
const 1801 DPtoHIMETRIC(lpSize);
1804 void HIMETRICtoLP(LPSIZE lpSize)
const 1806 HIMETRICtoDP(lpSize);
1809 #endif // !_WIN32_WCE 1812 BOOL FillRgn(HRGN hRgn, HBRUSH hBrush)
1814 ATLASSERT(m_hDC != NULL);
1815 return ::FillRgn(m_hDC, hRgn, hBrush);
1819 BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush,
int nWidth,
int nHeight)
1821 ATLASSERT(m_hDC != NULL);
1822 return ::FrameRgn(m_hDC, hRgn, hBrush, nWidth, nHeight);
1825 BOOL InvertRgn(HRGN hRgn)
1827 ATLASSERT(m_hDC != NULL);
1828 return ::InvertRgn(m_hDC, hRgn);
1831 BOOL PaintRgn(HRGN hRgn)
1833 ATLASSERT(m_hDC != NULL);
1834 return ::PaintRgn(m_hDC, hRgn);
1836 #endif // !_WIN32_WCE 1839 int GetClipBox(LPRECT lpRect)
const 1841 ATLASSERT(m_hDC != NULL);
1842 return ::GetClipBox(m_hDC, lpRect);
1845 int GetClipRgn(CRgn& region)
const 1847 ATLASSERT(m_hDC != NULL);
1849 region.CreateRectRgn(0, 0, 0, 0);
1851 int nRet = ::GetClipRgn(m_hDC, region);
1853 region.DeleteObject();
1859 BOOL PtVisible(
int x,
int y)
const 1861 ATLASSERT(m_hDC != NULL);
1862 return ::PtVisible(m_hDC, x, y);
1865 BOOL PtVisible(POINT point)
const 1867 ATLASSERT(m_hDC != NULL);
1868 return ::PtVisible(m_hDC, point.x, point.y);
1870 #endif // !_WIN32_WCE 1872 BOOL RectVisible(LPCRECT lpRect)
const 1874 ATLASSERT(m_hDC != NULL);
1875 return ::RectVisible(m_hDC, lpRect);
1878 int SelectClipRgn(HRGN hRgn)
1880 ATLASSERT(m_hDC != NULL);
1881 return ::SelectClipRgn(m_hDC, (HRGN)hRgn);
1884 int ExcludeClipRect(
int x1,
int y1,
int x2,
int y2)
1886 ATLASSERT(m_hDC != NULL);
1887 return ::ExcludeClipRect(m_hDC, x1, y1, x2, y2);
1890 int ExcludeClipRect(LPCRECT lpRect)
1892 ATLASSERT(m_hDC != NULL);
1893 return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1897 int ExcludeUpdateRgn(HWND hWnd)
1899 ATLASSERT(m_hDC != NULL);
1900 return ::ExcludeUpdateRgn(m_hDC, hWnd);
1902 #endif // !_WIN32_WCE 1904 int IntersectClipRect(
int x1,
int y1,
int x2,
int y2)
1906 ATLASSERT(m_hDC != NULL);
1907 return ::IntersectClipRect(m_hDC, x1, y1, x2, y2);
1910 int IntersectClipRect(LPCRECT lpRect)
1912 ATLASSERT(m_hDC != NULL);
1913 return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1917 int OffsetClipRgn(
int x,
int y)
1919 ATLASSERT(m_hDC != NULL);
1920 return ::OffsetClipRgn(m_hDC, x, y);
1923 int OffsetClipRgn(SIZE size)
1925 ATLASSERT(m_hDC != NULL);
1926 return ::OffsetClipRgn(m_hDC, size.cx, size.cy);
1929 int SelectClipRgn(HRGN hRgn,
int nMode)
1931 ATLASSERT(m_hDC != NULL);
1932 return ::ExtSelectClipRgn(m_hDC, hRgn, nMode);
1934 #endif // !_WIN32_WCE 1937 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 1938 BOOL GetCurrentPosition(LPPOINT lpPoint)
const 1940 ATLASSERT(m_hDC != NULL);
1941 return ::GetCurrentPositionEx(m_hDC, lpPoint);
1944 BOOL MoveTo(
int x,
int y, LPPOINT lpPoint = NULL)
1946 ATLASSERT(m_hDC != NULL);
1947 return ::MoveToEx(m_hDC, x, y, lpPoint);
1950 BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL)
1952 ATLASSERT(m_hDC != NULL);
1953 return MoveTo(point.x, point.y, lpPointRet);
1956 BOOL LineTo(
int x,
int y)
1958 ATLASSERT(m_hDC != NULL);
1959 return ::LineTo(m_hDC, x, y);
1962 BOOL LineTo(POINT point)
1964 ATLASSERT(m_hDC != NULL);
1965 return LineTo(point.x, point.y);
1967 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 1970 BOOL Arc(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
1972 ATLASSERT(m_hDC != NULL);
1973 return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
1976 BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
1978 ATLASSERT(m_hDC != NULL);
1979 return ::Arc(m_hDC, lpRect->left, lpRect->top,
1980 lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
1983 #endif // !_WIN32_WCE 1985 BOOL Polyline(LPPOINT lpPoints,
int nCount)
1987 ATLASSERT(m_hDC != NULL);
1988 return ::Polyline(m_hDC, lpPoints, nCount);
1992 BOOL AngleArc(
int x,
int y,
int nRadius,
float fStartAngle,
float fSweepAngle)
1994 ATLASSERT(m_hDC != NULL);
1995 return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle);
1998 BOOL ArcTo(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
2000 ATLASSERT(m_hDC != NULL);
2001 return ::ArcTo(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2004 BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2006 ATLASSERT(m_hDC != NULL);
2007 return ArcTo(lpRect->left, lpRect->top, lpRect->right,
2008 lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2011 int GetArcDirection()
const 2013 ATLASSERT(m_hDC != NULL);
2014 return ::GetArcDirection(m_hDC);
2017 int SetArcDirection(
int nArcDirection)
2019 ATLASSERT(m_hDC != NULL);
2020 return ::SetArcDirection(m_hDC, nArcDirection);
2023 BOOL PolyDraw(
const POINT* lpPoints,
const BYTE* lpTypes,
int nCount)
2025 ATLASSERT(m_hDC != NULL);
2026 return ::PolyDraw(m_hDC, lpPoints, lpTypes, nCount);
2029 BOOL PolylineTo(
const POINT* lpPoints,
int nCount)
2031 ATLASSERT(m_hDC != NULL);
2032 return ::PolylineTo(m_hDC, lpPoints, nCount);
2035 BOOL PolyPolyline(
const POINT* lpPoints,
2036 const DWORD* lpPolyPoints,
int nCount)
2038 ATLASSERT(m_hDC != NULL);
2039 return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount);
2042 BOOL PolyBezier(
const POINT* lpPoints,
int nCount)
2044 ATLASSERT(m_hDC != NULL);
2045 return ::PolyBezier(m_hDC, lpPoints, nCount);
2048 BOOL PolyBezierTo(
const POINT* lpPoints,
int nCount)
2050 ATLASSERT(m_hDC != NULL);
2051 return ::PolyBezierTo(m_hDC, lpPoints, nCount);
2053 #endif // !_WIN32_WCE 2056 BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush)
2058 ATLASSERT(m_hDC != NULL);
2059 return ::FillRect(m_hDC, lpRect, hBrush);
2062 BOOL FillRect(LPCRECT lpRect,
int nColorIndex)
2064 ATLASSERT(m_hDC != NULL);
2066 return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1));
2067 #else // CE specific 2068 return ::FillRect(m_hDC, lpRect, ::GetSysColorBrush(nColorIndex));
2069 #endif // _WIN32_WCE 2073 BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush)
2075 ATLASSERT(m_hDC != NULL);
2076 return ::FrameRect(m_hDC, lpRect, hBrush);
2078 #endif // !_WIN32_WCE 2080 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2081 BOOL InvertRect(LPCRECT lpRect)
2083 ATLASSERT(m_hDC != NULL);
2084 return ::InvertRect(m_hDC, lpRect);
2086 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2088 BOOL DrawIcon(
int x,
int y, HICON hIcon)
2090 ATLASSERT(m_hDC != NULL);
2092 return ::DrawIcon(m_hDC, x, y, hIcon);
2093 #else // CE specific 2094 return ::DrawIconEx(m_hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
2095 #endif // _WIN32_WCE 2098 BOOL DrawIcon(POINT point, HICON hIcon)
2100 ATLASSERT(m_hDC != NULL);
2102 return ::DrawIcon(m_hDC, point.x, point.y, hIcon);
2103 #else // CE specific 2104 return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
2105 #endif // _WIN32_WCE 2108 BOOL DrawIconEx(
int x,
int y, HICON hIcon,
int cxWidth,
int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
2110 ATLASSERT(m_hDC != NULL);
2111 return ::DrawIconEx(m_hDC, x, y, hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
2114 BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
2116 ATLASSERT(m_hDC != NULL);
2117 return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
2121 BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL)
2123 ATLASSERT(m_hDC != NULL);
2124 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_BITMAP);
2127 BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL)
2129 ATLASSERT(m_hDC != NULL);
2130 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_ICON);
2133 BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE,
int nTextLen = 0, HBRUSH hBrush = NULL)
2135 ATLASSERT(m_hDC != NULL);
2136 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags | (bPrefixText ? DST_PREFIXTEXT : DST_TEXT));
2139 BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL)
2141 ATLASSERT(m_hDC != NULL);
2142 return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX);
2144 #endif // !_WIN32_WCE 2148 BOOL Chord(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
2150 ATLASSERT(m_hDC != NULL);
2151 return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2154 BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2156 ATLASSERT(m_hDC != NULL);
2157 return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2159 #endif // !_WIN32_WCE 2161 void DrawFocusRect(LPCRECT lpRect)
2163 ATLASSERT(m_hDC != NULL);
2164 ::DrawFocusRect(m_hDC, lpRect);
2167 BOOL Ellipse(
int x1,
int y1,
int x2,
int y2)
2169 ATLASSERT(m_hDC != NULL);
2170 return ::Ellipse(m_hDC, x1, y1, x2, y2);
2173 BOOL Ellipse(LPCRECT lpRect)
2175 ATLASSERT(m_hDC != NULL);
2176 return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
2180 BOOL Pie(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
2182 ATLASSERT(m_hDC != NULL);
2183 return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2186 BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2188 ATLASSERT(m_hDC != NULL);
2189 return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2191 #endif // !_WIN32_WCE 2193 BOOL Polygon(LPPOINT lpPoints,
int nCount)
2195 ATLASSERT(m_hDC != NULL);
2196 return ::Polygon(m_hDC, lpPoints, nCount);
2200 BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts,
int nCount)
2202 ATLASSERT(m_hDC != NULL);
2203 return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount);
2205 #endif // !_WIN32_WCE 2207 BOOL Rectangle(
int x1,
int y1,
int x2,
int y2)
2209 ATLASSERT(m_hDC != NULL);
2210 return ::Rectangle(m_hDC, x1, y1, x2, y2);
2213 BOOL Rectangle(LPCRECT lpRect)
2215 ATLASSERT(m_hDC != NULL);
2216 return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
2219 BOOL RoundRect(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
2221 ATLASSERT(m_hDC != NULL);
2222 return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3);
2225 BOOL RoundRect(LPCRECT lpRect, POINT point)
2227 ATLASSERT(m_hDC != NULL);
2228 return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y);
2232 BOOL PatBlt(
int x,
int y,
int nWidth,
int nHeight, DWORD dwRop)
2234 ATLASSERT(m_hDC != NULL);
2235 return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop);
2238 BOOL BitBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
2239 int xSrc,
int ySrc, DWORD dwRop)
2241 ATLASSERT(m_hDC != NULL);
2242 return ::BitBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop);
2245 BOOL StretchBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, DWORD dwRop)
2247 ATLASSERT(m_hDC != NULL);
2248 return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop);
2251 COLORREF GetPixel(
int x,
int y)
const 2253 ATLASSERT(m_hDC != NULL);
2254 return ::GetPixel(m_hDC, x, y);
2257 COLORREF GetPixel(POINT point)
const 2259 ATLASSERT(m_hDC != NULL);
2260 return ::GetPixel(m_hDC, point.x, point.y);
2263 COLORREF SetPixel(
int x,
int y, COLORREF crColor)
2265 ATLASSERT(m_hDC != NULL);
2266 return ::SetPixel(m_hDC, x, y, crColor);
2269 COLORREF SetPixel(POINT point, COLORREF crColor)
2271 ATLASSERT(m_hDC != NULL);
2272 return ::SetPixel(m_hDC, point.x, point.y, crColor);
2276 BOOL FloodFill(
int x,
int y, COLORREF crColor)
2278 ATLASSERT(m_hDC != NULL);
2279 return ::FloodFill(m_hDC, x, y, crColor);
2282 BOOL ExtFloodFill(
int x,
int y, COLORREF crColor, UINT nFillType)
2284 ATLASSERT(m_hDC != NULL);
2285 return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType);
2287 #endif // !_WIN32_WCE 2289 BOOL MaskBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc, HBITMAP hMaskBitmap,
int xMask,
int yMask, DWORD dwRop)
2291 ATLASSERT(m_hDC != NULL);
2292 return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop);
2296 BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC,
int xSrc,
int ySrc,
int nWidth,
int nHeight, HBITMAP hMaskBitmap,
int xMask,
int yMask)
2298 ATLASSERT(m_hDC != NULL);
2299 return ::PlgBlt(m_hDC, lpPoint, hSrcDC, xSrc, ySrc, nWidth, nHeight, hMaskBitmap, xMask, yMask);
2302 BOOL SetPixelV(
int x,
int y, COLORREF crColor)
2304 ATLASSERT(m_hDC != NULL);
2305 return ::SetPixelV(m_hDC, x, y, crColor);
2308 BOOL SetPixelV(POINT point, COLORREF crColor)
2310 ATLASSERT(m_hDC != NULL);
2311 return ::SetPixelV(m_hDC, point.x, point.y, crColor);
2313 #endif // !_WIN32_WCE 2315 #if !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) 2317 BOOL TransparentBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, UINT crTransparent)
2319 ATLASSERT(m_hDC != NULL);
2320 return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent);
2322 #else // CE specific 2323 BOOL TransparentImage(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, UINT crTransparent)
2325 ATLASSERT(m_hDC != NULL);
2326 return ::TransparentImage(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent);
2328 #endif // _WIN32_WCE 2330 #if (!defined(_WIN32_WCE) || (_WIN32_WCE >= 420)) 2331 BOOL GradientFill(
const PTRIVERTEX pVertices, DWORD nVertices,
void* pMeshElements, DWORD nMeshElements, DWORD dwMode)
2333 ATLASSERT(m_hDC != NULL);
2334 return ::GradientFill(m_hDC, pVertices, nVertices, pMeshElements, nMeshElements, dwMode);
2337 BOOL GradientFillRect(RECT& rect, COLORREF clr1, COLORREF clr2,
bool bHorizontal)
2339 ATLASSERT(m_hDC != NULL);
2341 TRIVERTEX arrTvx[2] = { { 0 }, { 0 } };
2343 arrTvx[0].x = rect.left;
2344 arrTvx[0].y = rect.top;
2345 arrTvx[0].Red = MAKEWORD(0, GetRValue(clr1));
2346 arrTvx[0].Green = MAKEWORD(0, GetGValue(clr1));
2347 arrTvx[0].Blue = MAKEWORD(0, GetBValue(clr1));
2348 arrTvx[0].Alpha = 0;
2350 arrTvx[1].x = rect.right;
2351 arrTvx[1].y = rect.bottom;
2352 arrTvx[1].Red = MAKEWORD(0, GetRValue(clr2));
2353 arrTvx[1].Green = MAKEWORD(0, GetGValue(clr2));
2354 arrTvx[1].Blue = MAKEWORD(0, GetBValue(clr2));
2355 arrTvx[1].Alpha = 0;
2357 GRADIENT_RECT gr = { 0, 1 };
2359 return ::GradientFill(m_hDC, arrTvx, 2, &gr, 1, bHorizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V);
2361 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2363 #if !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) 2364 BOOL AlphaBlend(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, BLENDFUNCTION bf)
2366 ATLASSERT(m_hDC != NULL);
2367 return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf);
2369 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) 2370 #endif // !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) 2376 BOOL DitherBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC, HBITMAP hBitmap,
int xSrc,
int ySrc,
2377 HBRUSH hBrushBackground = ::GetSysColorBrush(COLOR_3DFACE),
2378 HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT),
2379 HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW))
2381 ATLASSERT(m_hDC != NULL || hBitmap != NULL);
2382 ATLASSERT(nWidth > 0 && nHeight > 0);
2385 CDCHandle dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC);
2386 ATLASSERT(dc.m_hDC != NULL);
2387 if(dc.m_hDC == NULL)
2391 CDC dcBW = ::CreateCompatibleDC(m_hDC);
2392 ATLASSERT(dcBW.m_hDC != NULL);
2393 if(dcBW.m_hDC == NULL)
2401 struct RGBBWBITMAPINFO
2403 BITMAPINFOHEADER bmiHeader;
2404 RGBQUAD bmiColors[2];
2407 RGBBWBITMAPINFO rgbBWBitmapInfo =
2409 {
sizeof(BITMAPINFOHEADER), nWidth, nHeight, 1, 1, BI_RGB, 0, 0, 0, 0, 0 },
2410 { { 0x00, 0x00, 0x00, 0x00 }, { 0xFF, 0xFF, 0xFF, 0x00 } }
2414 CBitmap bmpBW = ::CreateDIBSection(dcBW, (LPBITMAPINFO)&rgbBWBitmapInfo, DIB_RGB_COLORS, &pbitsBW, NULL, 0);
2415 ATLASSERT(bmpBW.m_hBitmap != NULL);
2416 if(bmpBW.m_hBitmap == NULL)
2424 HBITMAP hbmOldBW = dcBW.SelectBitmap(bmpBW);
2425 HBITMAP hbmOldDC = NULL;
2427 hbmOldDC = dc.SelectBitmap(hBitmap);
2431 CDC dcTemp1 = ::CreateCompatibleDC(m_hDC);
2432 CDC dcTemp2 = ::CreateCompatibleDC(m_hDC);
2434 bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight);
2436 bmpTemp2.CreateBitmap(nWidth, nHeight, 1, 1, NULL);
2437 HBITMAP hOldBmp1 = dcTemp1.SelectBitmap(bmpTemp1);
2438 HBITMAP hOldBmp2 = dcTemp2.SelectBitmap(bmpTemp2);
2440 dcTemp1.BitBlt(0, 0, nWidth, nHeight, dc, xSrc, ySrc, SRCCOPY);
2443 dcTemp1.SetBkColor(RGB(128, 128, 128));
2444 dcTemp2.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
2446 dcTemp1.BitBlt(0, 0, nWidth, nHeight, dcTemp2, 0, 0, SRCINVERT);
2451 dcBW.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
2454 dcTemp1.SelectBitmap(hOldBmp1);
2455 dcTemp2.SelectBitmap(hOldBmp2);
2459 if(hBrushBackground != NULL)
2461 RECT rc = { x, y, x + nWidth, y + nHeight };
2462 FillRect(&rc, hBrushBackground);
2467 HBRUSH hOldBrush = SelectBrush(hBrush3DEffect);
2468 BitBlt(x + 1, y + 1, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
2471 SelectBrush(hBrushDisabledImage);
2472 BitBlt(x, y, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
2474 SelectBrush(hOldBrush);
2475 dcBW.SelectBitmap(hbmOldBW);
2476 dc.SelectBitmap(hbmOldDC);
2486 BOOL TextOut(
int x,
int y, LPCTSTR lpszString,
int nCount = -1)
2488 ATLASSERT(m_hDC != NULL);
2490 nCount = lstrlen(lpszString);
2491 return ::TextOut(m_hDC, x, y, lpszString, nCount);
2493 #endif // !_WIN32_WCE 2495 BOOL ExtTextOut(
int x,
int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount = -1, LPINT lpDxWidths = NULL)
2497 ATLASSERT(m_hDC != NULL);
2499 nCount = lstrlen(lpszString);
2500 return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths);
2504 SIZE TabbedTextOut(
int x,
int y, LPCTSTR lpszString,
int nCount = -1,
int nTabPositions = 0, LPINT lpnTabStopPositions = NULL,
int nTabOrigin = 0)
2506 ATLASSERT(m_hDC != NULL);
2508 nCount = lstrlen(lpszString);
2509 LONG lRes = ::TabbedTextOut(m_hDC, x, y, lpszString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin);
2510 SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) };
2513 #endif // !_WIN32_WCE 2515 int DrawText(LPCTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat)
2517 ATLASSERT(m_hDC != NULL);
2519 ATLASSERT((uFormat & DT_MODIFYSTRING) == 0);
2520 #endif // !_WIN32_WCE 2521 return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat);
2524 int DrawText(LPTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat)
2526 ATLASSERT(m_hDC != NULL);
2527 return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat);
2531 int DrawTextEx(LPTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL)
2533 ATLASSERT(m_hDC != NULL);
2534 return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams);
2536 #endif // !_WIN32_WCE 2538 #if (_WIN32_WINNT >= 0x0501) 2539 int DrawShadowText(LPCWSTR lpstrText,
int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow,
int xOffset,
int yOffset)
2541 ATLASSERT(m_hDC != NULL);
2546 HMODULE hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
2547 ATLASSERT(hCommCtrlDLL != NULL);
2548 if(hCommCtrlDLL != NULL)
2550 typedef int (WINAPI *PFN_DrawShadowText)(HDC hDC, LPCWSTR lpstrText, UINT cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow,
int xOffset,
int yOffset);
2551 PFN_DrawShadowText pfnDrawShadowText = (PFN_DrawShadowText)::GetProcAddress(hCommCtrlDLL,
"DrawShadowText");
2552 ATLASSERT(pfnDrawShadowText != NULL);
2553 if(pfnDrawShadowText != NULL)
2554 nRet = pfnDrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset);
2555 ::FreeLibrary(hCommCtrlDLL);
2559 #endif // (_WIN32_WINNT >= 0x0501) 2561 BOOL GetTextExtent(LPCTSTR lpszString,
int nCount, LPSIZE lpSize)
const 2563 ATLASSERT(m_hDC != NULL);
2565 nCount = lstrlen(lpszString);
2566 return ::GetTextExtentPoint32(m_hDC, lpszString, nCount, lpSize);
2569 BOOL GetTextExtentExPoint(LPCTSTR lpszString,
int cchString, LPSIZE lpSize,
int nMaxExtent, LPINT lpnFit = NULL, LPINT alpDx = NULL)
2571 ATLASSERT(m_hDC != NULL);
2572 return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize);
2576 DWORD GetTabbedTextExtent(LPCTSTR lpszString,
int nCount = -1,
int nTabPositions = 0, LPINT lpnTabStopPositions = NULL)
const 2578 ATLASSERT(m_hDC != NULL);
2580 nCount = lstrlen(lpszString);
2581 return ::GetTabbedTextExtent(m_hDC, lpszString, nCount, nTabPositions, lpnTabStopPositions);
2584 BOOL GrayString(HBRUSH hBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM,
int), LPARAM lpData,
int nCount,
int x,
int y,
int nWidth,
int nHeight)
2586 ATLASSERT(m_hDC != NULL);
2587 return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight);
2589 #endif // !_WIN32_WCE 2591 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 2592 UINT GetTextAlign()
const 2594 ATLASSERT(m_hDC != NULL);
2595 return ::GetTextAlign(m_hDC);
2598 UINT SetTextAlign(UINT nFlags)
2600 ATLASSERT(m_hDC != NULL);
2601 return ::SetTextAlign(m_hDC, nFlags);
2603 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 2605 int GetTextFace(LPTSTR lpszFacename,
int nCount)
const 2607 ATLASSERT(m_hDC != NULL);
2608 return ::GetTextFace(m_hDC, nCount, lpszFacename);
2611 int GetTextFaceLen()
const 2613 ATLASSERT(m_hDC != NULL);
2614 return ::GetTextFace(m_hDC, 0, NULL);
2619 BOOL GetTextFace(BSTR& bstrFace)
const 2622 ATLASSERT(m_hDC != NULL);
2623 ATLASSERT(bstrFace == NULL);
2625 int nLen = GetTextFaceLen();
2630 LPTSTR lpszText = buff.Allocate(nLen);
2631 if(lpszText == NULL)
2634 if(!GetTextFace(lpszText, nLen))
2637 bstrFace = ::SysAllocString(T2OLE(lpszText));
2638 return (bstrFace != NULL) ? TRUE : FALSE;
2641 #endif // !_ATL_NO_COM 2643 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 2644 int GetTextFace(_CSTRING_NS::CString& strFace)
const 2646 ATLASSERT(m_hDC != NULL);
2648 int nLen = GetTextFaceLen();
2652 LPTSTR lpstr = strFace.GetBufferSetLength(nLen);
2655 int nRet = GetTextFace(lpstr, nLen);
2656 strFace.ReleaseBuffer();
2659 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 2661 BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics)
const 2663 ATLASSERT(m_hDC != NULL);
2664 return ::GetTextMetrics(m_hDC, lpMetrics);
2668 int SetTextJustification(
int nBreakExtra,
int nBreakCount)
2670 ATLASSERT(m_hDC != NULL);
2671 return ::SetTextJustification(m_hDC, nBreakExtra, nBreakCount);
2674 int GetTextCharacterExtra()
const 2676 ATLASSERT(m_hDC != NULL);
2677 return ::GetTextCharacterExtra(m_hDC);
2680 int SetTextCharacterExtra(
int nCharExtra)
2682 ATLASSERT(m_hDC != NULL);
2683 return ::SetTextCharacterExtra(m_hDC, nCharExtra);
2685 #endif // !_WIN32_WCE 2688 BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags)
2690 ATLASSERT(m_hDC != NULL);
2691 return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags);
2694 BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState)
2696 ATLASSERT(m_hDC != NULL);
2697 return ::DrawFrameControl(m_hDC, lpRect, nType, nState);
2701 BOOL ScrollDC(
int dx,
int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate)
2703 ATLASSERT(m_hDC != NULL);
2704 return ::ScrollDC(m_hDC, dx, dy, lpRectScroll, lpRectClip, hRgnUpdate, lpRectUpdate);
2709 BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer)
const 2711 ATLASSERT(m_hDC != NULL);
2712 return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer);
2716 BOOL GetCharWidth32(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer)
const 2718 ATLASSERT(m_hDC != NULL);
2719 return ::GetCharWidth32(m_hDC, nFirstChar, nLastChar, lpBuffer);
2722 DWORD SetMapperFlags(DWORD dwFlag)
2724 ATLASSERT(m_hDC != NULL);
2725 return ::SetMapperFlags(m_hDC, dwFlag);
2728 BOOL GetAspectRatioFilter(LPSIZE lpSize)
const 2730 ATLASSERT(m_hDC != NULL);
2731 return ::GetAspectRatioFilterEx(m_hDC, lpSize);
2734 BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc)
const 2736 ATLASSERT(m_hDC != NULL);
2737 return ::GetCharABCWidths(m_hDC, nFirstChar, nLastChar, lpabc);
2740 DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData)
const 2742 ATLASSERT(m_hDC != NULL);
2743 return ::GetFontData(m_hDC, dwTable, dwOffset, lpData, cbData);
2746 int GetKerningPairs(
int nPairs, LPKERNINGPAIR lpkrnpair)
const 2748 ATLASSERT(m_hDC != NULL);
2749 return ::GetKerningPairs(m_hDC, nPairs, lpkrnpair);
2752 UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm)
const 2754 ATLASSERT(m_hDC != NULL);
2755 return ::GetOutlineTextMetrics(m_hDC, cbData, lpotm);
2758 DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer,
const MAT2* lpmat2)
const 2760 ATLASSERT(m_hDC != NULL);
2761 return ::GetGlyphOutline(m_hDC, nChar, nFormat, lpgm, cbBuffer, lpBuffer, lpmat2);
2764 BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF)
const 2766 ATLASSERT(m_hDC != NULL);
2767 return ::GetCharABCWidthsFloat(m_hDC, nFirstChar, nLastChar, lpABCF);
2770 BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar,
float* lpFloatBuffer)
const 2772 ATLASSERT(m_hDC != NULL);
2773 return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer);
2775 #endif // !_WIN32_WCE 2779 int Escape(
int nEscape,
int nCount, LPCSTR lpszInData, LPVOID lpOutData)
2781 ATLASSERT(m_hDC != NULL);
2782 return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData);
2784 #endif // !_WIN32_WCE 2786 int Escape(
int nEscape,
int nInputSize, LPCSTR lpszInputData,
2787 int nOutputSize, LPSTR lpszOutputData)
2789 ATLASSERT(m_hDC != NULL);
2790 return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData);
2794 int DrawEscape(
int nEscape,
int nInputSize, LPCSTR lpszInputData)
2796 ATLASSERT(m_hDC != NULL);
2797 return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData);
2799 #endif // !_WIN32_WCE 2802 #if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) 2803 int StartDoc(LPCTSTR lpszDocName)
2806 di.cbSize =
sizeof(DOCINFO);
2807 di.lpszDocName = lpszDocName;
2808 return StartDoc(&di);
2811 int StartDoc(LPDOCINFO lpDocInfo)
2813 ATLASSERT(m_hDC != NULL);
2814 return ::StartDoc(m_hDC, lpDocInfo);
2819 ATLASSERT(m_hDC != NULL);
2820 return ::StartPage(m_hDC);
2825 ATLASSERT(m_hDC != NULL);
2826 return ::EndPage(m_hDC);
2829 int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC,
int))
2831 ATLASSERT(m_hDC != NULL);
2832 return ::SetAbortProc(m_hDC, (ABORTPROC)lpfn);
2837 ATLASSERT(m_hDC != NULL);
2838 return ::AbortDoc(m_hDC);
2843 ATLASSERT(m_hDC != NULL);
2844 return ::EndDoc(m_hDC);
2846 #endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) 2850 BOOL PlayMetaFile(HMETAFILE hMF)
2852 ATLASSERT(m_hDC != NULL);
2853 if(::GetDeviceCaps(m_hDC, TECHNOLOGY) == DT_METAFILE)
2856 return ::PlayMetaFile(m_hDC, hMF);
2860 return ::EnumMetaFile(m_hDC, hMF, EnumMetaFileProc, (LPARAM)
this);
2863 BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds)
2865 ATLASSERT(m_hDC != NULL);
2866 return ::PlayEnhMetaFile(m_hDC, hEnhMetaFile, lpBounds);
2869 BOOL AddMetaFileComment(UINT nDataSize,
const BYTE* pCommentData)
2871 ATLASSERT(m_hDC != NULL);
2872 return ::GdiComment(m_hDC, nDataSize, pCommentData);
2876 static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable, METARECORD* pMetaRec,
int nHandles, LPARAM lParam)
2880 switch (pMetaRec->rdFunction)
2882 case META_SETMAPMODE:
2883 pDC->SetMapMode((
int)(
short)pMetaRec->rdParm[0]);
2885 case META_SETWINDOWEXT:
2886 pDC->SetWindowExt((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2888 case META_SETWINDOWORG:
2889 pDC->SetWindowOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2891 case META_SETVIEWPORTEXT:
2892 pDC->SetViewportExt((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2894 case META_SETVIEWPORTORG:
2895 pDC->SetViewportOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2897 case META_SCALEWINDOWEXT:
2898 pDC->ScaleWindowExt((
int)(
short)pMetaRec->rdParm[3], (
int)(
short)pMetaRec->rdParm[2],
2899 (
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2901 case META_SCALEVIEWPORTEXT:
2902 pDC->ScaleViewportExt((
int)(
short)pMetaRec->rdParm[3], (
int)(
short)pMetaRec->rdParm[2],
2903 (
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2905 case META_OFFSETVIEWPORTORG:
2906 pDC->OffsetViewportOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2911 case META_RESTOREDC:
2912 pDC->RestoreDC((
int)(
short)pMetaRec->rdParm[0]);
2914 case META_SETBKCOLOR:
2915 pDC->SetBkColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]);
2917 case META_SETTEXTCOLOR:
2918 pDC->SetTextColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]);
2922 case META_SELECTOBJECT:
2924 HGDIOBJ hObject = pHandleTable->objectHandle[pMetaRec->rdParm[0]];
2925 UINT nObjType = ::GetObjectType(hObject);
2929 HFONT hStockFont = (HFONT)::GetStockObject(SYSTEM_FONT);
2930 HFONT hFontOld = (HFONT)::SelectObject(pDC->m_hDC, hStockFont);
2931 HGDIOBJ hObjOld = ::SelectObject(pDC->m_hDC, hObject);
2932 if(hObjOld == hStockFont)
2935 pDC->SelectFont((HFONT)hObject);
2941 ::SelectObject(pDC->m_hDC, hFontOld);
2942 ::SelectObject(pDC->m_hDC, hObjOld);
2946 else if(nObjType == OBJ_FONT)
2949 pDC->SelectFont((HFONT)hObject);
2956 ::PlayMetaFileRecord(hDC, pHandleTable, pMetaRec, nHandles);
2962 #endif // !_WIN32_WCE 2968 ATLASSERT(m_hDC != NULL);
2969 return ::AbortPath(m_hDC);
2974 ATLASSERT(m_hDC != NULL);
2975 return ::BeginPath(m_hDC);
2980 ATLASSERT(m_hDC != NULL);
2981 return ::CloseFigure(m_hDC);
2986 ATLASSERT(m_hDC != NULL);
2987 return ::EndPath(m_hDC);
2992 ATLASSERT(m_hDC != NULL);
2993 return ::FillPath(m_hDC);
2998 ATLASSERT(m_hDC != NULL);
2999 return ::FlattenPath(m_hDC);
3002 BOOL StrokeAndFillPath()
3004 ATLASSERT(m_hDC != NULL);
3005 return ::StrokeAndFillPath(m_hDC);
3010 ATLASSERT(m_hDC != NULL);
3011 return ::StrokePath(m_hDC);
3016 ATLASSERT(m_hDC != NULL);
3017 return ::WidenPath(m_hDC);
3020 BOOL GetMiterLimit(PFLOAT pfMiterLimit)
const 3022 ATLASSERT(m_hDC != NULL);
3023 return ::GetMiterLimit(m_hDC, pfMiterLimit);
3026 BOOL SetMiterLimit(
float fMiterLimit)
3028 ATLASSERT(m_hDC != NULL);
3029 return ::SetMiterLimit(m_hDC, fMiterLimit, NULL);
3032 int GetPath(LPPOINT lpPoints, LPBYTE lpTypes,
int nCount)
const 3034 ATLASSERT(m_hDC != NULL);
3035 return ::GetPath(m_hDC, lpPoints, lpTypes, nCount);
3038 BOOL SelectClipPath(
int nMode)
3040 ATLASSERT(m_hDC != NULL);
3041 return ::SelectClipPath(m_hDC, nMode);
3043 #endif // !_WIN32_WCE 3046 static CBrushHandle PASCAL GetHalftoneBrush()
3048 HBRUSH halftoneBrush = NULL;
3049 WORD grayPattern[8] = { 0 };
3050 for(
int i = 0; i < 8; i++)
3051 grayPattern[i] = (WORD)(0x5555 << (i & 1));
3052 HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern);
3053 if(grayBitmap != NULL)
3055 halftoneBrush = ::CreatePatternBrush(grayBitmap);
3056 DeleteObject(grayBitmap);
3058 return CBrushHandle(halftoneBrush);
3061 void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, HBRUSH hBrush = NULL, HBRUSH hBrushLast = NULL)
3065 rgnOutside.CreateRectRgnIndirect(lpRect);
3066 RECT rect = *lpRect;
3067 ::InflateRect(&rect, -size.cx, -size.cy);
3068 ::IntersectRect(&rect, &rect, lpRect);
3070 rgnInside.CreateRectRgnIndirect(&rect);
3072 rgnNew.CreateRectRgn(0, 0, 0, 0);
3073 rgnNew.CombineRgn(rgnOutside, rgnInside, RGN_XOR);
3075 HBRUSH hBrushOld = NULL;
3076 CBrush brushHalftone;
3078 brushHalftone = hBrush = CDCHandle::GetHalftoneBrush();
3079 if(hBrushLast == NULL)
3080 hBrushLast = hBrush;
3084 if(lpRectLast != NULL)
3087 rgnLast.CreateRectRgn(0, 0, 0, 0);
3088 rgnOutside.SetRectRgn(lpRectLast->left, lpRectLast->top, lpRectLast->right, lpRectLast->bottom);
3090 ::InflateRect(&rect, -sizeLast.cx, -sizeLast.cy);
3091 ::IntersectRect(&rect, &rect, lpRectLast);
3092 rgnInside.SetRectRgn(rect.left, rect.top, rect.right, rect.bottom);
3093 rgnLast.CombineRgn(rgnOutside, rgnInside, RGN_XOR);
3096 if(hBrush == hBrushLast)
3098 rgnUpdate.CreateRectRgn(0, 0, 0, 0);
3099 rgnUpdate.CombineRgn(rgnLast, rgnNew, RGN_XOR);
3102 if(hBrush != hBrushLast && lpRectLast != NULL)
3105 SelectClipRgn(rgnLast);
3107 hBrushOld = SelectBrush(hBrushLast);
3108 PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT);
3109 SelectBrush(hBrushOld);
3114 SelectClipRgn(rgnUpdate.IsNull() ? rgnNew : rgnUpdate);
3116 hBrushOld = SelectBrush(hBrush);
3117 PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT);
3120 if(hBrushOld != NULL)
3121 SelectBrush(hBrushOld);
3122 SelectClipRgn(NULL);
3125 void FillSolidRect(LPCRECT lpRect, COLORREF clr)
3127 ATLASSERT(m_hDC != NULL);
3129 COLORREF clrOld = ::SetBkColor(m_hDC, clr);
3130 ATLASSERT(clrOld != CLR_INVALID);
3131 if(clrOld != CLR_INVALID)
3133 ::ExtTextOut(m_hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
3134 ::SetBkColor(m_hDC, clrOld);
3138 void FillSolidRect(
int x,
int y,
int cx,
int cy, COLORREF clr)
3140 ATLASSERT(m_hDC != NULL);
3142 RECT rect = { x, y, x + cx, y + cy };
3143 FillSolidRect(&rect, clr);
3146 void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight)
3148 Draw3dRect(lpRect->left, lpRect->top, lpRect->right - lpRect->left,
3149 lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight);
3152 void Draw3dRect(
int x,
int y,
int cx,
int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
3154 FillSolidRect(x, y, cx - 1, 1, clrTopLeft);
3155 FillSolidRect(x, y, 1, cy - 1, clrTopLeft);
3156 FillSolidRect(x + cx, y, -1, cy, clrBottomRight);
3157 FillSolidRect(x, y + cy, cx, -1, clrBottomRight);
3161 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 3162 int SetDIBitsToDevice(
int x,
int y, DWORD dwWidth, DWORD dwHeight,
int xSrc,
int ySrc, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse)
3164 ATLASSERT(m_hDC != NULL);
3165 return ::SetDIBitsToDevice(m_hDC, x, y, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
3167 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 3169 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 3170 int StretchDIBits(
int x,
int y,
int nWidth,
int nHeight,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse, DWORD dwRop)
3172 ATLASSERT(m_hDC != NULL);
3173 return ::StretchDIBits(m_hDC, x, y, nWidth, nHeight, xSrc, ySrc, nSrcWidth, nSrcHeight, lpvBits, lpbmi, uColorUse, dwRop);
3176 UINT GetDIBColorTable(UINT uStartIndex, UINT cEntries, RGBQUAD* pColors)
const 3178 ATLASSERT(m_hDC != NULL);
3179 return ::GetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors);
3182 UINT SetDIBColorTable(UINT uStartIndex, UINT cEntries, CONST RGBQUAD* pColors)
3184 ATLASSERT(m_hDC != NULL);
3185 return ::SetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors);
3187 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 3190 #if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 3191 int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd)
3193 ATLASSERT(m_hDC != NULL);
3194 return ::ChoosePixelFormat(m_hDC, ppfd);
3197 int DescribePixelFormat(
int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
3199 ATLASSERT(m_hDC != NULL);
3200 return ::DescribePixelFormat(m_hDC, iPixelFormat, nBytes, ppfd);
3203 int GetPixelFormat()
const 3205 ATLASSERT(m_hDC != NULL);
3206 return ::GetPixelFormat(m_hDC);
3209 BOOL SetPixelFormat(
int iPixelFormat, CONST PIXELFORMATDESCRIPTOR* ppfd)
3211 ATLASSERT(m_hDC != NULL);
3212 return ::SetPixelFormat(m_hDC, iPixelFormat, ppfd);
3217 ATLASSERT(m_hDC != NULL);
3218 return ::SwapBuffers(m_hDC);
3221 HGLRC wglCreateContext()
3223 ATLASSERT(m_hDC != NULL);
3224 return ::wglCreateContext(m_hDC);
3227 HGLRC wglCreateLayerContext(
int iLayerPlane)
3229 ATLASSERT(m_hDC != NULL);
3230 return ::wglCreateLayerContext(m_hDC, iLayerPlane);
3233 BOOL wglMakeCurrent(HGLRC hglrc)
3235 ATLASSERT(m_hDC != NULL);
3236 return ::wglMakeCurrent(m_hDC, hglrc);
3239 BOOL wglUseFontBitmaps(DWORD dwFirst, DWORD dwCount, DWORD listBase)
3241 ATLASSERT(m_hDC != NULL);
3242 return ::wglUseFontBitmaps(m_hDC, dwFirst, dwCount, listBase);
3245 BOOL wglUseFontOutlines(DWORD dwFirst, DWORD dwCount, DWORD listBase, FLOAT deviation, FLOAT extrusion,
int format, LPGLYPHMETRICSFLOAT lpgmf)
3247 ATLASSERT(m_hDC != NULL);
3248 return ::wglUseFontOutlines(m_hDC, dwFirst, dwCount, listBase, deviation, extrusion, format, lpgmf);
3251 BOOL wglDescribeLayerPlane(
int iPixelFormat,
int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd)
3253 ATLASSERT(m_hDC != NULL);
3254 return ::wglDescribeLayerPlane(m_hDC, iPixelFormat, iLayerPlane, nBytes, plpd);
3257 int wglSetLayerPaletteEntries(
int iLayerPlane,
int iStart,
int cEntries, CONST COLORREF* pclr)
3259 ATLASSERT(m_hDC != NULL);
3260 return ::wglSetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr);
3263 int wglGetLayerPaletteEntries(
int iLayerPlane,
int iStart,
int cEntries, COLORREF* pclr)
3265 ATLASSERT(m_hDC != NULL);
3266 return ::wglGetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr);
3269 BOOL wglRealizeLayerPalette(
int iLayerPlane, BOOL bRealize)
3271 ATLASSERT(m_hDC != NULL);
3272 return ::wglRealizeLayerPalette(m_hDC, iLayerPlane, bRealize);
3275 BOOL wglSwapLayerBuffers(UINT uPlanes)
3277 ATLASSERT(m_hDC != NULL);
3278 return ::wglSwapLayerBuffers(m_hDC, uPlanes);
3280 #endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 3283 #if (_WIN32_WINNT >= 0x0500) 3284 COLORREF GetDCPenColor()
const 3286 ATLASSERT(m_hDC != NULL);
3287 return ::GetDCPenColor(m_hDC);
3290 COLORREF SetDCPenColor(COLORREF clr)
3292 ATLASSERT(m_hDC != NULL);
3293 return ::SetDCPenColor(m_hDC, clr);
3296 COLORREF GetDCBrushColor()
const 3298 ATLASSERT(m_hDC != NULL);
3299 return ::GetDCBrushColor(m_hDC);
3302 COLORREF SetDCBrushColor(COLORREF clr)
3304 ATLASSERT(m_hDC != NULL);
3305 return ::SetDCBrushColor(m_hDC, clr);
3309 DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs)
const 3311 ATLASSERT(m_hDC != NULL);
3312 return ::GetFontUnicodeRanges(m_hDC, lpgs);
3314 #endif // !_WIN32_WCE 3316 DWORD GetGlyphIndices(LPCTSTR lpstr,
int cch, LPWORD pgi, DWORD dwFlags)
const 3318 ATLASSERT(m_hDC != NULL);
3319 return ::GetGlyphIndices(m_hDC, lpstr, cch, pgi, dwFlags);
3322 BOOL GetTextExtentPointI(LPWORD pgiIn,
int cgi, LPSIZE lpSize)
const 3324 ATLASSERT(m_hDC != NULL);
3325 return ::GetTextExtentPointI(m_hDC, pgiIn, cgi, lpSize);
3328 BOOL GetTextExtentExPointI(LPWORD pgiIn,
int cgi,
int nMaxExtent, LPINT lpnFit, LPINT alpDx, LPSIZE lpSize)
const 3330 ATLASSERT(m_hDC != NULL);
3331 return ::GetTextExtentExPointI(m_hDC, pgiIn, cgi, nMaxExtent, lpnFit, alpDx, lpSize);
3334 BOOL GetCharWidthI(UINT giFirst, UINT cgi, LPWORD pgi, LPINT lpBuffer)
const 3336 ATLASSERT(m_hDC != NULL);
3337 return ::GetCharWidthI(m_hDC, giFirst, cgi, pgi, lpBuffer);
3340 BOOL GetCharABCWidthsI(UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc)
const 3342 ATLASSERT(m_hDC != NULL);
3343 return ::GetCharABCWidthsI(m_hDC, giFirst, cgi, pgi, lpabc);
3345 #endif // (_WIN32_WINNT >= 0x0500) 3348 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) 3349 BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries)
3351 ATLASSERT(m_hDC != NULL);
3352 return ::ColorCorrectPalette(m_hDC, hPalette, dwFirstEntry, dwNumOfEntries);
3354 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) 3374 ATLASSERT(::IsWindow(hWnd));
3376 m_hDC = ::BeginPaint(hWnd, &m_ps);
3381 ATLASSERT(m_hDC != NULL);
3382 ATLASSERT(::IsWindow(m_hWnd));
3383 ::EndPaint(m_hWnd, &m_ps);
3397 ATLASSERT(hWnd == NULL || ::IsWindow(hWnd));
3399 m_hDC = ::GetDC(hWnd);
3404 ATLASSERT(m_hDC != NULL);
3405 ::ReleaseDC(m_hWnd, Detach());
3418 ATLASSERT(hWnd == NULL || ::IsWindow(hWnd));
3420 m_hDC = ::GetWindowDC(hWnd);
3425 ATLASSERT(m_hDC != NULL);
3426 ::ReleaseDC(m_hWnd, Detach());
3440 CMemoryDC(HDC hDC, RECT& rcPaint) : m_hDCOriginal(hDC), m_hBmpOld(NULL)
3442 m_rcPaint = rcPaint;
3443 CreateCompatibleDC(m_hDCOriginal);
3444 ATLASSERT(m_hDC != NULL);
3445 m_bmp.CreateCompatibleBitmap(m_hDCOriginal, m_rcPaint.right - m_rcPaint.left, m_rcPaint.bottom - m_rcPaint.top);
3446 ATLASSERT(m_bmp.m_hBitmap != NULL);
3447 m_hBmpOld = SelectBitmap(m_bmp);
3448 SetViewportOrg(-m_rcPaint.left, -m_rcPaint.top);
3453 ::BitBlt(m_hDCOriginal, m_rcPaint.left, m_rcPaint.top, m_rcPaint.right - m_rcPaint.left, m_rcPaint.bottom - m_rcPaint.top, m_hDC, m_rcPaint.left, m_rcPaint.top, SRCCOPY);
3454 SelectBitmap(m_hBmpOld);
3468 HENHMETAFILE m_hEMF;
3471 ENHMETAHEADER m_header;
3472 PIXELFORMATDESCRIPTOR m_pfd;
3475 CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_pBits(NULL), m_pDesc(NULL), m_hEMF(hEMF)
3485 BYTE* GetEnhMetaFileBits()
3487 ATLASSERT(m_hEMF != NULL);
3488 UINT nBytes = ::GetEnhMetaFileBits(m_hEMF, 0, NULL);
3491 ATLTRY(m_pBits =
new BYTE[nBytes]);
3492 if (m_pBits != NULL)
3493 ::GetEnhMetaFileBits(m_hEMF, nBytes, m_pBits);
3497 LPTSTR GetEnhMetaFileDescription()
3499 ATLASSERT(m_hEMF != NULL);
3500 UINT nLen = ::GetEnhMetaFileDescription(m_hEMF, 0, NULL);
3503 ATLTRY(m_pDesc =
new TCHAR[nLen]);
3504 if (m_pDesc != NULL)
3505 nLen = ::GetEnhMetaFileDescription(m_hEMF, nLen, m_pDesc);
3509 ENHMETAHEADER* GetEnhMetaFileHeader()
3511 ATLASSERT(m_hEMF != NULL);
3512 memset(&m_header, 0,
sizeof(m_header));
3513 m_header.iType = EMR_HEADER;
3514 m_header.nSize =
sizeof(ENHMETAHEADER);
3515 UINT n = ::GetEnhMetaFileHeader(m_hEMF,
sizeof(ENHMETAHEADER), &m_header);
3516 return (n != 0) ? &m_header : NULL;
3519 PIXELFORMATDESCRIPTOR* GetEnhMetaFilePixelFormat()
3521 ATLASSERT(m_hEMF != NULL);
3522 memset(&m_pfd, 0,
sizeof(m_pfd));
3523 UINT n = ::GetEnhMetaFilePixelFormat(m_hEMF,
sizeof(m_pfd), &m_pfd);
3524 return (n != 0) ? &m_pfd : NULL;
3529 template <
bool t_bManaged>
3534 HENHMETAFILE m_hEMF;
3543 if(t_bManaged && m_hEMF != NULL)
3554 void Attach(HENHMETAFILE hEMF)
3556 if(t_bManaged && m_hEMF != NULL && m_hEMF != hEMF)
3561 HENHMETAFILE Detach()
3563 HENHMETAFILE hEMF = m_hEMF;
3568 operator HENHMETAFILE()
const {
return m_hEMF; }
3570 bool IsNull()
const {
return (m_hEMF == NULL); }
3574 ATLASSERT(m_hEMF != NULL);
3575 BOOL bRet = ::DeleteEnhMetaFile(m_hEMF);
3580 UINT GetEnhMetaFileBits(UINT cbBuffer, LPBYTE lpbBuffer)
const 3582 ATLASSERT(m_hEMF != NULL);
3583 return ::GetEnhMetaFileBits(m_hEMF, cbBuffer, lpbBuffer);
3586 UINT GetEnhMetaFileDescription(UINT cchBuffer, LPTSTR lpszDescription)
const 3588 ATLASSERT(m_hEMF != NULL);
3589 return ::GetEnhMetaFileDescription(m_hEMF, cchBuffer, lpszDescription);
3592 UINT GetEnhMetaFileHeader(LPENHMETAHEADER lpemh)
const 3594 ATLASSERT(m_hEMF != NULL);
3595 lpemh->iType = EMR_HEADER;
3596 lpemh->nSize =
sizeof(ENHMETAHEADER);
3597 return ::GetEnhMetaFileHeader(m_hEMF,
sizeof(ENHMETAHEADER), lpemh);
3600 UINT GetEnhMetaFilePaletteEntries(UINT cEntries, LPPALETTEENTRY lppe)
const 3602 ATLASSERT(m_hEMF != NULL);
3603 return ::GetEnhMetaFilePaletteEntries(m_hEMF, cEntries, lppe);
3606 UINT GetEnhMetaFilePixelFormat(DWORD cbBuffer, PIXELFORMATDESCRIPTOR* ppfd)
const 3608 ATLASSERT(m_hEMF != NULL);
3609 return ::GetEnhMetaFilePixelFormat(m_hEMF, cbBuffer, ppfd);
3627 Create(hdc, NULL, lpRect, NULL);
3628 ATLASSERT(m_hDC != NULL);
3631 CEnhMetaFileDC(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
3633 Create(hdcRef, lpFilename, lpRect, lpDescription);
3634 ATLASSERT(m_hDC != NULL);
3639 HENHMETAFILE hEMF = Close();
3641 ::DeleteEnhMetaFile(hEMF);
3645 void Create(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
3647 ATLASSERT(m_hDC == NULL);
3648 m_hDC = ::CreateEnhMetaFile(hdcRef, lpFilename, lpRect, lpDescription);
3651 HENHMETAFILE Close()
3653 HENHMETAFILE hEMF = NULL;
3656 hEMF = ::CloseEnhMetaFile(m_hDC);
3663 #endif // !_WIN32_WCE 3669 #ifndef _WTL_NO_DIB16 3671 #define DIBINFO16_BITFIELDS { 31744, 992, 31 } 3676 BITMAPINFOHEADER bmiHeader;
3677 RGBQUAD bmiColors[3];
3681 BITMAPINFOHEADER bmih = {
sizeof(BITMAPINFOHEADER), size.cx, size.cy,
3682 1, 16, BI_BITFIELDS, 2 * size.cx * size.cy , 0, 0, 3 };
3683 DWORD dw[3] = DIBINFO16_BITFIELDS ;
3686 SecureHelper::memcpy_x(bmiColors,
sizeof(bmiColors), dw, 3 *
sizeof(DWORD));
3693 inline bool AtlIsDib16(LPBITMAPINFOHEADER pbmih)
3695 return (pbmih->biBitCount == 16) && (pbmih->biCompression == BI_BITFIELDS);
3698 inline int AtlGetDibColorTableSize(LPBITMAPINFOHEADER pbmih)
3700 switch (pbmih->biBitCount)
3705 return pbmih->biClrUsed ? pbmih->biClrUsed : 1 << pbmih->biBitCount;
3710 return pbmih->biCompression == BI_BITFIELDS ? 3 : 0;
3718 inline int AtlGetDibNumColors(LPBITMAPINFOHEADER pbmih)
3720 switch (pbmih->biBitCount)
3725 if (pbmih->biClrUsed)
3726 return pbmih->biClrUsed;
3730 if (pbmih->biCompression == BI_BITFIELDS )
3737 if (pbmih->biCompression == BI_BITFIELDS )
3745 return 1 << pbmih->biBitCount;
3748 inline HBITMAP AtlGetDibBitmap(LPBITMAPINFO pbmi)
3753 LPBYTE pDibBits = (LPBYTE)pbmi +
sizeof(BITMAPINFOHEADER) + AtlGetDibColorTableSize(&pbmi->bmiHeader) *
sizeof(RGBQUAD);
3754 HBITMAP hbm = CreateDIBSection(dc, pbmi, DIB_RGB_COLORS, &pBits, NULL, NULL);
3757 int cbBits = pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biHeight * pbmi->bmiHeader.biBitCount / 8;
3758 SecureHelper::memcpy_x(pBits, cbBits, pDibBits, pbmi->bmiHeader.biSizeImage);
3764 inline HBITMAP AtlCopyBitmap(HBITMAP hbm, SIZE sizeDst,
bool bAsBitmap =
false)
3766 CDC hdcSrc = CreateCompatibleDC(NULL);
3767 CDC hdcDst = CreateCompatibleDC(NULL);
3769 CBitmapHandle hbmOld = NULL, hbmOld2 = NULL, bmSrc = hbm;
3771 CBitmap bmNew = NULL;
3773 SIZE sizeSrc = { 0 };
3774 bmSrc.GetSize(sizeSrc);
3776 hbmOld = hdcSrc.SelectBitmap(bmSrc);
3780 bmNew.CreateCompatibleBitmap(hdcSrc, sizeDst.cx, sizeDst.cy);
3785 LPVOID pBits = NULL;
3786 bmNew = CreateDIBSection(hdcDst, (
const BITMAPINFO*)&dib16, DIB_RGB_COLORS, &pBits, NULL, NULL);
3789 ATLASSERT(!bmNew.IsNull());
3791 hbmOld2 = hdcDst.SelectBitmap(bmNew);
3794 if ((sizeDst.cx == sizeSrc.cx) && (sizeDst.cy == sizeSrc.cy))
3795 bOK = hdcDst.BitBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, SRCCOPY);
3797 bOK = hdcDst.StretchBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, sizeSrc.cx, sizeSrc.cy, SRCCOPY);
3799 hdcSrc.SelectBitmap(hbmOld);
3800 hdcDst.SelectBitmap(hbmOld2);
3803 bmNew.DeleteObject();
3805 return bmNew.Detach();
3808 inline HLOCAL AtlCreatePackedDib16(HBITMAP hbm, SIZE size)
3810 DIBSECTION ds = { 0 };
3812 bool bCopied =
false;
3814 bool bOK = GetObject(hbm,
sizeof(ds), &ds) ==
sizeof(ds);
3815 if ((bOK == FALSE) || (ds.dsBm.bmBits == NULL) || (AtlIsDib16(&ds.dsBmih) == FALSE) ||
3816 (ds.dsBmih.biWidth != size.cx ) || (ds.dsBmih.biHeight != size.cy ))
3818 if ((hbm = AtlCopyBitmap(hbm, size)) != NULL)
3821 bOK = GetObject(hbm,
sizeof(ds), &ds) ==
sizeof(ds);
3829 if((bOK != FALSE) && (AtlIsDib16(&ds.dsBmih) != FALSE) && (ds.dsBm.bmBits != NULL))
3831 pDib = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,
sizeof(
DIBINFO16) + ds.dsBmih.biSizeImage);
3834 SecureHelper::memcpy_x(pDib,
sizeof(
DIBINFO16) + ds.dsBmih.biSizeImage, &ds.dsBmih,
sizeof(
DIBINFO16));
3835 SecureHelper::memcpy_x(pDib +
sizeof(
DIBINFO16), ds.dsBmih.biSizeImage, ds.dsBm.bmBits, ds.dsBmih.biSizeImage);
3839 if (bCopied ==
true)
3842 return (HLOCAL)pDib;
3845 inline bool AtlSetClipboardDib16(HBITMAP hbm, SIZE size, HWND hWnd)
3847 ATLASSERT(::IsWindow(hWnd));
3848 BOOL bOK = OpenClipboard(hWnd);
3851 bOK = EmptyClipboard();
3854 HLOCAL hDib = AtlCreatePackedDib16(hbm, size);
3857 bOK = SetClipboardData(CF_DIB, hDib) != NULL;
3869 return (bOK != FALSE);
3872 inline HBITMAP AtlGetClipboardDib(HWND hWnd)
3874 ATLASSERT(::IsWindow(hWnd) != FALSE);
3876 if (OpenClipboard(hWnd) != FALSE)
3878 LPBITMAPINFO pbmi = (LPBITMAPINFO)GetClipboardData(CF_DIB);
3880 hbm = AtlGetDibBitmap(pbmi);
3887 #endif // _WTL_NO_DIB16 3891 #endif // __ATLGDI_H__ Definition: atlwinx.h:455
Definition: atlgdi.h:1007
Definition: atlgdi.h:3388
Definition: atlgdi.h:3674
Definition: atlapp.h:1317
Definition: atlgdi.h:1211
Definition: atlgdi.h:3364
Definition: atlgdi.h:3409
Definition: atlgdi.h:3430