|
-
Mar 9th, 2003, 03:04 PM
#1
Thread Starter
Member
BackBuffering ! =)
Hi !
Here's the Class for BackBuffering, It's easy. =)
Code:
Public Class IBackBuffer
Private mvarBitmap As System.Drawing.Bitmap
Private mvarBuffer As System.Drawing.Graphics
Private mvarGraphics As System.Drawing.Graphics
Private mvarForm As System.Windows.Forms.Form
Public Sub Connect(ByVal xForm As System.Windows.Forms.Form)
mvarForm = xForm
mvarGraphics = mvarForm.CreateGraphics
mvarBitmap = New Bitmap(mvarForm.Width, mvarForm.Height)
mvarBuffer = Graphics.FromImage(mvarBitmap)
End Sub
Public ReadOnly Property Graphics() As System.Drawing.Graphics
Get
Return mvarBuffer
End Get
End Property
Public Sub DoPainting()
mvarGraphics.DrawImage(mvarBitmap, 0, 0)
End Sub
End Class
This is how you use it:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xBackBuffer As New IBackBuffer()
'Connect BackBuffer Component to Form1
xBackBuffer.Connect(Form1)
'#############################
'Do Your Graphics Drawing Here
'#############################
'You Draw you graphics using xBackBuffer.Graphics
'xBackBuffer.Graphics.*
'#############################
'Finally, Flicker Free paint your graphics.
xBackBuffer.DoPainting()
End Sub
There you go. =)
-
Mar 9th, 2003, 03:08 PM
#2
Sleep mode
that's cool ,yeah cool .
what does it do btw?? .lol
-
Mar 9th, 2003, 03:12 PM
#3
Sleep mode
ooh that was related to the other post I guess . Thanx anyways .
-
Sep 11th, 2003, 07:57 AM
#4
yay gay
i am trying to put a owner drawn item in a panel that draws a progressbar......then i do some text proccessing and i want to use it...the problem is that when i use the progress bar in it the text work gets like 30% slower and even worse the panel progressbar flickers a lot! how do i prevent it from flickering?
\m/  \m/
-
Sep 11th, 2003, 08:09 AM
#5
I wonder how many charact
Are you drawing the ProgressBar (overriding the Paint event)?
If so, you should be able to do "double-buffering"...
Look up ControlStyles in your help index... and look for DoubleBuffering.
Me.SetStyles(ControlStyles.AllPaintinginWMPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
-
Sep 11th, 2003, 08:14 AM
#6
I wonder how many charact
-
Sep 11th, 2003, 08:47 AM
#7
yay gay
yes im going read it but in the mean time i have the following method of the status bar im inheriting:
Code:
protected override void OnDrawItem(StatusBarDrawItemEventArgs e) {
if (e.Panel.Style == StatusBarPanelStyle.OwnerDraw) {
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(SystemColors.ActiveCaptionText),
e.Bounds.X,
e.Bounds.Y,
GetPercentage(e.Bounds.Width),
e.Bounds.Height);
base.OnDrawItem (e);
}
}
sorry because its in c# but what should i change here? i tried to put ut string in the begginig and when i tried it the progress bar just shown ALL in the same color(the default one) without showing any panel
\m/  \m/
-
Sep 11th, 2003, 08:51 AM
#8
yay gay
bah the drawning error was my fault when converting the vb.net string to c# string....now it works but it does not any double buffering(at least it still flickers a lot)
what am i suposed to do?
\m/  \m/
-
Sep 11th, 2003, 09:07 AM
#9
I wonder how many charact
Ok, are you writing in C# or VB?
-
Sep 11th, 2003, 09:08 AM
#10
yay gay
c# but u can say things in vb.net or c# its the same i understand them boot lol
\m/  \m/
-
Sep 11th, 2003, 09:26 AM
#11
I wonder how many charact
Egh.. alright. Problems can arise because you have a form, a status bar, and a progress bar. So you basically have 3 controls that may at some point redraw themselves, and may invalidate themselves.
But from what I understand, you are invalidating just the progressbar, because you are writing text to its center, correct?
If so, the only real way I could help is to be able to look at that control class's source. And of course, if you are using .Net 2003, I probably will be out of luck.
So, try putting this in your progressbar constructor.
Code:
// Set the value of the double-buffering style bits to true.
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
Here's a reference... http://msdn.microsoft.com/library/de...styletopic.asp
http://msdn.microsoft.com/library/de...classtopic.asp
http://msdn.microsoft.com/library/de...ncontrols7.asp
Last edited by nemaroller; Sep 11th, 2003 at 09:33 AM.
-
Sep 11th, 2003, 09:31 AM
#12
yay gay
well i tried and it just doesnt paint all the status bar
\m/  \m/
-
Sep 11th, 2003, 09:36 AM
#13
I wonder how many charact
Could you upload the source for your progressbar?
-
Sep 11th, 2003, 09:36 AM
#14
yay gay
-
Sep 11th, 2003, 09:42 AM
#15
yay gay
hmm the project is a bit complex for me to upload but i can show the progressbar code:
Code:
public class ProgressBarStatusBar : StatusBar {
private int _progress = 0;
public int Progress {
get { return _progress;
} set {
if (value >= 0 && value <= 100) {
_progress = value;
Refresh();
}
}
}
public ProgressBarStatusBar() {
SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer, true);
UpdateStyles();
}
protected override void OnDrawItem(StatusBarDrawItemEventArgs e) {
if (e.Panel.Style == StatusBarPanelStyle.OwnerDraw) {
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(SystemColors.ActiveCaptionText),
e.Bounds.X,
e.Bounds.Y,
GetPercentage(e.Bounds.Width),
e.Bounds.Height);
base.OnDrawItem (e);
}
}
private int GetPercentage(int panelSize) {
return Convert.ToInt32(
(double)panelSize * (double)_progress / (double)100);
}
}
}
then..just add a statusbar to ur form and add an owner drawn item.
to put a value to the progressbar do the following:
((StatusBarProgressBar)statusBar1).Progress = 50;
\m/  \m/
-
Sep 11th, 2003, 03:25 PM
#16
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|