Click here to Skip to main content
15,891,787 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a modeless dialog box with a listview.

Listview has following styles/extended styles:

LVS_EX_FULLROWSELECT, LVS_EX_GRIDLINES, LVS_EX_DOUBLEBUFFER and LVS_REPORT.

Dialog's background is a bitmap image.

Listview has transparent background and transparent text's background and this is set with the call to following APIs: ListView_SetTextBkColor( hwndListView, CLR_NONE ); and SendMessage( hwndListView, LVM_SETBKCOLOR, (WPARAM)0, (LPARAM)CLR_NONE );

Here is the small screenshot of how it looks:
http://pbrd.co/1dTbKbk[^]

The problem manifests when I vertically scroll the listview-its client area is not repainted properly:

http://pbrd.co/1dTbSrw[^]

I have used the following code to solve this:
C++
case WM_NOTIFY:
        if( ( (LPNMHDR)lParam )->idFrom == IDC_LIST1 )
            if( ( (LPNMHDR)lParam )->code == LVN_ENDSCROLL || 
                ( (LPNMHDR)lParam )->code == LVN_BEGINSCROLL )
                InvalidateRect( ((LPNMHDR)lParam)->hwndFrom, NULL, TRUE );
        return TRUE;


But the problem remains when user clicks on an item, and moves up/down with the keyboard arrows.

Also, picture in the listview's client area sometimes "jumps up" and then repositions properly, during the repaint, if I scroll using mouse wheel.

I have searched online for a solution but have failed so I ask this:

What is the proper way to handle listview's scrolling so I can fix this problem?

Thank you.

Best regards.
Posted
Updated 16-Jan-14 2:17am
v4
Comments
KarstenK 15-Jan-14 13:40pm    
why not only on msg LVN_ENDSCROLL?
AlwaysLearningNewStuff 15-Jan-14 13:54pm    
To be honest, I am trying this for the first time, so I thought that this was the right way.

EDIT:

If I only go with LVN_ENDSCROLL the flickering increases.
KarstenK 16-Jan-14 2:15am    
you should tweak InvalidateRect( ((LPNMHDR)lParam)->hwndFrom, rcList1, FALSE );
AlwaysLearningNewStuff 16-Jan-14 3:10am    
OK, I have tried your suggestion and I see no visual improvement. Everything looks the same.

I have added LVS_EX_DOUBLEBUFFER style and it does not flicker anymore.

The problem I have now is with proper handling of WM_MOUSEWHEEL message. Sometimes the image in listview's client area "jumps up" and then returns to normal position during continuous scrolling with the mouse wheel. This effect happens both with my and yours implementation.

Also, my problems are not solved when I scroll using keyboard arrows.

Thank you for your suggestions.

Best regards.
Richard MacCutchan 16-Jan-14 8:06am    
Are you using the LVBKIF_STYLE_TILE flag in your LVBKIMAGE structure when you set the background image?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900