PC Review


Reply
Thread Tools Rate Thread

Container for VisualStyles

 
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      14th Nov 2006
Is there a Windows.Forms 2.0 container that implements Windows XP VIsual
Styles?

I know the TabControl does but I need a non-tabbed container that does so as
well in order to match the appearance of a TabControl in my application.
Currently, I am using a panel but with the Windows XP theme turned on, the
TabControl background turns light (is it white? I can't tell for sure) but
the background of the panel control used alongside the TabControl stays gray.

Thanks in advance,

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA
 
Reply With Quote
 
 
 
 
Linda Liu [MSFT]
Guest
Posts: n/a
 
      14th Nov 2006
Hi Dale,

When we apply Windows XP Visual Styles to an application, all the controls
in the application will take a Windows XP look.

However, each control may have a different appearance for Windows XP Visual
Styles. For example, the TabControl control's background has a light color
but the Panel control's background has a gray color. In addition, if the
Appearance property of the TabControl is set to Buttons or FlatButtons, its
background color will turn to gray color.

You have mentioned that you want a non-tabbed container that match the
appearance of a TabControl in your application. Why not use a TabControl
and removing all the tabpages within it?

Hope this helps.
If my suggestion is not appropriate to your scenario, please feel free to
let me know.



Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      14th Nov 2006
I thought your idea was a great one but then, when I tried it, I found out
that you cannot add controls to a TabControl. Apparently, the only conrol
that can be added to a TabControl is a TabPage.

My situation is this: I have two views of my data - simple and advanced.
In simple mode, all of the data fits on one form. In advanced, it takes 4
tabs to view the data. When the user selects simple view, it goes against
Microsoft's usability guidelines for the TabControl to use the TabControl
with only one tab. But I still need the user experience to be the same as
the advanced view but just no tabs.


--
Dale Preston
MCAD C#
MCSE, MCDBA


"Linda Liu [MSFT]" wrote:

> Hi Dale,
>
> When we apply Windows XP Visual Styles to an application, all the controls
> in the application will take a Windows XP look.
>
> However, each control may have a different appearance for Windows XP Visual
> Styles. For example, the TabControl control's background has a light color
> but the Panel control's background has a gray color. In addition, if the
> Appearance property of the TabControl is set to Buttons or FlatButtons, its
> background color will turn to gray color.
>
> You have mentioned that you want a non-tabbed container that match the
> appearance of a TabControl in your application. Why not use a TabControl
> and removing all the tabpages within it?
>
> Hope this helps.
> If my suggestion is not appropriate to your scenario, please feel free to
> let me know.
>
>
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Mick Doherty
Guest
Posts: n/a
 
      14th Nov 2006
Hide the tabs by altering the TabControls DisplayRectangle

http://www.dotnetrix.co.uk/tabcontrols.html --> Add a HideTabs property to
turn on/off the Tabs

Other than that, if you're using VS2005, and it sounds like you are, you
should be able to use the VisualStyleRenderer class to paint the appropriate
appearance in a Panel.
http://msdn2.microsoft.com/en-us/lib...erenderer.aspx

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


"Dale" <(E-Mail Removed)> wrote in message
news:FA32C592-499E-4DD3-B2B8-(E-Mail Removed)...
>I thought your idea was a great one but then, when I tried it, I found out
> that you cannot add controls to a TabControl. Apparently, the only conrol
> that can be added to a TabControl is a TabPage.
>
> My situation is this: I have two views of my data - simple and advanced.
> In simple mode, all of the data fits on one form. In advanced, it takes 4
> tabs to view the data. When the user selects simple view, it goes against
> Microsoft's usability guidelines for the TabControl to use the TabControl
> with only one tab. But I still need the user experience to be the same
> as
> the advanced view but just no tabs.
>
>
> --
> Dale Preston
> MCAD C#
> MCSE, MCDBA
>
>
> "Linda Liu [MSFT]" wrote:
>
>> Hi Dale,
>>
>> When we apply Windows XP Visual Styles to an application, all the
>> controls
>> in the application will take a Windows XP look.
>>
>> However, each control may have a different appearance for Windows XP
>> Visual
>> Styles. For example, the TabControl control's background has a light
>> color
>> but the Panel control's background has a gray color. In addition, if the
>> Appearance property of the TabControl is set to Buttons or FlatButtons,
>> its
>> background color will turn to gray color.
>>
>> You have mentioned that you want a non-tabbed container that match the
>> appearance of a TabControl in your application. Why not use a TabControl
>> and removing all the tabpages within it?
>>
>> Hope this helps.
>> If my suggestion is not appropriate to your scenario, please feel free to
>> let me know.
>>
>>
>>
>> Sincerely,
>> Linda Liu
>> Microsoft Online Community Support
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscripti...ult.aspx#notif
>> ications.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscripti...t/default.aspx.
>> ==================================================
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>



 
Reply With Quote
 
Linda Liu [MSFT]
Guest
Posts: n/a
 
      15th Nov 2006
Hi Dale,

Thank you for your reply.

Yes, you're right. We could only place TabPage on a TabControl control.

As for a workaround for your scenario, I suggest that you add a TabPage on
the TabControl to display the data in simple mode and draw the TabControl
control by custom code using VisualStyleRenderer class. To do this, we
could derive a new control from TabControl class. In the derived class, set
the ControlStyles.UserPaint to true and override the OnPaint method to draw
the TabPage. Note that we don't draw the tab of the TabPage in order to
hide it.

The following is a sample.

using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Drawing;

class MyTabControl : TabControl
{
public MyTabControl()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
DrawControl(e.Graphics);
}

private void DrawControl(Graphics g)
{
if (!Visible)
{
return;
}
VisualStyleRenderer render = new
VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
Rectangle TabArea = this.DisplayRectangle;
TabArea.Y = TabArea.Y + 1;
TabArea.Width = TabArea.Width + 1;
int nDelta = SystemInformation.Border3DSize.Width;
TabArea.Inflate(nDelta, nDelta);
render.DrawBackground(g, TabArea);
}
}

Build the project and drag MyTabControl from Toolbox on your form. You add
only one TabPage on the MyTabControl control and then add some controls
you'd like on the TabPage.

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

 
Reply With Quote
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      17th Nov 2006
Thank you. I think between Mick and this, I will have my problem solved.

Regards,

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA


"Linda Liu [MSFT]" wrote:

> Hi Dale,
>
> Thank you for your reply.
>
> Yes, you're right. We could only place TabPage on a TabControl control.
>
> As for a workaround for your scenario, I suggest that you add a TabPage on
> the TabControl to display the data in simple mode and draw the TabControl
> control by custom code using VisualStyleRenderer class. To do this, we
> could derive a new control from TabControl class. In the derived class, set
> the ControlStyles.UserPaint to true and override the OnPaint method to draw
> the TabPage. Note that we don't draw the tab of the TabPage in order to
> hide it.
>
> The following is a sample.
>
> using System.Windows.Forms;
> using System.Windows.Forms.VisualStyles;
> using System.Drawing;
>
> class MyTabControl : TabControl
> {
> public MyTabControl()
> {
> this.SetStyle(ControlStyles.UserPaint, true);
> this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
> this.SetStyle(ControlStyles.DoubleBuffer, true);
> this.SetStyle(ControlStyles.ResizeRedraw, true);
> this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
> }
>
> protected override void OnPaint(PaintEventArgs e)
> {
> base.OnPaint(e);
> DrawControl(e.Graphics);
> }
>
> private void DrawControl(Graphics g)
> {
> if (!Visible)
> {
> return;
> }
> VisualStyleRenderer render = new
> VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
> Rectangle TabArea = this.DisplayRectangle;
> TabArea.Y = TabArea.Y + 1;
> TabArea.Width = TabArea.Width + 1;
> int nDelta = SystemInformation.Border3DSize.Width;
> TabArea.Inflate(nDelta, nDelta);
> render.DrawBackground(g, TabArea);
> }
> }
>
> Build the project and drag MyTabControl from Toolbox on your form. You add
> only one TabPage on the MyTabControl control and then add some controls
> you'd like on the TabPage.
>
> Hope this helps.
> If you have anything unclear, please feel free to let me know.
>
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom container control with limited container region mnuckols@gmail.com Microsoft C# .NET 1 27th Aug 2007 05:01 PM
VisualStyles in DeskBands =?Utf-8?B?RGFpc3VrZQ==?= Microsoft Dot NET Framework 0 25th Aug 2005 06:31 PM
Disable XP VisualStyles =?Utf-8?B?QWx2byB2b24gQ29zc2VsIEk=?= Microsoft C# .NET 0 17th Jul 2005 09:25 AM
How to determine minimum size of a container to show all controls in the container? John Microsoft Dot NET Framework Forms 1 26th Aug 2004 05:37 PM
Make Container UserControl force controls to be added to a child container control Codemonkey Microsoft Dot NET Framework Forms 2 21st Nov 2003 08:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:12 PM.