Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

TabControl and Transparency

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Dankert - 04 Apr 2005 22:47 GMT
(Notes:  This is with DotNet 1.1, Windows XP SP2)
I have a tabcontrol located on a form where the form has a background image.
Ideally, I would like to have the background near the upper-portion of the
tabs be transparent so the image of the form will show through.  Initially,
this seemed to work fine without modification.  However, after using it
briefly, it is apparent that the tabs flicker immensely when you move the
mouse over them.  To solve this, I assumed I would be able to owner-draw the
tabcontrol, however by specifying this the entire top-section of the
tabcontrol remains the drab gray color and draws the rectangle to the right
of the tabs.  So, this seems to work even less than had I let the control
draw itself.

Doing a quick newsgroup search, I found two threads where this has been
reported back in 2002 and a Microsoft representative posted that this was a
bug that would be addressed.  Being that this is almost three years later, I
am hoping there is a known workaround other than overriding OnPaint and
OnPaintBackground (or at least an example of how to sucessfully override
these, as this can be a daunting task).

Newsgroup posts from 2002 for reference:
http://groups-beta.google.com/group/microsoft.public.dotnet.framework/browse_thr
ead/thread/9f25dc16b97efebf/e01dc8403fadc8e1?q=%22dotnet%22+tabcontrol+transpare
ncy&rnum=1#e01dc8403fadc8e1


http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/browse_
thread/thread/7404c7a51763a57b/c80ffc9efc71243c?q=%22dotnet%22+tabcontrol+transp
arency&rnum=4#c80ffc9efc71243c


Thanks, any help would be appreciated.

Bob Dankert
Bob Dankert - 04 Apr 2005 22:59 GMT
As a note, I am not using HotTrack - I turned this both on and off and had
the same issues either way.

Bob

> (Notes:  This is with DotNet 1.1, Windows XP SP2)
> I have a tabcontrol located on a form where the form has a background
[quoted text clipped - 23 lines]
>
> Bob Dankert
Mick Doherty - 05 Apr 2005 11:06 GMT
When using a BackgroundImage property the painting is very slow.
The TabControl does not support Transparent Background and AFAIK this is not
going to be addressed, although Visual Styled TabControls do appear to have
a Transparent Background.

You'll find a TabControl on my downloads page that does support Transparent
Background, but does not support XP Visual Styles. It also supports one or
two other frequently requested features.
http://dotnetrix.co.uk/download/TabControlEX.dll

If all you want is to ease the flicker then add the following code to your
form:
\\\
'Modify Sub New as follows
Public Sub New()
   MyBase.New()

   'This call is required by the Windows Form Designer.
   InitializeComponent()
   'Add any initialization after the InitializeComponent() call
   setstyle(ControlStyles.AllPaintingInWmPaint Or _
               ControlStyles.DoubleBuffer Or _
               ControlStyles.ResizeRedraw Or _
               ControlStyles.UserPaint, True)
End Sub

'and add this code to the form
Private BackImage As Bitmap

Private Sub MainForm_Load(ByVal sender As System.Object, _
           ByVal e As System.EventArgs) Handles MyBase.Load
   If Not BackgroundImage Is Nothing Then
       BackImage = New Bitmap(Me.BackgroundImage)
       Me.BackgroundImage = Nothing
   End If
End Sub

Protected Overrides Sub OnPaintBackground(ByVal pevent As _
           System.Windows.Forms.PaintEventArgs)
   If BackImage Is Nothing Then
       MyBase.OnPaintBackground(pevent)
   Else
       pevent.Graphics.DrawImage(BackImage, Point.Empty)
   End If
End Sub
///

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> (Notes:  This is with DotNet 1.1, Windows XP SP2)
> I have a tabcontrol located on a form where the form has a background
[quoted text clipped - 23 lines]
>
> Bob Dankert

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.