Hi Johan,
I'm just curious. Is the problem solved.
B\rgds
100
"Sagaert Johan" <ysagaert_jy@hotmail.com> wrote in message
news:3f87d1bd$0$31726$ba620e4c@reader1.news.skynet .be...[color=blue]
> Hi
> Thanks for your reply , now it works just as i would like !!!!!!!!!!!
>
> I have put the Parent.Invalidate in the controls MouseUp event ,this seems
> to be enough.
>
> Now my next problem is how to solve this issue in the Compact framework
> ,since CF does not have the CreateParams method...
>
> Best regards Johan
http://www.qsl.net/on5di/
>
>
>
>
> "100" <100@100.com> wrote in message
> news:OXlX%238zjDHA.1004@TK2MSFTNGP09.phx.gbl...[color=green]
> > A little correction. It seems like calling invalidate with
> > invalidateChildren=false is not enough to stop Paint event for the child
> > control. As a result Parent.Invalidate is called over and over again[/color][/color]
(like[color=blue][color=green]
> > infinite loop of messages).
> > More logic has to be put in childe's control Paint event.
> >
> > The idea I came up with is to use a flag in the child's control class
> >
> > public class Hotspot : Control
> >
> > {
> > private bool mStopPaint = false;
> > //..... other members
> >
> > protected override void[/color][/color]
OnPaint(System.Windows.Forms.PaintEventArgs[color=blue][color=green]
> > e )
> > {
> > if(mStopPaint) return;
> > base.OnPaint(e); //If you needed it it's better to call it[/color]
> before[color=green]
> > your painting
> >
> > if (bPushed)
> > {
> > //..... not changed
> > }
> > else
> > {
> > mStopPaint = true;
> > Parent.Invalidate(this.Bounds, false); //Fires parent's
> > paint event
> > Parent.Update(); //This want return until the parent is[/color]
> not[color=green]
> > repainted. We need that in order to mStopPaint flag to work
> > mStopPaint = false;
> > }
> >
> > }
> > //.....The rest of the class
> > }
> >
> >
> > HTH
> > B\rgds
> > 100
> >
> > "100" <100@100.com> wrote in message
> > news:envgihzjDHA.2432@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Hi Johan,
> > >
> > > Now I see what your issue is. Ok, the problem is that when a control[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> > > created the framework by default sets WS_CLIPCHILDREN windows style to[/color][/color]
> the[color=green][color=darkred]
> > > underlaying window. This style cause any part of of the client area[/color]
> > covered[color=darkred]
> > > by a child control to be excluded of the invalid region. As a result[/color][/color][/color]
all[color=blue][color=green][color=darkred]
> > > drawing in those areas are clipped.
> > > What you can do is to reset this style. I don't know if it is good[/color][/color][/color]
idea[color=blue]
> to[color=green][color=darkred]
> > > use such platform dependant features, but this solves your problem. So[/color]
> > what[color=darkred]
> > > you can do is:
> > >
> > > 1. Add the following property to your main form:
> > > protected override CreateParams CreateParams
> > > {
> > > get
> > > {
> > > CreateParams createParams = base.CreateParams;
> > > createParams.Style &= ~0x02000000; //reset WS_CLIPCHILDREN
> > > return createParams;
> > > }
> > > }
> > >
> > > 2. Now you have to restore the main form's clent area when the mouse[/color]
> > button[color=darkred]
> > > is released. You can't simply ignore OnPaint event in the child[/color][/color][/color]
control.[color=blue][color=green][color=darkred]
> > > This will not repaint the main form. You have to do something to fire[/color]
> > Paint[color=darkred]
> > > event in the parent form. There is my suggestion for the child[/color][/color][/color]
control's[color=blue][color=green][color=darkred]
> > > Paint event implementation:
> > >
> > > protected override void OnPaint(System.Windows.Forms.PaintEventArgs[/color][/color][/color]
e )[color=blue][color=green][color=darkred]
> > > {
> > > base.OnPaint(e); //If you needed it it's better to call it before[/color]
> > your[color=darkred]
> > > painting
> > > if (bPushed)
> > > {
> > >
> > > Graphics gxOff; //Offscreen graphics
> > > if (m_bmpOffscreen == null) //Bitmap for doublebuffering
> > > {
> > > m_bmpOffscreen = new Bitmap(ClientSize.Width,[/color]
> > ClientSize.Height,[color=darkred]
> > > e.Graphics); //I believe is better to use this constructor
> > > }
> > > gxOff = Graphics.FromImage(m_bmpOffscreen);
> > > //gxOff.Clear(Color.Empty); - I believe it is not necessary[/color][/color][/color]
sice[color=blue][color=green]
> > it[color=darkred]
> > > doesnt do anything
> > > gxOff.FillRectangle(GrayBrush,5,5,ClientSize.Width-10,
> > > ClientSize.Height-10);
> > > e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
> > > }
> > > else
> > > {
> > > Parent.Invalidate(this.Bounds, false); //Fires parent's paint[/color]
> > event[color=darkred]
> > > }
> > > }
> > >
> > >
> > > HTH
> > > B\rgds
> > > 100
> > >
> > >
> > > "Sagaert Johan" <REMOVEsagaert_jREMOVE@hotmail.com> wrote in message
> > > news:unHQr3vjDHA.1676@TK2MSFTNGP09.phx.gbl...
> > > >
> > > >
> > > > "100" <100@100.com> wrote in message
> > > > news:OtKU52pjDHA.360@TK2MSFTNGP12.phx.gbl...
> > > > > Hi Johan,
> > > > >
> > > > > 1. Dont use Color.Empty for clearing the bitmap. This won't clear
> > > > anything.
> > > > > You should use color instead.
> > > > >
> > > > > something like:
> > > > > gxOff.Clear(this.BackColor);
> > > > >
> > > > > 2. Move
> > > > > e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
> > > > > out of the if(bPushed) block. You paint the control only if the[/color][/color]
> button[color=green][color=darkred]
> > > is
> > > > > down. And you don't paint (clear ) anything if the button is up.
> > > >
> > > >
> > > > Thats just my problem,i don't want anything to be painted when i[/color][/color]
> don't[color=green][color=darkred]
> > > > press my control,
> > > > the only thing i want to see is the form , or the image i draw on[/color][/color][/color]
the[color=blue][color=green]
> > form[color=darkred]
> > > .
> > > >
> > > > In my form i draw a background image in the forms paint event, and[/color][/color][/color]
the[color=blue]
> i[color=green][color=darkred]
> > > > would like to use
> > > >
> > > > my control to create hotspots almost identical as they create[/color][/color][/color]
hotspots[color=blue][color=green]
> > on[color=darkred]
> > > > images of html pages.
> > > >
> > > > I don't understand why part of the form the is'nt painted correctly[/color][/color][/color]
if[color=blue][color=green]
> > my[color=darkred]
> > > > control does'nt do any painting by itself.Even if i call the forms
> > > > invalidate, the form paint routine seems to skip the area where my[/color]
> > control[color=darkred]
> > > > is.
> > > >
> > > > Johan
> > > >
> > > >
> > > >
> > > >
> > > > > Beside I have one suggestion. If you want to paint the whole clent
> > > > rectangle
> > > > > by yourself consider setting control styles:
> > > > >
> > > > > this.SetStyle(ControlStyles.DoubleBuffer |[/color][/color][/color]
ControlStyles.UserPaint[color=blue]
> |[color=green][color=darkred]
> > > > > ControlStyles.AllPaintingInWmPaint, true);
> > > > >
> > > > > Even if you have your own offscreen bitmap you should set
> > > > > ControlStyles.DoubleBuffer style in order to avoid flickering.
> > > > >
> > > > > HTH
> > > > > B\rgds
> > > > > 100
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]