Feedback Submitted Last Night:
Feedback Case #52928
Can anyone explain this. I triplicated a my canvas control and put ONE listbox control on a window. When I don't load any data into the listbox, all 3 canvas controls work fine. Once I put data into the listbox, the FIRST canvas control will only re-paint itself when the window is re-positioned.
If I put TWO listbox controls in the window, ALL THREE canvas controls become unresponsive and even the first listbox becomes semi-unresponsive:
@Christoph Dnbsp;Vocht Looks like the canvas is having a lot of CPU load . Maybe you used .refresh a lot? Try changing that to .Invalide(false). That will speed up a lot of things for sure.
something in the listbox control is eating up CPU.
I never use refresh in the canvases, only invalidate.
Possibly related to this post: flooding-the-log-cgdataprovidercreatedirect-invalid-size-0/0#p382973
@Julian S Chad, do you have any code paths from inside the Canvas.Paint that can reach a Canvas.Invalidate? If you do then you could end up with an endless loop of paints that only shows its head when you add more controls which end up clogging the event loop.
I just checked, and thankfully, I only call invalidate in ONE place. The entire control is drawn to a picture and then invalidate is called where the paint method only draws the picture.
Setting transparent=false on the canvas property alleviated some of the issues, but exposed another "bug" regarding a super's properties via Inspect Behavior. Hijacking my own thread here, but if you disable transparent property via "inspect behavior" and then close the dialog, Transparent is gone if you try inspect behavior again. I had to delete the class from the project and re-insert it to get Transparent back. Odd
@Dave S If your PAINT EVENT consists only ofg.drawpicture myPicture,0,0
Then I suggesting setting ERASEBACKGROUND and TRANSPARENT both to FALSE
and if you are putting your "picture" into BackDrop, then don't
Transparent = False got rid of the flickering.(Still a bug acknowledged by Xojo).
EraseBackground is not a property. Did you mean something else?
but it's not in this list:
and it's not coming up at all in code completion or in inspect behavior. It's showing up as DEPRECATED when I tried to compile Erasebackground = false.
If DoubleBuffer is True, then you should set EraseBackground to False. If EraseBackground is not disabled, then it will cause the Canvas to flicker.
But I don't see an option to set EraseBackground to False from the IDE. Saving a sample project I get as default:
Begin Canvas Canvas1 AcceptFocus = False AcceptTabs = False AutoDeactivate = True Backdrop = 0 DoubleBuffer = False Enabled = True EraseBackground = True Height = 272
and changing DoubleBuffer from the IDE to True:
Begin Canvas Canvas1 AcceptFocus = False AcceptTabs = False AutoDeactivate = True Backdrop = 0 DoubleBuffer = True Enabled = True EraseBackground = True Height = 272
It will be good if we change the DoubleBuffer to True change the EraseBackground to False, at least for new people using Xojo.
Also, I don't fully understand https://docs.xojo.com/index.php/Canvas.EraseBackground
Indicates whether the entire Canvas is erased when doing any drawing operations or resizing.
It defaults to True for backwards compatibility.
This property is only used on Windows. Its setting has no effect on macOS or Linux.
If you set DoubleBuffer to True, then you should set EraseBackground to False. Otherwise, it will cause the Canvas to flicker.
What backwards compatibility?
Canvas.EraseBackground was first introduced with 2005r1, maybe is time to set it as False as default?
Edit: this with new project and 2018r1.1, I'll test with r2
@Julian S Oh William also highlighted the line in the listbox code that was causing the canvas painting issue as well as fixing the flicker. Hopefully that fixes everything? :)
Yea. There’s a bug with the listbox which worsened in R2 where cell borders eat up CPU. I’ll be submitting a case for that. Do you have any workarounds for cell borders?
@Chad P Do you have any workarounds for cell borders?
You're referring to the line William highlighted?
If you move:
CellBorderRight(row, column) = ListBox.BorderThinSolid
from SuperListBox.CellBackgroundPaint to after:
Cell(LastIndex, j) = col //recordArray(i)//rs.IdxField(i+1).StringValue
CellBorderRight(lastIndex, j) = ListBox.BorderThinSolid
in SuperListBox.Populate and any other places you want to set it rather than putting it inside the CellBackgroundPaint event then things should work as expected.