기본적으로 테두리는 WS_THICKFRAME style이 적용 되어 있어야 한다.
void CWnd::OnNcPaint()
{
CRect rcWindow;
GetWindowRect( &rcWindow );
rcWindow.OffsetRect( -rcWindow.left, -rcWindow.top );
int nX = 0;
int nY = 0;
LONG lStyle = ::GetWindowLong( this->GetSafeHwnd(), GWL_STYLE );
// WS_BORDER 속성이 적용되어 있느냐 없느냐에 따라 두께 계산
if ( lStyle & WS_BORDER )
{
nX = GetSystemMetrics(SM_CXSIZEFRAME);
nY = GetSystemMetrics(SM_CYSIZEFRAME);
}
else
{
nX = GetSystemMetrics(SM_CXSIZEFRAME) - GetSystemMetrics(SM_CXBORDER);
nY = GetSystemMetrics(SM_CYSIZEFRAME) - GetSystemMetrics(SM_CYBORDER);
}
CDC* pDC = GetWindowDC( );
// 테두리 영역만을 위해 가운데 영역 제외
pDC->ExcludeClipRect( nX, nY, rcWindow.right - nX, rcWindow.bottom - nY );
{
// 테두리에 그릴 내용
pDC->FillSolidRect( &rcWindow, RGB(255, 0, 0) );
}
ReleaseDC( pDC );
}
{
CRect rcWindow;
GetWindowRect( &rcWindow );
rcWindow.OffsetRect( -rcWindow.left, -rcWindow.top );
int nX = 0;
int nY = 0;
LONG lStyle = ::GetWindowLong( this->GetSafeHwnd(), GWL_STYLE );
// WS_BORDER 속성이 적용되어 있느냐 없느냐에 따라 두께 계산
if ( lStyle & WS_BORDER )
{
nX = GetSystemMetrics(SM_CXSIZEFRAME);
nY = GetSystemMetrics(SM_CYSIZEFRAME);
}
else
{
nX = GetSystemMetrics(SM_CXSIZEFRAME) - GetSystemMetrics(SM_CXBORDER);
nY = GetSystemMetrics(SM_CYSIZEFRAME) - GetSystemMetrics(SM_CYBORDER);
}
CDC* pDC = GetWindowDC( );
// 테두리 영역만을 위해 가운데 영역 제외
pDC->ExcludeClipRect( nX, nY, rcWindow.right - nX, rcWindow.bottom - nY );
{
// 테두리에 그릴 내용
pDC->FillSolidRect( &rcWindow, RGB(255, 0, 0) );
}
ReleaseDC( pDC );
}
'Development' 카테고리의 다른 글
[VC++] 링크 에러 LIBCMTD.lib(sprintf.obj) : error LNK2005: * 전체공개 (2) | 2010.07.28 |
---|---|
[Flash] Using “setTimeout()” in a custom class. (0) | 2010.07.17 |
[VC++] SystemParametesInfo(각종시스템정보조사) (0) | 2010.07.06 |
[VC++] SystemParametersInfo로 SPI_GETNONCLIENTMETRICS 오류시 방법(VS2008 이상) (1) | 2010.07.06 |
[VC++] SystemParametersInfo() 트레이 주위에 윈도우 생성 하기 (0) | 2010.07.06 |