RE: listview vertical scrollbar width
- From: jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Thu, 15 Feb 2007 07:47:07 GMT
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.
.
- Follow-Ups:
- RE: listview vertical scrollbar width
- From: koulbassa
- RE: listview vertical scrollbar width
- Prev by Date: Re: GDI leak in DataGridView
- Next by Date: Re: Form does not detect property has changed while serializing
- Previous by thread: Re: GDI leak in DataGridView
- Next by thread: RE: listview vertical scrollbar width
- Index(es):
Relevant Pages
|