Click here to Skip to main content
15,887,942 members
Home / Discussions / C#
   

C#

 
GeneralRe: version numbers Pin
Michael Flanakin24-Mar-04 6:50
Michael Flanakin24-Mar-04 6:50 
GeneralRe: version numbers Pin
surgeproof24-Mar-04 7:15
surgeproof24-Mar-04 7:15 
GeneralRe: version numbers Pin
Heath Stewart24-Mar-04 8:55
protectorHeath Stewart24-Mar-04 8:55 
GeneralRe: version numbers Pin
surgeproof24-Mar-04 9:19
surgeproof24-Mar-04 9:19 
GeneralRe: version numbers Pin
Michael Flanakin24-Mar-04 10:32
Michael Flanakin24-Mar-04 10:32 
QuestionTransparent Label on a Progressbar? Pin
DennisMetz24-Mar-04 5:54
DennisMetz24-Mar-04 5:54 
AnswerRe: Transparent Label on a Progressbar? Pin
surgeproof24-Mar-04 6:24
surgeproof24-Mar-04 6:24 
AnswerRe: Transparent Label on a Progressbar? Pin
Heath Stewart24-Mar-04 9:54
protectorHeath Stewart24-Mar-04 9:54 
If your goal is display a message while the progress bar increments (like the percentage, which was common with older controls), you might be better off just extending the existing ProgressBar and provide your own painting by overridding OnPaint (do your drawing after calling base.OnPaint to make sure that the progress bar itself is draw first and your code gets drawn on top of it).

Getting the label to be transparent actually has to do with the parent forum in which it's contained. This only works in Win2K and newer (i.e., XP, 2003) since it uses layered Windows, "Windows" (or forms, dialogs) being the optimal word. A transparent color or alpha value is specified for the form an any control that uses the same color (ambience) down the chain of child controls is transparent/translucent as well. Since the ProgressBar is not a form and would paint in different colors anyway, that's one problem (the reasons go deeper, but I won't get into that).

Your painting method could be as simple as:
protected override void OnPaint(PaintEventArgs e)
{
  base.OnPaint(e);
 
  int value = (int)(Value / Maximum);
  string s = value + "%";
 
  StringFormat format = StringFormat.GenericTypographic;
  format.Alignment = StringAlignment.Center;
 
  e.Graphics.DrawString(value + "%", Font, SystemBrushes.ControlText,
    (RectangleF)Bounds, format);
}
This is untested, but should work and at least give you some ideas.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Transparent Label on a Progressbar? Pin
DennisMetz24-Mar-04 11:40
DennisMetz24-Mar-04 11:40 
GeneralApps without Mice Pin
Andrew Torrance24-Mar-04 5:43
Andrew Torrance24-Mar-04 5:43 
GeneralRe: Apps without Mice Pin
surgeproof24-Mar-04 6:15
surgeproof24-Mar-04 6:15 
GeneralRe: Apps without Mice Pin
Colin Angus Mackay24-Mar-04 6:25
Colin Angus Mackay24-Mar-04 6:25 
GeneralRe: Apps without Mice Pin
Heath Stewart24-Mar-04 9:12
protectorHeath Stewart24-Mar-04 9:12 
Questionhow to wrap some dll functions from VC6 Pin
yyf24-Mar-04 5:37
yyf24-Mar-04 5:37 
AnswerRe: how to wrap some dll functions from VC6 Pin
Heath Stewart24-Mar-04 9:08
protectorHeath Stewart24-Mar-04 9:08 
GeneralRe: how to wrap some dll functions from VC6 Pin
yyf24-Mar-04 10:23
yyf24-Mar-04 10:23 
GeneralRe: how to wrap some dll functions from VC6 Pin
Heath Stewart24-Mar-04 11:19
protectorHeath Stewart24-Mar-04 11:19 
GeneralProperty Sheet Pin
DrGreen24-Mar-04 4:41
DrGreen24-Mar-04 4:41 
GeneralRe: Property Sheet Pin
Heath Stewart24-Mar-04 4:50
protectorHeath Stewart24-Mar-04 4:50 
GeneralRe: Property Sheet Pin
DrGreen24-Mar-04 5:08
DrGreen24-Mar-04 5:08 
GeneralRe: Property Sheet Pin
Heath Stewart24-Mar-04 5:13
protectorHeath Stewart24-Mar-04 5:13 
GeneralRe: Property Sheet Pin
DrGreen24-Mar-04 5:27
DrGreen24-Mar-04 5:27 
GeneralTreeview context menu remains visible Pin
CStiefeling24-Mar-04 4:26
CStiefeling24-Mar-04 4:26 
GeneralRe: Treeview context menu remains visible Pin
CStiefeling24-Mar-04 4:35
CStiefeling24-Mar-04 4:35 
GeneralRegistry Entry Pin
Guinness4Strength24-Mar-04 3:12
Guinness4Strength24-Mar-04 3:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.