473,226 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Double Buffering and MyBase.OnPaint(pe)

Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed
up things and avoid flikkering using Double Buffering. To draw the normal
things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works fine,
but I think it should work better if my MyBase.OnPaint also painted in my
buffer.

Am I wrong? And how should I do this? I kind of need to link the pe-argument
to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc
'....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter
Jul 22 '05 #1
5 2380
Hi,

Why dont you use setstyle for the control to doublebuffer.

http://msdn.microsoft.com/library/de...styletopic.asp

Ken
----------------------
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed
up things and avoid flikkering using Double Buffering. To draw the normal
things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works fine,
but I think it should work better if my MyBase.OnPaint also painted in my
buffer.

Am I wrong? And how should I do this? I kind of need to link the pe-argument
to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc
'....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter

Jul 22 '05 #2
Hi,

I did that already. I based my solution to this:
www.bobpowell.net/doublebuffer.htm

although by relooking to it I think I'm having automatic and manual double
buffering together in my application, hehe :-)
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uo**************@tk2msftngp13.phx.gbl...
Hi,

Why dont you use setstyle for the control to doublebuffer.

http://msdn.microsoft.com/library/de...styletopic.asp
Ken
----------------------
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed
up things and avoid flikkering using Double Buffering. To draw the normal
things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works fine, but I think it should work better if my MyBase.OnPaint also painted in my
buffer.

Am I wrong? And how should I do this? I kind of need to link the pe-argument to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc
'....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter

Jul 22 '05 #3
Please, don't cross-post in irrelevant newsgroups (ado.net????).

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed
up things and avoid flikkering using Double Buffering. To draw the normal
things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works
fine,
but I think it should work better if my MyBase.OnPaint also painted in my
buffer.

Am I wrong? And how should I do this? I kind of need to link the
pe-argument
to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc
'....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter

Jul 22 '05 #4
I'm not sure but I think one disadvantage to the method you are using with
the _BackBuffer is that you are repainting the entire control each time the
paint event is fired rather than just the invalidated rectangle...depending
on what you are painting each time, maybe you have to do this.
--
Dennis in Houston
"DraguVaso" wrote:
Hi,

I did that already. I based my solution to this:
www.bobpowell.net/doublebuffer.htm

although by relooking to it I think I'm having automatic and manual double
buffering together in my application, hehe :-)
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uo**************@tk2msftngp13.phx.gbl...
Hi,

Why dont you use setstyle for the control to doublebuffer.

http://msdn.microsoft.com/library/de...styletopic.asp

Ken
----------------------
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed
up things and avoid flikkering using Double Buffering. To draw the normal
things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works

fine,
but I think it should work better if my MyBase.OnPaint also painted in my
buffer.

Am I wrong? And how should I do this? I kind of need to link the

pe-argument
to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc
'....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter


Jul 22 '05 #5
That's indeed a good remark. Although the Paint-event repaints every time
the whole DataGrid, so I need to repaint my stuff also each time :-/ it
should be nicer indeed if I could disable some things to be repainted, but
idon't know if something like that is possible or not.

with disabling the paint of the background I guess saved alreaddy some
time...

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
I'm not sure but I think one disadvantage to the method you are using with
the _BackBuffer is that you are repainting the entire control each time the paint event is fired rather than just the invalidated rectangle...depending on what you are painting each time, maybe you have to do this.
--
Dennis in Houston
"DraguVaso" wrote:
Hi,

I did that already. I based my solution to this:
www.bobpowell.net/doublebuffer.htm

although by relooking to it I think I'm having automatic and manual double
buffering together in my application, hehe :-)
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uo**************@tk2msftngp13.phx.gbl...
Hi,

Why dont you use setstyle for the control to doublebuffer.

http://msdn.microsoft.com/library/de...styletopic.asp

Ken
----------------------
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:eK*************@TK2MSFTNGP14.phx.gbl...
Hi,

I have my custom Inherited DataGrid. I override the OnPaint-event to speed up things and avoid flikkering using Double Buffering. To draw the normal things of the DataGrid I have to call the MyBase.OnPain(pe). But in my
opinion it doesn't seem to be painted on the buffer. Everything works

fine,
but I think it should work better if my MyBase.OnPaint also painted in my buffer.

Am I wrong? And how should I do this? I kind of need to link the

pe-argument
to my g-object?

This is the code :

Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'DoubleBuffer-functions********
If _backBuffer Is Nothing Then
_backBuffer = New Bitmap(Me.ClientSize.Width,
Me.ClientSize.Height)
End If

Dim g As Graphics = Graphics.FromImage(_backBuffer)
'Paint on the Graphics object here
'DoubleBuffer-functions********

MyBase.OnPaint(pe)

'I do my special stuff here with the g-object (custom cilumnheaders etc '....
'DoubleBuffer-functions********
g.Dispose()
'Copy the back buffer to the screen
pe.Graphics.DrawImageUnscaled(_backBuffer, 0, 0)
'DoubleBuffer-functions********
End Sub

Thanks a lot in advance!

Pieter


Jul 26 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Glass | last post by:
I have read plenty about applying double buffering for animation and self drawn forms. Is there a way to apply it to a form with many standard controls on it (textboxes, labels etc) ?? I have...
8
by: DraguVaso | last post by:
Hi, I want to override the MyBase.OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs) of the DataGrid, to have some custom property's designed (other column headers etc). The problem is...
5
by: Ron Vecchi | last post by:
I have a custyom control that has a property which wraps a collection. When I add controls to the collection the OnPaint method of these newly added controls never get fired. But if I take the...
3
by: Xarky | last post by:
Hi, I am overriding the method given to draw ellipses on my window, using the following code. My problem is that I have a button that every time it is pressed, a variable is inremented,...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
1
by: Nuno Magalhaes | last post by:
How can I catch an exception inside an event? I want to capture the exception of an OnPaint event in a picturebox because sometimes it's not displayed and gives me an error. Another question...
5
by: DraguVaso | last post by:
Hi, I have my custom Inherited DataGrid. I override the OnPaint-event to speed up things and avoid flikkering using Double Buffering. To draw the normal things of the DataGrid I have to call the...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.