Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
GeneralRe: Strange GDI+ error Pin
leppie31-Mar-04 6:21
leppie31-Mar-04 6:21 
General.NET Remoting Pin
Prasad Anand30-Mar-04 18:29
Prasad Anand30-Mar-04 18:29 
GeneralRe: .NET Remoting Pin
Heath Stewart31-Mar-04 3:42
protectorHeath Stewart31-Mar-04 3:42 
GeneralKey Press Pin
DucLinh30-Mar-04 14:54
DucLinh30-Mar-04 14:54 
GeneralRe: Key Press Pin
Charlie Williams30-Mar-04 16:02
Charlie Williams30-Mar-04 16:02 
Generalreading from sqldatareader Pin
pgraeve30-Mar-04 14:39
pgraeve30-Mar-04 14:39 
GeneralRe: reading from sqldatareader Pin
Heath Stewart30-Mar-04 16:42
protectorHeath Stewart30-Mar-04 16:42 
QuestionWhy do my graphics still flicker? Pin
adonisv30-Mar-04 14:30
adonisv30-Mar-04 14:30 
Why won't this double buffer? Sigh | :sigh:

I'm drawing this graph that allows you to either move value sliders or input values and redraw the graph. I've looked at tons of double buffering examples and they all seem to be doing the same or similar type of code. But my graph still flickers. BAH! Cry | :((

[code]public void DrawGraph()
{
this.UpdateGraphVariables();
Point[] pointarray=new Point[5];
Pen newpen = new Pen(Color.Black);

this.m_bmImageOffScreen = new Bitmap(this.Width, this.Height);
this.m_gOffScreen = Graphics.FromImage(this.m_bmImageOffScreen);
this.m_gBuffer=Graphics.FromHwnd(this.Handle);



//computational stuff
//not interesting

I do all my drawing on the bitmap...
//Set point of origin to be 50,50 on the form
this.m_gOffScreen.TranslateTransform(50,130);
this.m_gOffScreen.DrawLine(newpen,1,1,1,150);
this.m_gOffScreen.DrawLine(newpen,1,150,150,150);

//Draw X and y axis
this.m_gOffScreen.DrawLine(newpen,-3,30,3,30);
this.m_gOffScreen.DrawLine(newpen,-3,60,3,60);
this.m_gOffScreen.DrawLine(newpen,-3,90,3,90);
...


//Join the points
pointarray[0]=new Point(30,Convert.ToInt32(a));
pointarray[1]=new Point(60,Convert.ToInt32(b));
pointarray[2]=new Point(90,Convert.ToInt32(c));
pointarray[3]=new Point(120,Convert.ToInt32(d));
pointarray[4]=new Point(150,Convert.ToInt32(f));
this.m_gOffScreen.DrawLines(new Pen(Color.Yellow),pointarray);

Then I attempt to double buffer! D'Oh! | :doh:

if (this.m_bmOldBitmap != null)
{
this.m_bmOldBitmap.Dispose();
}

this.m_bmOldBitmap = this.m_bmImageOffScreen;
this.m_gBuffer.Clear(this.BackColor);

this.m_gBuffer.DrawImage(this.m_bmOldBitmap,30,50);
}[/code]

It still flickers! Dead | X|
AnswerRe: Why do my graphics still flicker? Pin
Roman Rodov30-Mar-04 14:37
Roman Rodov30-Mar-04 14:37 
GeneralRe: Why do my graphics still flicker? Pin
adonisv30-Mar-04 14:40
adonisv30-Mar-04 14:40 
GeneralRe: Why do my graphics still flicker? Pin
Heath Stewart30-Mar-04 16:44
protectorHeath Stewart30-Mar-04 16:44 
GeneralRe: Why do my graphics still flicker? Pin
adonisv31-Mar-04 16:36
adonisv31-Mar-04 16:36 
AnswerRe: Why do my graphics still flicker? Pin
blackthunder00130-Mar-04 14:41
blackthunder00130-Mar-04 14:41 
GeneralRe: Why do my graphics still flicker? Pin
adonisv30-Mar-04 14:59
adonisv30-Mar-04 14:59 
AnswerRe: Why do my graphics still flicker? Pin
Anonymous30-Mar-04 20:11
Anonymous30-Mar-04 20:11 
GeneralI call Invalidate() Pin
adonisv31-Mar-04 16:43
adonisv31-Mar-04 16:43 
Questionhandling multiple connections? Pin
Anonymous30-Mar-04 12:21
Anonymous30-Mar-04 12:21 
AnswerRe: handling multiple connections? Pin
Heath Stewart30-Mar-04 12:54
protectorHeath Stewart30-Mar-04 12:54 
GeneralIDisposable Pin
blackthunder00130-Mar-04 10:01
blackthunder00130-Mar-04 10:01 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 10:17
protectorHeath Stewart30-Mar-04 10:17 
GeneralRe: IDisposable Pin
blackthunder00130-Mar-04 14:32
blackthunder00130-Mar-04 14:32 
GeneralRe: IDisposable Pin
Heath Stewart30-Mar-04 16:24
protectorHeath Stewart30-Mar-04 16:24 
QuestionHow do i import/use these dll's ? Pin
mihaimarinescu30-Mar-04 8:53
mihaimarinescu30-Mar-04 8:53 
AnswerRe: How do i import/use these dll's ? Pin
Heath Stewart30-Mar-04 9:38
protectorHeath Stewart30-Mar-04 9:38 
AnswerRe: How do i import/use these dll's ? Pin
Dave Kreskowiak30-Mar-04 9:39
mveDave Kreskowiak30-Mar-04 9:39 

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.