Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Can't resize PictureBox in MDI Frame window
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Can't resize PictureBox in MDI Frame window

 Post Reply Post Reply
Author
Message
DaveH View Drop Down
Groupie
Groupie


Joined: 22 December 2008
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote DaveH Quote  Post ReplyReply Direct Link To This Post Topic: Can't resize PictureBox in MDI Frame window
    Posted: 25 June 2026 at 5:48pm
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

Inventory and Distribution Management for QuickBooks
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.