Repainting problem On Minimize and Close button
-
Hi, I have property sheet wizard application and I am repaining its title bar and creating new minimize and close button on title bar. The following codes are doing things ok. but when i try to right click on task bar button( applications task bar button - close/minimize application from system menu) minimize and close button is not repinted as expected. The codes are void CSamplePaintSheet::OnNcPaint() { CWindowDC dc( this ); ModifyStyle(NULL,WS_SYSMENU|WS_MINIMIZEBOX); Default(); ReDrawCaptionBar( &dc ); ReleaseDC( &dc ); } BOOL CSamplePaintSheet::OnNcActivate( BOOL bActivate ) { OnNcPaint(); return TRUE; } void CSamplePaintSheet::ReDrawCaptionBar(CDC *pDC ) { CRect rc; this->GetWindowRect( rc ); ScreenToClient( rc ); rcCap = rc; rcCap.bottom = ::GetSystemMetrics( SM_CYCAPTION ) + ::GetSystemMetrics( SM_CYFIXEDFRAME ); rcCap.right += ::GetSystemMetrics( SM_CXFIXEDFRAME ); CString szTitle(_T("Sample Paint Application")); SetWindowTextW( szTitle ); CBrush brSolid( CLR_GRAY ); pDC->FillRect( &rcCap, &brSolid ); CRect rcLeft( rc ); rcLeft.top = rcCap.bottom; rcLeft.right = ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcLeft.bottom = rc.Height(); pDC->FillRect( &rcLeft, &brSolid ); CRect rcRight( rc ); rcRight.left = rcCap.right - ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcRight.top = rcLeft.top; rcRight.right = rcCap.right; rcRight.bottom = rcLeft.bottom; pDC->FillRect( &rcRight, &brSolid ); CRect rcBottom( rc ); rcBottom.left = rcLeft.left; rcBottom.top = rcRight.bottom - ::GetSystemMetrics(SM_CYFIXEDFRAME) - nBottomBorderHeight; rcBottom.right = rc.Width(); rcBottom.bottom = rcRight.bottom; pDC->FillRect( &rcBottom, &brSolid ); CSize sizeText = pDC->GetTextExtent( szTitle ); int nCy = HIWORD( ::GetDialogBaseUnits() ); rcText = rcCap; rcText.left = ::GetSystemMetrics( SM_CYFIXEDFRAME ); rcText.right = rcText.left + ( sizeText.cx ); rcText.top = (rcCap.bottom - (nCy + 1))/2; rcText.bottom = rcText.top + nCy + 1; pDC->SetBkMode( TRANSPARENT ); pDC->DrawText( szTitle, rcText, DT_LEFT | DT_SINGLELINE ); rcBtClose = rc; rcBtClose.top = ::GetSystemMetrics( SM_CYFIXEDFRAME )+ 3; rcBtClose.right = rcBottom.right - ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcBtClose.left = rcBtClose.right - ::GetSystemMetrics( SM
-
Hi, I have property sheet wizard application and I am repaining its title bar and creating new minimize and close button on title bar. The following codes are doing things ok. but when i try to right click on task bar button( applications task bar button - close/minimize application from system menu) minimize and close button is not repinted as expected. The codes are void CSamplePaintSheet::OnNcPaint() { CWindowDC dc( this ); ModifyStyle(NULL,WS_SYSMENU|WS_MINIMIZEBOX); Default(); ReDrawCaptionBar( &dc ); ReleaseDC( &dc ); } BOOL CSamplePaintSheet::OnNcActivate( BOOL bActivate ) { OnNcPaint(); return TRUE; } void CSamplePaintSheet::ReDrawCaptionBar(CDC *pDC ) { CRect rc; this->GetWindowRect( rc ); ScreenToClient( rc ); rcCap = rc; rcCap.bottom = ::GetSystemMetrics( SM_CYCAPTION ) + ::GetSystemMetrics( SM_CYFIXEDFRAME ); rcCap.right += ::GetSystemMetrics( SM_CXFIXEDFRAME ); CString szTitle(_T("Sample Paint Application")); SetWindowTextW( szTitle ); CBrush brSolid( CLR_GRAY ); pDC->FillRect( &rcCap, &brSolid ); CRect rcLeft( rc ); rcLeft.top = rcCap.bottom; rcLeft.right = ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcLeft.bottom = rc.Height(); pDC->FillRect( &rcLeft, &brSolid ); CRect rcRight( rc ); rcRight.left = rcCap.right - ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcRight.top = rcLeft.top; rcRight.right = rcCap.right; rcRight.bottom = rcLeft.bottom; pDC->FillRect( &rcRight, &brSolid ); CRect rcBottom( rc ); rcBottom.left = rcLeft.left; rcBottom.top = rcRight.bottom - ::GetSystemMetrics(SM_CYFIXEDFRAME) - nBottomBorderHeight; rcBottom.right = rc.Width(); rcBottom.bottom = rcRight.bottom; pDC->FillRect( &rcBottom, &brSolid ); CSize sizeText = pDC->GetTextExtent( szTitle ); int nCy = HIWORD( ::GetDialogBaseUnits() ); rcText = rcCap; rcText.left = ::GetSystemMetrics( SM_CYFIXEDFRAME ); rcText.right = rcText.left + ( sizeText.cx ); rcText.top = (rcCap.bottom - (nCy + 1))/2; rcText.bottom = rcText.top + nCy + 1; pDC->SetBkMode( TRANSPARENT ); pDC->DrawText( szTitle, rcText, DT_LEFT | DT_SINGLELINE ); rcBtClose = rc; rcBtClose.top = ::GetSystemMetrics( SM_CYFIXEDFRAME )+ 3; rcBtClose.right = rcBottom.right - ::GetSystemMetrics( SM_CXFIXEDFRAME ); rcBtClose.left = rcBtClose.right - ::GetSystemMetrics( SM