|
-
October 18th, 2010, 02:34 PM
#1
Flickering on Win7 Progress Control Text
I am using Win32 API (no MFC) and am handling the WM_PAINT message to draw text over a progress control for windows 7, problem is I get a flicker every time that little light burst effect thing runs across the progress bar, anyone have an idea on how to solve this?
//my code...
//case WM_ERASEBKGND: //tried this, problem still not solved
//case WM_NCPAINT: //tried this, problem still not solved
case WM_PAINT:
{
//OnPaint(); //tried pre-painting, does not work
//Let the control paint its own elements
LRESULT nOriginalReturn = CallWindowProc(m_OrgWinProc,hwnd,msg,wParam,lParam);
//Draw my text on top of the control
if(OnPaint())
{return 0;}else{return nOriginalReturn;}
break;
}
BOOL ProgressEx::OnPaint()
{
try
{
HDC hdc = ::GetWindowDC(m_hWnd);
RECT rc;
::GetWindowRect(m_hWnd,&rc);
//change window rect cordinates to client cordinates
rc.bottom -= rc.top;
rc.right -= rc.left;
rc.left = 0;
rc.top = 0;
HFONT oldfont = (HFONT)SelectObject(hdc,m_font);
SetBkMode(hdc,TRANSPARENT);
SetTextColor(hdc,0x000000);//black text
DrawText(hdc,"Hello",-1,&rc,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_NOCLIP);
SelectObject(hdc,oldfont);//reselect the old font
ReleaseDC(m_hWnd,hdc);
return TRUE;
}
catch(...){}
return FALSE;
}
Last edited by 12oclocker; October 18th, 2010 at 02:40 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|