RE: listview vertical scrollbar width



Thank you Jeffrey

Excellent answer!

I was not aware it was this complex, and I simply can not spend a lot of
time on this right now. I will likely choose another control--likely a
datagrid--that will allow me to change the vertical scroll bar dimensions.

Again, thanks for your help.
-Kevin

""Jeffrey Tan[MSFT]"" wrote:

Hi,

This question is much more complicated than it looks like. .Net Winform
ListView control encapsulates Windows build-in List-View to leverage its
various functions.

Windows has two kinds of scroll bars. There are the "built-in" scroll bars
that you get when you use the WS_HSCROLL and/or WS_VSCROLL window styles,
and there are scroll bar controls, which are child windows hosted in the
parent controls. ListView control's scrollbars are the first case, that is
the VScrollbar is drawn by Windows because of the WS_VSCROLL window style.
You may use Spy++ to view ListView control structure and its windows style
to verify this.

Since Windows help the .Net Winform to draw the WS_VSCROLL scrollbar in
ListView, .Net Winform has very little control over the painting process,
all the work are done in the Win32 WndProc. More complex, Scrollbars are
considered the non-client area of ListView, so this WS_VSCROLL scrollbar is
drawn by WM_NCPAINT based on my experience.

So, logically, if we want to customize the Scrollbar, we should resort to
the Win32 ListView messages to control it. Unfortunately, Win32 ListView
messages did not expose any interface for us to change the WS_VSCROLL
scrollbar width, this introduced the complexity of this issue. An official
solution is getting rid of the default Windows painting for WS_VSCROLL
scrollbar and drawing the vscrollbar ourselves. However, we have to
owner-draw everything in ListView, which is really complex. Evenmore, we
should draw the non-client area of ListView.

Another guy "Hans Dietrich" found this complexity and used another tricky
way of hidding the WS_VSCROLL scrollbar by removing WS_VSCROLL style, and
then create the second type of VScrollBar control to simulate the
WS_VSCROLL scrollbar function. Since VScrollBar control is a control, it is
easy to change its width. However, other details are still a little
complex. He written a C++ sample in the article below, you may give the
basic logic a read:
"ResizeScrollbar - How to change width of built-in scroll bars"
http://www.codeproject.com/miscctrl/resizescrollbar.asp

Sorry, I can not find any C# sample implementing the same logic as the
article.

If you still want to go on with implementing this logic in C#, please feel
free to tell me, I will try my best to help you. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



.



Relevant Pages

  • RE: listview vertical scrollbar width
    ... ListView control encapsulates Windows build-in List-View to leverage its ... Windows has two kinds of scroll bars. ... You may use Spy++ to view ListView control structure and its windows style ... considered the non-client area of ListView, so this WS_VSCROLL scrollbar is ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Scrolling OwnerDrawn Controls
    ... Read the article on understanding AutoScroll in the GDI+ FAQ. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... > - A content area filling the rest of the control. ... > - Implementing scrolling using ScrollBar controls [Slow painting, ...
    (microsoft.public.dotnet.framework.drawing)
  • Performanceproblem in a large loop under XP but not under W2K
    ... we have a perfomance problem under XP wich didn't exist under Windows ... We use a ListView Control wich updates the MenuItems in the click ... Exit For ...
    (comp.lang.basic.visual.misc)
  • Re: VirtualAllocEx alternative?
    ... HWND child = GetWindow; ... control* over the third party app, I see no other approach that would work ... of things it just isn't in Windows Mobile. ... Basically I have an application that is displaying a ListView ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: ListView Problem - better explanation i hope
    ... The ListView is a Windows control that you drag from the toolboz and drop it ... If you haven't got a window number in your InternetExplorer object then I ... Internet Explorer windows that are open on my computer. ...
    (microsoft.public.dotnet.languages.csharp)