📄 atlgdi.h
字号:
ATLASSERT(m_hDC != NULL);
return ::RoundRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, point.x, point.y);
}
// Bitmap Functions
BOOL PatBlt(int x, int y, int nWidth, int nHeight, DWORD dwRop)
{
ATLASSERT(m_hDC != NULL);
return ::PatBlt(m_hDC, x, y, nWidth, nHeight, dwRop);
}
BOOL BitBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC,
int xSrc, int ySrc, DWORD dwRop)
{
ATLASSERT(m_hDC != NULL);
return ::BitBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, dwRop);
}
BOOL StretchBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop)
{
ATLASSERT(m_hDC != NULL);
return ::StretchBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, dwRop);
}
COLORREF GetPixel(int x, int y) const
{
ATLASSERT(m_hDC != NULL);
return ::GetPixel(m_hDC, x, y);
}
COLORREF GetPixel(POINT point) const
{
ATLASSERT(m_hDC != NULL);
return ::GetPixel(m_hDC, point.x, point.y);
}
COLORREF SetPixel(int x, int y, COLORREF crColor)
{
ATLASSERT(m_hDC != NULL);
return ::SetPixel(m_hDC, x, y, crColor);
}
COLORREF SetPixel(POINT point, COLORREF crColor)
{
ATLASSERT(m_hDC != NULL);
return ::SetPixel(m_hDC, point.x, point.y, crColor);
}
#ifndef _WIN32_WCE
BOOL FloodFill(int x, int y, COLORREF crColor)
{
ATLASSERT(m_hDC != NULL);
return ::FloodFill(m_hDC, x, y, crColor);
}
BOOL ExtFloodFill(int x, int y, COLORREF crColor, UINT nFillType)
{
ATLASSERT(m_hDC != NULL);
return ::ExtFloodFill(m_hDC, x, y, crColor, nFillType);
}
#endif //!_WIN32_WCE
BOOL MaskBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, HBITMAP hMaskBitmap, int xMask, int yMask, DWORD dwRop)
{
ATLASSERT(m_hDC != NULL);
return ::MaskBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, hMaskBitmap, xMask, yMask, dwRop);
}
#ifndef _WIN32_WCE
BOOL PlgBlt(LPPOINT lpPoint, HDC hSrcDC, int xSrc, int ySrc, int nWidth, int nHeight, HBITMAP hMaskBitmap, int xMask, int yMask)
{
ATLASSERT(m_hDC != NULL);
return ::PlgBlt(m_hDC, lpPoint, hSrcDC, xSrc, ySrc, nWidth, nHeight, hMaskBitmap, xMask, yMask);
}
BOOL SetPixelV(int x, int y, COLORREF crColor)
{
ATLASSERT(m_hDC != NULL);
return ::SetPixelV(m_hDC, x, y, crColor);
}
BOOL SetPixelV(POINT point, COLORREF crColor)
{
ATLASSERT(m_hDC != NULL);
return ::SetPixelV(m_hDC, point.x, point.y, crColor);
}
#endif //!_WIN32_WCE
#if !defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE)
BOOL AlphaBlend(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, BLENDFUNCTION bf)
{
ATLASSERT(m_hDC != NULL);
return ::AlphaBlend(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, bf);
}
BOOL TransparentBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, UINT crTransparent)
{
ATLASSERT(m_hDC != NULL);
return ::TransparentBlt(m_hDC, x, y, nWidth, nHeight, hSrcDC, xSrc, ySrc, nSrcWidth, nSrcHeight, crTransparent);
}
BOOL GradientFill(const PTRIVERTEX pVertices, DWORD nVertices, void* pMeshElements, DWORD nMeshElements, DWORD dwMode)
{
ATLASSERT(m_hDC != NULL);
return ::GradientFill(m_hDC, pVertices, nVertices, pMeshElements, nMeshElements, dwMode);
}
#endif //!defined(_ATL_NO_MSIMG) && !defined(_WIN32_WCE)
// Extra bitmap functions
// Helper function for painting a disabled toolbar or menu bitmap
// This function can take either an HBITMAP (for SS) or a DC with
// the bitmap already painted (for cmdbar)
BOOL DitherBlt(int x, int y, int nWidth, int nHeight, HDC hSrcDC, HBITMAP hBitmap, int xSrc, int ySrc,
HBRUSH hBrushBackground = ::GetSysColorBrush(COLOR_3DFACE),
HBRUSH hBrush3DEffect = ::GetSysColorBrush(COLOR_3DHILIGHT),
HBRUSH hBrushDisabledImage = ::GetSysColorBrush(COLOR_3DSHADOW))
{
ATLASSERT(m_hDC != NULL || hBitmap != NULL);
ATLASSERT(nWidth > 0 && nHeight > 0);
// Create a generic DC for all BitBlts
CDCHandle dc = (hSrcDC != NULL) ? hSrcDC : ::CreateCompatibleDC(m_hDC);
ATLASSERT(dc.m_hDC != NULL);
if(dc.m_hDC == NULL)
return FALSE;
// Create a DC for the monochrome DIB section
CDC dcBW = ::CreateCompatibleDC(m_hDC);
ATLASSERT(dcBW.m_hDC != NULL);
if(dcBW.m_hDC == NULL)
{
if(hSrcDC == NULL)
dc.DeleteDC();
return FALSE;
}
// Create the monochrome DIB section with a black and white palette
struct RGBBWBITMAPINFO
{
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[2];
};
RGBBWBITMAPINFO rgbBWBitmapInfo =
{
{ sizeof(BITMAPINFOHEADER), nWidth, nHeight, 1, 1, BI_RGB, 0, 0, 0, 0, 0 },
{ { 0x00, 0x00, 0x00, 0x00 }, { 0xFF, 0xFF, 0xFF, 0x00 } }
};
VOID* pbitsBW;
CBitmap bmpBW = ::CreateDIBSection(dcBW, (LPBITMAPINFO)&rgbBWBitmapInfo, DIB_RGB_COLORS, &pbitsBW, NULL, 0);
ATLASSERT(bmpBW.m_hBitmap != NULL);
if(bmpBW.m_hBitmap == NULL)
{
if(hSrcDC == NULL)
dc.DeleteDC();
return FALSE;
}
// Attach the monochrome DIB section and the bitmap to the DCs
HBITMAP hbmOldBW = dcBW.SelectBitmap(bmpBW);
HBITMAP hbmOldDC = NULL;
if(hBitmap != NULL)
hbmOldDC = dc.SelectBitmap(hBitmap);
// Block: Dark gray removal: we want (128, 128, 128) pixels to become black and not white
{
CDC dcTemp1 = ::CreateCompatibleDC(m_hDC);
CDC dcTemp2 = ::CreateCompatibleDC(m_hDC);
CBitmap bmpTemp1;
bmpTemp1.CreateCompatibleBitmap(dc, nWidth, nHeight);
CBitmap bmpTemp2;
bmpTemp2.CreateBitmap(nWidth, nHeight, 1, 1, NULL);
HBITMAP hOldBmp1 = dcTemp1.SelectBitmap(bmpTemp1);
HBITMAP hOldBmp2 = dcTemp2.SelectBitmap(bmpTemp2);
// Let's copy our image, it will be altered
dcTemp1.BitBlt(0, 0, nWidth, nHeight, dc, xSrc, ySrc, SRCCOPY);
// All dark gray pixels will become white, the others black
dcTemp1.SetBkColor(RGB(128, 128, 128));
dcTemp2.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
// Do an XOR to set to black these white pixels
dcTemp1.BitBlt(0, 0, nWidth, nHeight, dcTemp2, 0, 0, SRCINVERT);
// BitBlt the bitmap into the monochrome DIB section
// The DIB section will do a true monochrome conversion
// The magenta background being closer to white will become white
dcBW.BitBlt(0, 0, nWidth, nHeight, dcTemp1, 0, 0, SRCCOPY);
// Cleanup
dcTemp1.SelectBitmap(hOldBmp1);
dcTemp2.SelectBitmap(hOldBmp2);
}
// Paint the destination rectangle using hBrushBackground
if(hBrushBackground != NULL)
{
RECT rc = { x, y, x + nWidth, y + nHeight };
FillRect(&rc, hBrushBackground);
}
// BitBlt the black bits in the monochrome bitmap into hBrush3DEffect color in the destination DC
// The magic ROP comes from the Charles Petzold's book
HBRUSH hOldBrush = SelectBrush(hBrush3DEffect);
BitBlt(x + 1, y + 1, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
// BitBlt the black bits in the monochrome bitmap into hBrushDisabledImage color in the destination DC
SelectBrush(hBrushDisabledImage);
BitBlt(x, y, nWidth, nHeight, dcBW, 0, 0, 0xB8074A);
SelectBrush(hOldBrush);
dcBW.SelectBitmap(hbmOldBW);
dc.SelectBitmap(hbmOldDC);
if(hSrcDC == NULL)
dc.DeleteDC();
return TRUE;
}
// Text Functions
#ifndef _WIN32_WCE
BOOL TextOut(int x, int y, LPCTSTR lpszString, int nCount = -1)
{
ATLASSERT(m_hDC != NULL);
if(nCount == -1)
nCount = lstrlen(lpszString);
return ::TextOut(m_hDC, x, y, lpszString, nCount);
}
#endif //!_WIN32_WCE
BOOL ExtTextOut(int x, int y, UINT nOptions, LPCRECT lpRect, LPCTSTR lpszString, UINT nCount = -1, LPINT lpDxWidths = NULL)
{
ATLASSERT(m_hDC != NULL);
if(nCount == -1)
nCount = lstrlen(lpszString);
return ::ExtTextOut(m_hDC, x, y, nOptions, lpRect, lpszString, nCount, lpDxWidths);
}
#ifndef _WIN32_WCE
SIZE TabbedTextOut(int x, int y, LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL, int nTabOrigin = 0)
{
ATLASSERT(m_hDC != NULL);
if(nCount == -1)
nCount = lstrlen(lpszString);
LONG lRes = ::TabbedTextOut(m_hDC, x, y, lpszString, nCount, nTabPositions, lpnTabStopPositions, nTabOrigin);
SIZE size = { GET_X_LPARAM(lRes), GET_Y_LPARAM(lRes) };
return size;
}
#endif //!_WIN32_WCE
int DrawText(LPCTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat)
{
ATLASSERT(m_hDC != NULL);
return ::DrawText(m_hDC, lpstrText, cchText, lpRect, uFormat);
}
#ifndef _WIN32_WCE
int DrawTextEx(LPTSTR lpstrText, int cchText, LPRECT lpRect, UINT uFormat, LPDRAWTEXTPARAMS lpDTParams = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawTextEx(m_hDC, lpstrText, cchText, lpRect, uFormat, lpDTParams);
}
#endif //!_WIN32_WCE
#if (_WIN32_WINNT >= 0x0501)
int DrawShadowText(LPCWSTR lpstrText, int cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset)
{
ATLASSERT(m_hDC != NULL);
// This function is present only if comctl32.dll version 6 is loaded;
// we use LoadLibrary/GetProcAddress to allow apps compiled with
// _WIN32_WINNT >= 0x0501 to run on older Windows/CommCtrl
int nRet = 0;
HMODULE hCommCtrlDLL = ::LoadLibrary(_T("comctl32.dll"));
ATLASSERT(hCommCtrlDLL != NULL);
if(hCommCtrlDLL != NULL)
{
typedef int (WINAPI *PFN_DrawShadowText)(HDC hDC, LPCWSTR lpstrText, UINT cchText, LPRECT lpRect, DWORD dwFlags, COLORREF clrText, COLORREF clrShadow, int xOffset, int yOffset);
PFN_DrawShadowText pfnDrawShadowText = (PFN_DrawShadowText)::GetProcAddress(hCommCtrlDLL, "DrawShadowText");
ATLASSERT(pfnDrawShadowText != NULL); // this function requires CommCtrl6
if(pfnDrawShadowText != NULL)
nRet = pfnDrawShadowText(m_hDC, lpstrText, cchText, lpRect, dwFlags, clrText, clrShadow, xOffset, yOffset);
::FreeLibrary(hCommCtrlDLL);
}
return nRet;
}
#endif //(_WIN32_WINNT >= 0x0501)
BOOL GetTextExtent(LPCTSTR lpszString, int nCount, LPSIZE lpSize) const
{
ATLASSERT(m_hDC != NULL);
if(nCount == -1)
nCount = lstrlen(lpszString);
return ::GetTextExtentPoint32(m_hDC, lpszString, nCount, lpSize);
}
#ifndef _WIN32_WCE
BOOL GetTextExtentExPoint(LPCTSTR lpszString, int cchString, LPSIZE lpSize, int nMaxExtent, LPINT lpnFit = NULL, LPINT alpDx = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::GetTextExtentExPoint(m_hDC, lpszString, cchString, nMaxExtent, lpnFit, alpDx, lpSize);
}
DWORD GetTabbedTextExtent(LPCTSTR lpszString, int nCount = -1, int nTabPositions = 0, LPINT lpnTabStopPositions = NULL) const
{
ATLASSERT(m_hDC != NULL);
if(nCount == -1)
nCount = lstrlen(lpszString);
return ::GetTabbedTextExtent(m_hDC, lpszString, nCount, nTabPositions, lpnTabStopPositions);
}
BOOL GrayString(HBRUSH hBrush, BOOL (CALLBACK* lpfnOutput)(HDC, LPARAM, int), LPARAM lpData, int nCount, int x, int y, int nWidth, int nHeight)
{
ATLASSERT(m_hDC != NULL);
return ::GrayString(m_hDC, hBrush, (GRAYSTRINGPROC)lpfnOutput, lpData, nCount, x, y, nWidth, nHeight);
}
#endif //!_WIN32_WCE
#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
UINT GetTextAlign() const
{
ATLASSERT(m_hDC != NULL);
return ::GetTextAlign(m_hDC);
}
UINT SetTextAlign(UINT nFlags)
{
ATLASSERT(m_hDC != NULL);
return ::SetTextAlign(m_hDC, nFlags);
}
#endif //!defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
int GetTextFace(LPTSTR lpszFacename, int nCount) const
{
ATLASSERT(m_hDC != NULL);
return ::GetTextFace(m_hDC, nCount, lpszFacename);
}
int GetTextFaceLen() const
{
ATLASSERT(m_hDC != NULL);
return ::GetTextFace(m_hDC, 0, NULL);
}
#ifndef _ATL_NO_COM
#ifdef _OLEAUTO_H_
BOOL GetTextFace(BSTR& bstrFace) const
{
USES_CONVERSION;
ATLASSERT(m_hDC != NULL);
ATLASSERT(bstrFace == NULL);
int nLen = GetTextFaceLen();
if(nLen == 0)
return FALSE;
LPTSTR lpszText = (LPTSTR)_alloca(nLen * sizeof(TCHAR));
if(!GetTextFace(lpszText, nLen))
return FALSE;
bstrFace = ::SysAllocString(T2OLE(lpszText));
return (bstrFace != NULL) ? TRUE : FALSE;
}
#endif
#endif //!_ATL_NO_COM
#if defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
int GetTextFace(_CSTRING_NS::CString& strFace) const
{
ATLASSERT(m_hDC != NULL);
int nLen = GetTextFaceLen();
if(nLen == 0)
return 0;
LPTSTR lpstr = strFace.GetBufferSetLength(nLen);
if(lpstr == NULL)
return 0;
int nRet = GetTextFace(lpstr, nLen);
strFace.ReleaseBuffer();
return nRet;
}
#endif //defined(_WTL_USE_CSTRING) || defined(__ATLSTR_H__)
BOOL GetTextMetrics(LPTEXTMETRIC lpMetrics) const
{
ATLASSERT(m_hDC != NULL);
return ::GetTextMetrics(m_hDC, lpMetrics);
}
#ifndef _WIN32_WCE
int SetTextJustification(int nBreakExtra, int nBreakCount)
{
ATLASSERT(m_hDC != NULL);
return ::SetTextJustification(m_hDC, nBreakExtra, nBreakCount);
}
int GetTextCharacterExtra() const
{
ATLASSERT(m_hDC != NULL);
return ::GetTextCharacterExtra(m_hDC);
}
int SetTextCharacterExtra(int nCharExtra)
{
ATLASSERT(m_hDC != NULL);
return ::SetTextCharacterExtra(m_hDC, nCharExtra);
}
#endif //!_WIN32_WCE
// Advanced Drawing
BOOL DrawEdge(LPRECT lpRect, UINT nEdge, UINT nFlags)
{
ATLASSERT(m_hDC != NULL);
return ::DrawEdge(m_hDC, lpRect, nEdge, nFlags);
}
BOOL DrawFrameControl(LPRECT lpRect, UINT nType, UINT nState)
{
ATLASSERT(m_hDC != NULL);
return ::DrawFrameControl(m_hDC, lpRect, nType, nState);
}
// Scrolling Functions
BOOL ScrollDC(int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate)
{
ATLASSERT(m_hDC != NULL);
return ::ScrollDC(m_hDC, dx, dy, lpRectScroll, lpRectClip, hRgnUpdate, lpRectUpdate);
}
// Font Functions
#ifndef _WIN32_WCE
BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCharWidth(m_hDC, nFirstChar, nLastChar, lpBuffer);
}
// GetCharWidth32 is not supported under Win9x
BOOL GetCharWidth32(UINT nFirstChar, UINT nLastChar, LPINT lpBuffer) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCharWidth32(m_hDC, nFirstChar, nLastChar, lpBuffer);
}
DWORD SetMapperFlags(DWORD dwFlag)
{
ATLASSERT(m_hDC != NULL);
return ::SetMapperFlags(m_hDC, dwFlag);
}
BOOL GetAspectRatioFilter(LPSIZE lpSize) const
{
ATLASSERT(m_hDC != NULL);
return ::GetAspectRatioFilterEx(m_hDC, lpSize);
}
BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABC lpabc) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCharABCWidths(m_hDC, nFirstChar, nLastChar, lpabc);
}
DWORD GetFontData(DWORD dwTable, DWORD dwOffset, LPVOID lpData, DWORD cbData) const
{
ATLASSERT(m_hDC != NULL);
return ::GetFontData(m_hDC, dwTable, dwOffset, lpData, cbData);
}
int GetKerningPairs(int nPairs, LPKERNINGPAIR lpkrnpair) const
{
ATLASSERT(m_hDC != NULL);
return ::GetKerningPairs(m_hDC, nPairs, lpkrnpair);
}
UINT GetOutlineTextMetrics(UINT cbData, LPOUTLINETEXTMETRIC lpotm) const
{
ATLASSERT(m_hDC != NULL);
return ::GetOutlineTextMetrics(m_hDC, cbData, lpotm);
}
DWORD GetGlyphOutline(UINT nChar, UINT nFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2* lpmat2) const
{
ATLASSERT(m_hDC != NULL);
return ::GetGlyphOutline(m_hDC, nChar, nFormat, lpgm, cbBuffer, lpBuffer, lpmat2);
}
BOOL GetCharABCWidths(UINT nFirstChar, UINT nLastChar, LPABCFLOAT lpABCF) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCharABCWidthsFloat(m_hDC, nFirstChar, nLastChar, lpABCF);
}
BOOL GetCharWidth(UINT nFirstChar, UINT nLastChar, float* lpFloatBuffer) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCharWidthFloat(m_hDC, nFirstChar, nLastChar, lpFloatBuffer);
}
#endif //!_WIN32_WCE
// Printer/Device Escape Functions
#ifndef
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -