<br><br><div class="gmail_quote">2011/5/22 Zaher Dirkey <span dir="ltr"><<a href="mailto:parmaja@gmail.com">parmaja@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div class="gmail_quote"><div><div></div><div class="h5">2011/5/22 Max Vlasov <span dir="ltr"><<a href="mailto:max.vlasov@gmail.com" target="_blank">max.vlasov@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><br><div class="gmail_quote"><div>2011/5/22 Zaher Dirkey <span dir="ltr"><<a href="mailto:parmaja@gmail.com" target="_blank">parmaja@gmail.com</a>></span><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><br><div class="gmail_quote"><div><div></div><div><div>2011/5/22 Max Vlasov <span dir="ltr"><<a href="mailto:max.vlasov@gmail.com" target="_blank">max.vlasov@gmail.com</a>></span><br></div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
Hi,<br>I encountered a problem I don't know how to solve.<br><br></div><div>In Delphi I used the following trick. In the WM_Paint before inheried call I got update region with successive calls to GetUpdateRect (to determine if it exists) and GetUpdateRgn afterwards. This allowed to get the correct region before BeginPaint is called (it validates the region so getting it after BeginPaint makes no sense). <br>
<br>But in Lazarus WM_Paint handler already contains DC and also GetUpdateRect call is failed. As I understand, this is because the WindowProc from win32callback.inc already did BeginPaint and provided the dc for the following call to the control WM_Paint. <br>
<br></div><font color="#888888"><br>Max Vlasov<br>
</font><br></blockquote></div></div><div><br>Check Canvas.ClipRect <br> <br></div></div><br></div></blockquote></div><br><br>Zaher, thanks, <br>but this is irrelevant, clipping rects and regions is just the way to define canvas/device context limiting area until explicitly canceled. It was used by Delphi and (probably) Lazarus to implement TGraphicControl, component working almost as TWinControl but without window handles. <br>
...<br>Max<br><font color="#888888"><br></font></blockquote></div></div><div><br>Not understand u, can u give us an example<br></div></div>Thanks<br>-- <br></div></blockquote></div><br><br>Ok, <br>simple form, one button. The following code works in Delphi (press button, redrawing with Alt-Tab or by dragging some other window over this window). In Lazarus it always goes to 'failed'. <br>
My version: with Delphi vcl logic BeginPaint will be inside inherited, with Lazarus it already was before in the non-object WindowProc <br><br>Max<br>...<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>
{ change Bounds to @ARect in Delphi since it's declared as PRect }<br> InvalidateRect(Handle, Bounds(0, 0, 100, 100), true);<br>end;<br><br>...<br> private<br> procedure WmPaint(var Msg: TWmPaint);message WM_Paint;<br>
<br><br>procedure TForm1.WmPaint(var Msg: TWmPaint);<br>var<br> ARect: TRect;<br>begin<br> if GetUpdateRect(Handle, ARect, false) then<br> begin<br> Caption:=format('Update Rect is ok (%d, %d, %d, %d)', [ARect.Left, ARect.Top, ARect.Right, ARect.Bottom]);<br>
end<br> else<br> Caption:='Update Rect is failed';<br><br> inherited;<br>end;<br><br><br>