473,385 Members | 1,396 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,385 software developers and data experts.

Onpaint and Invalidate question

Hi, I am just learning "how-to" by reading some of the existing
article solutions in this newsgroup. I happened to come across this
one. Tom Spink knows what he is talking about and I am wondering why
he has done something.

My question is how does this work

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

My understanding was that Invalidate() raises an OnPaint(..) event, so
therefore this should be recursive shouldn't it?

Thank you
Colin


From: "Tom Spink" <th**********@ntlworld.com>
References: <uY**************@TK2MSFTNGP11.phx.gbl>
Subject: Re: e.Graphics.DrawLine Method
Date: Fri, 28 Feb 2003 07:55:04 -0000
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1105
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1105
Message-ID: <u5**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp,microsoft .public.dotnet.languages.vb
NNTP-Posting-Host: pc3-hart4-4-cust115.midd.cable.ntl.com
81.104.59.115
Try overriding the OnPaint event, then invalidating the form:

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

--
==============================================
Happy To Help,
Tom Spink
(th**********@ntlworld.com)
http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day
"Steve Le Monnier" <st*********@no.spam.please.hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I'm using the following code to draw to horizontal lines to give an etched
effect.

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawLine(SystemPens.ControlLightLight, new Point(-1,
this.panBottom.Top -1), new Point(this.Width +1, this.panBottom.Top -1));
e.Graphics.DrawLine(SystemPens.ControlDarkDark, new Point(-1,
this.panBottom.Top-2), new Point(this.Width +1, this.panBottom.Top-2));
}

This works fine until the form is resized then I end up with lines
everywhere!

Now we no longer have line controls other than using two labels how is one
to draw lines on forms and have them behave when the form is resized?

Cheers

Steve

Nov 20 '05 #1
3 6178
Yes it is recursive. By the way, did you look at your
scrollposition ---can't de determined post? I think I found your solution.
Go take a look!
"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om...
Hi, I am just learning "how-to" by reading some of the existing
article solutions in this newsgroup. I happened to come across this
one. Tom Spink knows what he is talking about and I am wondering why
he has done something.

My question is how does this work

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

My understanding was that Invalidate() raises an OnPaint(..) event, so
therefore this should be recursive shouldn't it?

Thank you
Colin


From: "Tom Spink" <th**********@ntlworld.com>
References: <uY**************@TK2MSFTNGP11.phx.gbl>
Subject: Re: e.Graphics.DrawLine Method
Date: Fri, 28 Feb 2003 07:55:04 -0000
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1105
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1105
Message-ID: <u5**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp,microsoft .public.dotnet.languages.v
b NNTP-Posting-Host: pc3-hart4-4-cust115.midd.cable.ntl.com
81.104.59.115
Try overriding the OnPaint event, then invalidating the form:

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

--
==============================================
Happy To Help,
Tom Spink
(th**********@ntlworld.com)
http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day
"Steve Le Monnier" <st*********@no.spam.please.hotmail.com> wrote in message news:uY**************@TK2MSFTNGP11.phx.gbl...
I'm using the following code to draw to horizontal lines to give an etched effect.

private void Form1_Paint(object sender,

System.Windows.Forms.PaintEventArgs
e)
{
e.Graphics.DrawLine(SystemPens.ControlLightLight, new Point(-1,
this.panBottom.Top -1), new Point(this.Width +1, this.panBottom.Top -1)); e.Graphics.DrawLine(SystemPens.ControlDarkDark, new Point(-1,
this.panBottom.Top-2), new Point(this.Width +1, this.panBottom.Top-2));
}

This works fine until the form is resized then I end up with lines
everywhere!

Now we no longer have line controls other than using two labels how is one to draw lines on forms and have them behave when the form is resized?

Cheers

Steve

Nov 20 '05 #2
I think what is written below would be a very, very bad thing. Where did
you see the source?
"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om...
Hi, I am just learning "how-to" by reading some of the existing
article solutions in this newsgroup. I happened to come across this
one. Tom Spink knows what he is talking about and I am wondering why
he has done something.

My question is how does this work

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

My understanding was that Invalidate() raises an OnPaint(..) event, so
therefore this should be recursive shouldn't it?

Thank you
Colin


From: "Tom Spink" <th**********@ntlworld.com>
References: <uY**************@TK2MSFTNGP11.phx.gbl>
Subject: Re: e.Graphics.DrawLine Method
Date: Fri, 28 Feb 2003 07:55:04 -0000
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1105
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1105
Message-ID: <u5**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp,microsoft .public.dotnet.languages.v
b NNTP-Posting-Host: pc3-hart4-4-cust115.midd.cable.ntl.com
81.104.59.115
Try overriding the OnPaint event, then invalidating the form:

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

--
==============================================
Happy To Help,
Tom Spink
(th**********@ntlworld.com)
http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day
"Steve Le Monnier" <st*********@no.spam.please.hotmail.com> wrote in message news:uY**************@TK2MSFTNGP11.phx.gbl...
I'm using the following code to draw to horizontal lines to give an etched effect.

private void Form1_Paint(object sender,

System.Windows.Forms.PaintEventArgs
e)
{
e.Graphics.DrawLine(SystemPens.ControlLightLight, new Point(-1,
this.panBottom.Top -1), new Point(this.Width +1, this.panBottom.Top -1)); e.Graphics.DrawLine(SystemPens.ControlDarkDark, new Point(-1,
this.panBottom.Top-2), new Point(this.Width +1, this.panBottom.Top-2));
}

This works fine until the form is resized then I end up with lines
everywhere!

Now we no longer have line controls other than using two labels how is one to draw lines on forms and have them behave when the form is resized?

Cheers

Steve

Nov 20 '05 #3
Google groups search on "e.Graphics.DrawLine Method", the top article.

"Justin Weinberg" <jw*******@bravopos.com> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
I think what is written below would be a very, very bad thing. Where did
you see the source?
"Colin McGuire" <co***********@lycos.co.uk> wrote in message
news:ab**************************@posting.google.c om...
Hi, I am just learning "how-to" by reading some of the existing
article solutions in this newsgroup. I happened to come across this
one. Tom Spink knows what he is talking about and I am wondering why
he has done something.

My question is how does this work

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

My understanding was that Invalidate() raises an OnPaint(..) event, so
therefore this should be recursive shouldn't it?

Thank you
Colin


From: "Tom Spink" <th**********@ntlworld.com>
References: <uY**************@TK2MSFTNGP11.phx.gbl>
Subject: Re: e.Graphics.DrawLine Method
Date: Fri, 28 Feb 2003 07:55:04 -0000
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1105
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1105
Message-ID: <u5**************@TK2MSFTNGP10.phx.gbl>
Newsgroups:

microsoft.public.dotnet.languages.csharp,microsoft .public.dotnet.languages.v b
NNTP-Posting-Host: pc3-hart4-4-cust115.midd.cable.ntl.com
81.104.59.115
Try overriding the OnPaint event, then invalidating the form:

<pseudo>
Function To Override OnPaint(...)
Call Base Class OnPaint(...)
Me.Invalidate()
End Function
</pseudo>

--
==============================================
Happy To Help,
Tom Spink
(th**********@ntlworld.com)
http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day
"Steve Le Monnier" <st*********@no.spam.please.hotmail.com> wrote in

message
news:uY**************@TK2MSFTNGP11.phx.gbl...
I'm using the following code to draw to horizontal lines to give an etched effect.

private void Form1_Paint(object sender,

System.Windows.Forms.PaintEventArgs
e)
{
e.Graphics.DrawLine(SystemPens.ControlLightLight, new Point(-1,
this.panBottom.Top -1), new Point(this.Width +1, this.panBottom.Top -1)); e.Graphics.DrawLine(SystemPens.ControlDarkDark, new Point(-1,
this.panBottom.Top-2), new Point(this.Width +1, this.panBottom.Top-2)); }

This works fine until the form is resized then I end up with lines
everywhere!

Now we no longer have line controls other than using two labels how is one to draw lines on forms and have them behave when the form is resized?

Cheers

Steve



Nov 20 '05 #4

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

Similar topics

12
by: NewSun | last post by:
I draw a grid on a panel.And panel1' property AutoScroll is set true.When HScroollBar is Scroolling,the grid is error. I have rewritten the mathod of WndProc.But the effect is unexpected. How can...
11
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the...
8
by: Mark Johnson | last post by:
Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or...
3
by: Chan | last post by:
Invalidate() is a member of System.Windows.Forms.Form. It marks an area of the client window as invalid and, therefore, in need of repainting, and then makes sure a Paint event is raised. But...
20
by: BB | last post by:
Hello all, I am trying to override OnPaint in a custom textbox control (so I can drawstring a caption, etc.). In the code below, I get the "painting the form" message as expected, but not the...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
1
by: sean | last post by:
I'm trying to create "rubber-band" rectangles by overriding the OnPaint method to place rectangles on top of all graphic controls, but when I call Me.Invalidate() (when the user moves the mouse),...
8
by: colin | last post by:
Hi, this probaly isnt the most relevant place to ask this, but Im using a windows forms in c# timer to process user input and invalidate a window if its changed. Im having problems in that the...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.