Print Page | Close Window

how to avoid blinking windows when invisible

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=13754
Printed Date: 29 September 2024 at 9:22pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: how to avoid blinking windows when invisible
Posted By: jshan
Subject: how to avoid blinking windows when invisible
Date Posted: 22 March 2009 at 3:02am
Hi.
 
I'm using ProgressBar ctrl in my report ctrl.
When the progressbar ctrl is working invisible like when minimized or underneath another window.
Whole system windows are terribly blinking with high cpu rates. Especially. when minimized.
 
I borrowed the progressbar routine from your example code.
 
How to avoid this things ?
 
regards.
 


-------------
: xtp 16.2.0(Unicode static lib)

: windows 7 Pro Kor sp1(64bit)

: vs 2012 update 2 MFC




Replies:
Posted By: jshan
Date Posted: 22 March 2009 at 9:14am

void CRecordItemProgressEx::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics)
{
 if(!(pDrawArgs && pMetrics))
  return;
 // draw text
 CXTPReportRecordItemText::OnDrawCaption(pDrawArgs, pMetrics);

 if(!m_bUseProgress)
  return;

 CDC* pDC = pDrawArgs->pDC;
 CXTPFontDC font(pDC);
 CRect rcItem = pDrawArgs->rcItem;
 CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager();
 
 rcItem.left -= 2;
 rcItem.right += 2;
 rcItem.top -= 1;
 rcItem.bottom += 1;

 pDC->FillSolidRect(rcItem, m_bgColor);

// rcItem.bottom -= 1;
// rcItem.left += 1;  // leave margin in case row is highlighted
//  // draw border
//  pDC->Draw3dRect(&rcItem, RGB(0,0,0), ::GetSysColor(COLOR_BTNSHADOW));

 // draw progress bar and text
 CRect LeftRect, RightRect;
 RightRect = LeftRect = rcItem;

 int w = (LeftRect.Width() * m_nProgress) / 100;
 LeftRect.right = LeftRect.left + w - 1;
 RightRect.left = LeftRect.right;

 pDC->FillSolidRect(LeftRect, m_fgColor); // RGB(160, 32, 240)

 if (m_strProgress != _T(""))
 {
  CString str;
  str.Format(_T("%s %d%%"), m_strProgress, m_nProgress);

  pDC->SetBkMode(TRANSPARENT);

  CRect TextRect;
  TextRect = rcItem;
  TextRect.DeflateRect(1, 1);
  font.SetFont(pPaintManager->GetTextFont());
  CRgn rgn;
  rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom);
  pDC->SelectClipRgn(&rgn);
  pDC->SetTextColor(RGB(255, 255, 255));
  pDC->DrawText(str, &TextRect, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
  rgn.DeleteObject();

  rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom);
  pDC->SelectClipRgn(&rgn);
  pDC->SetTextColor(RGB(0, 0, 0));
  pDC->DrawText(str, &TextRect, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
  rgn.DeleteObject();

  pDC->SelectClipRgn(NULL);
 }
}

 
This is my progressbar routine.  Actually, I added fancy fuction which can be able to draw some texts in the progress bar.
is this code kinda overshooting ? or is there any tunning point ?
 
regards.
 
P.S: not only Hiden state, but also when two or more progress bar in the report contrl are making Blinking.
(It's File transfer progress bars)
 
 


-------------
: xtp 16.2.0(Unicode static lib)

: windows 7 Pro Kor sp1(64bit)

: vs 2012 update 2 MFC




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net