> Have I misunderstood something, if I call this.Refresh() on a
> usercontrol, should its paint event be invoked. Well it doesnt, any
> suggstions why?
To Invoke the paint event you should call "this.Invalidate()"
--
Greetings
Jochen
Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Yes, it invokes Paint.
So there three different ways to trigger painting.
1. Invalidate - this will invalidate some area on the calient rectangle.
Paint will be invoked, but at some point after. Paint event is triggered in
responce to WM_PAINT event, which is low-priority message. Thus paint might
be not the next event fired.
2. Update - forces WM_PAINT (Paint event). WM_PAINT is placed on the message
queue only if ther is an invalid region (if there is nothing to repint paint
won't be fired). You can combine several Invalidate calls to form a complex
invalid region and if you want to have the form painted immediately you
should call Update. Update blocks until painting finishes.
Note: eventhough in the paint event you have e.ClipRectangle this is the
bounding rectangle of the invalid region. The actual clipping is done in a
region. You can draw only inside the invalidated parts.
3. Refresh is the same as Update, but it invalidates the whole client
rectangle and triggers painting immediately.
So, I guess the problem might be that you you have hooked wrong paint event
(e.g. you have form with panel on it, you refresh the panel, but wait on
form's Paint event)
However, if you can post some code demonstrating your problem we can help
you better.
--
B\rgds
HTH
100 [C# MVP]
"Jesper," <anon...@discussions.microsoft.com> wrote in message
news:3E8BC459-2275-42AB...@microsoft.com...
> Hi,
>
> Have I misunderstood something, if I call this.Refresh() on a usercontrol,
should its paint event be invoked. Well it doesnt, any suggstions why?
>
> best regards
> Jesper.
> Hi Jesper,
>
> Yes, it invokes Paint.
>
> So there three different ways to trigger painting.
> 1. Invalidate - this will invalidate some area on the calient
> rectangle. Paint will be invoked, but at some point after. Paint event
> is triggered in responce to WM_PAINT event, which is low-priority
> message.
By the way: WM_PAINT is not a real message. It is just a flag inside the
window. If no message is to process then this flag is checked and a
"WM_PAINT message is "generated".
See: RDW_INTERNALPAINT
All you wrote is completely correct except that WM_PAINT is a real message
this is what GetMessage and PeekMessage returns and DispathchMessage
dispatches. Hence, from the applications point of view there is such a
message. What is not real is that when invalidate a region or a region
becomes invalid becose of something else windows doesn't place WM_PAINT in
the message queue (WM_PAINT never exist in the queue) rather windwos
combines the invalid region and sets a flag. Checking that flag is
low-priority task (the flag is checked only if the queue is empty). Thus, it
is usually said that WM_PAINT is low-priority message.
Thanks for clarifying that point.
--
B\rgds
100 [C# MVP]