[Lazarus] Visual "uglyness" when creating TSynEdit @ runtime in my app

luiz americo pereira camara luizmed at oi.com.br
Sat Jan 5 15:54:45 CET 2013

2013/1/5 luiz americo pereira camara <luizmed at oi.com.br>:
> 2013/1/5 Martin <lazarus at mfriebe.de>:
>> On 05/01/2013 12:57, luiz americo pereira camara wrote:
>>> 2013/1/5 Martin <lazarus at mfriebe.de>:
>>>> On 05/01/2013 11:19, luiz americo pereira camara wrote:
>>>>> Can you check (comment ShowScrollBar) if the paint you are seeing is
>>>>> really from ShowScrollBar?
>>>> This would not make sense?
>>>> Nothing, except the scrollbars is painted (SynEdit does not paint).
>>> I understood that SynEdit.Paint was called when setting Parent in your
>>> system, but seems this is not the case.
>>> Although in the description of Bart he sees the whole SynEdit painted.
>> I am sure he was mistaken:
>>>   for a
>>> brief moment you can see the TSynEdit,
>> He would see the 2 scrollbars, and in the sort time he would not have paid
>> attention to the absence of all else. Seing the 2 scrollbars *flicker* it is
>> only natural to assume one saw the synedit flicker.
> OK.
> Now i see the issue. At runtime i could not notice the flicker and
> there's no WM_PAINT message involved, only stepping with the debugger
> is possible to see the control painted
> Try
> putting SWP_NOREDRAW in SetWindowPos
> It fixed here, but not sure of collateral effects

The collateral effect is that if a control is hidden, it will be still
be show until is there a new paint cycle

I come with the below implementation that will have the following
behavior. I could not find issues but needs more testing

- When a control is hidden, it's redraw immediately as is today
- When a control is show, its not redraw immediately. The window is
invalidated and a paint message is queued

class procedure TWin32WSWinControl.ShowHide(const AWinControl: TWinControl);
  VisibilityToFlag: array[Boolean] of UINT = (SWP_HIDEWINDOW,
  WinHandle: HWND;
  WinVisible: Boolean;
  WinHandle := AWinControl.Handle;
  WinVisible := AWinControl.HandleObjectShouldBeVisible;
  Windows.SetWindowPos(WinHandle, 0, 0, 0, 0, 0,
  //invalidate the window so it can be painted after show
  if WinVisible then
    Windows.RedrawWindow(WinHandle, nil, 0, RDW_INVALIDATE or RDW_FRAME);


More information about the Lazarus mailing list