|
Hi, I have a VB6 MDIForm with a CommandBars control, and have aligned a PictureBox on the left. In the CommandBars_RepositionAlignedControls event handle, I call CommandBars.MoveAlignedControl on the PictureBox, and everything looks good.
However, I want to change the width of the PictureBox at runtime. If the CommandBars isn't on the form, it works as expected. However, when the CommandBars is on the form, changing the Width property of the PictureBox doesn't do anything: no visible change, and if I set the Width, then read it back, it's unchanged.
A small project that demonstrates the problem: Create a new VB6 project that contains an MDIForm. On the MDIForm, put a CommandBars control named CommandBars and a PictureBox named Picture1. Set the Align of Picture1 to Align Left and the Width to 2000. Put a CommandButton named Command1 inside Picture1, near the upper-left.
Private Sub Command1_Click() Dim NewWidth As Single NewWidth = IIf(Picture1.Width > 1000, 1000, 2000) Picture1.Width = NewWidth Debug.Print "Set to " & NewWidth & ", actual width is " & Picture1.Width ' Trying RecalcLayout to see if it helps, but it doesn't. ' It does cause the RepositionAlignedControl event to fire though. CommandBars.RecalcLayout End Sub
Private Sub CommandBars_RepositionAlignedControls(Left As Long, Top As Long, Right As Long, Bottom As Long) CommandBars.MoveAlignedControl Picture1, Left, Top, Right, Bottom End Sub
If you remove the CommandBars from the form and comment out the lines that reference it, it works as expected: Clicking the button toggles the PictureBox width between two sizes. With CommandBars, clicking the button doesn't do anything, and the Debug message says "Set to 1000, actual width is 2004"
SuitePro 22.0.0 on Windows 11.
------------- SuitePro version 22.0.0
David Huang CAI Software, LLC
https://www.acctivate.com" rel="nofollow - Inventory and Distribution Management for QuickBooks
|