Yeah, you found the problem alright The MsgBox isnāt even being displayed behind the window however it makes the sound and puts the window into a modal state.
Even if the columns are empty, changing ColumnAlignment causes a repaint, comment out both of those lines to be on the safe side and perform those actions outside the Paint, like in the Open or just before you load data. If you want to see it stuck in there, leave the lines in and add system.DebugLog(āPAINTā) after the lines and watch the debug output, itāll never end, then try it with the two lines commented out.
You shouldnāt do anything in a paint that could cause the control to re-paint or you can end up in a really tight loop that effects the performance of the app in strange ways or even locks it up totally.
Thanks Julian - you are a champion!
Although I found which bit of code was causing the issue( took me half a day, and half a sleepless night), I didnāt understand why.
Thanks for the explanation!
Does the same issue still happen if you turn implicit instance off? Windows donāt inadvertently get dragged to the front with it off. I donāt have my work setup going on a Sunday so I canāt test on Windows, but if someone wants to explore that curiosity Iād be interested in the results.
I just turned it off an tried it, the problem was still there. Its probably more to do with the message queue jamming up due to infinite paint messages than anything else.
And everyone is wondering why Windows Graphics or Xojo-built Windows apps are so slowā¦
if Me.ColumnAlignment(2) = Listbox.AlignLeft is already like that, a second Me.ColumnAlignment(2) = Listbox.AlignLeft should not force a re-paint. Xojoās Windows Framework could prevent that.
Such as it could prevent a whole lot of other unnecessary paint events being triggered. I guess thatās why I find a lot of (legacy) code like this in our project: if (theControl.Enabled <> boolEnabled) then theControl.Enabled = boolEnabled. Even āworseā in situations where Controls are being re-positioned, because changing both .Top and .Left may cause a whole lot in the Windows being redrawn not just once, but twiceā¦ okay, thatās an uneducated rant, which should be double-checked with Xojo 2018/Windows. But it certainly caused a lot of flicker before that could be avoided like that.
Anyway - it seems that Xojoās Windows Framework is nowadays even less tolerant of things like thatā¦ and I donāt know if thatās good or bad There are about 3 different Forum threads in within just a couple of days with weird bug descriptions - all caused by setting some āGUI propertyā in a .Paint-event.
@Rob Lang
I suggested earlier to try MessageDialog.
Today I have downloaded your example project and replaced the concerning MsgBox with MessageDialog.
'MsgBox "Worksheet is loaded and ready to use." + EndOfLine + EndOfLine + "Business: " + CurrentBASName + EndOfLine + "Tax Year: " + Str(CurrentBASYear) // Disable MsgBox and replace it with MessageDialog
Dim d As New MessageDialog // declare the MessageDialog object
Dim b As MessageDialogButton // for handling the result
d.ActionButton.Caption = "OK"
d.Message = "Worksheet is loaded and ready to use." + EndOfLine + EndOfLine + "Business: " + CurrentBASName + EndOfLine + "Tax Year: " + Str(CurrentBASYear)
b = d.ShowModal // display the dialog
When I run your your project and create a worksheet the message is shown as should be.