views:

590

answers:

2

Hi there, I'm having a weird behaviour with a left-aligned TabControl in VB.NET. Screenshot:

alt text

What I wanted was to have the tabs literally the same way they would be if rotated 90 degrees to the left.

Does it have something to do with the fact I'm not (god forbid) using the standard XP theme? Any solution to just make it work? (Even if it's hard, but I don't want a control that has a contrasting style, I want the program looking consistent)

Thanks!

Happy ending:

alt text

+4  A: 

Ok, I solved the issue. If someone else has the same problem, use this control. It's free under MIT license. Screenshot by the author:

alt text

Note that the author made two controls. My advice: the second one has incorrect support for cleartype (It rotates after subpixel rendering), but it's easier to use, and has better padding control. Go for it! =)

EDIT If you use C++ and need it for that, there's an approach. Picture of the result: alt text
The author was very descriptive on how he did it, which is good, example: alt text
This is the link to the article.

Another very good approach is SkyBound's multi-purpose VisualStyles component. Seems that the binaries are free but the source is not, very fair deal. I'll check it out later, but if you need some visualstyles bug fixing, it seems like a choice.
alt text
from the authors:

first and foremost, it quashes XP theme bugs, silently, efficiently and automatically. But it also provides a simple set of classes which you can use to draw your own controls using the Windows XP Theme API.

Check this. and more from the author.

Problem solved!! =D

Camilo Martin
+2  A: 

Yes, it is a bug in the visual styles renderer for the tab control. Looks like you already found a replacement. Another low-impact approach is to selectively disable visual styles for the control. It will revert back to battle-ship gray, correctly drawing vertical tabs. Tab page content will still render properly.

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class FixedTabControl : TabControl {
  [DllImportAttribute("uxtheme.dll")]
  private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);

  protected override void OnHandleCreated(EventArgs e) {
    SetWindowTheme(this.Handle, "", "");
    base.OnHandleCreated(e);
  }
}
Hans Passant
Thanks, but with no styles it looks horrible. I hate to use applications that look like they were made 10 years ago. And this is such a big bug that it makes any out-of-the-box tab alignment unusable, for a simple reason; the only thing that makes left, bottom or right alignment of tabs usable, is aesthetic.
Camilo Martin
Well, I don't disagree. Not sure what happened to the Microsoft programmer that wrote that code, smells like s/he got run over by a bus. It is everybody's job to find a workaround for the bus mishap, that's not a Good Thing. Use the one you found at your discretion, I can only recommend a solution Least Likely To Break some day.
Hans Passant
+2 on that! For every single bug they produce, 1000s of dirty workarounds have to be made by countless developers. I guess that has to do with leaving room for selling more products and making "updates" a matter of bug-fixing.
Camilo Martin