[Lazarus] Getting update rect/region in Windows

Max Vlasov max.vlasov at gmail.com
Sun May 22 19:16:35 CEST 2011


2011/5/22 Zaher Dirkey <parmaja at gmail.com>

> 2011/5/22 Max Vlasov <max.vlasov at gmail.com>
>
>>
>>
>> 2011/5/22 Zaher Dirkey <parmaja at gmail.com>
>>
>>> 2011/5/22 Max Vlasov <max.vlasov at gmail.com>
>>>
>>>>
>>>>
>>>> 2011/5/22 Zaher Dirkey <parmaja at gmail.com>
>>>>
>>>>>
>>>>> 2011/5/22 Max Vlasov <max.vlasov at gmail.com>
>>>>>
>>>>>> Hi,
>>>>>> I encountered a problem I don't know how to solve.
>>>>>>
>>>>>> 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).
>>>>>>
>>>>>> 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.
>>>>>>
>>>>>>
>>>>>> Max Vlasov
>>>>>>
>>>>>>
>>>>> Check Canvas.ClipRect
>>>>>
>>>>>
>>>>>
>>>>
>>>> Zaher, thanks,
>>>> 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.
>>>>  ...
>>>> Max
>>>>
>>>>
>>> Not understand u, can u give us an example
>>> Thanks
>>> --
>>>
>>
>>
>> Ok,
>> 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'.
>> My version: with Delphi vcl logic BeginPaint will be inside inherited,
>> with Lazarus it already was before in the non-object WindowProc
>>
>> Max
>>
>>
> In Lazarus i used
> procedure Paint; override;
>
> and
>
> Canvas.ClipRect;
>
> It is work for me as Hans-Peter said in his message.
>
> If you ask about Rgn (Region), it more complected to work on all platforms,
> i think it is not founded.
>
>

Thanks, I understand that I should avoid any platform-specific code if I
want inter-platform compatibility.

Currently I tried to intervene calling SetWindowLong(... GWL_WNDPROC) and
inside my "overriden" Window Proc I get the region and call WindowProc and
it helped. If anyone knows more "official" way to do this, please let me
know.

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110522/b83f72b0/attachment-0003.html>


More information about the Lazarus mailing list