Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - how to avoid blinking windows when invisible
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to avoid blinking windows when invisible

 Post Reply Post Reply
Author
Message
jshan View Drop Down
Groupie
Groupie
Avatar

Joined: 07 December 2007
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote jshan Quote  Post ReplyReply Direct Link To This Post Topic: how to avoid blinking windows when invisible
    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

Back to Top
jshan View Drop Down
Groupie
Groupie
Avatar

Joined: 07 December 2007
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote jshan Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.