📄 atlgdi.h
字号:
return ::DPtoLP(m_hDC, (LPPOINT)lpRect, 2);
}
BOOL DPtoLP(LPSIZE lpSize) const
{
SIZE sizeWinExt = { 0, 0 };
if(!GetWindowExt(&sizeWinExt))
return FALSE;
SIZE sizeVpExt = { 0, 0 };
if(!GetViewportExt(&sizeVpExt))
return FALSE;
lpSize->cx = MulDiv(lpSize->cx, abs(sizeWinExt.cx), abs(sizeVpExt.cx));
lpSize->cy = MulDiv(lpSize->cy, abs(sizeWinExt.cy), abs(sizeVpExt.cy));
return TRUE;
}
BOOL LPtoDP(LPPOINT lpPoints, int nCount = 1) const
{
ATLASSERT(m_hDC != NULL);
return ::LPtoDP(m_hDC, lpPoints, nCount);
}
BOOL LPtoDP(LPRECT lpRect) const
{
ATLASSERT(m_hDC != NULL);
return ::LPtoDP(m_hDC, (LPPOINT)lpRect, 2);
}
BOOL LPtoDP(LPSIZE lpSize) const
{
SIZE sizeWinExt = { 0, 0 };
if(!GetWindowExt(&sizeWinExt))
return FALSE;
SIZE sizeVpExt = { 0, 0 };
if(!GetViewportExt(&sizeVpExt))
return FALSE;
lpSize->cx = ::MulDiv(lpSize->cx, abs(sizeVpExt.cx), abs(sizeWinExt.cx));
lpSize->cy = ::MulDiv(lpSize->cy, abs(sizeVpExt.cy), abs(sizeWinExt.cy));
return TRUE;
}
// Special Coordinate Functions (useful for dealing with metafiles and OLE)
#define HIMETRIC_INCH 2540 // HIMETRIC units per inch
void DPtoHIMETRIC(LPSIZE lpSize) const
{
ATLASSERT(m_hDC != NULL);
int nMapMode;
if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
{
// when using a constrained map mode, map against physical inch
((CDCHandle*)this)->SetMapMode(MM_HIMETRIC);
DPtoLP(lpSize);
((CDCHandle*)this)->SetMapMode(nMapMode);
}
else
{
// map against logical inch for non-constrained mapping modes
int cxPerInch = GetDeviceCaps(LOGPIXELSX);
int cyPerInch = GetDeviceCaps(LOGPIXELSY);
ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
lpSize->cx = MulDiv(lpSize->cx, HIMETRIC_INCH, cxPerInch);
lpSize->cy = MulDiv(lpSize->cy, HIMETRIC_INCH, cyPerInch);
}
}
void HIMETRICtoDP(LPSIZE lpSize) const
{
ATLASSERT(m_hDC != NULL);
int nMapMode;
if((nMapMode = GetMapMode()) < MM_ISOTROPIC && nMapMode != MM_TEXT)
{
// when using a constrained map mode, map against physical inch
((CDCHandle*)this)->SetMapMode(MM_HIMETRIC);
LPtoDP(lpSize);
((CDCHandle*)this)->SetMapMode(nMapMode);
}
else
{
// map against logical inch for non-constrained mapping modes
int cxPerInch = GetDeviceCaps(LOGPIXELSX);
int cyPerInch = GetDeviceCaps(LOGPIXELSY);
ATLASSERT(cxPerInch != 0 && cyPerInch != 0);
lpSize->cx = MulDiv(lpSize->cx, cxPerInch, HIMETRIC_INCH);
lpSize->cy = MulDiv(lpSize->cy, cyPerInch, HIMETRIC_INCH);
}
}
void LPtoHIMETRIC(LPSIZE lpSize) const
{
LPtoDP(lpSize);
DPtoHIMETRIC(lpSize);
}
void HIMETRICtoLP(LPSIZE lpSize) const
{
HIMETRICtoDP(lpSize);
DPtoLP(lpSize);
}
#endif //!_WIN32_WCE
// Region Functions
BOOL FillRgn(HRGN hRgn, HBRUSH hBrush)
{
ATLASSERT(m_hDC != NULL);
return ::FillRgn(m_hDC, hRgn, hBrush);
}
#ifndef _WIN32_WCE
BOOL FrameRgn(HRGN hRgn, HBRUSH hBrush, int nWidth, int nHeight)
{
ATLASSERT(m_hDC != NULL);
return ::FrameRgn(m_hDC, hRgn, hBrush, nWidth, nHeight);
}
BOOL InvertRgn(HRGN hRgn)
{
ATLASSERT(m_hDC != NULL);
return ::InvertRgn(m_hDC, hRgn);
}
BOOL PaintRgn(HRGN hRgn)
{
ATLASSERT(m_hDC != NULL);
return ::PaintRgn(m_hDC, hRgn);
}
#endif //!_WIN32_WCE
// Clipping Functions
int GetClipBox(LPRECT lpRect) const
{
ATLASSERT(m_hDC != NULL);
return ::GetClipBox(m_hDC, lpRect);
}
#ifndef _WIN32_WCE
BOOL PtVisible(int x, int y) const
{
ATLASSERT(m_hDC != NULL);
return ::PtVisible(m_hDC, x, y);
}
BOOL PtVisible(POINT point) const
{
ATLASSERT(m_hDC != NULL);
return ::PtVisible(m_hDC, point.x, point.y);
}
#endif //!_WIN32_WCE
BOOL RectVisible(LPCRECT lpRect) const
{
ATLASSERT(m_hDC != NULL);
return ::RectVisible(m_hDC, lpRect);
}
int SelectClipRgn(HRGN hRgn)
{
ATLASSERT(m_hDC != NULL);
return ::SelectClipRgn(m_hDC, (HRGN)hRgn);
}
int ExcludeClipRect(int x1, int y1, int x2, int y2)
{
ATLASSERT(m_hDC != NULL);
return ::ExcludeClipRect(m_hDC, x1, y1, x2, y2);
}
int ExcludeClipRect(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
return ::ExcludeClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
#ifndef _WIN32_WCE
int ExcludeUpdateRgn(HWND hWnd)
{
ATLASSERT(m_hDC != NULL);
return ::ExcludeUpdateRgn(m_hDC, hWnd);
}
#endif //!_WIN32_WCE
int IntersectClipRect(int x1, int y1, int x2, int y2)
{
ATLASSERT(m_hDC != NULL);
return ::IntersectClipRect(m_hDC, x1, y1, x2, y2);
}
int IntersectClipRect(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
return ::IntersectClipRect(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
#ifndef _WIN32_WCE
int OffsetClipRgn(int x, int y)
{
ATLASSERT(m_hDC != NULL);
return ::OffsetClipRgn(m_hDC, x, y);
}
int OffsetClipRgn(SIZE size)
{
ATLASSERT(m_hDC != NULL);
return ::OffsetClipRgn(m_hDC, size.cx, size.cy);
}
int SelectClipRgn(HRGN hRgn, int nMode)
{
ATLASSERT(m_hDC != NULL);
return ::ExtSelectClipRgn(m_hDC, hRgn, nMode);
}
#endif //!_WIN32_WCE
// Line-Output Functions
#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
BOOL GetCurrentPosition(LPPOINT lpPoint) const
{
ATLASSERT(m_hDC != NULL);
return ::GetCurrentPositionEx(m_hDC, lpPoint);
}
BOOL MoveTo(int x, int y, LPPOINT lpPoint = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::MoveToEx(m_hDC, x, y, lpPoint);
}
BOOL MoveTo(POINT point, LPPOINT lpPointRet = NULL)
{
ATLASSERT(m_hDC != NULL);
return MoveTo(point.x, point.y, lpPointRet);
}
BOOL LineTo(int x, int y)
{
ATLASSERT(m_hDC != NULL);
return ::LineTo(m_hDC, x, y);
}
BOOL LineTo(POINT point)
{
ATLASSERT(m_hDC != NULL);
return LineTo(point.x, point.y);
}
#endif //!defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
#ifndef _WIN32_WCE
BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
ATLASSERT(m_hDC != NULL);
return ::Arc(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Arc(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
ATLASSERT(m_hDC != NULL);
return ::Arc(m_hDC, lpRect->left, lpRect->top,
lpRect->right, lpRect->bottom, ptStart.x, ptStart.y,
ptEnd.x, ptEnd.y);
}
#endif //!_WIN32_WCE
BOOL Polyline(LPPOINT lpPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::Polyline(m_hDC, lpPoints, nCount);
}
#ifndef _WIN32_WCE
BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle)
{
ATLASSERT(m_hDC != NULL);
return ::AngleArc(m_hDC, x, y, nRadius, fStartAngle, fSweepAngle);
}
BOOL ArcTo(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
ATLASSERT(m_hDC != NULL);
return ::ArcTo(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL ArcTo(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
ATLASSERT(m_hDC != NULL);
return ArcTo(lpRect->left, lpRect->top, lpRect->right,
lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
int GetArcDirection() const
{
ATLASSERT(m_hDC != NULL);
return ::GetArcDirection(m_hDC);
}
int SetArcDirection(int nArcDirection)
{
ATLASSERT(m_hDC != NULL);
return ::SetArcDirection(m_hDC, nArcDirection);
}
BOOL PolyDraw(const POINT* lpPoints, const BYTE* lpTypes, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolyDraw(m_hDC, lpPoints, lpTypes, nCount);
}
BOOL PolylineTo(const POINT* lpPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolylineTo(m_hDC, lpPoints, nCount);
}
BOOL PolyPolyline(const POINT* lpPoints,
const DWORD* lpPolyPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolyPolyline(m_hDC, lpPoints, lpPolyPoints, nCount);
}
BOOL PolyBezier(const POINT* lpPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolyBezier(m_hDC, lpPoints, nCount);
}
BOOL PolyBezierTo(const POINT* lpPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolyBezierTo(m_hDC, lpPoints, nCount);
}
#endif //!_WIN32_WCE
// Simple Drawing Functions
BOOL FillRect(LPCRECT lpRect, HBRUSH hBrush)
{
ATLASSERT(m_hDC != NULL);
return ::FillRect(m_hDC, lpRect, hBrush);
}
BOOL FillRect(LPCRECT lpRect, int nColorIndex)
{
ATLASSERT(m_hDC != NULL);
#ifndef _WIN32_WCE
return ::FillRect(m_hDC, lpRect, (HBRUSH)LongToPtr(nColorIndex + 1));
#else // CE specific
return ::FillRect(m_hDC, lpRect, ::GetSysColorBrush(nColorIndex));
#endif //_WIN32_WCE
}
#ifndef _WIN32_WCE
BOOL FrameRect(LPCRECT lpRect, HBRUSH hBrush)
{
ATLASSERT(m_hDC != NULL);
return ::FrameRect(m_hDC, lpRect, hBrush);
}
#endif //!_WIN32_WCE
#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 420)
BOOL InvertRect(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
return ::InvertRect(m_hDC, lpRect);
}
#endif //!defined(_WIN32_WCE) || (_WIN32_WCE >= 420)
BOOL DrawIcon(int x, int y, HICON hIcon)
{
ATLASSERT(m_hDC != NULL);
#ifndef _WIN32_WCE
return ::DrawIcon(m_hDC, x, y, hIcon);
#else // CE specific
return ::DrawIconEx(m_hDC, x, y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
#endif //_WIN32_WCE
}
BOOL DrawIcon(POINT point, HICON hIcon)
{
ATLASSERT(m_hDC != NULL);
#ifndef _WIN32_WCE
return ::DrawIcon(m_hDC, point.x, point.y, hIcon);
#else // CE specific
return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, 0, 0, 0, NULL, DI_NORMAL);
#endif //_WIN32_WCE
}
BOOL DrawIconEx(int x, int y, HICON hIcon, int cxWidth, int cyWidth, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawIconEx(m_hDC, x, y, hIcon, cxWidth, cyWidth, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
}
BOOL DrawIconEx(POINT point, HICON hIcon, SIZE size, UINT uStepIfAniCur = 0, HBRUSH hbrFlickerFreeDraw = NULL, UINT uFlags = DI_NORMAL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawIconEx(m_hDC, point.x, point.y, hIcon, size.cx, size.cy, uStepIfAniCur, hbrFlickerFreeDraw, uFlags);
}
#ifndef _WIN32_WCE
BOOL DrawState(POINT pt, SIZE size, HBITMAP hBitmap, UINT nFlags, HBRUSH hBrush = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hBitmap, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_BITMAP);
}
BOOL DrawState(POINT pt, SIZE size, HICON hIcon, UINT nFlags, HBRUSH hBrush = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)hIcon, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_ICON);
}
BOOL DrawState(POINT pt, SIZE size, LPCTSTR lpszText, UINT nFlags, BOOL bPrefixText = TRUE, int nTextLen = 0, HBRUSH hBrush = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, NULL, (LPARAM)lpszText, (WPARAM)nTextLen, pt.x, pt.y, size.cx, size.cy, nFlags | (bPrefixText ? DST_PREFIXTEXT : DST_TEXT));
}
BOOL DrawState(POINT pt, SIZE size, DRAWSTATEPROC lpDrawProc, LPARAM lData, UINT nFlags, HBRUSH hBrush = NULL)
{
ATLASSERT(m_hDC != NULL);
return ::DrawState(m_hDC, hBrush, lpDrawProc, lData, 0, pt.x, pt.y, size.cx, size.cy, nFlags | DST_COMPLEX);
}
#endif //!_WIN32_WCE
// Ellipse and Polygon Functions
#ifndef _WIN32_WCE
BOOL Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
ATLASSERT(m_hDC != NULL);
return ::Chord(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Chord(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
ATLASSERT(m_hDC != NULL);
return ::Chord(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
#endif //!_WIN32_WCE
void DrawFocusRect(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
::DrawFocusRect(m_hDC, lpRect);
}
BOOL Ellipse(int x1, int y1, int x2, int y2)
{
ATLASSERT(m_hDC != NULL);
return ::Ellipse(m_hDC, x1, y1, x2, y2);
}
BOOL Ellipse(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
return ::Ellipse(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
#ifndef _WIN32_WCE
BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
ATLASSERT(m_hDC != NULL);
return ::Pie(m_hDC, x1, y1, x2, y2, x3, y3, x4, y4);
}
BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd)
{
ATLASSERT(m_hDC != NULL);
return ::Pie(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y);
}
#endif //!_WIN32_WCE
BOOL Polygon(LPPOINT lpPoints, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::Polygon(m_hDC, lpPoints, nCount);
}
#ifndef _WIN32_WCE
BOOL PolyPolygon(LPPOINT lpPoints, LPINT lpPolyCounts, int nCount)
{
ATLASSERT(m_hDC != NULL);
return ::PolyPolygon(m_hDC, lpPoints, lpPolyCounts, nCount);
}
#endif //!_WIN32_WCE
BOOL Rectangle(int x1, int y1, int x2, int y2)
{
ATLASSERT(m_hDC != NULL);
return ::Rectangle(m_hDC, x1, y1, x2, y2);
}
BOOL Rectangle(LPCRECT lpRect)
{
ATLASSERT(m_hDC != NULL);
return ::Rectangle(m_hDC, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
}
BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)
{
ATLASSERT(m_hDC != NULL);
return ::RoundRect(m_hDC, x1, y1, x2, y2, x3, y3);
}
BOOL RoundRect(LPCRECT lpRect, POINT point)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -