Scroll Bar Flashing

Discussions about document viewing.
Post Reply
dapedley
Posts: 10
Joined: Fri Feb 08, 2008 5:19 pm

Scroll Bar Flashing

Post by dapedley » Sun Oct 12, 2008 6:26 pm

I have a tall but narrow image displayed, which requires a vertical scroll bar. All works OK, except that the scroll bar frequently 'flashes' between grey and grey with black dots. This is very distracting.

What causes this 'flashing' and how to stop it please? Using BDS C++ under Win XP.

Regards, David

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Scroll Bar Flashing

Post by Loïc » Mon Oct 13, 2008 10:51 am

Hi,
What causes this 'flashing' and how to stop it please
Cause: A bug within the environment of development used to build GdViewer...
Solution: Force your application to use the XP theme. Unfortunately, I don't know how to do that using BSD C++ but I think this information can easily be found using google or BSD newsgroups.


Best regards,

Loïc

User avatar
justcode
Posts: 26
Joined: Wed Jul 15, 2009 9:20 pm

Re: Scroll Bar Flashing

Post by justcode » Fri Aug 23, 2013 4:35 pm

The issue is that the library is setting focus to the scroll bars which according to Microsoft is a no-no.
My solution is to stop focus from being given to the scrollbars when the control gets focus.
You can subclass the control with MFC and override the OnSetFocus() handler and add the following code.

Code: Select all

void CGdViewerWnd::OnSetFocus(CWnd* pOldWnd)
{
    // fix scrollbar flashing by not allowing focus to be given to the scrollbar 
    // in the first place (hide them, give view focus, reshow them)

    // see if the scrollbars are present on the viewer
    CWnd* pVScroll = FindWindowEx(GetSafeHwnd(), NULL, "ThunderRT6VScrollBar", NULL);
    CWnd* pHScroll = FindWindowEx(GetSafeHwnd(), NULL, "ThunderRT6HScrollBar", NULL);

    // see if the scrollbar is currently visible on the viewer
    BOOL bVScrollVisible = (pVScroll) ? pVScroll->IsWindowVisible() : FALSE;
    BOOL bHScrollVisible = (pHScroll) ? pHScroll->IsWindowVisible() : FALSE;

    // if the scrollbar is visible, hide it while we change focus
    if(bVScrollVisible) pVScroll->ShowWindow(SW_HIDE);
    if(bHScrollVisible) pHScroll->ShowWindow(SW_HIDE);

    // let the activeX control get the focus 
    // focus cannot be given to scrollbars if they are hidden
    __super::OnSetFocus(pOldWnd);    

    // if the scrollbar was hidden by us, show them again
    if(bVScrollVisible) pVScroll->ShowWindow(SW_SHOW);
    if(bHScrollVisible) pHScroll->ShowWindow(SW_SHOW);
}
Not sure why the engineers here could not come up with a simple work around but this is how I handled it and it seems to work 99.9% of the time.

Hope this helps. ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest