Question

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

Was it helpful?

Solution

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 http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_GIF&ds=20040309
The author was very descriptive on how he did it, which is good, example: alt text http://www.codeguru.com/dbfiles/get_image.php?id=6385&lbl=CXPTABCTRL_RIGHT_GIF&ds=20040309
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
(source: skybound.ca)

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

OTHER TIPS

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);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top