04-29-2005, 11:04 PM
I have a resizeable form with menu & status bar and I want to resize the controls(picturebox) in the form, how do I find the size of the menu bar programmatically? Im can put a static size but when I move from Win2k to XP the picture box is too large and overlaps the statusbar...
04-29-2005, 11:21 PM
Use the form's .ScaleWidth and .ScaleHeight properties when calculating the position of the controls. Size the picture box by subtracting the height of the status bar from the form's .ScaleHeight and move it to the top of the form. The width can remain the same size as the form's .ScaleWidth if it is to take the full width of the form.
Do the moving in the Form Resize event. Note that controls can not be moved when a form is minimized so deal with that in your code. Something like this...
Private Sub Form_Resize()
'Only move controls if form is visible.
If Me.WindowState <> vbMinimized Then
StatusBar.Move Me.ScaleLeft, Me.ScaleHeight - StatusBar.Height, Me.ScaleWidth
Picture1.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight - StatusBar.Height