473,657 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control.Paint gone missing

Consider a UserControl TopCont that contains two other UserControls,
CompA and CompB.

Somewhere in the constructor of TopCont we have

CompA.Paint += new PaintEventHandl er(compA_Paint) ;
CompB.Paint += new PaintEventHandl er(compB_Paint) ;

I am calling Invalidate() on both of the child components and this
results in their respective paint methods executing. However at some
point when I call CompA.Invalidat e(), its painting method (compA_Paint)
is not being called. (this is what I am trying to figure out). I *never
*actively* do

CompA.Paint -= new PaintEventHandl er(compA_Paint) ;

so I'm wondering how this would occur? Also I am using the debugger to
step over the lines of code where I have observed this happening but I
don't ever see the Control.Paint when I inspect the component.
I guess my second question is how at a given breakpoint can you inspect
a control and see which method was += to the Paint event?
Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
5 2258
vooose wrote:
Consider a UserControl TopCont that contains two other UserControls,
CompA and CompB.

Somewhere in the constructor of TopCont we have

CompA.Paint += new PaintEventHandl er(compA_Paint) ;
CompB.Paint += new PaintEventHandl er(compB_Paint) ;

I am calling Invalidate() on both of the child components and this
results in their respective paint methods executing. However at some
point when I call CompA.Invalidat e(), its painting method
(compA_Paint) is not being called. (this is what I am trying to
figure out). I *never *actively* do

CompA.Paint -= new PaintEventHandl er(compA_Paint) ;

so I'm wondering how this would occur? Also I am using the debugger to
step over the lines of code where I have observed this happening but I
don't ever see the Control.Paint when I inspect the component.
I guess my second question is how at a given breakpoint can you
inspect a control and see which method was += to the Paint event?
Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


ok, here is your first "is it plugged in" type question.

does the code that does the invalidate actually get called ? for
example if you are doing the invalidate in a property setter you may
find that the invalidate is not actually getting called. example....
public SomeComplexType MyComplexType
{
get
{
return _myPrivateCompl exType;
}
set
{
invalidate();
_myPrivateCompl exType;
}
}
later in your code somewhere

MyControl.MyCom plexType.Color = Colors.Blue;

this will not cause your setter to fire (and subsequently the
invalidate), because as far as your control is concerned the property
has not been changed only a sub property has changed so the private
field still contains the same object, in fact its the getter that has
fired.

I don't know if this is your problem, but it is a common issue.

Regards Tim.
Nov 16 '05 #2
Tim thanks for your reply.

In this case I can guarantee that Invalidate() on the troublesome
component. In fact, the first thing I did was add a method called
InvalidateCompA () which looks like:

public void InvalidateCompA ()
{
contA.Invalidat e();
}

and I put a breakpoint at this line, and it was hit. As explained before
I couldnt determine what Paint methods were going to get called as a
result of this Invalidate() because I don't know where this info is
hidden in the debugger!

Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
vooose wrote:
Tim thanks for your reply.

In this case I can guarantee that Invalidate() on the troublesome
component. In fact, the first thing I did was add a method called
InvalidateCompA () which looks like:

public void InvalidateCompA ()
{
contA.Invalidat e();
}

and I put a breakpoint at this line, and it was hit. As explained
before I couldnt determine what Paint methods were going to get
called as a result of this Invalidate() because I don't know where
this info is hidden in the debugger!

Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


No probs, just sorry it didn't help. I had a problem myself a couple
weeks ago and this was the issue.

do you have a small project that reproduces this problem ? Perhaps you
could post that up.

Regards Tim.
Nov 16 '05 #4
Unfortunately I can't develop a stable recreate. However knowing how to
determine the event handler for

control.Paint += <where is this at debug time>

is going to help solve this one, as this is the thing that goes missing.
Do you know how to print out the paint handlers at runtime?

Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5
is going to help solve this one, as this is the thing that goes
missing. Do you know how to print out the paint handlers at runtime?


you mean you want to know if it fires ?

you can use Debug.WriteLine , that will write to the output window, so
you can at least see if has fired. (the Debug class is in the
System.Diagnost ics assembly)

Regards Tim.
Nov 16 '05 #6

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

Similar topics

13
2074
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does overflow. All I know is that the program is either stopped due to an exception at the end of Main or has exited after the Stack Overflow exception. (Both cases are Debug builds running in the debugger.) After a lot of trial and error (mostly...
11
6182
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 OnPaint . The recangle draws correct when i press the mouse, but when i release the mouse the background is not restored What should i do in the Onpaint to make sure the background (the form) is restored correctly ? This problem already keeps...
0
1909
by: vooose | last post by:
Consider a UserControl to which you do userControl.Paint += new PaintEventHandler(paint_method) If you don't like that way, and prefer to override onPaint( ) then the problem stated below still exists (I tried both ways). Imagine you have a Console.WriteLine( ) in the paint method so you know when its getting called. Also there is no place in the code that userControl.Paint is -+ so the event is *never* removed.
3
8991
by: pacemkr | last post by:
Is it possible to force a control to paint to a Graphics object (or Device Context, or a bitmap, anywhere aside from the form) that I provide. I am writing a windows form class that supports full alpha blending. Basically I'm trying to make a layered window that supports controls. In order to do that I need to redirect painting of the controls to a memory DC (which is then sent to the layered window). All this asuming that I figured out...
0
1660
by: RSB | last post by:
Hi Every one, i am trying to create a UserControl and i am passing a Array of strings to it. Now based on the Array elements i am creating the LinkButtons Dynamically. I am also passing a Event to this control and Lining the OnClick event of these LinkButtons to this Event. (Which works fine). Now the Thing which i cannot achieve is i want to Change the Back Color of the Clicked to LinkButton To a different color and i also don't want to...
20
2564
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 "painting the control". It also has no effect to explicitly call txtTest.Invalidate or txtTest.Refresh. Am I missing something simple here? Any push in the right direction is appreciated.
6
3141
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it works fine, it seems to fire when the form changes visibility. Here is the code. Private Sub lblP1JoyUp_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles lblP1JoyUp.Paint If lblP1JoyUp.Visible = True Then Dim...
0
8421
marktang
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...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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,...
0
8621
tracyyun
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...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1734
bsmnconsultancy
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...

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.