While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

Styling with Markdown is supported

Original Comment

Gravatar

Henrik Haftmann

# Reply

I'm new in .NET programming. Regarding flicker while scrolling … In Win32 you have to code all the scrolling behaviour yourself, i.e. handle WM_HSCROLL, WM_VSCROLL, eventually call ScrollWindow(). To prevent (slight) flicker which is caused by the small delay between ScrollWindow() invocation (quite fast) and slower WM_PAINT processing, ScrollWindow() has to be avoided, ScrollDC() should be used for the double-buffer bitmap, and then the invalid regions of the bitmap has to be actualized before "blt"ing it to the control's client area. Unfortunately, the .NET standard behaviour is to use ScrollWindow() inside its WM_HSCROLL / WS_VSCROLL message handler. So the solution starts capturing these messages in your own handlers …

However, in most cases, ScrollWindow() gives closer feedback to user input than any other method, because it's fast, and scroll distances are mostly less than half a client size.

Some applications call UpdateWindow() afterwards to accelerate updating of the newly-exposed invalid area, some not. It depends on complexity of the exposed area. While UpdateWindow() is in progress, further user input cannot be handled.

I'm searching for a scrollable image viewer with a miniature of the entire picture in one of the four corners, showing a red rectangle for the area currently shown. While I'm twiddeling with a solution, flickering is even more annoying because every scroll movement shifts this "fixed part of image" out of the corner. This kind of viewer is especially useful for very large images or vector graphics.

Gravatar

Richard Moss

# Reply

Henrik,

Thanks for your comments. I'm currently working on an update to the ImageBox control, and one of the things I've done is integrate a new base ScrollControl / VirtualScrollableControl that was provided to me last year - I've been able to use this as a drop-in replacement for .NET's ScrollableControl and this provides a fully flicker free experience (which is just as well fortunately as one of the enhancements I'd made to the control introduced some chronic flicker!). This control sets the WS_HSCROLL and WS_VSCROLL window styles and then handles the WM_VSCROLL and WM_HSCROLL messages. Happily this appears to be working rather nicely.

Hopefully this new update will be available soon.

Regards; Richard Moss