Hiding Tabcontrol horizontal scroll buttons

S

Steve

Hi All

I want to prevent the Windows Tabcontrol from showing the horizontal scroll
bar when the Number of Tabs exceeds the width of the control

I use code in 2 buttons to control the scrolling, as the default scroll
buttons are too hard to target on a Touch Screen

How do I do this?
 
J

Jeffrey Tan[MSFT]

Hi Steve,

Actually, there is no easy way to get this done. This is because the
TabControl control model is not designed for this fexibility and
customization. Let's perform some analysis to understand why.

By using Spy++, I find that the horizontal scroll buttons is a separate
control. My first thought is the .Net TabControl created this horizontal
scroll control internally, so I opened the Reflector tool to examine the
source code of TabControl. But I did not find any painting or control
creating code related.

Then, I am trying to use windbg to understand how the horizontal scroll
control is created. I set 2 breakpoints in user32!CreateWindowExA and
user32!CreateWindowExW. Every window creation will call these 2 functions:
0:000> bp user32!CreateWindowExW
0:000> bp user32!CreateWindowExA

When the breakpoint to the horizontal scroll control creation is triggered,
I got the call stack below:
0:000> knL
# ChildEBP RetAddr
00 0013e924 774ab0fa USER32!CreateWindowExW
01 0013e988 7742f7db comctl32!SHFusionCreateWindow+0x49
02 0013e9c4 7745e4d6 comctl32!CreateUpDownControl+0x2d
03 0013ea1c 7745e5cb comctl32!Tab_UpdateArrows+0x120
04 0013ea30 7745f1c0 comctl32!RedrawAll+0x1b
05 0013ea8c 774608c9 comctl32!Tab_OnInsertItem+0x143
06 0013eac8 7739b6e3 comctl32!Tab_WndProc+0x77f
07 0013eaf4 7739b874 USER32!InternalCallWinProc+0x28
08 0013eb6c 7739bfce USER32!UserCallWinProcCheckWow+0x151
09 0013eb9c 7739bf74 USER32!CallWindowProcAorW+0x98
0a 0013ebbc 7b07d2f4 USER32!CallWindowProcW+0x1b
0b 0013ec14 7b077d5c
System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.DefWndProc(System.
Windows.Forms.Message ByRef)+0x94
0c 0013ec7c 7b07538b
System_Windows_Forms_ni!System.Windows.Forms.Control.DefWndProc(System.Windo
ws.Forms.Message ByRef)+0xc
0d 0013ec7c 7b2cbce2
System_Windows_Forms_ni!System.Windows.Forms.Control.WndProc(System.Windows.
Forms.Message ByRef)+0x90b
0e 0013ece0 7b07d24d
System_Windows_Forms_ni!System.Windows.Forms.TabControl.WndProc(System.Windo
ws.Forms.Message ByRef)+0x1f2
0f 0013ed14 7b07d226
System_Windows_Forms_ni!System.Windows.Forms.Control+ControlNativeWindow.OnM
essage(System.Windows.Forms.Message ByRef)+0xd
10 0013ed14 7b08f335
System_Windows_Forms_ni!System.Windows.Forms.Control+ControlNativeWindow.Wnd
Proc(System.Windows.Forms.Message ByRef)+0xd6
11 0013ed14 003a223b
System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.DebuggableCallback
(IntPtr, Int32, IntPtr, IntPtr)+0x75
WARNING: Frame IP not in any known module. Following frames may be wrong.
12 0013ed38 7739b6e3 0x3a223b
13 0013ed64 7739b874 USER32!InternalCallWinProc+0x28

Oh, we can see that it is the Win32 TabControl itself that created this
scrollbar control, not .Net Winform.(Note: .Net Winform TabControl
encapsulates the Win32 TabControl internally). There is no methods we can
use to remove or hide this scrollbar control in .Net. Also, as I poked
around the Win32 TabControl messages, it also did not expose any way to
hide this control.

Now, the only way I can think of hidding this scrollbar control is
p/invoking FindWindow() Win32 API to find the scrollbar control and call
ShowWindow() win32 API to hide it. But, this is definitely a hack solution
with danger, which may not be compatible with the default control model of
TabControl.

Hope may analysis makes sense to 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.
 
S

Steve

Jeffrey

I have decided to Not worry about the scroll bars showing for the moment

Thanks for the reply though

Regards
Steve

"Jeffrey Tan[MSFT]" said:
Hi Steve,

Actually, there is no easy way to get this done. This is because the
TabControl control model is not designed for this fexibility and
customization. Let's perform some analysis to understand why.

By using Spy++, I find that the horizontal scroll buttons is a separate
control. My first thought is the .Net TabControl created this horizontal
scroll control internally, so I opened the Reflector tool to examine the
source code of TabControl. But I did not find any painting or control
creating code related.

Then, I am trying to use windbg to understand how the horizontal scroll
control is created. I set 2 breakpoints in user32!CreateWindowExA and
user32!CreateWindowExW. Every window creation will call these 2 functions:
0:000> bp user32!CreateWindowExW
0:000> bp user32!CreateWindowExA

When the breakpoint to the horizontal scroll control creation is
triggered,
I got the call stack below:
0:000> knL
# ChildEBP RetAddr
00 0013e924 774ab0fa USER32!CreateWindowExW
01 0013e988 7742f7db comctl32!SHFusionCreateWindow+0x49
02 0013e9c4 7745e4d6 comctl32!CreateUpDownControl+0x2d
03 0013ea1c 7745e5cb comctl32!Tab_UpdateArrows+0x120
04 0013ea30 7745f1c0 comctl32!RedrawAll+0x1b
05 0013ea8c 774608c9 comctl32!Tab_OnInsertItem+0x143
06 0013eac8 7739b6e3 comctl32!Tab_WndProc+0x77f
07 0013eaf4 7739b874 USER32!InternalCallWinProc+0x28
08 0013eb6c 7739bfce USER32!UserCallWinProcCheckWow+0x151
09 0013eb9c 7739bf74 USER32!CallWindowProcAorW+0x98
0a 0013ebbc 7b07d2f4 USER32!CallWindowProcW+0x1b
0b 0013ec14 7b077d5c
System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.DefWndProc(System.
Windows.Forms.Message ByRef)+0x94
0c 0013ec7c 7b07538b
System_Windows_Forms_ni!System.Windows.Forms.Control.DefWndProc(System.Windo
ws.Forms.Message ByRef)+0xc
0d 0013ec7c 7b2cbce2
System_Windows_Forms_ni!System.Windows.Forms.Control.WndProc(System.Windows.
Forms.Message ByRef)+0x90b
0e 0013ece0 7b07d24d
System_Windows_Forms_ni!System.Windows.Forms.TabControl.WndProc(System.Windo
ws.Forms.Message ByRef)+0x1f2
0f 0013ed14 7b07d226
System_Windows_Forms_ni!System.Windows.Forms.Control+ControlNativeWindow.OnM
essage(System.Windows.Forms.Message ByRef)+0xd
10 0013ed14 7b08f335
System_Windows_Forms_ni!System.Windows.Forms.Control+ControlNativeWindow.Wnd
Proc(System.Windows.Forms.Message ByRef)+0xd6
11 0013ed14 003a223b
System_Windows_Forms_ni!System.Windows.Forms.NativeWindow.DebuggableCallback
(IntPtr, Int32, IntPtr, IntPtr)+0x75
WARNING: Frame IP not in any known module. Following frames may be wrong.
12 0013ed38 7739b6e3 0x3a223b
13 0013ed64 7739b874 USER32!InternalCallWinProc+0x28

Oh, we can see that it is the Win32 TabControl itself that created this
scrollbar control, not .Net Winform.(Note: .Net Winform TabControl
encapsulates the Win32 TabControl internally). There is no methods we can
use to remove or hide this scrollbar control in .Net. Also, as I poked
around the Win32 TabControl messages, it also did not expose any way to
hide this control.

Now, the only way I can think of hidding this scrollbar control is
p/invoking FindWindow() Win32 API to find the scrollbar control and call
ShowWindow() win32 API to hide it. But, this is definitely a hack solution
with danger, which may not be compatible with the default control model of
TabControl.

Hope may analysis makes sense to 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.
 
S

Steve

Mick

Thanks for the reply

Had a quick look at your site and the control looks good

Will follow up in the future when I get some free time

Regards
Steve

"Mick Doherty"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top