Argument out of range in TAdvToolbar when disconnecting monitor

Received a bug report from a customer that had an "Argument out of range" error within TAdvToolBar. He said it occurred when he unplugged his computer from a second monitor. I don't know which monitor our app was running on at the time, but by the look of the call stack, I suspect it was on the monitor that was being disconnected since it is trying to rescale.

TAdvToolbar 6.8.3.9
Delphi 11.3

Stack trace:

unplugging computer from second monitor

Argument out of range.


[0000000000E797F1] System.Classes.TCollection.GetItem (Line 6398, "System.Classes.pas")
[0000000002309BB6] AdvToolBar.TRowCollection.GetItem (Line 26359, "AdvToolBar.pas")
[000000000230B2E6] AdvToolBar.TRowCollection.SetToolBarTopAndHeight (Line 26816, "AdvToolBar.pas")
[00000000022D989D] AdvToolBar.TAdvDockPanel.SetToolBarBounds (Line 12284, "AdvToolBar.pas")
[00000000022EC838] AdvToolBar.TAdvCustomToolBar.SetBounds (Line 17025, "AdvToolBar.pas")
[00000000010CD239] Vcl.Controls.TControl.SetHeight (Line 5968, "Vcl.Controls.pas")
[00000000022EF9BF] AdvToolBar.TAdvCustomToolBar.UpdateSize (Line 18045, "AdvToolBar.pas")
[00000000022FF6EA] AdvToolBar.TAdvCustomToolBar.ChangeScale (Line 23170, "AdvToolBar.pas")
[00000000010CDC38] Vcl.Controls.TControl.ScaleForPPI (Line 6262, "Vcl.Controls.pas")
[00000000010DBD47] Vcl.Controls.TWinControl.ScaleForPPI (Line 12461, "Vcl.Controls.pas")
[00000000010DBE60] Vcl.Controls.TWinControl.ScaleControlsForDpi (Line 12482, "Vcl.Controls.pas")
[00000000010DBE60] -= a recursive area removed =- (Line 4)
[00000000010DBD38] Vcl.Controls.TWinControl.ScaleForPPI (Line 12460, "Vcl.Controls.pas")
[00000000010DBE60] Vcl.Controls.TWinControl.ScaleControlsForDpi (Line 12482, "Vcl.Controls.pas")
[00000000012818C1] Vcl.Forms.TCustomForm.ScaleForPPIRect (Line 4311, "Vcl.Forms.pas")
[000000000128B6AE] Vcl.Forms.TCustomForm.WMDpiChanged (Line 7478, "Vcl.Forms.pas")

I can only assume that this is the VCL TForm.Monitor that becomes undefined. We added extra checks for this and these will be included in the next update.