This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Michael Kelsey |
Is this doable? I want to create an IE-like status bar that contains a progress bar. Any hints?
Thanks, MichaelK
|
|
|
| |
|
| |
| |
| Jacob Grass \(MVP\) (VIP) |
Yup. Here you are (I tried to accomodate for wrapping, but may have missed a little):
Option Strict On
Imports System.Windows.Forms Imports System.Drawing
Public Class ProgressStatusBar Inherits StatusBar
Public Sub New() MyBase.New() Me.SizingGrip = False Me.ShowPanels = True End Sub
Protected Overrides Sub OnDrawItem( _ ByVal e As StatusBarDrawItemEventArgs)
If e.Panel.GetType Is Type.GetType( _ "ProgressStatusBarExample.ProgressPanel") Then
Dim ProgressPanel As ProgressPanel = _ CType(e.Panel, ProgressPanel)
If ProgressPanel.Value > ProgressPanel.Minimum Then Dim NewWidth As Integer = _ CType(((ProgressPanel.Value / ProgressPanel.Maximum _ ) * ProgressPanel.Width), Integer)
Dim NewBounds As Rectangle = e.Bounds Dim PaintBrush As New SolidBrush(ProgressPanel.ForeColor)
NewBounds.Width = NewWidth e.Graphics.FillRegion(PaintBrush, New [Region](NewBounds)) PaintBrush.Dispose() Else MyBase.OnDrawItem(e) End If Else MyBase.OnDrawItem(e) End If End Sub
End Class
Public Class ProgressPanel Inherits StatusBarPanel
Private m_Minimum As Integer = 1 Private m_Maximum As Integer = 100 Private m_Value As Integer = 0 Private m_Step As Integer = 1
Public Sub New() MyBase.New() Me.Style = StatusBarPanelStyle.OwnerDraw End Sub
Public Sub PerformStep() Me.Value += Me.Step End Sub
Public Sub Increment(ByVal Amount As Integer) Me.Value += Amount End Sub
Public Property [Step]() As Integer Get Return m_Step End Get Set(ByVal Value As Integer) m_Step = Value End Set End Property
Public Property Minimum() As Integer Get Return m_Minimum End Get Set(ByVal Value As Integer) m_Minimum = Value End Set End Property
Public Property Maximum() As Integer Get Return m_Maximum End Get Set(ByVal Value As Integer) m_Maximum = Value End Set End Property
Public Property Value() As Integer Get Return m_Value End Get Set(ByVal Value As Integer) m_Value = Value Me.Parent.Refresh() End Set End Property
Private m_Color As Color = Color.Black
Public Property ForeColor() As Color Get Return m_Color End Get Set(ByVal Value As Color) m_Color = Value End Set End Property
End Class
-- Jacob Grass Microsoft .NET MVP
"Michael Kelsey" <Click here to reveal e-mail address> wrote in message news:OjarkI$wBHA.2552@tkmsftngp04... [Original message clipped]
|
|
|
| |
|
|
| |
|
| |
| bobh |
Whenever this question is asked, Jacob always answers faster than me.
Better late than never, here is the C# version:
/////////////////////////////
// application level
ProgressStatusBar psb;
ProgressPanel pp;
public Form1() {
...
pp = new ProgressPanel();
pp.AutoSize = StatusBarPanelAutoSize.Spring;
psb = new ProgressStatusBar();
psb.Parent = this;
psb.Panels.AddRange(new ProgressPanel[] {pp});
ResizeRedraw = true;
this.Controls.Add(psb);
}
//////////////////////////////
private void button1_Click(object sender, System.EventArgs e)
{
psb.UpdateValue(pp, pp.Value+10);
Invalidate(true);
}
[Original message clipped]
"Michael Kelsey" <Click here to reveal e-mail address> wrote in message news:OjarkI$wBHA.2552@tkmsftngp04... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Jacob Grass \(MVP\) (VIP) |
[Original message clipped]
LOL.
Next time I see the question, I'll pause for a bit so you get the glory :-)
-- Jacob Grass Microsoft .NET MVP
|
|
|
| |
|
|
| |
| |
| bobh |
No, that's o.k. Anyway, I am so ready for the next "MessageBeep()" question. I keep the "complete" MessageBeep() answer on my clipboard.
"Jacob Grass (MVP)" <Click here to reveal e-mail address> wrote in message news:eTRl8aTxBHA.1188@tkmsftngp07... [Original message clipped]
|
|
|
| |
|
| |
|
|
|
| |
| Bo Dagnall |
Here's a very simple solution to your problem. I borrowed VB.Net code from a developer named Matthew Hazlett. This is the link to the VB code: http://codeproject.com/vb/net/ProgressStatus.asp. I rewrote it in C# below:
<pre> using System; using System.Windows.Forms;
namespace XXXX { /// <summary> /// Summary description for ProgressStatus. /// </summary> public class ProgressStatus : StatusBar { public ProgressBar progressBar = new ProgressBar(); private int panelWithProgressBar = -1;
public ProgressStatus() { progressBar.Hide(); this.Controls.Add(progressBar); this.SizingGrip = false; this.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.ProgressStatus_DrawItem); }
public int setProgressBar { get { return panelWithProgressBar; } set { panelWithProgressBar = value; this.Panels[panelWithProgressBar].Style = StatusBarPanelStyle.OwnerDraw; } }
private void ProgressStatus_DrawItem(object sender, StatusBarDrawItemEventArgs sbdevent) { progressBar.Location = new System.Drawing.Point(sbdevent.Bounds.X, sbdevent.Bounds.Y); progressBar.Size = new System.Drawing.Size(sbdevent.Bounds.Width, sbdevent.Bounds.Height); progressBar.Show(); } } } </pre>
Here's the code to implement it: <pre> private void Form1_Load(object sender, System.EventArgs e) { StatusBarPanel pnlInfo = new StatusBarPanel(); StatusBarPanel pnlProgress = new StatusBarPanel();
pnlInfo.Text = "this is text"; pnlInfo.Width = 100; pnlProgress.AutoSize = StatusBarPanelAutoSize.Spring;
StatusBarControl.Panels.Add(pnlInfo); StatusBarControl.Panels.Add(pnlProgress); StatusBarControl.ShowPanels = true; StatusBarControl.setProgressBar = 1;
this.Controls.Add(StatusBarControl); } </pre>
Hope this helps. -Bo Dagnall -------------------------------- From: Bo Dagnall
-------------------------------- From: Bo Dagnall
|
|
|
| |
|
|
| |
|
|
|
|
|