CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    60

    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
  •  





Click Here to Expand Forum to Full Width

Featured