From: kpg on
"Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in news:152382DE-
8C71-4858-A742-BEBB5EE72669(a)microsoft.com:

> You probably need to override OnPaintBackground and have it do nothing.


You mean for the form or the user control?

In either case my form and/or control do not seem to have a
OnPaintBackground event. All I have is a paint event.

Is this becuase I'm using VB?

If so, I'll gladly switch over to C# for this control...



From: Chris Tacke, MVP on
Just like you should be doing for Paint, override the method (in the
control). It's not an event. Handling this in an event is going to be
slower by nature I think.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



"kpg" <no(a)spam.com> wrote in message
news:Xns9C738311EB12Eipostthereforeiam(a)207.46.248.16...
> "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in news:152382DE-
> 8C71-4858-A742-BEBB5EE72669(a)microsoft.com:
>
>> You probably need to override OnPaintBackground and have it do nothing.
>
>
> You mean for the form or the user control?
>
> In either case my form and/or control do not seem to have a
> OnPaintBackground event. All I have is a paint event.
>
> Is this becuase I'm using VB?
>
> If so, I'll gladly switch over to C# for this control...
>
>
>

From: kpg on
"Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in news:E87BADDE-
6289-4D4D-B497-356B2DC51175(a)microsoft.com:

> Just like you should be doing for Paint, override the method (in the
> control). It's not an event. Handling this in an event is going to be
> slower by nature I think.
>
>

Got it. I was thinking OnPaintBackground was an event, sounds like an
event.

Anyway this works perfectly - no flicker at all.

Thanks,
kpg
From: Christopher Fairbairn [MVP] on
Hi,

"kpg" <no(a)spam.com> wrote in message
news:Xns9C739DA30B711ipostthereforeiam(a)207.46.248.16...
> "Chris Tacke, MVP" <ctacke.at.opennetcf.dot.com> wrote in news:E87BADDE-
> 6289-4D4D-B497-356B2DC51175(a)microsoft.com:
> Got it. I was thinking OnPaintBackground was an event, sounds like an
> event.

Most Microsoft APIs follow the advice outlined in their "Design Guidelines
for Class Library Developer" documentation (available at
http://msdn.microsoft.com/en-us/library/ms229042.aspx).

In particular there is a section within this document discussing recommended
best practices for exposing Events from a custom class -
http://msdn.microsoft.com/en-us/library/ms229011.aspx

The general design pattern Microsoft uses is for an event called "Paint" to
have an associated virtual method called "OnPaint". This allows subclasses
to override the method instead of needing to add an event handler. This
provides a bit more efficiency and flexability in what a subclass can do
over an ordinary event handler.

The inverse is not always true however, in the case of the background
painting mechanism there is an OnPaintBackground virtual method, but no
matching "PaintBackground" event.

Its uncommon to find an event that starts with the word "On", but that is
not to say there aren't classes out there like that...

Hope this helps,
Christopher Fairbairn