Another flicker reduction workaround

Seeing as this is a hot topic I thought I’d throw this out. This has to do with resizing a window with many controls in Windows. This example is from an early version of Shorts Designer. The window consists of a Page Panel (ppView) which has two pages each consisting of a container control containing many other controls. The problem I was facing was this…

No Buffer

I added a blank canvas surrounding the Page Panel (ResizeMask) which has an initial state of not visible. All sides are locked to the window. Two properties were also added to the window. ResizingWin (boolean) and ResizeBuffer (Picture)

The window Resizing event code:

[code]Sub Resizing() Handles Resizing
#if TargetWin32 then

// Keep the pagepanel size in synch with the mask
ppView.Width = ResizeMask.Width
ppView.Height = ResizeMask.Height

ResizeBuffer = new Picture(ResizeMask.Width, ResizeMask.Height)

ppView.DrawInto ResizeBuffer.Graphics, 0, 0

if ResizingWin = false then
  
  ResizingWin = true
  
  ResizeMask.Visible = true
  
  // move the mask out of the visible space
  ppView.top = -5000
  ppView.Left = -5000
  
end if

ResizeMask.Invalidate(false)

#endif

End Sub
[/code]

The window Resized Code:

[code]Sub Resized() Handles Resized
#if TargetWin32 then

// move the view back
ppView.top = 20
ppView.Left = 20

ResizeMask.Visible = false

ResizingWin = false

ResizeBuffer = nil

#endif
End Sub
[/code]

The end result…

Resize Mask

I’m sure this was the result of other people’s ideas on the forum. I’ve found it to be a useful workaround.