Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Go Back  Xtreme Visual Basic Talk > > > Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).


Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2012, 10:59 AM
priyamtheone priyamtheone is offline
Regular
 
Join Date: May 2008
Posts: 72
Question Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).


Ensure ApplyVisualStyles is enabled in your system. Place a ToolStripProgressBar on a toolstrip, run your application and minimize the form. Now change the theme of your computer to Windows Classic and restore the form. See the interior of the ToolStripProgrssBar becomes black. It doesn't even change if you refresh the form. How does the user know the status of the progress if it remains black always? Any approach to fugure it out? Regards.
Reply With Quote
  #2  
Old 08-04-2012, 02:12 PM
hDC_0Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 560
Default handling SystemEvents.UserPreferenceChanged and ToolStripItem.OnPaint method override

Have you tried using any code to handle the handle SystemEvents.UserPreferenceChanged event for e.Category=VisualStyle.
(and possibly change the progressbar.Style)

Some links:
Handling System Events in VB.Net

There is also some "Private Sub UserPreferenceChangedHandler" code on this StackOverFlow page.

Another option to try..
One of the ToolStripProgressBar methods is OnPaint, which
raises the Paint event (inherited from ToolStripControlHost).
MSDN has some ToolStripItem.OnPaint method overrides code.

Another way (which is little bit awkward) would be to redirect the ToolStripProgressBar increment calls
which from code at the bottom of this page might look like:
Code:
Private Sub incrementBar(ByVal pb As ToolStripProgressBar)
  pb.Increment(1)
  pb.ProgressBar.Refresh()

  Dim g As Graphics = pb.ProgressBar.CreateGraphics

  'draw custom custom graphics here..

  br.Dispose()
  g.Dispose()
End Sub
I believe this is based on VB.Net code to allow the percentage text of completion to be displayed on a .Net progress bar control
(which in turn is based on a C#.Net CodeProject "Extended ProgressBar" code, which has a longer explanation of the methodology designed toward creating a custom user control).

Lastly, have you had a chance to peruse the MSDN article:
"Rendering Controls with Visual Styles"?

The interesting (possibly relevant) part:
Quote:
Other classes can only draw the related control when visual styles are available,
and their members will throw an exception if visual styles are disabled. These classes include:
ProgressBarRenderer
If you click on the ProgressBarRenderer link above, that page contains the following info:
Quote:
If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows,
the methods of this class will draw the progress bar with the current visual style.
Otherwise, the methods and properties of this class will throw an InvalidOperationException.
To determine whether the members of this class can be used,
you can check the value of the IsSupported property.
..which bring up the question; Are you using any structured exception handling to test for visual styles?

Last edited by hDC_0; 08-04-2012 at 03:21 PM.
Reply With Quote
  #3  
Old 08-06-2012, 11:26 AM
priyamtheone priyamtheone is offline
Regular
 
Join Date: May 2008
Posts: 72
Thumbs up

Handling the Paint event doesn't work. Your first option seems to work the best. Thanks for a detailed post.
Reply With Quote
Reply

Tags
.net 4.0, csharp, visual basic 2010, visual studio 2010


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms). Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
 
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
Problem in ToolStripProgressBar painting (VS.Net 2010, WinForms).
 
-->