开发者

Problem with TabControl alignment in VB.NET

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

Problem with TabControl alignment in VB.NET

What I wanted was to have the tabs literal开发者_JS百科ly 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:

Problem with TabControl alignment in VB.NET


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:

Problem with TabControl alignment in VB.NET

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.

Problem with TabControl alignment in VB.NET


(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


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);
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜