VC++ CDialog 자체 그리기(개선 버전)
5937 단어 VC++ (기본 편)VC++VC++ (컨트롤 편)
void CSWDialog::DrawSysMenu(Gdiplus::Graphics& g)
{
CRect rcClient; GetClientRect(rcClient);
g.SetSmoothingMode(Gdiplus::/*SmoothingModeAntiAlias*/SmoothingModeHighQuality);
if (m_bSysMnu[SYSMNU_CLOSE])
{
if (m_pSysCloseBitmap)
{
CRect rcClip = CRect(0, 0, m_pSysCloseBitmap->GetWidth() / 3, m_pSysCloseBitmap->GetHeight());
if (m_nSysMnuHover == SYSMNU_CLOSE)
rcClip.OffsetRect(m_pSysCloseBitmap->GetWidth() / 3, 0);
CRect rcShow(m_rcClose);
g.DrawImage(m_pSysCloseBitmap, RectF(rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height()), rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), UnitPixel, NULL, NULL, NULL);
}
else
{
CRect rcShow(m_rcClose);
//////////////////////////////////////////////////////////////////////////
if (m_nSysMnuHover == SYSMNU_CLOSE) {
BYTE byAlpha = 128;
Color colors[] =
{
Color(byAlpha, 255, 255, 255),
Color(byAlpha, 0, 255, 0),
};
float positions[] = { 0.0f, 1.0f };
LinearGradientBrush linGrBrush(RectF(0, 0, 80, 80), Color::White, Color::Green, LinearGradientModeVertical);
//linGrBrush.SetInterpolationColors(colors, positions, 2);
g.FillRectangle(&linGrBrush, rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height());
}
{
rcShow.DeflateRect(6, 6);
g.TranslateTransform(rcShow.left, rcShow.top);
Gdiplus::Pen pen(Color(240, 0, 0, 0), 3);
pen.SetStartCap(Gdiplus::LineCapRound);
pen.SetEndCap(Gdiplus::LineCapRound);
pen.SetLineJoin(Gdiplus::LineJoinRound);
Point points[] = { Point(0, 0), Point(rcShow.Width(), rcShow.Height()), Point(0, rcShow.Height()), Point(rcShow.Width(), 0) };
g.DrawLine(&pen, points[0], points[1]);
g.DrawLine(&pen, points[2], points[3]);
g.ResetTransform();
}
//////////////////////////////////////////////////////////////////////////
}
}
if (m_bSysMnu[SYSMNU_MAX])
{
if (m_pSysMaxBitmap)
{
CRect rcClip = CRect(0, 0, m_pSysMaxBitmap->GetWidth() / 3, m_pSysMaxBitmap->GetHeight() / 2);
if (IsZoomed())
rcClip.OffsetRect(0, m_pSysMaxBitmap->GetHeight() / 2);
if (m_nSysMnuHover == SYSMNU_MAX)
rcClip.OffsetRect(m_pSysMaxBitmap->GetWidth() / 3, 0);
CRect rcShow(m_rcMax);
g.DrawImage(m_pSysMaxBitmap, RectF(rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height()), rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), UnitPixel, NULL, NULL, NULL);
}
else
{
CRect rcShow(m_rcMax);
//////////////////////////////////////////////////////////////////////////
if (m_nSysMnuHover == SYSMNU_MAX) {
BYTE byAlpha = 128;
Color colors[] =
{
Color(byAlpha, 255, 255, 255),
Color(byAlpha, 0, 255, 0),
};
float positions[] = { 0.0f, 1.0f };
LinearGradientBrush linGrBrush(RectF(0, 0, 80, 80), Color::White, Color::Green, LinearGradientModeVertical);
//linGrBrush.SetInterpolationColors(colors, positions, 2);
g.FillRectangle(&linGrBrush, rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height());
}
{
rcShow.DeflateRect(6, 6);
Gdiplus::Pen pen(Color(255, 0, 0, 0), 2);
if (IsZoomed())
{
rcShow.top += 8;
rcShow.right -= 8;
g.TranslateTransform(rcShow.left, rcShow.top);
g.DrawRectangle(&pen, 0, 0, rcShow.Width(), rcShow.Height());
Point points[] = { Point(0, 2), Point(rcShow.Width(), 2) };
g.DrawLine(&pen, points[0], points[1]);
rcShow.OffsetRect(8, -8);
{
g.ResetTransform();
g.TranslateTransform(rcShow.left, rcShow.top);
g.DrawRectangle(&pen, 0, 0, rcShow.Width(), 2);
//g.DrawLine(&pen, Point(0, 0), Point(rcShow.Width(), 0));
//g.DrawLine(&pen, Point(0, 1), Point(rcShow.Width(), 1));
g.DrawLine(&pen, Point(0, 0), Point(0, rcShow.Height() - 5));
g.DrawLine(&pen, Point(rcShow.Width(), 0), Point(rcShow.Width(), rcShow.Height()));
g.DrawLine(&pen, Point(5, rcShow.Height()), Point(rcShow.Width(), rcShow.Height()));
}
}
else
{
g.TranslateTransform(rcShow.left, rcShow.top);
g.DrawRectangle(&pen, 0, 0, rcShow.Width(), rcShow.Height());
Point points[] = { Point(0, 2), Point(rcShow.Width(), 2) };
g.DrawLine(&pen, points[0], points[1]);
}
g.ResetTransform();
}
//////////////////////////////////////////////////////////////////////////
}
}
if (m_bSysMnu[SYSMNU_MIN])
{
if (m_pSysMinBitmap)
{
CRect rcClip = CRect(0, 0, m_pSysMinBitmap->GetWidth() / 3, m_pSysMinBitmap->GetHeight());
if (m_nSysMnuHover == SYSMNU_MIN)
rcClip.OffsetRect(m_pSysMinBitmap->GetWidth() / 3, 0);
CRect rcShow(m_rcMin);
g.DrawImage(m_pSysMinBitmap, RectF(rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height()), rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), UnitPixel, NULL, NULL, NULL);
}
else
{
CRect rcShow(m_rcMin);
//////////////////////////////////////////////////////////////////////////
if (m_nSysMnuHover == SYSMNU_MIN) {
BYTE byAlpha = 128;
Color colors[] =
{
Color(byAlpha, 255, 255, 255),
Color(byAlpha, 0, 255, 0),
};
float positions[] = { 0.0f, 1.0f };
LinearGradientBrush linGrBrush(RectF(0, 0, 80, 80), Color::White, Color::Green, LinearGradientModeVertical);
//linGrBrush.SetInterpolationColors(colors, positions, 2);
g.FillRectangle(&linGrBrush, rcShow.left, rcShow.top, rcShow.Width(), rcShow.Height());
}
{
rcShow.DeflateRect(6, 6);
rcShow.OffsetRect(0, 16);
g.TranslateTransform(rcShow.left, rcShow.top);
Gdiplus::SolidBrush brush(Color(255, 0, 0, 0));
g.FillRectangle(&brush, 0, 0, rcShow.Width(), 3);
g.ResetTransform();
}
//////////////////////////////////////////////////////////////////////////
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Cannot find compiler 'cl.exe' in PATH을 인스톨하고, C++ 환경도 있을 수 있었는데도 cl의 패스가 통과하고 있지 않다고 하는 에러가 나왔다. 전제 C/C++ 컴파일러 (cl.exe)는 VisualStudio Installer에서 C++ 데스크톱 개발...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.