Windows Darkmode flickers white when embedding container controls

Windows Darkmode flickers white when embedding container controls

I tried everything that I could think of but it always flickers white briefly as I switch between them. Which of course is horrible to see the white flashes when your in dark mode.

Bellow is example of the case just about.

Does anyone know of good way to eliminate this flicker ?

Public Sub SwitchViews(newView as IContextPanel)
  Using EinhugurMacOSBridge
  
  if CurrentPanel <> nil then
    CurrentPanel.Close()
  end if
  
  CurrentPanel = newView
  
  BlockRedraw(ContainerControl(newView))
  
  newView.EmbedPanel(self,180,160,541,430)
  
  //newView.Refresh()
  
  AllowRedraw(ContainerControl(newView))
  
  newView.LoadData(WeakAddressOf UIStateNotify)
  
  #If TargetMacOS
    mTouchBarReceipt = NSTouchBar.RegisterForWindow(Self, AddressOf CreateTouchBar)
  #EndIf
  
  // If mDecryptButton <> Nil Then
  // UIStateNotify
  // end if
  
  
End Sub

I actually found the root of the problem just now after hours of battling with this.

It is the CurrentPanel.Close

That generates the flicker. If I dont close it at all then the switching causes no flicker.

I still need to find way to close it somehow

Ok so I found fix,

But I really think there is bug there in Xojo, that it flickers white in Darkmode when you close container control.

The fix bellow works because I embed new control first over the area where the old was, then close the old instead of closing first and embedding later.

Using EinhugurMacOSBridge

var oldPanel as IContextPanel

if CurrentPanel <> nil then
  oldPanel = CurrentPanel
end if

CurrentPanel = newView

newView.EmbedPanel(self,180,160,541,430)

newView.Refresh()

newView.LoadData(WeakAddressOf UIStateNotify)

#If TargetMacOS
  mTouchBarReceipt = NSTouchBar.RegisterForWindow(Self, AddressOf CreateTouchBar)
#EndIf


if oldPanel <> nil then
  // Close the old view after the new View has covered the area to prevent Xojo to do ugly
  // white flicker in the area which was covered by the old container.
  oldPanel.Close()
end if

I haven’t looked into this yet as I assumed it was still a work in progress as the IDE does it and it looks hideous.

I got it quite nice after a days work, and once I realized the flicker was caused by ContainerControl.Close, then its quite nice and no flicker anywhere in the App.

(It is not big app though as you probably know)

Did you set doublebuffer for that container ?

Their not double buffer no.

Though problem was only when closing the control. So after its gone…then the main window does the mess by cleaning the window wrong.