Hello!
I'm writing user control, the custom progress bar. It should show current
position, when application is playing an MP3 file. The problem is that
sometimes, when it redraws itself, it flickers undesirably, spoiling all the
impression. I can not find any regularity in its behaviour. It moves
smoothly, then suddenly flickers, and continues moving.
Here is the fragment of my code:
Private Sub PlayingSlideBar_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim Middle As Integer = GetMiddle(CurrentTime.Ticks) 'GetMiddle()
returns current position of the crawler
Dim MiddleRectangle As New Rectangle(Middle - 5, 0, 10, Height)
e.Graphics.FillRectangle(New SolidBrush(LColor), New Rectangle(0, 0,
Middle - 5, Height))
e.Graphics.FillRectangle(New SolidBrush(RColor), New Rectangle(Middle +
5, 0, Width, Height)) 'LColor and RColor are properties of a control
e.Graphics.FillRectangle(New
Drawing2D.LinearGradientBrush(MiddleRectangle, LColor, RColor,
Drawing2D.LinearGradientMode.Horizontal), MiddleRectangle)
If Border > 0 Then e.Graphics.DrawRectangle(New Pen(Color.Black,
(Border - 1) * 2 + 1), New Rectangle(0, 0, Width - 1, Height - 1))
e.Dispose()
End Sub
Public Property TimeNow() As TimeSpan 'it represents current value
Get
Return CurrentTime 'CurrentTime is internal variable
End Get
Set(ByVal Value As TimeSpan)
Dim OldValueTicks As Long = CurrentTime.Ticks
If Value.Ticks < TrackLength.Ticks Then CurrentTime = Value Else CurrentTime
= TrackLength
If GetMiddle(Value.Ticks) <> GetMiddle(OldValueTicks) Then Refresh()
End Set
End Property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Maybe, I'm doing something wrong? 4 1418
There is a progress bar control you know? But otherwise, the reason it
flickers is probably because you are not double buffering it. Create a
bitmap, render to it and then blit the bitmap to the coordinates, rather
than drawing directly onto the e.Graphics context.
"Dragon" <dr****@rol.ru> wrote in message news:d8**********@news.rol.ru... Hello! I'm writing user control, the custom progress bar. It should show current position, when application is playing an MP3 file. The problem is that sometimes, when it redraws itself, it flickers undesirably, spoiling all the impression. I can not find any regularity in its behaviour. It moves smoothly, then suddenly flickers, and continues moving. Here is the fragment of my code:
Private Sub PlayingSlideBar_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint Dim Middle As Integer = GetMiddle(CurrentTime.Ticks) 'GetMiddle() returns current position of the crawler Dim MiddleRectangle As New Rectangle(Middle - 5, 0, 10, Height) e.Graphics.FillRectangle(New SolidBrush(LColor), New Rectangle(0, 0, Middle - 5, Height)) e.Graphics.FillRectangle(New SolidBrush(RColor), New Rectangle(Middle + 5, 0, Width, Height)) 'LColor and RColor are properties of a control e.Graphics.FillRectangle(New Drawing2D.LinearGradientBrush(MiddleRectangle, LColor, RColor, Drawing2D.LinearGradientMode.Horizontal), MiddleRectangle) If Border > 0 Then e.Graphics.DrawRectangle(New Pen(Color.Black, (Border - 1) * 2 + 1), New Rectangle(0, 0, Width - 1, Height - 1)) e.Dispose() End Sub
Public Property TimeNow() As TimeSpan 'it represents current value
Get Return CurrentTime 'CurrentTime is internal variable End Get
Set(ByVal Value As TimeSpan) Dim OldValueTicks As Long = CurrentTime.Ticks If Value.Ticks < TrackLength.Ticks Then CurrentTime = Value Else CurrentTime = TrackLength If GetMiddle(Value.Ticks) <> GetMiddle(OldValueTicks) Then Refresh() End Set
End Property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Maybe, I'm doing something wrong?
Will you next time please set your datetime and location to the right one
before you sent a message to this newsgroup.
Thanks
Cor
> blit the bitmap to the coordinates, rather than drawing directly onto the e.Graphics context.
Do you mean "e.Graphics.DrawImage(myBitmap, 0, 0)"? I've already tried this,
but it does not solve the problem, it only slows redrawing down instead. Is
there another way?
~~~
I am very sorry for invalid date. I've just noticed it was wrong.
You still need to tell it you are doublebuffering so that it wont raise the
PaintBackground event. You need to use SetStyle to make it double buffer,
and there are 3 things. DoubleBuffer, AllPaintingInWMPaint, and UserPaint.
"Dragon" <no@spam.please> wrote in message news:d8**********@news.rol.ru... blit the bitmap to the coordinates, rather than drawing directly onto the e.Graphics context.
Do you mean "e.Graphics.DrawImage(myBitmap, 0, 0)"? I've already tried this, but it does not solve the problem, it only slows redrawing down instead. Is there another way?
~~~ I am very sorry for invalid date. I've just noticed it was wrong. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BestNews |
last post by:
Hi,
I used an ActiveX control in C# client Application . I have
created 'n' number of ActiveX controls on the UserControl. After user
interaction some of the activeX control have to be refreshed...
|
by: Joaquin Grech |
last post by:
Hi
I did alot of research on this on the web and msdn and I couldn't find
anything.
I have a listview showing as a grid (table looking, with rows and columns
and no images at all, only text)....
|
by: Jack Smash |
last post by:
Hi,
I'm using a UserControl object for all the graphics handling in my
application. However, if I select an image and move it around, I get
flickering. So in order to get rid of the flickering,...
|
by: John Lee |
last post by:
Hi,
I have a windows application that uses the listview to display about 50
items in detailed view - 4 columns. The first column is static and other
columns will be updated in 100-1000ms - it...
|
by: John Lee |
last post by:
Thanks Jay for your response.
I tried your code and it still flickering a lot. To demonstrate it, you can
grab a listview, create 3 columns - name, value, timestamp, in form_load
event to add 50...
| |
by: Brian Henry |
last post by:
I created a smooth progress bar with this code.. but if you update the
values in a row quickly of it and watch it on screen it flickers... how
would i change this to reduce the flickering?...
|
by: Jim Hubbard |
last post by:
Has anyone seen a fix for the flickering effect you get when resizing a
Webbrowser control?
It's really irritating and doesn't make for a professional-looking
application.
|
by: n00b |
last post by:
I have some forms with maybe around 30 controls on each and anytime I load
these forms different parts of it start flickering though not all of them at
once and not the same ones everytime. the...
|
by: Mark Thompson |
last post by:
I have a problem with my Visual Basic .NET 2003 application which I
have so far been unable to resolve.
I am trying to get an OpenGL control that I have created working
properly as a control on...
|
by: kulabhishek |
last post by:
Hello all.
I have developed one user control "Grid" in C# and I am using it in another user control inside one panel.
The AutoScroll property for the panel is enabled.
When the height or...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |