I have a System.Windows. Forms.Form onto which I add a Panel (MyPanel)
directly derived from System.Windows. Forms.Panel.
Here are the important code fragments ...
public class MyPanel : Panel
{
............... ..............
public MyPanel () : base ()
{
this.SetStyle (ControlStyles. DoubleBuffer, true);
this.SetStyle (ControlStyles. AllPaintingInWm Paint, true);
this.SetStyle (ControlStyles. UserPaint, true);
}
protected override void OnPaintBackgrou nd (PaintEventArgs pe)
{
return;
}
protected override void OnPaint (PaintEventArgs pe)
{
using (Graphics g = this.CreateGrap hics ())
.............
............... ............... ............
The "OnPaint ()" routine uses the graphics context to draw some graphs etc.
Now, I have added the override to "OnPaintBackgro und ()" in order to see the
order of events which take place. In reality I do NOT override this method as
the standard Panel implementation does all I need it to do.
What happens is OnPaintBackgrou nd is entered and when exited On Paint is
entered.. So far so good.
When I simply let the app fly, every second I call Refresh () on the single
instance of the MyPanel object, this in turn ultimately invokes my On Paint
method which redraws my graphs. HOWEVER, the graph appears very quickly, then
is cleared again and the standard Form grey background replaces the graph
drawn in the panel.
Why is my Panel data displayed correctly but then instantly cleared. I send
the Refresh call directly to the MyPanel instance and not to the parent form.
I have moved the code logic from a combination that ALMOST worked perfectly,
ie the double buffering worked but wanted to remove the initial erase flicker.
In this previous working scneario, I had a Panel (not a derived Panel, ie
MyPanel), which sat directly on a CustomControl. Then the Refresh () produced
the graph data that persisted on the display until the second timer fired and
the data (plus flicker) was then redisplayed. WHY BY USING MY DERIVED PANEL
ON A FORM DOES MY CODE BEHAVE SO DIFFERENTLY TO THAT OF DISPLAYING A NATICE
PANEL ON A CUSTOMCONTROL.
So, once again, my graph appears for an instant, then is overwritten by the
standard Form Grey background colour. I do NOT have an active
OnPaintBackgrou nd and do NOT handle the associated event.
Many thanks for your time. 6 6451
Since you don't handle the OnPaintBackgrou nd, perhaps the base class
event is firing and that is what is erasing your background? Perhaps
you should handle the OnPaintBackgrou nd and then NOT call the base
class handler.
Also, you might check the Control.SetStyl e command and use the
AllPaintingInWm Paint enum. I think that prevents the background from
being erased.
One last thought, does you OnPaint call the base class OnPaint? Where
does this happen?
Whoops! I re-read your post and that you are calling SetStyle so
ignore that part of my reply.
The OnPaint method passes the Graphics instnace to your app via the
PaintEventArgs. You're not using it.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"Paul_Madde n" <u21795@uwe> wrote in message news:602397c798 29c@uwe... I have a System.Windows. Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows. Forms.Panel.
Here are the important code fragments ...
public class MyPanel : Panel { ............... ..............
public MyPanel () : base () { this.SetStyle (ControlStyles. DoubleBuffer, true); this.SetStyle (ControlStyles. AllPaintingInWm Paint, true); this.SetStyle (ControlStyles. UserPaint, true); }
protected override void OnPaintBackgrou nd (PaintEventArgs pe) { return; }
protected override void OnPaint (PaintEventArgs pe) { using (Graphics g = this.CreateGrap hics ())
............. ............... ............... ...........
The "OnPaint ()" routine uses the graphics context to draw some graphs etc.
Now, I have added the override to "OnPaintBackgro und ()" in order to see the order of events which take place. In reality I do NOT override this method as the standard Panel implementation does all I need it to do.
What happens is OnPaintBackgrou nd is entered and when exited On Paint is entered.. So far so good.
When I simply let the app fly, every second I call Refresh () on the single instance of the MyPanel object, this in turn ultimately invokes my On Paint method which redraws my graphs. HOWEVER, the graph appears very quickly, then is cleared again and the standard Form grey background replaces the graph drawn in the panel.
Why is my Panel data displayed correctly but then instantly cleared. I send the Refresh call directly to the MyPanel instance and not to the parent form.
I have moved the code logic from a combination that ALMOST worked perfectly, ie the double buffering worked but wanted to remove the initial erase flicker. In this previous working scneario, I had a Panel (not a derived Panel, ie MyPanel), which sat directly on a CustomControl. Then the Refresh () produced the graph data that persisted on the display until the second timer fired and the data (plus flicker) was then redisplayed. WHY BY USING MY DERIVED PANEL ON A FORM DOES MY CODE BEHAVE SO DIFFERENTLY TO THAT OF DISPLAYING A NATICE PANEL ON A CUSTOMCONTROL.
So, once again, my graph appears for an instant, then is overwritten by the standard Form Grey background colour. I do NOT have an active OnPaintBackgrou nd and do NOT handle the associated event.
Many thanks for your time.
Hoi Kevin. You are indeed correct. I am in the UK now and will return to my
office in Zeurich late Monday . I will try using the graphics context passed
via "pe". I was assuming te "this.CreateGra phics" would point to one and the
same.
This is the first time I have used this forum and am absolutely astonished at
just how many threads are started each day. Shame the rest of the world can't
colaborate so eagerly in all matters political.
I'll let you know how things pan out when I give it a go.
Many thanks Kevin.
Paul.
Kevin Spencer wrote: The OnPaint method passes the Graphics instnace to your app via the PaintEventArgs . You're not using it.
I have a System.Windows. Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows. Forms.Panel. [quoted text clipped - 71 lines] Many thanks for your time.
--
Message posted via DotNetMonster.c om http://www.dotnetmonster.com/Uwe/For...sharp/200605/1
What I have noticed is that when I do not override, the base class
OnPaintBackgrou nd fires, followed by my OnPaint routine. Things are fine up
to here. However, after the OnPaint call, the background is again cleared.
The call stack which results from my original call to myPanel.Refresh () is
pretty deep and I believe something is happening as I travers back up the
stack, after my OnPaint () routine has been called.
Paul_Madden wrote: I have a System.Windows. Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows. Forms.Panel.
Here are the important code fragments ...
public class MyPanel : Panel { ............... ..............
public MyPanel () : base () { this.SetStyle (ControlStyles. DoubleBuffer, true); this.SetStyle (ControlStyles. AllPaintingInWm Paint, true); this.SetStyle (ControlStyles. UserPaint, true); }
protected override void OnPaintBackgrou nd (PaintEventArgs pe) { return; }
protected override void OnPaint (PaintEventArgs pe) { using (Graphics g = this.CreateGrap hics ())
............. .............. ............... ............
The "OnPaint ()" routine uses the graphics context to draw some graphs etc.
Now, I have added the override to "OnPaintBackgro und ()" in order to see the order of events which take place. In reality I do NOT override this method as the standard Panel implementation does all I need it to do.
What happens is OnPaintBackgrou nd is entered and when exited On Paint is entered.. So far so good.
When I simply let the app fly, every second I call Refresh () on the single instance of the MyPanel object, this in turn ultimately invokes my On Paint method which redraws my graphs. HOWEVER, the graph appears very quickly, then is cleared again and the standard Form grey background replaces the graph drawn in the panel.
Why is my Panel data displayed correctly but then instantly cleared. I send the Refresh call directly to the MyPanel instance and not to the parent form.
I have moved the code logic from a combination that ALMOST worked perfectly, ie the double buffering worked but wanted to remove the initial erase flicker. In this previous working scneario, I had a Panel (not a derived Panel, ie MyPanel), which sat directly on a CustomControl. Then the Refresh () produced the graph data that persisted on the display until the second timer fired and the data (plus flicker) was then redisplayed. WHY BY USING MY DERIVED PANEL ON A FORM DOES MY CODE BEHAVE SO DIFFERENTLY TO THAT OF DISPLAYING A NATICE PANEL ON A CUSTOMCONTROL.
So, once again, my graph appears for an instant, then is overwritten by the standard Form Grey background colour. I do NOT have an active OnPaintBackgro und and do NOT handle the associated event.
Many thanks for your time.
--
Message posted via DotNetMonster.c om http://www.dotnetmonster.com/Uwe/For...sharp/200605/1
Hoi Kevin, many many thanks. This was indeed the problem. I assumed the
Graphics context returned by this.CreateGrap hics would be OK. Don't
understand why pe.Graphics passed to the Paint routine differs but it sure
does.
Now have flicker free graphics which persist.
Many many thanks once again.
Paul.
Kevin Spencer wrote: The OnPaint method passes the Graphics instnace to your app via the PaintEventArgs . You're not using it.
I have a System.Windows. Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows. Forms.Panel. [quoted text clipped - 71 lines] Many thanks for your time.
--
Message posted via http://www.dotnetmonster.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian K |
last post by:
I am new to Apache Batik and I am now doing a SVG Editor for my
project.
I use Java as programming language. I use Batik to generate the SVG
from Java Graphics2D, as I would like to transform the SVG to other
graphics formats (e.g. JPG, PNG, TIFF), an error occured, the error is
that the graphics don't specify the size of graphics, so that even I
can transform to JPG (for example), but the JPG file cannot display
any graphics. Then I...
|
by: Christian Soltenborn |
last post by:
Hi guys,
I have a question to VB .NET: I add a Graphics object to a panel and use
a bunch of DrawLine methods etc (it's really nice and convenient).
But: As soon as I send my form (which contains the panel) to the task
bar and get it back, the graphics are gone.
I guess that I need to add an event handler to the pane (or the form?),
but which event do I have to handle? And which method do I call on the
panel to get it repainted?...
|
by: Xah Lee |
last post by:
Of Interest:
Introduction to 3D Graphics Programing
http://xahlee.org/3d/index.html
Currently, this introduction introduces you to the graphics format of
Mathematica, and two Java Applet utilities that allows you to view them
with live rotation in a web browser. Also, it includes a introductory
tutorial to POV-Ray.
|
by: achiever |
last post by:
I am a IIIrd electronics Engg student
i want to know what is the role of graphics in c
is it ok to spend a lot of time on learning c graphic or to start the
new language like JAVA.
Thanks in advance.
|
by: she_prog |
last post by:
Dear All,
I need to save the content of a panel to a bitmap. The panel can have
many child controls which also need to be saved. The problem would be
solved if I could have the panel saved to a Graphics object, which is
the same as if I'd need to print it. It'd be easy using
Control.DrawToBitmap, but I also need the invisible part of the panel
(which is hidden because of scrolling) and DrawToBitmap just takes a
screenshot.
| |
by: Andy |
last post by:
Hi,
I am using the following code to render a text string in a new bitmap
file. The code works, but the text looks, well, crappy, even though I
told it to use ClearType hints. Any idea how to make the text look
nicer?
Thanks
Andy
|
by: gsal |
last post by:
What would be the easiest way to go about offering 3D graphics for the
purpose of rendering geometry?
Suppose engineers (my co-workes) have to design some enclosure,
nozzle, bracket, or whatever physical part/component, I would like to
write a program where they can at least see the resulting geometry and
navigate it, i.e., zoon-in/out, rotate, pan. On the side, I could
have data entry fields with the input parameters and when something...
|
by: Jon Harrop |
last post by:
I am writing a 3D graphing component built upon WPF and would like to have
2D vector graphics (e.g. typeset mathematics) as labels laid out from 3D
coordinates. For example, a tick on an axis has a 3D coordinate and its 2D
label might be right-aligned to the 2D projection of that 3D point.
The following Mathematica plot illustrates the functionality I am after:
http://math.arizona.edu/~goriely/M322/Mathma-ComplexFunc.jpg
I have done...
|
by: SAL |
last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps
section of either web.config or machine.config but it didn't work.
It seems that most pages in my webapp are okay but a couple of the Firefox
is munging up.
So, on my information page there is a gridview in the content section of the
page. The masterpage contains searching capabilities for the gridview. The
masterpage has controls contained in a panel control,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |