15 #error atlgdi.h requires atlapp.h to be included first 28 #endif // _INC_WINDOWSX 31 #if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE) 32 #pragma comment(lib, "msimg32.lib") 34 #if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 35 #pragma comment(lib, "opengl32.lib") 78 inline LPBITMAPINFOHEADER AtlGetBitmapResourceInfo(HMODULE hModule,
ATL::_U_STRINGorID image)
80 HRSRC hResource = ::FindResource(hModule, image.m_lpstr, RT_BITMAP);
81 ATLASSERT(hResource != NULL);
82 HGLOBAL hGlobal = ::LoadResource(hModule, hResource);
83 ATLASSERT(hGlobal != NULL);
84 LPBITMAPINFOHEADER pBitmapInfoHeader = (LPBITMAPINFOHEADER)::LockResource(hGlobal);
85 ATLASSERT(pBitmapInfoHeader != NULL);
86 return pBitmapInfoHeader;
89 inline WORD AtlGetBitmapResourceBitsPerPixel(HMODULE hModule,
ATL::_U_STRINGorID image)
91 LPBITMAPINFOHEADER pBitmapInfoHeader = AtlGetBitmapResourceInfo(hModule, image);
92 ATLASSERT(pBitmapInfoHeader != NULL);
93 return pBitmapInfoHeader->biBitCount;
98 return AtlGetBitmapResourceBitsPerPixel(ModuleHelper::GetResourceInstance(), image);
110 return (AtlGetBitmapResourceBitsPerPixel(image) == 32);
117 template <
bool t_bManaged>
125 CPenT(HPEN hPen = NULL) : m_hPen(hPen)
130 if(t_bManaged && m_hPen != NULL)
140 void Attach(HPEN hPen)
142 if(t_bManaged && m_hPen != NULL && m_hPen != hPen)
143 ::DeleteObject(m_hPen);
154 operator HPEN()
const {
return m_hPen; }
156 bool IsNull()
const {
return (m_hPen == NULL); }
159 HPEN CreatePen(
int nPenStyle,
int nWidth, COLORREF crColor)
161 ATLASSERT(m_hPen == NULL);
162 m_hPen = ::CreatePen(nPenStyle, nWidth, crColor);
167 HPEN CreatePen(
int nPenStyle,
int nWidth,
const LOGBRUSH* pLogBrush,
int nStyleCount = 0,
const DWORD* lpStyle = NULL)
169 ATLASSERT(m_hPen == NULL);
170 m_hPen = ::ExtCreatePen(nPenStyle, nWidth, pLogBrush, nStyleCount, lpStyle);
173 #endif // !_WIN32_WCE 175 HPEN CreatePenIndirect(LPLOGPEN lpLogPen)
177 ATLASSERT(m_hPen == NULL);
178 m_hPen = ::CreatePenIndirect(lpLogPen);
184 ATLASSERT(m_hPen != NULL);
185 BOOL bRet = ::DeleteObject(m_hPen);
192 int GetLogPen(LOGPEN* pLogPen)
const 194 ATLASSERT(m_hPen != NULL);
195 return ::GetObject(m_hPen,
sizeof(LOGPEN), pLogPen);
198 bool GetLogPen(LOGPEN& LogPen)
const 200 ATLASSERT(m_hPen != NULL);
201 return (::GetObject(m_hPen,
sizeof(LOGPEN), &LogPen) ==
sizeof(LOGPEN));
205 int GetExtLogPen(EXTLOGPEN* pLogPen,
int nSize =
sizeof(EXTLOGPEN))
const 207 ATLASSERT(m_hPen != NULL);
208 return ::GetObject(m_hPen, nSize, pLogPen);
211 bool GetExtLogPen(EXTLOGPEN& ExtLogPen,
int nSize =
sizeof(EXTLOGPEN))
const 213 ATLASSERT(m_hPen != NULL);
214 int nRet = ::GetObject(m_hPen, nSize, &ExtLogPen);
215 return ((nRet > 0) && (nRet <= nSize));
217 #endif // !_WIN32_WCE 227 template <
bool t_bManaged>
235 CBrushT(HBRUSH hBrush = NULL) : m_hBrush(hBrush)
240 if(t_bManaged && m_hBrush != NULL)
250 void Attach(HBRUSH hBrush)
252 if(t_bManaged && m_hBrush != NULL && m_hBrush != hBrush)
253 ::DeleteObject(m_hBrush);
259 HBRUSH hBrush = m_hBrush;
264 operator HBRUSH()
const {
return m_hBrush; }
266 bool IsNull()
const {
return (m_hBrush == NULL); }
269 HBRUSH CreateSolidBrush(COLORREF crColor)
271 ATLASSERT(m_hBrush == NULL);
272 m_hBrush = ::CreateSolidBrush(crColor);
277 HBRUSH CreateHatchBrush(
int nIndex, COLORREF crColor)
279 ATLASSERT(m_hBrush == NULL);
280 m_hBrush = ::CreateHatchBrush(nIndex, crColor);
283 #endif // !_WIN32_WCE 285 #if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 286 HBRUSH CreateBrushIndirect(
const LOGBRUSH* lpLogBrush)
288 ATLASSERT(m_hBrush == NULL);
290 m_hBrush = ::CreateBrushIndirect(lpLogBrush);
292 m_hBrush = ATL::CreateBrushIndirect(lpLogBrush);
296 #endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 298 HBRUSH CreatePatternBrush(HBITMAP hBitmap)
300 ATLASSERT(m_hBrush == NULL);
301 m_hBrush = ::CreatePatternBrush(hBitmap);
305 HBRUSH CreateDIBPatternBrush(HGLOBAL hPackedDIB, UINT nUsage)
307 ATLASSERT(hPackedDIB != NULL);
308 const void* lpPackedDIB = GlobalLock(hPackedDIB);
309 ATLASSERT(lpPackedDIB != NULL);
310 m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage);
311 GlobalUnlock(hPackedDIB);
315 HBRUSH CreateDIBPatternBrush(
const void* lpPackedDIB, UINT nUsage)
317 ATLASSERT(m_hBrush == NULL);
318 m_hBrush = ::CreateDIBPatternBrushPt(lpPackedDIB, nUsage);
322 HBRUSH CreateSysColorBrush(
int nIndex)
324 ATLASSERT(m_hBrush == NULL);
325 m_hBrush = ::GetSysColorBrush(nIndex);
331 ATLASSERT(m_hBrush != NULL);
332 BOOL bRet = ::DeleteObject(m_hBrush);
339 int GetLogBrush(LOGBRUSH* pLogBrush)
const 341 ATLASSERT(m_hBrush != NULL);
342 return ::GetObject(m_hBrush,
sizeof(LOGBRUSH), pLogBrush);
345 bool GetLogBrush(LOGBRUSH& LogBrush)
const 347 ATLASSERT(m_hBrush != NULL);
348 return (::GetObject(m_hBrush,
sizeof(LOGBRUSH), &LogBrush) ==
sizeof(LOGBRUSH));
364 memset(
this, 0,
sizeof(LOGFONT));
374 ATLASSERT(::GetObjectType(hFont) == OBJ_FONT);
375 ::GetObject(hFont,
sizeof(LOGFONT), (LOGFONT*)
this);
378 HFONT CreateFontIndirect()
380 return ::CreateFontIndirect(
this);
390 return (lfWeight >= FW_BOLD);
393 void MakeBolder(
int iScale = 1)
395 lfWeight += FW_BOLD * iScale;
398 void MakeLarger(
int iScale)
406 void SetHeight(LONG nPointSize, HDC hDC = NULL)
408 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
410 lfHeight = -::MulDiv(nPointSize, ::GetDeviceCaps(hDC1, LOGPIXELSY), 72);
412 ::ReleaseDC(NULL, hDC1);
415 LONG GetHeight(HDC hDC = NULL)
const 417 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
419 LONG nPointSize = ::MulDiv(-lfHeight, 72, ::GetDeviceCaps(hDC1, LOGPIXELSY));
421 ::ReleaseDC(NULL, hDC1);
426 LONG GetDeciPointHeight(HDC hDC = NULL)
const 428 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
430 POINT ptOrg = { 0, 0 };
431 ::DPtoLP(hDC1, &ptOrg, 1);
433 pt.y = abs(lfHeight) + ptOrg.y;
434 ::LPtoDP(hDC1, &pt,1);
435 LONG nDeciPoint = ::MulDiv(pt.y, 720, ::GetDeviceCaps(hDC1, LOGPIXELSY));
438 LONG nDeciPoint = ::MulDiv(abs(lfHeight), 720, ::GetDeviceCaps(hDC1, LOGPIXELSY));
441 ::ReleaseDC(NULL, hDC1);
446 void SetHeightFromDeciPoint(LONG nDeciPtHeight, HDC hDC = NULL)
448 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
451 pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720);
452 ::DPtoLP(hDC1, &pt, 1);
453 POINT ptOrg = { 0, 0 };
454 ::DPtoLP(hDC1, &ptOrg, 1);
455 lfHeight = -abs(pt.y - ptOrg.y);
458 lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), nDeciPtHeight, 720));
461 ::ReleaseDC(NULL, hDC1);
465 void SetCaptionFont()
467 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
468 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
469 Copy(&ncm.lfCaptionFont);
474 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
475 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
476 Copy(&ncm.lfMenuFont);
481 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
482 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
483 Copy(&ncm.lfStatusFont);
486 void SetMessageBoxFont()
488 NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() };
489 ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0));
490 Copy(&ncm.lfMessageFont);
492 #endif // !_WIN32_WCE 494 void Copy(
const LOGFONT* pLogFont)
496 ATLASSERT(pLogFont != NULL);
497 *(LOGFONT*)
this = *pLogFont;
506 CLogFont& operator =(
const LOGFONT& src)
514 ATLASSERT(::GetObjectType(hFont) == OBJ_FONT);
515 ::GetObject(hFont,
sizeof(LOGFONT), (LOGFONT*)
this);
519 bool operator ==(
const LOGFONT& logfont)
const 521 return(logfont.lfHeight == lfHeight &&
522 logfont.lfWidth == lfWidth &&
523 logfont.lfEscapement == lfEscapement &&
524 logfont.lfOrientation == lfOrientation &&
525 logfont.lfWeight == lfWeight &&
526 logfont.lfItalic == lfItalic &&
527 logfont.lfUnderline == lfUnderline &&
528 logfont.lfStrikeOut == lfStrikeOut &&
529 logfont.lfCharSet == lfCharSet &&
530 logfont.lfOutPrecision == lfOutPrecision &&
531 logfont.lfClipPrecision == lfClipPrecision &&
532 logfont.lfQuality == lfQuality &&
533 logfont.lfPitchAndFamily == lfPitchAndFamily &&
534 lstrcmp(logfont.lfFaceName, lfFaceName) == 0);
539 template <
bool t_bManaged>
547 CFontT(HFONT hFont = NULL) : m_hFont(hFont)
552 if(t_bManaged && m_hFont != NULL)
562 void Attach(HFONT hFont)
564 if(t_bManaged && m_hFont != NULL && m_hFont != hFont)
565 ::DeleteObject(m_hFont);
571 HFONT hFont = m_hFont;
576 operator HFONT()
const {
return m_hFont; }
578 bool IsNull()
const {
return (m_hFont == NULL); }
581 HFONT CreateFontIndirect(
const LOGFONT* lpLogFont)
583 ATLASSERT(m_hFont == NULL);
584 m_hFont = ::CreateFontIndirect(lpLogFont);
588 #if !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) 589 HFONT CreateFontIndirectEx(CONST ENUMLOGFONTEXDV* penumlfex)
591 ATLASSERT(m_hFont == NULL);
592 m_hFont = ::CreateFontIndirectEx(penumlfex);
595 #endif // !defined(_WIN32_WCE) && (_WIN32_WINNT >= 0x0500) 597 #if !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 598 HFONT CreateFont(
int nHeight,
int nWidth,
int nEscapement,
599 int nOrientation,
int nWeight, BYTE bItalic, BYTE bUnderline,
600 BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
601 BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily,
602 LPCTSTR lpszFacename)
604 ATLASSERT(m_hFont == NULL);
606 m_hFont = ::CreateFont(nHeight, nWidth, nEscapement,
607 nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
608 nCharSet, nOutPrecision, nClipPrecision, nQuality,
609 nPitchAndFamily, lpszFacename);
611 m_hFont = ATL::CreateFont(nHeight, nWidth, nEscapement,
612 nOrientation, nWeight, bItalic, bUnderline, cStrikeOut,
613 nCharSet, nOutPrecision, nClipPrecision, nQuality,
614 nPitchAndFamily, lpszFacename);
618 #endif // !defined(_WIN32_WCE) || (_ATL_VER >= 0x0800) 620 HFONT CreatePointFont(
int nPointSize, LPCTSTR lpszFaceName, HDC hDC = NULL,
bool bBold =
false,
bool bItalic =
false)
622 LOGFONT logFont = { 0 };
623 logFont.lfCharSet = DEFAULT_CHARSET;
624 logFont.lfHeight = nPointSize;
625 SecureHelper::strncpy_x(logFont.lfFaceName, _countof(logFont.lfFaceName), lpszFaceName, _TRUNCATE);
628 logFont.lfWeight = FW_BOLD;
630 logFont.lfItalic = (BYTE)TRUE;
632 return CreatePointFontIndirect(&logFont, hDC);
635 HFONT CreatePointFontIndirect(
const LOGFONT* lpLogFont, HDC hDC = NULL)
637 HDC hDC1 = (hDC != NULL) ? hDC : ::GetDC(NULL);
640 LOGFONT logFont = *lpLogFont;
643 pt.y = ::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720);
644 ::DPtoLP(hDC1, &pt, 1);
645 POINT ptOrg = { 0, 0 };
646 ::DPtoLP(hDC1, &ptOrg, 1);
647 logFont.lfHeight = -abs(pt.y - ptOrg.y);
650 logFont.lfHeight = -abs(::MulDiv(::GetDeviceCaps(hDC1, LOGPIXELSY), logFont.lfHeight, 720));
654 ::ReleaseDC(NULL, hDC1);
656 return CreateFontIndirect(&logFont);
661 ATLASSERT(m_hFont != NULL);
662 BOOL bRet = ::DeleteObject(m_hFont);
669 int GetLogFont(LOGFONT* pLogFont)
const 671 ATLASSERT(m_hFont != NULL);
672 return ::GetObject(m_hFont,
sizeof(LOGFONT), pLogFont);
675 bool GetLogFont(LOGFONT& LogFont)
const 677 ATLASSERT(m_hFont != NULL);
678 return (::GetObject(m_hFont,
sizeof(LOGFONT), &LogFont) ==
sizeof(LOGFONT));
689 template <
bool t_bManaged>
697 CBitmapT(HBITMAP hBitmap = NULL) : m_hBitmap(hBitmap)
702 if(t_bManaged && m_hBitmap != NULL)
712 void Attach(HBITMAP hBitmap)
714 if(t_bManaged && m_hBitmap != NULL&& m_hBitmap != hBitmap)
715 ::DeleteObject(m_hBitmap);
721 HBITMAP hBitmap = m_hBitmap;
726 operator HBITMAP()
const {
return m_hBitmap; }
728 bool IsNull()
const {
return (m_hBitmap == NULL); }
733 ATLASSERT(m_hBitmap == NULL);
734 m_hBitmap = ::LoadBitmap(ModuleHelper::GetResourceInstance(), bitmap.m_lpstr);
738 HBITMAP LoadOEMBitmap(UINT nIDBitmap)
740 ATLASSERT(m_hBitmap == NULL);
741 m_hBitmap = ::LoadBitmap(NULL, MAKEINTRESOURCE(nIDBitmap));
746 HBITMAP LoadMappedBitmap(UINT nIDBitmap, UINT nFlags = 0, LPCOLORMAP lpColorMap = NULL,
int nMapSize = 0)
748 ATLASSERT(m_hBitmap == NULL);
749 m_hBitmap = ::CreateMappedBitmap(ModuleHelper::GetResourceInstance(), nIDBitmap, (WORD)nFlags, lpColorMap, nMapSize);
752 #endif // !_WIN32_WCE 754 HBITMAP CreateBitmap(
int nWidth,
int nHeight, UINT nPlanes, UINT nBitsPerPixel,
const void* lpBits)
756 ATLASSERT(m_hBitmap == NULL);
757 m_hBitmap = ::CreateBitmap(nWidth, nHeight, nPlanes, nBitsPerPixel, lpBits);
762 HBITMAP CreateBitmapIndirect(LPBITMAP lpBitmap)
764 ATLASSERT(m_hBitmap == NULL);
765 m_hBitmap = ::CreateBitmapIndirect(lpBitmap);
768 #endif // !_WIN32_WCE 770 HBITMAP CreateCompatibleBitmap(HDC hDC,
int nWidth,
int nHeight)
772 ATLASSERT(m_hBitmap == NULL);
773 m_hBitmap = ::CreateCompatibleBitmap(hDC, nWidth, nHeight);
778 HBITMAP CreateDiscardableBitmap(HDC hDC,
int nWidth,
int nHeight)
780 ATLASSERT(m_hBitmap == NULL);
781 m_hBitmap = ::CreateDiscardableBitmap(hDC, nWidth, nHeight);
784 #endif // !_WIN32_WCE 788 ATLASSERT(m_hBitmap != NULL);
789 BOOL bRet = ::DeleteObject(m_hBitmap);
796 int GetBitmap(BITMAP* pBitMap)
const 798 ATLASSERT(m_hBitmap != NULL);
799 return ::GetObject(m_hBitmap,
sizeof(BITMAP), pBitMap);
802 bool GetBitmap(BITMAP& bm)
const 804 ATLASSERT(m_hBitmap != NULL);
805 return (::GetObject(m_hBitmap,
sizeof(BITMAP), &bm) ==
sizeof(BITMAP));
808 bool GetSize(SIZE& size)
const 810 ATLASSERT(m_hBitmap != NULL);
814 size.cx = bm.bmWidth;
815 size.cy = bm.bmHeight;
820 DWORD GetBitmapBits(DWORD dwCount, LPVOID lpBits)
const 822 ATLASSERT(m_hBitmap != NULL);
823 return ::GetBitmapBits(m_hBitmap, dwCount, lpBits);
825 #endif // !_WIN32_WCE 827 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 828 DWORD SetBitmapBits(DWORD dwCount,
const void* lpBits)
830 ATLASSERT(m_hBitmap != NULL);
831 return ::SetBitmapBits(m_hBitmap, dwCount, lpBits);
833 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 836 BOOL GetBitmapDimension(LPSIZE lpSize)
const 838 ATLASSERT(m_hBitmap != NULL);
839 return ::GetBitmapDimensionEx(m_hBitmap, lpSize);
842 BOOL SetBitmapDimension(
int nWidth,
int nHeight, LPSIZE lpSize = NULL)
844 ATLASSERT(m_hBitmap != NULL);
845 return ::SetBitmapDimensionEx(m_hBitmap, nWidth, nHeight, lpSize);
849 HBITMAP CreateDIBitmap(HDC hDC, CONST BITMAPINFOHEADER* lpbmih, DWORD dwInit, CONST VOID* lpbInit, CONST BITMAPINFO* lpbmi, UINT uColorUse)
851 ATLASSERT(m_hBitmap == NULL);
852 m_hBitmap = ::CreateDIBitmap(hDC, lpbmih, dwInit, lpbInit, lpbmi, uColorUse);
855 #endif // !_WIN32_WCE 857 HBITMAP CreateDIBSection(HDC hDC, CONST BITMAPINFO* lpbmi, UINT uColorUse, VOID** ppvBits, HANDLE hSection, DWORD dwOffset)
859 ATLASSERT(m_hBitmap == NULL);
860 m_hBitmap = ::CreateDIBSection(hDC, lpbmi, uColorUse, ppvBits, hSection, dwOffset);
865 int GetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, LPVOID lpvBits, LPBITMAPINFO lpbmi, UINT uColorUse)
const 867 ATLASSERT(m_hBitmap != NULL);
868 return ::GetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
871 int SetDIBits(HDC hDC, UINT uStartScan, UINT cScanLines, CONST VOID* lpvBits, CONST BITMAPINFO* lpbmi, UINT uColorUse)
873 ATLASSERT(m_hBitmap != NULL);
874 return ::SetDIBits(hDC, m_hBitmap, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
876 #endif // !_WIN32_WCE 886 template <
bool t_bManaged>
894 CPaletteT(HPALETTE hPalette = NULL) : m_hPalette(hPalette)
899 if(t_bManaged && m_hPalette != NULL)
909 void Attach(HPALETTE hPalette)
911 if(t_bManaged && m_hPalette != NULL && m_hPalette != hPalette)
912 ::DeleteObject(m_hPalette);
913 m_hPalette = hPalette;
918 HPALETTE hPalette = m_hPalette;
923 operator HPALETTE()
const {
return m_hPalette; }
925 bool IsNull()
const {
return (m_hPalette == NULL); }
928 HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)
930 ATLASSERT(m_hPalette == NULL);
931 m_hPalette = ::CreatePalette(lpLogPalette);
936 HPALETTE CreateHalftonePalette(HDC hDC)
938 ATLASSERT(m_hPalette == NULL);
939 ATLASSERT(hDC != NULL);
940 m_hPalette = ::CreateHalftonePalette(hDC);
943 #endif // !_WIN32_WCE 947 ATLASSERT(m_hPalette != NULL);
948 BOOL bRet = ::DeleteObject(m_hPalette);
955 int GetEntryCount()
const 957 ATLASSERT(m_hPalette != NULL);
959 ::GetObject(m_hPalette,
sizeof(WORD), &nEntries);
960 return (
int)nEntries;
963 UINT GetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
const 965 ATLASSERT(m_hPalette != NULL);
966 return ::GetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
969 UINT SetPaletteEntries(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
971 ATLASSERT(m_hPalette != NULL);
972 return ::SetPaletteEntries(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
977 void AnimatePalette(UINT nStartIndex, UINT nNumEntries, LPPALETTEENTRY lpPaletteColors)
979 ATLASSERT(m_hPalette != NULL);
980 ::AnimatePalette(m_hPalette, nStartIndex, nNumEntries, lpPaletteColors);
983 BOOL ResizePalette(UINT nNumEntries)
985 ATLASSERT(m_hPalette != NULL);
986 return ::ResizePalette(m_hPalette, nNumEntries);
988 #endif // !_WIN32_WCE 990 UINT GetNearestPaletteIndex(COLORREF crColor)
const 992 ATLASSERT(m_hPalette != NULL);
993 return ::GetNearestPaletteIndex(m_hPalette, crColor);
1004 template <
bool t_bManaged>
1012 CRgnT(HRGN hRgn = NULL) : m_hRgn(hRgn)
1017 if(t_bManaged && m_hRgn != NULL)
1027 void Attach(HRGN hRgn)
1029 if(t_bManaged && m_hRgn != NULL && m_hRgn != hRgn)
1030 ::DeleteObject(m_hRgn);
1041 operator HRGN()
const {
return m_hRgn; }
1043 bool IsNull()
const {
return (m_hRgn == NULL); }
1046 HRGN CreateRectRgn(
int x1,
int y1,
int x2,
int y2)
1048 ATLASSERT(m_hRgn == NULL);
1049 m_hRgn = ::CreateRectRgn(x1, y1, x2, y2);
1053 HRGN CreateRectRgnIndirect(LPCRECT lpRect)
1055 ATLASSERT(m_hRgn == NULL);
1056 m_hRgn = ::CreateRectRgnIndirect(lpRect);
1061 HRGN CreateEllipticRgn(
int x1,
int y1,
int x2,
int y2)
1063 ATLASSERT(m_hRgn == NULL);
1064 m_hRgn = ::CreateEllipticRgn(x1, y1, x2, y2);
1068 HRGN CreateEllipticRgnIndirect(LPCRECT lpRect)
1070 ATLASSERT(m_hRgn == NULL);
1071 m_hRgn = ::CreateEllipticRgnIndirect(lpRect);
1075 HRGN CreatePolygonRgn(LPPOINT lpPoints,
int nCount,
int nMode)
1077 ATLASSERT(m_hRgn == NULL);
1078 m_hRgn = ::CreatePolygonRgn(lpPoints, nCount, nMode);
1082 HRGN CreatePolyPolygonRgn(LPPOINT lpPoints, LPINT lpPolyCounts,
int nCount,
int nPolyFillMode)
1084 ATLASSERT(m_hRgn == NULL);
1085 m_hRgn = ::CreatePolyPolygonRgn(lpPoints, lpPolyCounts, nCount, nPolyFillMode);
1089 HRGN CreateRoundRectRgn(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
1091 ATLASSERT(m_hRgn == NULL);
1092 m_hRgn = ::CreateRoundRectRgn(x1, y1, x2, y2, x3, y3);
1096 HRGN CreateFromPath(HDC hDC)
1098 ATLASSERT(m_hRgn == NULL);
1099 ATLASSERT(hDC != NULL);
1100 m_hRgn = ::PathToRegion(hDC);
1104 HRGN CreateFromData(
const XFORM* lpXForm,
int nCount,
const RGNDATA* pRgnData)
1106 ATLASSERT(m_hRgn == NULL);
1107 m_hRgn = ::ExtCreateRegion(lpXForm, nCount, pRgnData);
1110 #endif // !_WIN32_WCE 1114 ATLASSERT(m_hRgn != NULL);
1115 BOOL bRet = ::DeleteObject(m_hRgn);
1122 void SetRectRgn(
int x1,
int y1,
int x2,
int y2)
1124 ATLASSERT(m_hRgn != NULL);
1125 ::SetRectRgn(m_hRgn, x1, y1, x2, y2);
1128 void SetRectRgn(LPCRECT lpRect)
1130 ATLASSERT(m_hRgn != NULL);
1131 ::SetRectRgn(m_hRgn, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1134 int CombineRgn(HRGN hRgnSrc1, HRGN hRgnSrc2,
int nCombineMode)
1136 ATLASSERT(m_hRgn != NULL);
1137 return ::CombineRgn(m_hRgn, hRgnSrc1, hRgnSrc2, nCombineMode);
1140 int CombineRgn(HRGN hRgnSrc,
int nCombineMode)
1142 ATLASSERT(m_hRgn != NULL);
1143 return ::CombineRgn(m_hRgn, m_hRgn, hRgnSrc, nCombineMode);
1146 int CopyRgn(HRGN hRgnSrc)
1148 ATLASSERT(m_hRgn != NULL);
1149 return ::CombineRgn(m_hRgn, hRgnSrc, NULL, RGN_COPY);
1152 BOOL EqualRgn(HRGN hRgn)
const 1154 ATLASSERT(m_hRgn != NULL);
1155 return ::EqualRgn(m_hRgn, hRgn);
1158 int OffsetRgn(
int x,
int y)
1160 ATLASSERT(m_hRgn != NULL);
1161 return ::OffsetRgn(m_hRgn, x, y);
1164 int OffsetRgn(POINT point)
1166 ATLASSERT(m_hRgn != NULL);
1167 return ::OffsetRgn(m_hRgn, point.x, point.y);
1170 int GetRgnBox(LPRECT lpRect)
const 1172 ATLASSERT(m_hRgn != NULL);
1173 return ::GetRgnBox(m_hRgn, lpRect);
1176 BOOL PtInRegion(
int x,
int y)
const 1178 ATLASSERT(m_hRgn != NULL);
1179 return ::PtInRegion(m_hRgn, x, y);
1182 BOOL PtInRegion(POINT point)
const 1184 ATLASSERT(m_hRgn != NULL);
1185 return ::PtInRegion(m_hRgn, point.x, point.y);
1188 BOOL RectInRegion(LPCRECT lpRect)
const 1190 ATLASSERT(m_hRgn != NULL);
1191 return ::RectInRegion(m_hRgn, lpRect);
1194 int GetRegionData(LPRGNDATA lpRgnData,
int nDataSize)
const 1196 ATLASSERT(m_hRgn != NULL);
1197 return (
int)::GetRegionData(m_hRgn, nDataSize, lpRgnData);
1208 template <
bool t_bManaged>
1216 CDCT(HDC hDC = NULL) : m_hDC(hDC)
1222 if(t_bManaged && m_hDC != NULL)
1223 ::DeleteDC(Detach());
1232 void Attach(HDC hDC)
1234 if(t_bManaged && m_hDC != NULL && m_hDC != hDC)
1246 operator HDC()
const {
return m_hDC; }
1248 bool IsNull()
const {
return (m_hDC == NULL); }
1252 HWND WindowFromDC()
const 1254 ATLASSERT(m_hDC != NULL);
1255 return ::WindowFromDC(m_hDC);
1257 #endif // !_WIN32_WCE 1259 CPenHandle GetCurrentPen()
const 1261 ATLASSERT(m_hDC != NULL);
1262 return CPenHandle((HPEN)::GetCurrentObject(m_hDC, OBJ_PEN));
1265 CBrushHandle GetCurrentBrush()
const 1267 ATLASSERT(m_hDC != NULL);
1268 return CBrushHandle((HBRUSH)::GetCurrentObject(m_hDC, OBJ_BRUSH));
1271 CPaletteHandle GetCurrentPalette()
const 1273 ATLASSERT(m_hDC != NULL);
1274 return CPaletteHandle((HPALETTE)::GetCurrentObject(m_hDC, OBJ_PAL));
1277 CFontHandle GetCurrentFont()
const 1279 ATLASSERT(m_hDC != NULL);
1280 return CFontHandle((HFONT)::GetCurrentObject(m_hDC, OBJ_FONT));
1283 CBitmapHandle GetCurrentBitmap()
const 1285 ATLASSERT(m_hDC != NULL);
1286 return CBitmapHandle((HBITMAP)::GetCurrentObject(m_hDC, OBJ_BITMAP));
1289 HDC CreateDC(LPCTSTR lpszDriverName, LPCTSTR lpszDeviceName, LPCTSTR lpszOutput,
const DEVMODE* lpInitData)
1291 ATLASSERT(m_hDC == NULL);
1292 m_hDC = ::CreateDC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData);
1296 HDC CreateCompatibleDC(HDC hDC = NULL)
1298 ATLASSERT(m_hDC == NULL);
1299 m_hDC = ::CreateCompatibleDC(hDC);
1307 BOOL bRet = ::DeleteDC(m_hDC);
1316 ATLASSERT(m_hDC != NULL);
1317 return ::SaveDC(m_hDC);
1320 BOOL RestoreDC(
int nSavedDC)
1322 ATLASSERT(m_hDC != NULL);
1323 return ::RestoreDC(m_hDC, nSavedDC);
1326 int GetDeviceCaps(
int nIndex)
const 1328 ATLASSERT(m_hDC != NULL);
1329 return ::GetDeviceCaps(m_hDC, nIndex);
1333 UINT SetBoundsRect(LPCRECT lpRectBounds, UINT flags)
1335 ATLASSERT(m_hDC != NULL);
1336 return ::SetBoundsRect(m_hDC, lpRectBounds, flags);
1339 UINT GetBoundsRect(LPRECT lpRectBounds, UINT flags)
const 1341 ATLASSERT(m_hDC != NULL);
1342 return ::GetBoundsRect(m_hDC, lpRectBounds, flags);
1345 BOOL ResetDC(
const DEVMODE* lpDevMode)
1347 ATLASSERT(m_hDC != NULL);
1348 return ::ResetDC(m_hDC, lpDevMode) != NULL;
1352 BOOL GetBrushOrg(LPPOINT lpPoint)
const 1354 ATLASSERT(m_hDC != NULL);
1355 return ::GetBrushOrgEx(m_hDC, lpPoint);
1357 #endif // !_WIN32_WCE 1359 BOOL SetBrushOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1361 ATLASSERT(m_hDC != NULL);
1362 return ::SetBrushOrgEx(m_hDC, x, y, lpPoint);
1365 BOOL SetBrushOrg(POINT point, LPPOINT lpPointRet = NULL)
1367 ATLASSERT(m_hDC != NULL);
1368 return ::SetBrushOrgEx(m_hDC, point.x, point.y, lpPointRet);
1372 int EnumObjects(
int nObjectType,
int (CALLBACK* lpfn)(LPVOID, LPARAM), LPARAM lpData)
1374 ATLASSERT(m_hDC != NULL);
1376 return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, lpData);
1378 return ::EnumObjects(m_hDC, nObjectType, (GOBJENUMPROC)lpfn, (LPVOID)lpData);
1381 #endif // !_WIN32_WCE 1384 HPEN SelectPen(HPEN hPen)
1386 ATLASSERT(m_hDC != NULL);
1388 ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN || ::GetObjectType(hPen) == OBJ_EXTPEN);
1389 #else // CE specific 1390 ATLASSERT(hPen == NULL || ::GetObjectType(hPen) == OBJ_PEN);
1391 #endif // _WIN32_WCE 1392 return (HPEN)::SelectObject(m_hDC, hPen);
1395 HBRUSH SelectBrush(HBRUSH hBrush)
1397 ATLASSERT(m_hDC != NULL);
1398 ATLASSERT(hBrush == NULL || ::GetObjectType(hBrush) == OBJ_BRUSH);
1399 return (HBRUSH)::SelectObject(m_hDC, hBrush);
1402 HFONT SelectFont(HFONT hFont)
1404 ATLASSERT(m_hDC != NULL);
1405 ATLASSERT(hFont == NULL || ::GetObjectType(hFont) == OBJ_FONT);
1406 return (HFONT)::SelectObject(m_hDC, hFont);
1409 HBITMAP SelectBitmap(HBITMAP hBitmap)
1411 ATLASSERT(m_hDC != NULL);
1412 ATLASSERT(hBitmap == NULL || ::GetObjectType(hBitmap) == OBJ_BITMAP);
1413 return (HBITMAP)::SelectObject(m_hDC, hBitmap);
1416 int SelectRgn(HRGN hRgn)
1418 ATLASSERT(m_hDC != NULL);
1419 ATLASSERT(hRgn == NULL || ::GetObjectType(hRgn) == OBJ_REGION);
1420 return PtrToInt(::SelectObject(m_hDC, hRgn));
1424 HPEN SelectStockPen(
int nPen)
1426 ATLASSERT(m_hDC != NULL);
1427 #if (_WIN32_WINNT >= 0x0500) 1428 ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN || nPen == DC_PEN);
1430 ATLASSERT(nPen == WHITE_PEN || nPen == BLACK_PEN || nPen == NULL_PEN);
1431 #endif // !(_WIN32_WINNT >= 0x0500) 1432 return SelectPen((HPEN)::GetStockObject(nPen));
1435 HBRUSH SelectStockBrush(
int nBrush)
1437 #if (_WIN32_WINNT >= 0x0500) 1438 ATLASSERT((nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH) || nBrush == DC_BRUSH);
1440 ATLASSERT(nBrush >= WHITE_BRUSH && nBrush <= HOLLOW_BRUSH);
1441 #endif // !(_WIN32_WINNT >= 0x0500) 1442 return SelectBrush((HBRUSH)::GetStockObject(nBrush));
1445 HFONT SelectStockFont(
int nFont)
1448 ATLASSERT((nFont >= OEM_FIXED_FONT && nFont <= SYSTEM_FIXED_FONT) || nFont == DEFAULT_GUI_FONT);
1449 #else // CE specific 1450 ATLASSERT(nFont == SYSTEM_FONT);
1451 #endif // _WIN32_WCE 1452 return SelectFont((HFONT)::GetStockObject(nFont));
1455 HPALETTE SelectStockPalette(
int nPalette, BOOL bForceBackground)
1457 ATLASSERT(nPalette == DEFAULT_PALETTE);
1458 return SelectPalette((HPALETTE)::GetStockObject(nPalette), bForceBackground);
1462 COLORREF GetNearestColor(COLORREF crColor)
const 1464 ATLASSERT(m_hDC != NULL);
1465 return ::GetNearestColor(m_hDC, crColor);
1468 HPALETTE SelectPalette(HPALETTE hPalette, BOOL bForceBackground)
1470 ATLASSERT(m_hDC != NULL);
1472 return ::SelectPalette(m_hDC, hPalette, bForceBackground);
1475 UINT RealizePalette()
1477 ATLASSERT(m_hDC != NULL);
1478 return ::RealizePalette(m_hDC);
1484 ATLASSERT(m_hDC != NULL);
1485 ::UpdateColors(m_hDC);
1487 #endif // !_WIN32_WCE 1490 COLORREF GetBkColor()
const 1492 ATLASSERT(m_hDC != NULL);
1493 return ::GetBkColor(m_hDC);
1496 int GetBkMode()
const 1498 ATLASSERT(m_hDC != NULL);
1499 return ::GetBkMode(m_hDC);
1503 int GetPolyFillMode()
const 1505 ATLASSERT(m_hDC != NULL);
1506 return ::GetPolyFillMode(m_hDC);
1511 ATLASSERT(m_hDC != NULL);
1512 return ::GetROP2(m_hDC);
1515 int GetStretchBltMode()
const 1517 ATLASSERT(m_hDC != NULL);
1518 return ::GetStretchBltMode(m_hDC);
1520 #endif // !_WIN32_WCE 1522 COLORREF GetTextColor()
const 1524 ATLASSERT(m_hDC != NULL);
1525 return ::GetTextColor(m_hDC);
1528 COLORREF SetBkColor(COLORREF crColor)
1530 ATLASSERT(m_hDC != NULL);
1531 return ::SetBkColor(m_hDC, crColor);
1534 int SetBkMode(
int nBkMode)
1536 ATLASSERT(m_hDC != NULL);
1537 return ::SetBkMode(m_hDC, nBkMode);
1541 int SetPolyFillMode(
int nPolyFillMode)
1543 ATLASSERT(m_hDC != NULL);
1544 return ::SetPolyFillMode(m_hDC, nPolyFillMode);
1546 #endif // !_WIN32_WCE 1548 int SetROP2(
int nDrawMode)
1550 ATLASSERT(m_hDC != NULL);
1551 return ::SetROP2(m_hDC, nDrawMode);
1555 int SetStretchBltMode(
int nStretchMode)
1557 ATLASSERT(m_hDC != NULL);
1558 return ::SetStretchBltMode(m_hDC, nStretchMode);
1560 #endif // !_WIN32_WCE 1562 COLORREF SetTextColor(COLORREF crColor)
1564 ATLASSERT(m_hDC != NULL);
1565 return ::SetTextColor(m_hDC, crColor);
1569 BOOL GetColorAdjustment(LPCOLORADJUSTMENT lpColorAdjust)
const 1571 ATLASSERT(m_hDC != NULL);
1572 return ::GetColorAdjustment(m_hDC, lpColorAdjust);
1575 BOOL SetColorAdjustment(
const COLORADJUSTMENT* lpColorAdjust)
1577 ATLASSERT(m_hDC != NULL);
1578 return ::SetColorAdjustment(m_hDC, lpColorAdjust);
1582 int GetMapMode()
const 1584 ATLASSERT(m_hDC != NULL);
1585 return ::GetMapMode(m_hDC);
1588 BOOL GetViewportOrg(LPPOINT lpPoint)
const 1590 ATLASSERT(m_hDC != NULL);
1591 return ::GetViewportOrgEx(m_hDC, lpPoint);
1594 int SetMapMode(
int nMapMode)
1596 ATLASSERT(m_hDC != NULL);
1597 return ::SetMapMode(m_hDC, nMapMode);
1599 #endif // !_WIN32_WCE 1602 BOOL SetViewportOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1604 ATLASSERT(m_hDC != NULL);
1605 return ::SetViewportOrgEx(m_hDC, x, y, lpPoint);
1608 BOOL SetViewportOrg(POINT point, LPPOINT lpPointRet = NULL)
1610 ATLASSERT(m_hDC != NULL);
1611 return SetViewportOrg(point.x, point.y, lpPointRet);
1615 BOOL OffsetViewportOrg(
int nWidth,
int nHeight, LPPOINT lpPoint = NULL)
1617 ATLASSERT(m_hDC != NULL);
1618 return ::OffsetViewportOrgEx(m_hDC, nWidth, nHeight, lpPoint);
1622 BOOL GetViewportExt(LPSIZE lpSize)
const 1624 ATLASSERT(m_hDC != NULL);
1625 return ::GetViewportExtEx(m_hDC, lpSize);
1628 BOOL SetViewportExt(
int x,
int y, LPSIZE lpSize = NULL)
1630 ATLASSERT(m_hDC != NULL);
1631 return ::SetViewportExtEx(m_hDC, x, y, lpSize);
1634 BOOL SetViewportExt(SIZE size, LPSIZE lpSizeRet = NULL)
1636 ATLASSERT(m_hDC != NULL);
1637 return SetViewportExt(size.cx, size.cy, lpSizeRet);
1640 BOOL ScaleViewportExt(
int xNum,
int xDenom,
int yNum,
int yDenom, LPSIZE lpSize = NULL)
1642 ATLASSERT(m_hDC != NULL);
1643 return ::ScaleViewportExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
1645 #endif // !_WIN32_WCE 1649 BOOL GetWindowOrg(LPPOINT lpPoint)
const 1651 ATLASSERT(m_hDC != NULL);
1652 return ::GetWindowOrgEx(m_hDC, lpPoint);
1655 BOOL SetWindowOrg(
int x,
int y, LPPOINT lpPoint = NULL)
1657 ATLASSERT(m_hDC != NULL);
1658 return ::SetWindowOrgEx(m_hDC, x, y, lpPoint);
1661 BOOL SetWindowOrg(POINT point, LPPOINT lpPointRet = NULL)
1663 ATLASSERT(m_hDC != NULL);
1664 return SetWindowOrg(point.x, point.y, lpPointRet);
1667 BOOL OffsetWindowOrg(
int nWidth,
int nHeight, LPPOINT lpPoint = NULL)
1669 ATLASSERT(m_hDC != NULL);
1670 return ::OffsetWindowOrgEx(m_hDC, nWidth, nHeight, lpPoint);
1674 BOOL GetWindowExt(LPSIZE lpSize)
const 1676 ATLASSERT(m_hDC != NULL);
1677 return ::GetWindowExtEx(m_hDC, lpSize);
1680 BOOL SetWindowExt(
int x,
int y, LPSIZE lpSize = NULL)
1682 ATLASSERT(m_hDC != NULL);
1683 return ::SetWindowExtEx(m_hDC, x, y, lpSize);
1686 BOOL SetWindowExt(SIZE size, LPSIZE lpSizeRet = NULL)
1688 ATLASSERT(m_hDC != NULL);
1689 return SetWindowExt(size.cx, size.cy, lpSizeRet);
1692 BOOL ScaleWindowExt(
int xNum,
int xDenom,
int yNum,
int yDenom, LPSIZE lpSize = NULL)
1694 ATLASSERT(m_hDC != NULL);
1695 return ::ScaleWindowExtEx(m_hDC, xNum, xDenom, yNum, yDenom, lpSize);
1699 BOOL DPtoLP(LPPOINT lpPoints,
int nCount = 1)
const 1701 ATLASSERT(m_hDC != NULL);
1702 return ::DPtoLP(m_hDC, lpPoints, nCount);
1705 BOOL DPtoLP(LPRECT lpRect)
const 1707 ATLASSERT(m_hDC != NULL);
1708 return ::DPtoLP(m_hDC, (LPPOINT)lpRect, 2);
1711 BOOL DPtoLP(LPSIZE lpSize)
const 1713 SIZE sizeWinExt = { 0, 0 };
1714 if(!GetWindowExt(&sizeWinExt))
1716 SIZE sizeVpExt = { 0, 0 };
1717 if(!GetViewportExt(&sizeVpExt))
1719 lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx));
1720 lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeWinExt.cy), abs(sizeVpExt.cy));
1724 BOOL LPtoDP(LPPOINT lpPoints,
int nCount = 1)
const 1726 ATLASSERT(m_hDC != NULL);
1727 return ::LPtoDP(m_hDC, lpPoints, nCount);
1730 BOOL LPtoDP(LPRECT lpRect)
const 1732 ATLASSERT(m_hDC != NULL);
1733 return ::LPtoDP(m_hDC, (LPPOINT)lpRect, 2);
1736 BOOL LPtoDP(LPSIZE lpSize)
const 1738 SIZE sizeWinExt = { 0, 0 };
1739 if(!GetWindowExt(&sizeWinExt))
1741 SIZE sizeVpExt = { 0, 0 };
1742 if(!GetViewportExt(&sizeVpExt))
1744 lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx));
1745 lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeVpExt.cy), abs(sizeWinExt.cy));
1750 #define HIMETRIC_INCH 2540 // HIMETRIC units per inch 1752 void DPtoHIMETRIC(LPSIZE lpSize)
const 1754 ATLASSERT(m_hDC != NULL);
1756 if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
1759 ((
CDCHandle*)
this)->SetMapMode(MM_HIMETRIC);
1761 ((
CDCHandle*)
this)->SetMapMode(nMapMode);
1766 int cxPerInch = GetDeviceCaps(LOGPIXELSX);
1767 int cyPerInch = GetDeviceCaps(LOGPIXELSY);
1768 ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
1769 lpSize->cx = ::MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch);
1770 lpSize->cy = ::MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch);
1774 void HIMETRICtoDP(LPSIZE lpSize)
const 1776 ATLASSERT(m_hDC != NULL);
1778 if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
1781 ((
CDCHandle*)
this)->SetMapMode(MM_HIMETRIC);
1783 ((
CDCHandle*)
this)->SetMapMode(nMapMode);
1788 int cxPerInch = GetDeviceCaps(LOGPIXELSX);
1789 int cyPerInch = GetDeviceCaps(LOGPIXELSY);
1790 ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
1791 lpSize->cx = ::MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH);
1792 lpSize->cy = ::MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH);
1796 void LPtoHIMETRIC(LPSIZE lpSize)
const 1799 DPtoHIMETRIC(lpSize);
1802 void HIMETRICtoLP(LPSIZE lpSize)
const 1804 HIMETRICtoDP(lpSize);
1807 #endif // !_WIN32_WCE 1810 BOOL FillRgn(HRGN hRgn, HBRUSH hBrush)
1812 ATLASSERT(m_hDC != NULL);
1813 return ::FillRgn(m_hDC, hRgn, hBrush);
1817 BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush,
int nWidth,
int nHeight)
1819 ATLASSERT(m_hDC != NULL);
1820 return ::FrameRgn(m_hDC, hRgn, hBrush, nWidth, nHeight);
1823 BOOL InvertRgn(HRGN hRgn)
1825 ATLASSERT(m_hDC != NULL);
1826 return ::InvertRgn(m_hDC, hRgn);
1829 BOOL PaintRgn(HRGN hRgn)
1831 ATLASSERT(m_hDC != NULL);
1832 return ::PaintRgn(m_hDC, hRgn);
1834 #endif // !_WIN32_WCE 1837 int GetClipBox(LPRECT lpRect)
const 1839 ATLASSERT(m_hDC != NULL);
1840 return ::GetClipBox(m_hDC, lpRect);
1843 int GetClipRgn(CRgn& region)
const 1845 ATLASSERT(m_hDC != NULL);
1847 region.CreateRectRgn(0, 0, 0, 0);
1849 int nRet = ::GetClipRgn(m_hDC, region);
1851 region.DeleteObject();
1857 BOOL PtVisible(
int x,
int y)
const 1859 ATLASSERT(m_hDC != NULL);
1860 return ::PtVisible(m_hDC, x, y);
1863 BOOL PtVisible(POINT point)
const 1865 ATLASSERT(m_hDC != NULL);
1866 return ::PtVisible(m_hDC, point.x, point.y);
1868 #endif // !_WIN32_WCE 1870 BOOL RectVisible(LPCRECT lpRect)
const 1872 ATLASSERT(m_hDC != NULL);
1873 return ::RectVisible(m_hDC, lpRect);
1876 int SelectClipRgn(HRGN hRgn)
1878 ATLASSERT(m_hDC != NULL);
1879 return ::SelectClipRgn(m_hDC, (HRGN)hRgn);
1882 int ExcludeClipRect(
int x1,
int y1,
int x2,
int y2)
1884 ATLASSERT(m_hDC != NULL);
1885 return ::ExcludeClipRect(m_hDC, x1, y1, x2, y2);
1888 int ExcludeClipRect(LPCRECT lpRect)
1890 ATLASSERT(m_hDC != NULL);
1891 return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1895 int ExcludeUpdateRgn(HWND hWnd)
1897 ATLASSERT(m_hDC != NULL);
1898 return ::ExcludeUpdateRgn(m_hDC, hWnd);
1900 #endif // !_WIN32_WCE 1902 int IntersectClipRect(
int x1,
int y1,
int x2,
int y2)
1904 ATLASSERT(m_hDC != NULL);
1905 return ::IntersectClipRect(m_hDC, x1, y1, x2, y2);
1908 int IntersectClipRect(LPCRECT lpRect)
1910 ATLASSERT(m_hDC != NULL);
1911 return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1915 int OffsetClipRgn(
int x,
int y)
1917 ATLASSERT(m_hDC != NULL);
1918 return ::OffsetClipRgn(m_hDC, x, y);
1921 int OffsetClipRgn(SIZE size)
1923 ATLASSERT(m_hDC != NULL);
1924 return ::OffsetClipRgn(m_hDC, size.cx, size.cy);
1927 int SelectClipRgn(HRGN hRgn,
int nMode)
1929 ATLASSERT(m_hDC != NULL);
1930 return ::ExtSelectClipRgn(m_hDC, hRgn, nMode);
1932 #endif // !_WIN32_WCE 1935 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 1936 BOOL GetCurrentPosition(LPPOINT lpPoint)
const 1938 ATLASSERT(m_hDC != NULL);
1939 return ::GetCurrentPositionEx(m_hDC, lpPoint);
1942 BOOL MoveTo(
int x,
int y, LPPOINT lpPoint = NULL)
1944 ATLASSERT(m_hDC != NULL);
1945 return ::MoveToEx(m_hDC, x, y, lpPoint);
1948 BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL)
1950 ATLASSERT(m_hDC != NULL);
1951 return MoveTo(point.x, point.y, lpPointRet);
1954 BOOL LineTo(
int x,
int y)
1956 ATLASSERT(m_hDC != NULL);
1957 return ::LineTo(m_hDC, x, y);
1960 BOOL LineTo(POINT point)
1962 ATLASSERT(m_hDC != NULL);
1963 return LineTo(point.x, point.y);
1965 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 1968 BOOL Arc(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
1970 ATLASSERT(m_hDC != NULL);
1971 return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
1974 BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
1976 ATLASSERT(m_hDC != NULL);
1977 return ::Arc(m_hDC, lpRect->left, lpRect->top,
1978 lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
1981 #endif // !_WIN32_WCE 1983 BOOL Polyline(
const POINT* lpPoints,
int nCount)
1985 ATLASSERT(m_hDC != NULL);
1986 return ::Polyline(m_hDC, lpPoints, nCount);
1990 BOOL AngleArc(
int x,
int y,
int nRadius,
float fStartAngle,
float fSweepAngle)
1992 ATLASSERT(m_hDC != NULL);
1993 return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle);
1996 BOOL ArcTo(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
1998 ATLASSERT(m_hDC != NULL);
1999 return ::ArcTo(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2002 BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2004 ATLASSERT(m_hDC != NULL);
2005 return ArcTo(lpRect->left, lpRect->top, lpRect->right,
2006 lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2009 int GetArcDirection()
const 2011 ATLASSERT(m_hDC != NULL);
2012 return ::GetArcDirection(m_hDC);
2015 int SetArcDirection(
int nArcDirection)
2017 ATLASSERT(m_hDC != NULL);
2018 return ::SetArcDirection(m_hDC, nArcDirection);
2021 BOOL PolyDraw(
const POINT* lpPoints,
const BYTE* lpTypes,
int nCount)
2023 ATLASSERT(m_hDC != NULL);
2024 return ::PolyDraw(m_hDC, lpPoints, lpTypes, nCount);
2027 BOOL PolylineTo(
const POINT* lpPoints,
int nCount)
2029 ATLASSERT(m_hDC != NULL);
2030 return ::PolylineTo(m_hDC, lpPoints, nCount);
2033 BOOL PolyPolyline(
const POINT* lpPoints,
2034 const DWORD* lpPolyPoints,
int nCount)
2036 ATLASSERT(m_hDC != NULL);
2037 return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount);
2040 BOOL PolyBezier(
const POINT* lpPoints,
int nCount)
2042 ATLASSERT(m_hDC != NULL);
2043 return ::PolyBezier(m_hDC, lpPoints, nCount);
2046 BOOL PolyBezierTo(
const POINT* lpPoints,
int nCount)
2048 ATLASSERT(m_hDC != NULL);
2049 return ::PolyBezierTo(m_hDC, lpPoints, nCount);
2051 #endif // !_WIN32_WCE 2054 BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush)
2056 ATLASSERT(m_hDC != NULL);
2057 return ::FillRect(m_hDC, lpRect, hBrush);
2060 BOOL FillRect(LPCRECT lpRect,
int nColorIndex)
2062 ATLASSERT(m_hDC != NULL);
2064 return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1));
2065 #else // CE specific 2066 return ::FillRect(m_hDC, lpRect, ::GetSysColorBrush(nColorIndex));
2067 #endif // _WIN32_WCE 2071 BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush)
2073 ATLASSERT(m_hDC != NULL);
2074 return ::FrameRect(m_hDC, lpRect, hBrush);
2076 #endif // !_WIN32_WCE 2078 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2079 BOOL InvertRect(LPCRECT lpRect)
2081 ATLASSERT(m_hDC != NULL);
2082 return ::InvertRect(m_hDC, lpRect);
2084 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2086 BOOL DrawIcon(
int x,
int y, HICON hIcon)
2088 ATLASSERT(m_hDC != NULL);
2090 return ::DrawIcon(m_hDC, x, y, hIcon);
2091 #else // CE specific 2092 return ::DrawIconEx(m_hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
2093 #endif // _WIN32_WCE 2096 BOOL DrawIcon(POINT point, HICON hIcon)
2098 ATLASSERT(m_hDC != NULL);
2100 return ::DrawIcon(m_hDC, point.x, point.y, hIcon);
2101 #else // CE specific 2102 return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
2103 #endif // _WIN32_WCE 2106 BOOL DrawIconEx(
int x,
int y, HICON hIcon,
int cxWidth,
int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
2108 ATLASSERT(m_hDC != NULL);
2109 return ::DrawIconEx(m_hDC, x, y, hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
2112 BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
2114 ATLASSERT(m_hDC != NULL);
2115 return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
2119 BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL)
2121 ATLASSERT(m_hDC != NULL);
2122 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_BITMAP);
2125 BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL)
2127 ATLASSERT(m_hDC != NULL);
2128 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_ICON);
2131 BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE,
int nTextLen = 0, HBRUSH hBrush = NULL)
2133 ATLASSERT(m_hDC != NULL);
2134 return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags | (bPrefixText ? DST_PREFIXTEXT : DST_TEXT));
2137 BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL)
2139 ATLASSERT(m_hDC != NULL);
2140 return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX);
2142 #endif // !_WIN32_WCE 2146 BOOL Chord(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
2148 ATLASSERT(m_hDC != NULL);
2149 return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2152 BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2154 ATLASSERT(m_hDC != NULL);
2155 return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2157 #endif // !_WIN32_WCE 2159 void DrawFocusRect(LPCRECT lpRect)
2161 ATLASSERT(m_hDC != NULL);
2162 ::DrawFocusRect(m_hDC, lpRect);
2165 BOOL Ellipse(
int x1,
int y1,
int x2,
int y2)
2167 ATLASSERT(m_hDC != NULL);
2168 return ::Ellipse(m_hDC, x1, y1, x2, y2);
2171 BOOL Ellipse(LPCRECT lpRect)
2173 ATLASSERT(m_hDC != NULL);
2174 return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
2178 BOOL Pie(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4)
2180 ATLASSERT(m_hDC != NULL);
2181 return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
2184 BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
2186 ATLASSERT(m_hDC != NULL);
2187 return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
2189 #endif // !_WIN32_WCE 2191 BOOL Polygon(
const POINT* lpPoints,
int nCount)
2193 ATLASSERT(m_hDC != NULL);
2194 return ::Polygon(m_hDC, lpPoints, nCount);
2198 BOOL PolyPolygon(
const POINT* lpPoints,
const INT* lpPolyCounts,
int nCount)
2200 ATLASSERT(m_hDC != NULL);
2201 return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount);
2203 #endif // !_WIN32_WCE 2205 BOOL Rectangle(
int x1,
int y1,
int x2,
int y2)
2207 ATLASSERT(m_hDC != NULL);
2208 return ::Rectangle(m_hDC, x1, y1, x2, y2);
2211 BOOL Rectangle(LPCRECT lpRect)
2213 ATLASSERT(m_hDC != NULL);
2214 return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
2217 BOOL RoundRect(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
2219 ATLASSERT(m_hDC != NULL);
2220 return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3);
2223 BOOL RoundRect(LPCRECT lpRect, POINT point)
2225 ATLASSERT(m_hDC != NULL);
2226 return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y);
2230 BOOL PatBlt(
int x,
int y,
int nWidth,
int nHeight, DWORD dwRop)
2232 ATLASSERT(m_hDC != NULL);
2233 return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop);
2236 BOOL BitBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
2237 int xSrc,
int ySrc, DWORD dwRop)
2239 ATLASSERT(m_hDC != NULL);
2240 return ::BitBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop);
2243 BOOL StretchBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, DWORD dwRop)
2245 ATLASSERT(m_hDC != NULL);
2246 return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop);
2249 COLORREF GetPixel(
int x,
int y)
const 2251 ATLASSERT(m_hDC != NULL);
2252 return ::GetPixel(m_hDC, x, y);
2255 COLORREF GetPixel(POINT point)
const 2257 ATLASSERT(m_hDC != NULL);
2258 return ::GetPixel(m_hDC, point.x, point.y);
2261 COLORREF SetPixel(
int x,
int y, COLORREF crColor)
2263 ATLASSERT(m_hDC != NULL);
2264 return ::SetPixel(m_hDC, x, y, crColor);
2267 COLORREF SetPixel(POINT point, COLORREF crColor)
2269 ATLASSERT(m_hDC != NULL);
2270 return ::SetPixel(m_hDC, point.x, point.y, crColor);
2274 BOOL FloodFill(
int x,
int y, COLORREF crColor)
2276 ATLASSERT(m_hDC != NULL);
2277 return ::FloodFill(m_hDC, x, y, crColor);
2280 BOOL ExtFloodFill(
int x,
int y, COLORREF crColor, UINT nFillType)
2282 ATLASSERT(m_hDC != NULL);
2283 return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType);
2285 #endif // !_WIN32_WCE 2287 BOOL MaskBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc, HBITMAP hMaskBitmap,
int xMask,
int yMask, DWORD dwRop)
2289 ATLASSERT(m_hDC != NULL);
2290 return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop);
2294 BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC,
int xSrc,
int ySrc,
int nWidth,
int nHeight, HBITMAP hMaskBitmap,
int xMask,
int yMask)
2296 ATLASSERT(m_hDC != NULL);
2297 return ::PlgBlt(m_hDC, lpPoint, hSrcDC, xSrc, ySrc, nWidth, nHeight, hMaskBitmap, xMask, yMask);
2300 BOOL SetPixelV(
int x,
int y, COLORREF crColor)
2302 ATLASSERT(m_hDC != NULL);
2303 return ::SetPixelV(m_hDC, x, y, crColor);
2306 BOOL SetPixelV(POINT point, COLORREF crColor)
2308 ATLASSERT(m_hDC != NULL);
2309 return ::SetPixelV(m_hDC, point.x, point.y, crColor);
2311 #endif // !_WIN32_WCE 2313 #if !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) 2315 BOOL TransparentBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, UINT crTransparent)
2317 ATLASSERT(m_hDC != NULL);
2318 return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent);
2320 #else // CE specific 2321 BOOL TransparentImage(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, UINT crTransparent)
2323 ATLASSERT(m_hDC != NULL);
2324 return ::TransparentImage(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent);
2326 #endif // _WIN32_WCE 2328 #if (!defined(_WIN32_WCE) || (_WIN32_WCE >= 420)) 2329 BOOL GradientFill(
const PTRIVERTEX pVertices, DWORD nVertices,
void* pMeshElements, DWORD nMeshElements, DWORD dwMode)
2331 ATLASSERT(m_hDC != NULL);
2332 return ::GradientFill(m_hDC, pVertices, nVertices, pMeshElements, nMeshElements, dwMode);
2335 BOOL GradientFillRect(RECT& rect, COLORREF clr1, COLORREF clr2,
bool bHorizontal)
2337 ATLASSERT(m_hDC != NULL);
2339 TRIVERTEX arrTvx[2] = { { 0 }, { 0 } };
2341 arrTvx[0].x = rect.left;
2342 arrTvx[0].y = rect.top;
2343 arrTvx[0].Red = MAKEWORD(0, GetRValue(clr1));
2344 arrTvx[0].Green = MAKEWORD(0, GetGValue(clr1));
2345 arrTvx[0].Blue = MAKEWORD(0, GetBValue(clr1));
2346 arrTvx[0].Alpha = 0;
2348 arrTvx[1].x = rect.right;
2349 arrTvx[1].y = rect.bottom;
2350 arrTvx[1].Red = MAKEWORD(0, GetRValue(clr2));
2351 arrTvx[1].Green = MAKEWORD(0, GetGValue(clr2));
2352 arrTvx[1].Blue = MAKEWORD(0, GetBValue(clr2));
2353 arrTvx[1].Alpha = 0;
2355 GRADIENT_RECT gr = { 0, 1 };
2357 return ::GradientFill(m_hDC, arrTvx, 2, &gr, 1, bHorizontal ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V);
2359 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 420) 2361 #if !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) 2362 BOOL AlphaBlend(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC,
int xSrc,
int ySrc,
int nSrcWidth,
int nSrcHeight, BLENDFUNCTION bf)
2364 ATLASSERT(m_hDC != NULL);
2365 return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf);
2367 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE > 0x500) 2368 #endif // !defined(_ATL_NO_MSIMG) || defined(_WIN32_WCE) 2374 BOOL DitherBlt(
int x,
int y,
int nWidth,
int nHeight, HDC hSrcDC, HBITMAP hBitmap,
int xSrc,
int ySrc,
2375 HBRUSH hBrushBackground = ::GetSysColorBrush(COLOR_3DFACE),
2376 HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT),
2377 HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW))
2379 ATLASSERT(m_hDC != NULL || hBitmap != NULL);
2380 ATLASSERT(nWidth > 0 && nHeight > 0);
2383 CDCHandle dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC);
2384 ATLASSERT(dc.m_hDC != NULL);
2385 if(dc.m_hDC == NULL)
2389 CDC dcBW = ::CreateCompatibleDC(m_hDC);
2390 ATLASSERT(dcBW.m_hDC != NULL);
2391 if(dcBW.m_hDC == NULL)
2399 struct RGBBWBITMAPINFO
2401 BITMAPINFOHEADER bmiHeader;
2402 RGBQUAD bmiColors[2];
2405 RGBBWBITMAPINFO rgbBWBitmapInfo =
2407 {
sizeof(BITMAPINFOHEADER), nWidth, nHeight, 1, 1, BI_RGB, 0, 0, 0, 0, 0 },
2408 { { 0x00, 0x00, 0x00, 0x00 }, { 0xFF, 0xFF, 0xFF, 0x00 } }
2412 CBitmap bmpBW = ::CreateDIBSection(dcBW, (LPBITMAPINFO)&rgbBWBitmapInfo, DIB_RGB_COLORS, &pbitsBW, NULL, 0);
2413 ATLASSERT(bmpBW.m_hBitmap != NULL);
2414 if(bmpBW.m_hBitmap == NULL)
2422 HBITMAP hbmOldBW = dcBW.SelectBitmap(bmpBW);
2423 HBITMAP hbmOldDC = NULL;
2425 hbmOldDC = dc.SelectBitmap(hBitmap);
2429 CDC dcTemp1 = ::CreateCompatibleDC(m_hDC);
2430 CDC dcTemp2 = ::CreateCompatibleDC(m_hDC);
2432 bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight);
2434 bmpTemp2.CreateBitmap(nWidth, nHeight, 1, 1, NULL);
2435 HBITMAP hOldBmp1 = dcTemp1.SelectBitmap(bmpTemp1);
2436 HBITMAP hOldBmp2 = dcTemp2.SelectBitmap(bmpTemp2);
2438 dcTemp1.BitBlt(0, 0, nWidth, nHeight, dc, xSrc, ySrc, SRCCOPY);
2441 dcTemp1.SetBkColor(RGB(128, 128, 128));
2442 dcTemp2.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
2444 dcTemp1.BitBlt(0, 0, nWidth, nHeight, dcTemp2, 0, 0, SRCINVERT);
2449 dcBW.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
2452 dcTemp1.SelectBitmap(hOldBmp1);
2453 dcTemp2.SelectBitmap(hOldBmp2);
2457 if(hBrushBackground != NULL)
2459 RECT rc = { x, y, x + nWidth, y + nHeight };
2460 FillRect(&rc, hBrushBackground);
2465 HBRUSH hOldBrush = SelectBrush(hBrush3DEffect);
2466 BitBlt(x + 1, y + 1, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
2469 SelectBrush(hBrushDisabledImage);
2470 BitBlt(x, y, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
2472 SelectBrush(hOldBrush);
2473 dcBW.SelectBitmap(hbmOldBW);
2474 dc.SelectBitmap(hbmOldDC);
2484 BOOL TextOut(
int x,
int y, LPCTSTR lpszString,
int nCount = -1)
2486 ATLASSERT(m_hDC != NULL);
2488 nCount = lstrlen(lpszString);
2489 return ::TextOut(m_hDC, x, y, lpszString, nCount);
2491 #endif // !_WIN32_WCE 2493 BOOL ExtTextOut(
int x,
int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount = -1, LPINT lpDxWidths = NULL)
2495 ATLASSERT(m_hDC != NULL);
2497 nCount = lstrlen(lpszString);
2498 return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths);
2502 SIZE TabbedTextOut(
int x,
int y, LPCTSTR lpszString,
int nCount = -1,
int nTabPositions = 0, LPINT lpnTabStopPositions = NULL,
int nTabOrigin = 0)
2504 ATLASSERT(m_hDC != NULL);
2506 nCount = lstrlen(lpszString);
2507 LONG lRes = ::TabbedTextOut(m_hDC, x, y, lpszString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin);
2508 SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) };
2511 #endif // !_WIN32_WCE 2513 int DrawText(LPCTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat)
2515 ATLASSERT(m_hDC != NULL);
2517 ATLASSERT((uFormat & DT_MODIFYSTRING) == 0);
2518 #endif // !_WIN32_WCE 2519 return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat);
2522 int DrawText(LPTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat)
2524 ATLASSERT(m_hDC != NULL);
2525 return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat);
2529 int DrawTextEx(LPTSTR lpstrText,
int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL)
2531 ATLASSERT(m_hDC != NULL);
2532 return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams);
2534 #endif // !_WIN32_WCE 2536 #if (_WIN32_WINNT >= 0x0501) 2537 int DrawShadowText(LPCWSTR lpstrText,
int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow,
int xOffset,
int yOffset)
2539 ATLASSERT(m_hDC != NULL);
2544 HMODULE hCommCtrlDLL = ::LoadLibrary(_T(
"comctl32.dll"));
2545 ATLASSERT(hCommCtrlDLL != NULL);
2546 if(hCommCtrlDLL != NULL)
2548 typedef int (WINAPI *PFN_DrawShadowText)(HDC hDC, LPCWSTR lpstrText, UINT cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow,
int xOffset,
int yOffset);
2549 PFN_DrawShadowText pfnDrawShadowText = (PFN_DrawShadowText)::GetProcAddress(hCommCtrlDLL,
"DrawShadowText");
2550 ATLASSERT(pfnDrawShadowText != NULL);
2551 if(pfnDrawShadowText != NULL)
2552 nRet = pfnDrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset);
2553 ::FreeLibrary(hCommCtrlDLL);
2557 #endif // (_WIN32_WINNT >= 0x0501) 2559 BOOL GetTextExtent(LPCTSTR lpszString,
int nCount, LPSIZE lpSize)
const 2561 ATLASSERT(m_hDC != NULL);
2563 nCount = lstrlen(lpszString);
2564 return ::GetTextExtentPoint32(m_hDC, lpszString, nCount, lpSize);
2567 BOOL GetTextExtentExPoint(LPCTSTR lpszString,
int cchString, LPSIZE lpSize,
int nMaxExtent, LPINT lpnFit = NULL, LPINT alpDx = NULL)
2569 ATLASSERT(m_hDC != NULL);
2570 return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize);
2574 DWORD GetTabbedTextExtent(LPCTSTR lpszString,
int nCount = -1,
int nTabPositions = 0, LPINT lpnTabStopPositions = NULL)
const 2576 ATLASSERT(m_hDC != NULL);
2578 nCount = lstrlen(lpszString);
2579 return ::GetTabbedTextExtent(m_hDC, lpszString, nCount, nTabPositions, lpnTabStopPositions);
2582 BOOL GrayString(HBRUSH hBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM,
int), LPARAM lpData,
int nCount,
int x,
int y,
int nWidth,
int nHeight)
2584 ATLASSERT(m_hDC != NULL);
2585 return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight);
2587 #endif // !_WIN32_WCE 2589 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 2590 UINT GetTextAlign()
const 2592 ATLASSERT(m_hDC != NULL);
2593 return ::GetTextAlign(m_hDC);
2596 UINT SetTextAlign(UINT nFlags)
2598 ATLASSERT(m_hDC != NULL);
2599 return ::SetTextAlign(m_hDC, nFlags);
2601 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 2603 int GetTextFace(LPTSTR lpszFacename,
int nCount)
const 2605 ATLASSERT(m_hDC != NULL);
2606 return ::GetTextFace(m_hDC, nCount, lpszFacename);
2609 int GetTextFaceLen()
const 2611 ATLASSERT(m_hDC != NULL);
2612 return ::GetTextFace(m_hDC, 0, NULL);
2617 BOOL GetTextFace(BSTR& bstrFace)
const 2620 ATLASSERT(m_hDC != NULL);
2621 ATLASSERT(bstrFace == NULL);
2623 int nLen = GetTextFaceLen();
2628 LPTSTR lpszText = buff.Allocate(nLen);
2629 if(lpszText == NULL)
2632 if(!GetTextFace(lpszText, nLen))
2635 bstrFace = ::SysAllocString(T2OLE(lpszText));
2636 return (bstrFace != NULL) ? TRUE : FALSE;
2639 #endif // !_ATL_NO_COM 2641 #if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 2642 int GetTextFace(_CSTRING_NS::CString& strFace)
const 2644 ATLASSERT(m_hDC != NULL);
2646 int nLen = GetTextFaceLen();
2650 LPTSTR lpstr = strFace.GetBufferSetLength(nLen);
2653 int nRet = GetTextFace(lpstr, nLen);
2654 strFace.ReleaseBuffer();
2657 #endif // defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__) 2659 BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics)
const 2661 ATLASSERT(m_hDC != NULL);
2662 return ::GetTextMetrics(m_hDC, lpMetrics);
2666 int SetTextJustification(
int nBreakExtra,
int nBreakCount)
2668 ATLASSERT(m_hDC != NULL);
2669 return ::SetTextJustification(m_hDC, nBreakExtra, nBreakCount);
2672 int GetTextCharacterExtra()
const 2674 ATLASSERT(m_hDC != NULL);
2675 return ::GetTextCharacterExtra(m_hDC);
2678 int SetTextCharacterExtra(
int nCharExtra)
2680 ATLASSERT(m_hDC != NULL);
2681 return ::SetTextCharacterExtra(m_hDC, nCharExtra);
2683 #endif // !_WIN32_WCE 2686 BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags)
2688 ATLASSERT(m_hDC != NULL);
2689 return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags);
2692 BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState)
2694 ATLASSERT(m_hDC != NULL);
2695 return ::DrawFrameControl(m_hDC, lpRect, nType, nState);
2699 BOOL ScrollDC(
int dx,
int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate)
2701 ATLASSERT(m_hDC != NULL);
2702 return ::ScrollDC(m_hDC, dx, dy, lpRectScroll, lpRectClip, hRgnUpdate, lpRectUpdate);
2707 BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer)
const 2709 ATLASSERT(m_hDC != NULL);
2710 return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer);
2714 BOOL GetCharWidth32(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer)
const 2716 ATLASSERT(m_hDC != NULL);
2717 return ::GetCharWidth32(m_hDC, nFirstChar, nLastChar, lpBuffer);
2720 DWORD SetMapperFlags(DWORD dwFlag)
2722 ATLASSERT(m_hDC != NULL);
2723 return ::SetMapperFlags(m_hDC, dwFlag);
2726 BOOL GetAspectRatioFilter(LPSIZE lpSize)
const 2728 ATLASSERT(m_hDC != NULL);
2729 return ::GetAspectRatioFilterEx(m_hDC, lpSize);
2732 BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc)
const 2734 ATLASSERT(m_hDC != NULL);
2735 return ::GetCharABCWidths(m_hDC, nFirstChar, nLastChar, lpabc);
2738 DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData)
const 2740 ATLASSERT(m_hDC != NULL);
2741 return ::GetFontData(m_hDC, dwTable, dwOffset, lpData, cbData);
2744 int GetKerningPairs(
int nPairs, LPKERNINGPAIR lpkrnpair)
const 2746 ATLASSERT(m_hDC != NULL);
2747 return ::GetKerningPairs(m_hDC, nPairs, lpkrnpair);
2750 UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm)
const 2752 ATLASSERT(m_hDC != NULL);
2753 return ::GetOutlineTextMetrics(m_hDC, cbData, lpotm);
2756 DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer,
const MAT2* lpmat2)
const 2758 ATLASSERT(m_hDC != NULL);
2759 return ::GetGlyphOutline(m_hDC, nChar, nFormat, lpgm, cbBuffer, lpBuffer, lpmat2);
2762 BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF)
const 2764 ATLASSERT(m_hDC != NULL);
2765 return ::GetCharABCWidthsFloat(m_hDC, nFirstChar, nLastChar, lpABCF);
2768 BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar,
float* lpFloatBuffer)
const 2770 ATLASSERT(m_hDC != NULL);
2771 return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer);
2773 #endif // !_WIN32_WCE 2777 int Escape(
int nEscape,
int nCount, LPCSTR lpszInData, LPVOID lpOutData)
2779 ATLASSERT(m_hDC != NULL);
2780 return ::Escape(m_hDC, nEscape, nCount, lpszInData, lpOutData);
2782 #endif // !_WIN32_WCE 2784 int Escape(
int nEscape,
int nInputSize, LPCSTR lpszInputData,
2785 int nOutputSize, LPSTR lpszOutputData)
2787 ATLASSERT(m_hDC != NULL);
2788 return ::ExtEscape(m_hDC, nEscape, nInputSize, lpszInputData, nOutputSize, lpszOutputData);
2792 int DrawEscape(
int nEscape,
int nInputSize, LPCSTR lpszInputData)
2794 ATLASSERT(m_hDC != NULL);
2795 return ::DrawEscape(m_hDC, nEscape, nInputSize, lpszInputData);
2797 #endif // !_WIN32_WCE 2800 #if !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) 2801 int StartDoc(LPCTSTR lpszDocName)
2804 di.cbSize =
sizeof(DOCINFO);
2805 di.lpszDocName = lpszDocName;
2806 return StartDoc(&di);
2809 int StartDoc(LPDOCINFO lpDocInfo)
2811 ATLASSERT(m_hDC != NULL);
2812 return ::StartDoc(m_hDC, lpDocInfo);
2817 ATLASSERT(m_hDC != NULL);
2818 return ::StartPage(m_hDC);
2823 ATLASSERT(m_hDC != NULL);
2824 return ::EndPage(m_hDC);
2827 int SetAbortProc(BOOL (CALLBACK* lpfn)(HDC,
int))
2829 ATLASSERT(m_hDC != NULL);
2830 return ::SetAbortProc(m_hDC, (ABORTPROC)lpfn);
2835 ATLASSERT(m_hDC != NULL);
2836 return ::AbortDoc(m_hDC);
2841 ATLASSERT(m_hDC != NULL);
2842 return ::EndDoc(m_hDC);
2844 #endif // !defined(_WIN32_WCE) || ((_WIN32_WCE >= 200) && defined(StartDoc)) 2848 BOOL PlayMetaFile(HMETAFILE hMF)
2850 ATLASSERT(m_hDC != NULL);
2851 if(::GetDeviceCaps(m_hDC, TECHNOLOGY) == DT_METAFILE)
2854 return ::PlayMetaFile(m_hDC, hMF);
2858 return ::EnumMetaFile(m_hDC, hMF, EnumMetaFileProc, (LPARAM)
this);
2861 BOOL PlayMetaFile(HENHMETAFILE hEnhMetaFile, LPCRECT lpBounds)
2863 ATLASSERT(m_hDC != NULL);
2864 return ::PlayEnhMetaFile(m_hDC, hEnhMetaFile, lpBounds);
2867 BOOL AddMetaFileComment(UINT nDataSize,
const BYTE* pCommentData)
2869 ATLASSERT(m_hDC != NULL);
2870 return ::GdiComment(m_hDC, nDataSize, pCommentData);
2874 static int CALLBACK EnumMetaFileProc(HDC hDC, HANDLETABLE* pHandleTable, METARECORD* pMetaRec,
int nHandles, LPARAM lParam)
2878 switch (pMetaRec->rdFunction)
2880 case META_SETMAPMODE:
2881 pDC->SetMapMode((
int)(
short)pMetaRec->rdParm[0]);
2883 case META_SETWINDOWEXT:
2884 pDC->SetWindowExt((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2886 case META_SETWINDOWORG:
2887 pDC->SetWindowOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2889 case META_SETVIEWPORTEXT:
2890 pDC->SetViewportExt((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2892 case META_SETVIEWPORTORG:
2893 pDC->SetViewportOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2895 case META_SCALEWINDOWEXT:
2896 pDC->ScaleWindowExt((
int)(
short)pMetaRec->rdParm[3], (
int)(
short)pMetaRec->rdParm[2],
2897 (
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2899 case META_SCALEVIEWPORTEXT:
2900 pDC->ScaleViewportExt((
int)(
short)pMetaRec->rdParm[3], (
int)(
short)pMetaRec->rdParm[2],
2901 (
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2903 case META_OFFSETVIEWPORTORG:
2904 pDC->OffsetViewportOrg((
int)(
short)pMetaRec->rdParm[1], (
int)(
short)pMetaRec->rdParm[0]);
2909 case META_RESTOREDC:
2910 pDC->RestoreDC((
int)(
short)pMetaRec->rdParm[0]);
2912 case META_SETBKCOLOR:
2913 pDC->SetBkColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]);
2915 case META_SETTEXTCOLOR:
2916 pDC->SetTextColor(*(UNALIGNED COLORREF*)&pMetaRec->rdParm[0]);
2920 case META_SELECTOBJECT:
2922 HGDIOBJ hObject = pHandleTable->objectHandle[pMetaRec->rdParm[0]];
2923 UINT nObjType = ::GetObjectType(hObject);
2927 HFONT hStockFont = (HFONT)::GetStockObject(SYSTEM_FONT);
2928 HFONT hFontOld = (HFONT)::SelectObject(pDC->m_hDC, hStockFont);
2929 HGDIOBJ hObjOld = ::SelectObject(pDC->m_hDC, hObject);
2930 if(hObjOld == hStockFont)
2933 pDC->SelectFont((HFONT)hObject);
2939 ::SelectObject(pDC->m_hDC, hFontOld);
2940 ::SelectObject(pDC->m_hDC, hObjOld);
2944 else if(nObjType == OBJ_FONT)
2947 pDC->SelectFont((HFONT)hObject);
2954 ::PlayMetaFileRecord(hDC, pHandleTable, pMetaRec, nHandles);
2960 #endif // !_WIN32_WCE 2966 ATLASSERT(m_hDC != NULL);
2967 return ::AbortPath(m_hDC);
2972 ATLASSERT(m_hDC != NULL);
2973 return ::BeginPath(m_hDC);
2978 ATLASSERT(m_hDC != NULL);
2979 return ::CloseFigure(m_hDC);
2984 ATLASSERT(m_hDC != NULL);
2985 return ::EndPath(m_hDC);
2990 ATLASSERT(m_hDC != NULL);
2991 return ::FillPath(m_hDC);
2996 ATLASSERT(m_hDC != NULL);
2997 return ::FlattenPath(m_hDC);
3000 BOOL StrokeAndFillPath()
3002 ATLASSERT(m_hDC != NULL);
3003 return ::StrokeAndFillPath(m_hDC);
3008 ATLASSERT(m_hDC != NULL);
3009 return ::StrokePath(m_hDC);
3014 ATLASSERT(m_hDC != NULL);
3015 return ::WidenPath(m_hDC);
3018 BOOL GetMiterLimit(PFLOAT pfMiterLimit)
const 3020 ATLASSERT(m_hDC != NULL);
3021 return ::GetMiterLimit(m_hDC, pfMiterLimit);
3024 BOOL SetMiterLimit(
float fMiterLimit)
3026 ATLASSERT(m_hDC != NULL);
3027 return ::SetMiterLimit(m_hDC, fMiterLimit, NULL);
3030 int GetPath(LPPOINT lpPoints, LPBYTE lpTypes,
int nCount)
const 3032 ATLASSERT(m_hDC != NULL);
3033 return ::GetPath(m_hDC, lpPoints, lpTypes, nCount);
3036 BOOL SelectClipPath(
int nMode)
3038 ATLASSERT(m_hDC != NULL);
3039 return ::SelectClipPath(m_hDC, nMode);
3041 #endif // !_WIN32_WCE 3044 static CBrushHandle PASCAL GetHalftoneBrush()
3046 HBRUSH halftoneBrush = NULL;
3047 WORD grayPattern[8] = { 0 };
3048 for(
int i = 0; i < 8; i++)
3049 grayPattern[i] = (WORD)(0x5555 << (i & 1));
3050 HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern);
3051 if(grayBitmap != NULL)
3053 halftoneBrush = ::CreatePatternBrush(grayBitmap);
3054 DeleteObject(grayBitmap);
3056 return CBrushHandle(halftoneBrush);
3059 void DrawDragRect(LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, HBRUSH hBrush = NULL, HBRUSH hBrushLast = NULL)
3063 rgnOutside.CreateRectRgnIndirect(lpRect);
3064 RECT rect = *lpRect;
3065 ::InflateRect(&rect, -size.cx, -size.cy);
3066 ::IntersectRect(&rect, &rect, lpRect);
3068 rgnInside.CreateRectRgnIndirect(&rect);
3070 rgnNew.CreateRectRgn(0, 0, 0, 0);
3071 rgnNew.CombineRgn(rgnOutside, rgnInside, RGN_XOR);
3073 HBRUSH hBrushOld = NULL;
3074 CBrush brushHalftone;
3076 brushHalftone = hBrush = CDCHandle::GetHalftoneBrush();
3077 if(hBrushLast == NULL)
3078 hBrushLast = hBrush;
3082 if(lpRectLast != NULL)
3085 rgnLast.CreateRectRgn(0, 0, 0, 0);
3086 rgnOutside.SetRectRgn(lpRectLast->left, lpRectLast->top, lpRectLast->right, lpRectLast->bottom);
3088 ::InflateRect(&rect, -sizeLast.cx, -sizeLast.cy);
3089 ::IntersectRect(&rect, &rect, lpRectLast);
3090 rgnInside.SetRectRgn(rect.left, rect.top, rect.right, rect.bottom);
3091 rgnLast.CombineRgn(rgnOutside, rgnInside, RGN_XOR);
3094 if(hBrush == hBrushLast)
3096 rgnUpdate.CreateRectRgn(0, 0, 0, 0);
3097 rgnUpdate.CombineRgn(rgnLast, rgnNew, RGN_XOR);
3100 if(hBrush != hBrushLast && lpRectLast != NULL)
3103 SelectClipRgn(rgnLast);
3105 hBrushOld = SelectBrush(hBrushLast);
3106 PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT);
3107 SelectBrush(hBrushOld);
3112 SelectClipRgn(rgnUpdate.IsNull() ? rgnNew : rgnUpdate);
3114 hBrushOld = SelectBrush(hBrush);
3115 PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT);
3118 if(hBrushOld != NULL)
3119 SelectBrush(hBrushOld);
3120 SelectClipRgn(NULL);
3123 void FillSolidRect(LPCRECT lpRect, COLORREF clr)
3125 ATLASSERT(m_hDC != NULL);
3127 COLORREF clrOld = ::SetBkColor(m_hDC, clr);
3128 ATLASSERT(clrOld != CLR_INVALID);
3129 if(clrOld != CLR_INVALID)
3131 ::ExtTextOut(m_hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
3132 ::SetBkColor(m_hDC, clrOld);
3136 void FillSolidRect(
int x,
int y,
int cx,
int cy, COLORREF clr)
3138 ATLASSERT(m_hDC != NULL);
3140 RECT rect = { x, y, x + cx, y + cy };
3141 FillSolidRect(&rect, clr);
3144 void Draw3dRect(LPCRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight)
3146 Draw3dRect(lpRect->left, lpRect->top, lpRect->right - lpRect->left,
3147 lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight);
3150 void Draw3dRect(
int x,
int y,
int cx,
int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
3152 FillSolidRect(x, y, cx - 1, 1, clrTopLeft);
3153 FillSolidRect(x, y, 1, cy - 1, clrTopLeft);
3154 FillSolidRect(x + cx, y, -1, cy, clrBottomRight);
3155 FillSolidRect(x, y + cy, cx, -1, clrBottomRight);
3159 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 3160 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)
3162 ATLASSERT(m_hDC != NULL);
3163 return ::SetDIBitsToDevice(m_hDC, x, y, dwWidth, dwHeight, xSrc, ySrc, uStartScan, cScanLines, lpvBits, lpbmi, uColorUse);
3165 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 410) 3167 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 3168 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)
3170 ATLASSERT(m_hDC != NULL);
3171 return ::StretchDIBits(m_hDC, x, y, nWidth, nHeight, xSrc, ySrc, nSrcWidth, nSrcHeight, lpvBits, lpbmi, uColorUse, dwRop);
3174 UINT GetDIBColorTable(UINT uStartIndex, UINT cEntries, RGBQUAD* pColors)
const 3176 ATLASSERT(m_hDC != NULL);
3177 return ::GetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors);
3180 UINT SetDIBColorTable(UINT uStartIndex, UINT cEntries, CONST RGBQUAD* pColors)
3182 ATLASSERT(m_hDC != NULL);
3183 return ::SetDIBColorTable(m_hDC, uStartIndex, cEntries, pColors);
3185 #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) 3188 #if !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 3189 int ChoosePixelFormat(CONST PIXELFORMATDESCRIPTOR* ppfd)
3191 ATLASSERT(m_hDC != NULL);
3192 return ::ChoosePixelFormat(m_hDC, ppfd);
3195 int DescribePixelFormat(
int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
3197 ATLASSERT(m_hDC != NULL);
3198 return ::DescribePixelFormat(m_hDC, iPixelFormat, nBytes, ppfd);
3201 int GetPixelFormat()
const 3203 ATLASSERT(m_hDC != NULL);
3204 return ::GetPixelFormat(m_hDC);
3207 BOOL SetPixelFormat(
int iPixelFormat, CONST PIXELFORMATDESCRIPTOR* ppfd)
3209 ATLASSERT(m_hDC != NULL);
3210 return ::SetPixelFormat(m_hDC, iPixelFormat, ppfd);
3215 ATLASSERT(m_hDC != NULL);
3216 return ::SwapBuffers(m_hDC);
3219 HGLRC wglCreateContext()
3221 ATLASSERT(m_hDC != NULL);
3222 return ::wglCreateContext(m_hDC);
3225 HGLRC wglCreateLayerContext(
int iLayerPlane)
3227 ATLASSERT(m_hDC != NULL);
3228 return ::wglCreateLayerContext(m_hDC, iLayerPlane);
3231 BOOL wglMakeCurrent(HGLRC hglrc)
3233 ATLASSERT(m_hDC != NULL);
3234 return ::wglMakeCurrent(m_hDC, hglrc);
3237 BOOL wglUseFontBitmaps(DWORD dwFirst, DWORD dwCount, DWORD listBase)
3239 ATLASSERT(m_hDC != NULL);
3240 return ::wglUseFontBitmaps(m_hDC, dwFirst, dwCount, listBase);
3243 BOOL wglUseFontOutlines(DWORD dwFirst, DWORD dwCount, DWORD listBase, FLOAT deviation, FLOAT extrusion,
int format, LPGLYPHMETRICSFLOAT lpgmf)
3245 ATLASSERT(m_hDC != NULL);
3246 return ::wglUseFontOutlines(m_hDC, dwFirst, dwCount, listBase, deviation, extrusion, format, lpgmf);
3249 BOOL wglDescribeLayerPlane(
int iPixelFormat,
int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd)
3251 ATLASSERT(m_hDC != NULL);
3252 return ::wglDescribeLayerPlane(m_hDC, iPixelFormat, iLayerPlane, nBytes, plpd);
3255 int wglSetLayerPaletteEntries(
int iLayerPlane,
int iStart,
int cEntries, CONST COLORREF* pclr)
3257 ATLASSERT(m_hDC != NULL);
3258 return ::wglSetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr);
3261 int wglGetLayerPaletteEntries(
int iLayerPlane,
int iStart,
int cEntries, COLORREF* pclr)
3263 ATLASSERT(m_hDC != NULL);
3264 return ::wglGetLayerPaletteEntries(m_hDC, iLayerPlane, iStart, cEntries, pclr);
3267 BOOL wglRealizeLayerPalette(
int iLayerPlane, BOOL bRealize)
3269 ATLASSERT(m_hDC != NULL);
3270 return ::wglRealizeLayerPalette(m_hDC, iLayerPlane, bRealize);
3273 BOOL wglSwapLayerBuffers(UINT uPlanes)
3275 ATLASSERT(m_hDC != NULL);
3276 return ::wglSwapLayerBuffers(m_hDC, uPlanes);
3278 #endif // !defined(_ATL_NO_OPENGL) && !defined(_WIN32_WCE) 3281 #if (_WIN32_WINNT >= 0x0500) 3282 COLORREF GetDCPenColor()
const 3284 ATLASSERT(m_hDC != NULL);
3285 return ::GetDCPenColor(m_hDC);
3288 COLORREF SetDCPenColor(COLORREF clr)
3290 ATLASSERT(m_hDC != NULL);
3291 return ::SetDCPenColor(m_hDC, clr);
3294 COLORREF GetDCBrushColor()
const 3296 ATLASSERT(m_hDC != NULL);
3297 return ::GetDCBrushColor(m_hDC);
3300 COLORREF SetDCBrushColor(COLORREF clr)
3302 ATLASSERT(m_hDC != NULL);
3303 return ::SetDCBrushColor(m_hDC, clr);
3307 DWORD GetFontUnicodeRanges(LPGLYPHSET lpgs)
const 3309 ATLASSERT(m_hDC != NULL);
3310 return ::GetFontUnicodeRanges(m_hDC, lpgs);
3312 #endif // !_WIN32_WCE 3314 DWORD GetGlyphIndices(LPCTSTR lpstr,
int cch, LPWORD pgi, DWORD dwFlags)
const 3316 ATLASSERT(m_hDC != NULL);
3317 return ::GetGlyphIndices(m_hDC, lpstr, cch, pgi, dwFlags);
3320 BOOL GetTextExtentPointI(LPWORD pgiIn,
int cgi, LPSIZE lpSize)
const 3322 ATLASSERT(m_hDC != NULL);
3323 return ::GetTextExtentPointI(m_hDC, pgiIn, cgi, lpSize);
3326 BOOL GetTextExtentExPointI(LPWORD pgiIn,
int cgi,
int nMaxExtent, LPINT lpnFit, LPINT alpDx, LPSIZE lpSize)
const 3328 ATLASSERT(m_hDC != NULL);
3329 return ::GetTextExtentExPointI(m_hDC, pgiIn, cgi, nMaxExtent, lpnFit, alpDx, lpSize);
3332 BOOL GetCharWidthI(UINT giFirst, UINT cgi, LPWORD pgi, LPINT lpBuffer)
const 3334 ATLASSERT(m_hDC != NULL);
3335 return ::GetCharWidthI(m_hDC, giFirst, cgi, pgi, lpBuffer);
3338 BOOL GetCharABCWidthsI(UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc)
const 3340 ATLASSERT(m_hDC != NULL);
3341 return ::GetCharABCWidthsI(m_hDC, giFirst, cgi, pgi, lpabc);
3343 #endif // (_WIN32_WINNT >= 0x0500) 3346 #if (WINVER >= 0x0500) && !defined(_WIN32_WCE) 3347 BOOL ColorCorrectPalette(HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries)
3349 ATLASSERT(m_hDC != NULL);
3350 return ::ColorCorrectPalette(m_hDC, hPalette, dwFirstEntry, dwNumOfEntries);
3352 #endif // (WINVER >= 0x0500) && !defined(_WIN32_WCE) 3372 ATLASSERT(::IsWindow(hWnd));
3374 m_hDC = ::BeginPaint(hWnd, &m_ps);
3379 ATLASSERT(m_hDC != NULL);
3380 ATLASSERT(::IsWindow(m_hWnd));
3381 ::EndPaint(m_hWnd, &m_ps);
3395 ATLASSERT(hWnd == NULL || ::IsWindow(hWnd));
3397 m_hDC = ::GetDC(hWnd);
3402 ATLASSERT(m_hDC != NULL);
3403 ::ReleaseDC(m_hWnd, Detach());
3416 ATLASSERT(hWnd == NULL || ::IsWindow(hWnd));
3418 m_hDC = ::GetWindowDC(hWnd);
3423 ATLASSERT(m_hDC != NULL);
3424 ::ReleaseDC(m_hWnd, Detach());
3438 CMemoryDC(HDC hDC,
const RECT& rcPaint) : m_hDCOriginal(hDC), m_hBmpOld(NULL)
3440 m_rcPaint = rcPaint;
3441 CreateCompatibleDC(m_hDCOriginal);
3442 ATLASSERT(m_hDC != NULL);
3443 m_bmp.CreateCompatibleBitmap(m_hDCOriginal, m_rcPaint.right - m_rcPaint.left, m_rcPaint.bottom - m_rcPaint.top);
3444 ATLASSERT(m_bmp.m_hBitmap != NULL);
3445 m_hBmpOld = SelectBitmap(m_bmp);
3446 SetViewportOrg(-m_rcPaint.left, -m_rcPaint.top);
3451 ::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);
3452 SelectBitmap(m_hBmpOld);
3466 HENHMETAFILE m_hEMF;
3469 ENHMETAHEADER m_header;
3470 PIXELFORMATDESCRIPTOR m_pfd;
3473 CEnhMetaFileInfo(HENHMETAFILE hEMF) : m_pBits(NULL), m_pDesc(NULL), m_hEMF(hEMF)
3483 BYTE* GetEnhMetaFileBits()
3485 ATLASSERT(m_hEMF != NULL);
3486 UINT nBytes = ::GetEnhMetaFileBits(m_hEMF, 0, NULL);
3489 ATLTRY(m_pBits =
new BYTE[nBytes]);
3490 if (m_pBits != NULL)
3491 ::GetEnhMetaFileBits(m_hEMF, nBytes, m_pBits);
3495 LPTSTR GetEnhMetaFileDescription()
3497 ATLASSERT(m_hEMF != NULL);
3498 UINT nLen = ::GetEnhMetaFileDescription(m_hEMF, 0, NULL);
3501 ATLTRY(m_pDesc =
new TCHAR[nLen]);
3502 if (m_pDesc != NULL)
3503 nLen = ::GetEnhMetaFileDescription(m_hEMF, nLen, m_pDesc);
3507 ENHMETAHEADER* GetEnhMetaFileHeader()
3509 ATLASSERT(m_hEMF != NULL);
3510 memset(&m_header, 0,
sizeof(m_header));
3511 m_header.iType = EMR_HEADER;
3512 m_header.nSize =
sizeof(ENHMETAHEADER);
3513 UINT n = ::GetEnhMetaFileHeader(m_hEMF,
sizeof(ENHMETAHEADER), &m_header);
3514 return (n != 0) ? &m_header : NULL;
3517 PIXELFORMATDESCRIPTOR* GetEnhMetaFilePixelFormat()
3519 ATLASSERT(m_hEMF != NULL);
3520 memset(&m_pfd, 0,
sizeof(m_pfd));
3521 UINT n = ::GetEnhMetaFilePixelFormat(m_hEMF,
sizeof(m_pfd), &m_pfd);
3522 return (n != 0) ? &m_pfd : NULL;
3527 template <
bool t_bManaged>
3532 HENHMETAFILE m_hEMF;
3541 if(t_bManaged && m_hEMF != NULL)
3552 void Attach(HENHMETAFILE hEMF)
3554 if(t_bManaged && m_hEMF != NULL && m_hEMF != hEMF)
3559 HENHMETAFILE Detach()
3561 HENHMETAFILE hEMF = m_hEMF;
3566 operator HENHMETAFILE()
const {
return m_hEMF; }
3568 bool IsNull()
const {
return (m_hEMF == NULL); }
3572 ATLASSERT(m_hEMF != NULL);
3573 BOOL bRet = ::DeleteEnhMetaFile(m_hEMF);
3578 UINT GetEnhMetaFileBits(UINT cbBuffer, LPBYTE lpbBuffer)
const 3580 ATLASSERT(m_hEMF != NULL);
3581 return ::GetEnhMetaFileBits(m_hEMF, cbBuffer, lpbBuffer);
3584 UINT GetEnhMetaFileDescription(UINT cchBuffer, LPTSTR lpszDescription)
const 3586 ATLASSERT(m_hEMF != NULL);
3587 return ::GetEnhMetaFileDescription(m_hEMF, cchBuffer, lpszDescription);
3590 UINT GetEnhMetaFileHeader(LPENHMETAHEADER lpemh)
const 3592 ATLASSERT(m_hEMF != NULL);
3593 lpemh->iType = EMR_HEADER;
3594 lpemh->nSize =
sizeof(ENHMETAHEADER);
3595 return ::GetEnhMetaFileHeader(m_hEMF,
sizeof(ENHMETAHEADER), lpemh);
3598 UINT GetEnhMetaFilePaletteEntries(UINT cEntries, LPPALETTEENTRY lppe)
const 3600 ATLASSERT(m_hEMF != NULL);
3601 return ::GetEnhMetaFilePaletteEntries(m_hEMF, cEntries, lppe);
3604 UINT GetEnhMetaFilePixelFormat(DWORD cbBuffer, PIXELFORMATDESCRIPTOR* ppfd)
const 3606 ATLASSERT(m_hEMF != NULL);
3607 return ::GetEnhMetaFilePixelFormat(m_hEMF, cbBuffer, ppfd);
3625 Create(hdc, NULL, lpRect, NULL);
3626 ATLASSERT(m_hDC != NULL);
3629 CEnhMetaFileDC(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
3631 Create(hdcRef, lpFilename, lpRect, lpDescription);
3632 ATLASSERT(m_hDC != NULL);
3637 HENHMETAFILE hEMF = Close();
3639 ::DeleteEnhMetaFile(hEMF);
3643 void Create(HDC hdcRef, LPCTSTR lpFilename, LPCRECT lpRect, LPCTSTR lpDescription)
3645 ATLASSERT(m_hDC == NULL);
3646 m_hDC = ::CreateEnhMetaFile(hdcRef, lpFilename, lpRect, lpDescription);
3649 HENHMETAFILE Close()
3651 HENHMETAFILE hEMF = NULL;
3654 hEMF = ::CloseEnhMetaFile(m_hDC);
3661 #endif // !_WIN32_WCE 3667 #ifndef _WTL_NO_DIB16 3669 #define DIBINFO16_BITFIELDS { 31744, 992, 31 } 3674 BITMAPINFOHEADER bmiHeader;
3675 RGBQUAD bmiColors[3];
3679 BITMAPINFOHEADER bmih = {
sizeof(BITMAPINFOHEADER), size.cx, size.cy,
3680 1, 16, BI_BITFIELDS, (DWORD)(2 * size.cx * size.cy), 0, 0, 3 };
3681 DWORD dw[3] = DIBINFO16_BITFIELDS ;
3684 SecureHelper::memcpy_x(bmiColors,
sizeof(bmiColors), dw, 3 *
sizeof(DWORD));
3691 inline bool AtlIsDib16(LPBITMAPINFOHEADER pbmih)
3693 return (pbmih->biBitCount == 16) && (pbmih->biCompression == BI_BITFIELDS);
3696 inline int AtlGetDibColorTableSize(LPBITMAPINFOHEADER pbmih)
3698 switch (pbmih->biBitCount)
3703 return pbmih->biClrUsed ? pbmih->biClrUsed : 1 << pbmih->biBitCount;
3708 return pbmih->biCompression == BI_BITFIELDS ? 3 : 0;
3716 inline int AtlGetDibNumColors(LPBITMAPINFOHEADER pbmih)
3718 switch (pbmih->biBitCount)
3723 if (pbmih->biClrUsed)
3724 return pbmih->biClrUsed;
3728 if (pbmih->biCompression == BI_BITFIELDS )
3735 if (pbmih->biCompression == BI_BITFIELDS )
3743 return 1 << pbmih->biBitCount;
3746 inline HBITMAP AtlGetDibBitmap(LPBITMAPINFO pbmi)
3751 LPBYTE pDibBits = (LPBYTE)pbmi +
sizeof(BITMAPINFOHEADER) + AtlGetDibColorTableSize(&pbmi->bmiHeader) *
sizeof(RGBQUAD);
3752 HBITMAP hbm = CreateDIBSection(dc, pbmi, DIB_RGB_COLORS, &pBits, NULL, NULL);
3755 int cbBits = pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biHeight * pbmi->bmiHeader.biBitCount / 8;
3756 SecureHelper::memcpy_x(pBits, cbBits, pDibBits, pbmi->bmiHeader.biSizeImage);
3762 inline HBITMAP AtlCopyBitmap(HBITMAP hbm, SIZE sizeDst,
bool bAsBitmap =
false)
3764 CDC hdcSrc = CreateCompatibleDC(NULL);
3765 CDC hdcDst = CreateCompatibleDC(NULL);
3767 CBitmapHandle hbmOld = NULL, hbmOld2 = NULL, bmSrc = hbm;
3769 CBitmap bmNew = NULL;
3771 SIZE sizeSrc = { 0 };
3772 bmSrc.GetSize(sizeSrc);
3774 hbmOld = hdcSrc.SelectBitmap(bmSrc);
3778 bmNew.CreateCompatibleBitmap(hdcSrc, sizeDst.cx, sizeDst.cy);
3783 LPVOID pBits = NULL;
3784 bmNew = CreateDIBSection(hdcDst, (
const BITMAPINFO*)&dib16, DIB_RGB_COLORS, &pBits, NULL, NULL);
3787 ATLASSERT(!bmNew.IsNull());
3789 hbmOld2 = hdcDst.SelectBitmap(bmNew);
3792 if ((sizeDst.cx == sizeSrc.cx) && (sizeDst.cy == sizeSrc.cy))
3793 bOK = hdcDst.BitBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, SRCCOPY);
3795 bOK = hdcDst.StretchBlt(0, 0, sizeDst.cx, sizeDst.cy, hdcSrc, 0, 0, sizeSrc.cx, sizeSrc.cy, SRCCOPY);
3797 hdcSrc.SelectBitmap(hbmOld);
3798 hdcDst.SelectBitmap(hbmOld2);
3801 bmNew.DeleteObject();
3803 return bmNew.Detach();
3806 inline HLOCAL AtlCreatePackedDib16(HBITMAP hbm, SIZE size)
3808 DIBSECTION ds = { 0 };
3810 bool bCopied =
false;
3812 bool bOK = GetObject(hbm,
sizeof(ds), &ds) ==
sizeof(ds);
3813 if ((bOK == FALSE) || (ds.dsBm.bmBits == NULL) || (AtlIsDib16(&ds.dsBmih) == FALSE) ||
3814 (ds.dsBmih.biWidth != size.cx ) || (ds.dsBmih.biHeight != size.cy ))
3816 if ((hbm = AtlCopyBitmap(hbm, size)) != NULL)
3819 bOK = GetObject(hbm,
sizeof(ds), &ds) ==
sizeof(ds);
3827 if((bOK != FALSE) && (AtlIsDib16(&ds.dsBmih) != FALSE) && (ds.dsBm.bmBits != NULL))
3829 pDib = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,
sizeof(
DIBINFO16) + ds.dsBmih.biSizeImage);
3832 SecureHelper::memcpy_x(pDib,
sizeof(
DIBINFO16) + ds.dsBmih.biSizeImage, &ds.dsBmih,
sizeof(
DIBINFO16));
3833 SecureHelper::memcpy_x(pDib +
sizeof(
DIBINFO16), ds.dsBmih.biSizeImage, ds.dsBm.bmBits, ds.dsBmih.biSizeImage);
3837 if (bCopied ==
true)
3840 return (HLOCAL)pDib;
3843 inline bool AtlSetClipboardDib16(HBITMAP hbm, SIZE size, HWND hWnd)
3845 ATLASSERT(::IsWindow(hWnd));
3846 BOOL bOK = OpenClipboard(hWnd);
3849 bOK = EmptyClipboard();
3852 HLOCAL hDib = AtlCreatePackedDib16(hbm, size);
3855 bOK = SetClipboardData(CF_DIB, hDib) != NULL;
3867 return (bOK != FALSE);
3870 inline HBITMAP AtlGetClipboardDib(HWND hWnd)
3872 ATLASSERT(::IsWindow(hWnd) != FALSE);
3874 if (OpenClipboard(hWnd) != FALSE)
3876 LPBITMAPINFO pbmi = (LPBITMAPINFO)GetClipboardData(CF_DIB);
3878 hbm = AtlGetDibBitmap(pbmi);
3885 #endif // _WTL_NO_DIB16 3889 #endif // __ATLGDI_H__ Definition: atlwinx.h:452
Definition: atlgdi.h:1005
Definition: atlgdi.h:3386
Definition: atlgdi.h:3672
Definition: atlapp.h:1455
Definition: atlgdi.h:1209
Definition: atlgdi.h:3362
Definition: atlgdi.h:3407
Definition: atlgdi.h:3428