By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,149 Members | 885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,149 IT Pros & Developers. It's quick & easy.

XP Themed controls on a Tab Control?

P: n/a
I decided to use a tab control for my latest project. On Windows XP, the
tab control itself is themed (tabs are themed), but the tab pages and
any controls I put on them are not themed (except for textboxes).

Done a bit of googling on this subject and I found a lot of people with
the same problem, but no real solution.

Has anyone come up with a good way to get controls to appear themed on a
tab page?

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If you mean many of the contained controls appear as black on some systems,
then I have come across this problem. I have not found an answer.

Best wishes

Paul Bromley
"Terry Olsen" <to******@hotmail.com> wrote in message
news:uS*************@TK2MSFTNGP12.phx.gbl...
I decided to use a tab control for my latest project. On Windows XP, the
tab control itself is themed (tabs are themed), but the tab pages and
any controls I put on them are not themed (except for textboxes).

Done a bit of googling on this subject and I found a lot of people with
the same problem, but no real solution.

Has anyone come up with a good way to get controls to appear themed on a
tab page?

*** Sent via Developersdex http://www.developersdex.com ***

Dec 15 '05 #2

P: n/a
They don't appear black. The command buttons and radio buttons I put on
the tab page are displayed as they appear in Windows 2000 and below. I
have the FlatStyle set to System but that doesn't help. The wierd thing
is that the textboxes that I put on the tab page DO appear as XP themed
controls.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '05 #3

P: n/a

"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
They don't appear black. The command buttons and radio buttons I put on
the tab page are displayed as they appear in Windows 2000 and below. I
have the FlatStyle set to System but that doesn't help. The wierd thing
is that the textboxes that I put on the tab page DO appear as XP themed
controls.


Terry, I was going to post and say that this sort of stuff is fixed in VS
2005 (I know they did a lot of work with themes in .NET 2.0). But I just
threw together a 2003 project to see the issue and everything on my tab page
is XP themed...? Although I've read, using themes in 1.1 can lead to a
world of hurt. :)

I changed Button1 and Radiobutton1's FlatStyle to System and launched the
form from a Sub Main after enabling visual styles.

Can you duplicate with my posted code?

Greg
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.TabControl1 = New System.Windows.Forms.TabControl
Me.TabPage1 = New System.Windows.Forms.TabPage
Me.Button1 = New System.Windows.Forms.Button
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.Button2 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Location = New System.Drawing.Point(40, 32)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(456, 352)
Me.TabControl1.TabIndex = 0
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.TextBox1)
Me.TabPage1.Controls.Add(Me.Button1)
Me.TabPage1.Controls.Add(Me.RadioButton1)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(448, 326)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "TabPage1"
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button1.Location = New System.Drawing.Point(24, 72)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
'
'RadioButton1
'
Me.RadioButton1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.RadioButton1.Location = New System.Drawing.Point(24, 32)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "RadioButton1"
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button2.Location = New System.Drawing.Point(296, 416)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 1
Me.Button2.Text = "Button2"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(24, 112)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = "TextBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(656, 478)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TabControl1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.ResumeLayout(False)

End Sub

#End Region

Public Shared Sub Main()

System.Windows.Forms.Application.EnableVisualStyle s()
System.Windows.Forms.Application.Run(New Form1)

End Sub 'Main

End Class
Dec 15 '05 #4

P: n/a
I got this one figured out, though I don't know why this works. Here's
the code I was using to enable visual styles:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

This worked for everything I've written up until now, when I used the
Tab Control. Seems in order to get the controls to be themed when on
the tab control, you must put an Application.DoEvents just before the
Run(New Form1) line and behold, all controls are now themed.

So the new code looks like this:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
Application.DoEvents
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

If someone knows WHY this works, clue me in, will ya?

Thanks!
*** Sent via Developersdex http://www.developersdex.com ***
Dec 16 '05 #5

P: n/a
I had read of adding the DoEvents line, and almost included it. But my
example seemed to work without, so I didn't.

I seriously would consider upgrading to 2005 (if it is an option) before
investing too much effort with XP Themes. I've read that people have had
some weird, hard to troubleshoot problems due soley to using themes and .NET
1.x. YMMV

Greg
"Terry Olsen" <to******@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
I got this one figured out, though I don't know why this works. Here's
the code I was using to enable visual styles:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

This worked for everything I've written up until now, when I used the
Tab Control. Seems in order to get the controls to be themed when on
the tab control, you must put an Application.DoEvents just before the
Run(New Form1) line and behold, all controls are now themed.

So the new code looks like this:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
Application.DoEvents
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

If someone knows WHY this works, clue me in, will ya?

Thanks!
*** Sent via Developersdex http://www.developersdex.com ***

Dec 16 '05 #6

P: n/a
I use 2005 for personal projects at home. However, I must use 2003 at work
because they have not yet certified Framework 2.0. Until they clear it for
use on company hardware, I'm stuck with 2003. The XP Theme is not required,
but some of the workstations have been upgraded to XP from 2K and a change
of scenery is nice...

"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
I had read of adding the DoEvents line, and almost included it. But my
example seemed to work without, so I didn't.

I seriously would consider upgrading to 2005 (if it is an option) before
investing too much effort with XP Themes. I've read that people have had
some weird, hard to troubleshoot problems due soley to using themes and
.NET 1.x. YMMV

Greg
"Terry Olsen" <to******@hotmail.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
I got this one figured out, though I don't know why this works. Here's
the code I was using to enable visual styles:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

This worked for everything I've written up until now, when I used the
Tab Control. Seems in order to get the controls to be themed when on
the tab control, you must put an Application.DoEvents just before the
Run(New Form1) line and behold, all controls are now themed.

So the new code looks like this:

<System.STAThread()> _
Public Shared Sub Main()
If OSFeature.Feature.IsPresent(OSFeature.Themes) Then _
System.Windows.Forms.Application.EnableVisualStyle s()
End If
Application.DoEvents
System.Windows.Forms.Application.Run(New Form1)
End Sub 'Main

If someone knows WHY this works, clue me in, will ya?

Thanks!
*** Sent via Developersdex http://www.developersdex.com ***


Dec 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.