Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Repainting problem On Minimize and Close button

Repainting problem On Minimize and Close button

Scheduled Pinned Locked Moved C / C++ / MFC
dotnethelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    ksrameshkanth
    wrote on last edited by
    #1

    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

    K 1 Reply Last reply
    0
    • K ksrameshkanth

      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

      K Offline
      K Offline
      kcynic
      wrote on last edited by
      #2

      Re draw it in WM_ACTIVATE

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups