在StatusBar中重绘ProgressBar [英] Redraw ProgressBar in StatusBar

查看:81
本文介绍了在StatusBar中重绘ProgressBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在进度条运行时调整窗体大小(放大)

矩形图形不会到达矩形的末尾?


我有一个带有一个按钮的表单,一个状态栏有三个状态栏面板


这是帮助的代码


那里有什么问题?


#Region" ProgressBar"

公共结构进度面板


Dim x As Integer


Dim y As Integer


昏暗宽度为整数


昏暗高度为整数


结束结构


Dim pb As Drawing.Drawing2D.LinearGradientBrush


Dim myProgressPanel作为progresspanel


Dim g As Graphics


Dim rect As Rectangle


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs)处理Button1.Click


Dim t As New Threading.Thread(AddressOf progress)


t.Start()


End Sub


Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As

System.Windows.Forms.StatusBarDrawItemEventArgs)处理StatusBar1.DrawItem

myProgressPanel.x = sbdevent.Bounds.X


myProgressPanel.y = sbdevent.Bounds.Y


myProgressPanel.Width = sbdevent.Bounds.Width

myProgressPanel。高度= sbdevent.Bounds.Height


结束子


私有子StatusBar1_Resize(ByVal发送者为对象,ByVal e As

System.EventArgs)处理StatusBar1.Resize


StatusBar1.Invalidate(rect)


End Sub

子进度()


Dim i,j,w作为整数


j = 10000

g = Me.StatusBar1.CreateGraphics


对于i = 0到j


w = CInt((myProgressPanel.Width / j )* i)


如果w = 0那么w = 1


rect =新矩形(myProgressPanel.x,myProgressPanel.y,w,

myProgressPanel.Height)


pb =新Drawing.Drawing2D.LinearGradientBrush(rect,Color.AntiqueWhite,

Color.LightBlue,Drawing.Drawing2D.LinearGradientMode.Vertical)


g.FillRectangle(pb, rect)


g.DrawString(w.ToString,New Font(" Arial",10,FontStyle.Regular,

GraphicsUnit.Point),New SolidBrush(Color.Red),myProgressPanel.x,

myProgressPanel.y)

Me.StatusBar1.Panels(0).Text = w.ToString


下一页


Me.StatusBar1.Panels(0).Text =" 0"


g.Flush()


结束子


#End Region

解决方案
"尼古拉斯" < NL ***** @ hotmail.com> schrieb

当我在进度条运行时调整窗体大小(放大)
矩形绘图不会到达矩形的末尾?

我得到了一个带有一个按钮的表单,一个带有三个状态栏的状态栏

这是帮助的代码

那里有什么问题?
[code]




我尝试了你的代码,但我无法重现这个问题。我可以在另一个线程中绘制

面板的过程中调整窗体大小

(调整停靠状态栏的大小)(调整面板大小),面板总是完全填充。 />
-

Armin


重新产生我得到的错误:


1)启动应用程序(不应该最大化) - (如果全屏启动

没问题)

2)按下按钮启动进度条

3)当进度条递增时,抓住表格的右侧

广泛拉伸表格然后在进度条前释放鼠标

停止。进度条计数器仍然应该递增(指示状态栏面板的宽度

),但绘图不再是他的

原始最大宽度而不是结束小组。


感谢您的帮助,如果您发现任何内容



" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

news:uo ************* @tk2msftngp13.phx.gbl ...

" Nicolas" < NL ***** @ hotmail.com> schrieb

当我在进度条运行时调整窗体大小(放大)
矩形绘图不会到达矩形的末尾?

我得到了一个带有一个按钮的表单,一个带有三个状态栏的状态栏

这是帮助的代码

那里有什么问题?
[code] <我尝试了你的代码,但我无法重现这个问题。我可以在另一个线程中绘制
面板时调整



表格(调整停靠状态栏的大小(调整面板大小)),面板总是完全填满。 />
-
Armin





我知道这对我们没有帮助你但是我想请你帮我做一个

进度条吧。我需要制作一个弹出进度条(在表格上),这将显示文件下载的进度。


你可以帮助我。


谢谢,

-

Dino Buljubasic

软件开发人员
http://rivusglobal.com


" Nicolas" < NL ***** @ hotmail.com>在消息中写道

news:eK ************* @tk2msftngp13.phx.gbl ...

当我调整大小时(放大)进度条运行时的形状
矩形图不会到达矩形的末尾?

我有一个带有一个按钮的表单,一个带有三个状态栏的状态栏

以下是帮助代码

那里有什么问题?

#Region" ProgressBar"

Public Structure progresspanel

Dim x As Integer

Dim y As Integer

昏暗的宽度为整数

昏暗的高度为整数

结束结构

Dim pb As Drawing.Drawing2D.LinearGradientBrush

Dim myProgressPanel作为进度面板

Dim g As Graphics

Dim rect As Rectangle

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理Button1.Click

Dim t As New Threading.Thread(AddressOf progress)

t.Start()

End Sub

Private Sub StatusBar1_DrawItem(ByVal sender As Object,ByVal sbdevent As / / System.Windows.Forms.StatusBarDrawItemEventArgs)处理
StatusBar1.DrawItem
myProgressPanel.x = sbdevent.Bounds.X

myProgressPanel.y = sbdevent.Bounds.Y

myProgressPanel.Width = sbdevent.Bounds.Width

myProgressPanel.Height = sbdevent.Bounds.Height

End Sub

私有子StatusBar1_Resize(ByVal发送者为对象,ByVal e As
System.EventArgs)处理StatusBar1.Resize

StatusBar1.Invalidate(rect)

结束子

子进度()

Dim i,j,w as Integer

j = 10000

g = Me.StatusBar1.CreateGraphics

对于i = 0到j

w = CInt((myProgressPanel.Width / j)* i)

如果w = 0那么w = 1

rect = New Rectangle(myProgressPanel.x,myProgressPanel.y,w,
myProgressPanel.Height)

pb =新画ing.Drawing2D.LinearGradientBrush(rect,Color.AntiqueWhite,
Color.LightBlue,Drawing.Drawing2D.LinearGradientMode.Vertical)

g.FillRectangle(pb,rect)

g.DrawString(w.ToString,New Font(" Arial",10,FontStyle.Regular,
GraphicsUnit.Point),New SolidBrush(Color.Red),myProgressPanel.x,
myProgressPanel .y)

Me.StatusBar1.Panels(0).Text = w.ToString

下一页

Me.StatusBar1.Panels(0) .Text =" 0"

g.Flush()

End Sub

#End Region



When I resize (Enlarge) the form while the progress bar is running the
rectangle drawing is not going to the end of the rectangle?

I got a form with one button, one statusbar with three statusbarpanel

Here is the code for help

What is wrong there?

#Region "ProgressBar"

Public Structure progresspanel

Dim x As Integer

Dim y As Integer

Dim Width As Integer

Dim Height As Integer

End Structure

Dim pb As Drawing.Drawing2D.LinearGradientBrush

Dim myProgressPanel As progresspanel

Dim g As Graphics

Dim rect As Rectangle

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim t As New Threading.Thread(AddressOf progress)

t.Start()

End Sub

Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As
System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem

myProgressPanel.x = sbdevent.Bounds.X

myProgressPanel.y = sbdevent.Bounds.Y

myProgressPanel.Width = sbdevent.Bounds.Width

myProgressPanel.Height = sbdevent.Bounds.Height

End Sub

Private Sub StatusBar1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles StatusBar1.Resize

StatusBar1.Invalidate(rect)

End Sub

Sub progress()

Dim i, j, w As Integer

j = 10000

g = Me.StatusBar1.CreateGraphics

For i = 0 To j

w = CInt((myProgressPanel.Width / j) * i)

If w = 0 Then w = 1

rect = New Rectangle(myProgressPanel.x, myProgressPanel.y, w,
myProgressPanel.Height)

pb = New Drawing.Drawing2D.LinearGradientBrush(rect, Color.AntiqueWhite,
Color.LightBlue, Drawing.Drawing2D.LinearGradientMode.Vertical)

g.FillRectangle(pb, rect)

g.DrawString(w.ToString, New Font("Arial", 10, FontStyle.Regular,
GraphicsUnit.Point), New SolidBrush(Color.Red), myProgressPanel.x,
myProgressPanel.y)

Me.StatusBar1.Panels(0).Text = w.ToString

Next

Me.StatusBar1.Panels(0).Text = "0"

g.Flush()

End Sub

#End Region

解决方案

"Nicolas" <nl*****@hotmail.com> schrieb

When I resize (Enlarge) the form while the progress bar is running
the rectangle drawing is not going to the end of the rectangle?

I got a form with one button, one statusbar with three
statusbarpanel

Here is the code for help

What is wrong there?
[code]



I tried your code but I can not reproduce the problem. I can resize the form
(resizing the docked statusbar (resizing the panel)) during painting the
panel in the other thread and the panel is always filled completely.
--
Armin


To rreproduce the error that I got:

1) launch the application (should not be maximized) - (if launch full screen
no problem)
2) press the button to start the progress bar
3) while the progress bar is incrementing, grab the right side of the form
to strech widely the form then release the mouse before the progressbar
stop. The progress bar counter should still increment (indicating the width
of the statusbarpanel) but the drawing is not going anyfurther then his
original maximum width instead of going to the end of the panel.

Thank you for your help if you find anything


"Armin Zingler" <az*******@freenet.de> wrote in message
news:uo*************@tk2msftngp13.phx.gbl...

"Nicolas" <nl*****@hotmail.com> schrieb

When I resize (Enlarge) the form while the progress bar is running
the rectangle drawing is not going to the end of the rectangle?

I got a form with one button, one statusbar with three
statusbarpanel

Here is the code for help

What is wrong there?
[code]
I tried your code but I can not reproduce the problem. I can resize the


form (resizing the docked statusbar (resizing the panel)) during painting the
panel in the other thread and the panel is always filled completely.
--
Armin



Hi,
I know this is not of help to you but I''d like to ask you help me make a
progress bar. I need to make a pop up progress bar (on a form) that will
show progress of a file download.

Can you help me with that.

Thanks,
--
Dino Buljubasic
Software Developer
http://rivusglobal.com

"Nicolas" <nl*****@hotmail.com> wrote in message
news:eK*************@tk2msftngp13.phx.gbl...

When I resize (Enlarge) the form while the progress bar is running the
rectangle drawing is not going to the end of the rectangle?

I got a form with one button, one statusbar with three statusbarpanel

Here is the code for help

What is wrong there?

#Region "ProgressBar"

Public Structure progresspanel

Dim x As Integer

Dim y As Integer

Dim Width As Integer

Dim Height As Integer

End Structure

Dim pb As Drawing.Drawing2D.LinearGradientBrush

Dim myProgressPanel As progresspanel

Dim g As Graphics

Dim rect As Rectangle

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim t As New Threading.Thread(AddressOf progress)

t.Start()

End Sub

Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As
System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem
myProgressPanel.x = sbdevent.Bounds.X

myProgressPanel.y = sbdevent.Bounds.Y

myProgressPanel.Width = sbdevent.Bounds.Width

myProgressPanel.Height = sbdevent.Bounds.Height

End Sub

Private Sub StatusBar1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles StatusBar1.Resize

StatusBar1.Invalidate(rect)

End Sub

Sub progress()

Dim i, j, w As Integer

j = 10000

g = Me.StatusBar1.CreateGraphics

For i = 0 To j

w = CInt((myProgressPanel.Width / j) * i)

If w = 0 Then w = 1

rect = New Rectangle(myProgressPanel.x, myProgressPanel.y, w,
myProgressPanel.Height)

pb = New Drawing.Drawing2D.LinearGradientBrush(rect, Color.AntiqueWhite,
Color.LightBlue, Drawing.Drawing2D.LinearGradientMode.Vertical)

g.FillRectangle(pb, rect)

g.DrawString(w.ToString, New Font("Arial", 10, FontStyle.Regular,
GraphicsUnit.Point), New SolidBrush(Color.Red), myProgressPanel.x,
myProgressPanel.y)

Me.StatusBar1.Panels(0).Text = w.ToString

Next

Me.StatusBar1.Panels(0).Text = "0"

g.Flush()

End Sub

#End Region



这篇关于在StatusBar中重绘ProgressBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆