Overridden OnPaint method not called on form
-
I have no idea what you would want to see. Other than than the fact that I am using a regular System.Windows.Forms form, I have no idea what else matters. All that I should need to do is write an overridden onpaint method... doing this has worked in other applications. that is the only thing that I know is relevant. I have simply written a method override. Here is the content but its all commented out because except for the call to the base method because it wasn't working. Putting a break point in here indicates that the method isn't being executed at all. It is working fine in other applications where I have overwritten the OnPaint method.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
/*if (designMode)
base.OnPaint(e);
else
{
switch (DisplayMode)
{
case DisplayMode.DesktopWidget:
if (UseWorkerAPI)
{
IntPtr dc = GetDCEx(hWorkerAPI, IntPtr.Zero, (DeviceContextValues)0x403);
base.OnPaint(new PaintEventArgs(Graphics.FromHdc(dc), e.ClipRectangle));
}
break;
case DisplayMode.WindowWidget:
base.OnPaint(e);
break;
default:
break;
}
}*/
}OK ... that doesn't helps ... My questions are : - you work with FORMS ...? - you have created you own customized Form (I call it myForm) which derives from FORM ...? - on that myForm you overrided the Method OnPaint ...? - you have tested how it works with another Form (perhaps called Form1) which derives from myForm ...? - why are the code-parts in your sample code commented out ...? If you answer all of these questions it is perhaps possible to help you ...
-
I have no idea what you would want to see. Other than than the fact that I am using a regular System.Windows.Forms form, I have no idea what else matters. All that I should need to do is write an overridden onpaint method... doing this has worked in other applications. that is the only thing that I know is relevant. I have simply written a method override. Here is the content but its all commented out because except for the call to the base method because it wasn't working. Putting a break point in here indicates that the method isn't being executed at all. It is working fine in other applications where I have overwritten the OnPaint method.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
/*if (designMode)
base.OnPaint(e);
else
{
switch (DisplayMode)
{
case DisplayMode.DesktopWidget:
if (UseWorkerAPI)
{
IntPtr dc = GetDCEx(hWorkerAPI, IntPtr.Zero, (DeviceContextValues)0x403);
base.OnPaint(new PaintEventArgs(Graphics.FromHdc(dc), e.ClipRectangle));
}
break;
case DisplayMode.WindowWidget:
base.OnPaint(e);
break;
default:
break;
}
}*/
} -
I have no idea what you would want to see. Other than than the fact that I am using a regular System.Windows.Forms form, I have no idea what else matters. All that I should need to do is write an overridden onpaint method... doing this has worked in other applications. that is the only thing that I know is relevant. I have simply written a method override. Here is the content but its all commented out because except for the call to the base method because it wasn't working. Putting a break point in here indicates that the method isn't being executed at all. It is working fine in other applications where I have overwritten the OnPaint method.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
/*if (designMode)
base.OnPaint(e);
else
{
switch (DisplayMode)
{
case DisplayMode.DesktopWidget:
if (UseWorkerAPI)
{
IntPtr dc = GetDCEx(hWorkerAPI, IntPtr.Zero, (DeviceContextValues)0x403);
base.OnPaint(new PaintEventArgs(Graphics.FromHdc(dc), e.ClipRectangle));
}
break;
case DisplayMode.WindowWidget:
base.OnPaint(e);
break;
default:
break;
}
}*/
}Hello all who have made comments. I am replying to my own comment so that I can address all of your comments in one reply. All of you except for OriginalGriff are asking questions that I have already implied or explicitly written answers too: Perhaps some of you don't speak English so I will clarify. This statement implies that the code I provided above is in a class derived from System.Windows.Forms: "Other than than the fact that I am using a regular System.Windows.Forms form" As for why I commented code out, I answered that question with the statement: "Here is the content but its all commented out because except for the call to the base method because it wasn't working." If you don't understand any of the above statements, then ask about that. Otherwise please don't ask questions that I have already answered. It wastes everyone's time. For my part, I probably could have written that second statement better as: "Here is the content but it's all commented out because, except for the call to the base method, because it wasn't working." OriginalGriff: 1. Yes 2. Yes 3. No. I did not want the form drawn normally under certain conditions. EVERYONE: I wrote a test program to both figure this issue out and move forward with my purpose since that test program is working correctly. I have learned that overriding OnPaint will not accomplish what I am currently trying to do (which is to make the application into a desktop widget when the user decides... that means drawing it as part of the desktop). However, I would still like to troubleshoot this in case I need to override OnPaint for another reason... chances are good I may need to since this is a very customized form.
-
Hello all who have made comments. I am replying to my own comment so that I can address all of your comments in one reply. All of you except for OriginalGriff are asking questions that I have already implied or explicitly written answers too: Perhaps some of you don't speak English so I will clarify. This statement implies that the code I provided above is in a class derived from System.Windows.Forms: "Other than than the fact that I am using a regular System.Windows.Forms form" As for why I commented code out, I answered that question with the statement: "Here is the content but its all commented out because except for the call to the base method because it wasn't working." If you don't understand any of the above statements, then ask about that. Otherwise please don't ask questions that I have already answered. It wastes everyone's time. For my part, I probably could have written that second statement better as: "Here is the content but it's all commented out because, except for the call to the base method, because it wasn't working." OriginalGriff: 1. Yes 2. Yes 3. No. I did not want the form drawn normally under certain conditions. EVERYONE: I wrote a test program to both figure this issue out and move forward with my purpose since that test program is working correctly. I have learned that overriding OnPaint will not accomplish what I am currently trying to do (which is to make the application into a desktop widget when the user decides... that means drawing it as part of the desktop). However, I would still like to troubleshoot this in case I need to override OnPaint for another reason... chances are good I may need to since this is a very customized form.
-
I am trying to override the OnPaint and OnPaintBackground methods for my Application's main form. For some reason neither of the methods are being called EVER. They are completely ignored. What am I doing wrong?
Wild guess: your project got corrupted. Try "rebuild all". :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Wild guess: your project got corrupted. Try "rebuild all". :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
LOL. Already tried that. Didn't work.
-
I just tried something similar (using the code you posted) and it works every time. There must be something else in your form/project that is preventing it calling your OnPaint override.
Yeah. I know. I tried it again in the newer "test" app (as I mention in my most recent post above). It works fine. I still can't find anything wrong with the project app. I am hoping someone will have an idea of what could possibly get in the way of the override being called.
-
Yeah. I know. I tried it again in the newer "test" app (as I mention in my most recent post above). It works fine. I still can't find anything wrong with the project app. I am hoping someone will have an idea of what could possibly get in the way of the override being called.
-
That is exactly when a guess is required... When all information is available, you can rationally deduce what causes the problem. ;)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
That is exactly when a guess is required... When all information is available, you can rationally deduce what causes the problem. ;)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Until then... For now I can live without an answer.
-
Until then... For now I can live without an answer.