Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > How to resize control correctly?


Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2005, 11:04 PM
vbbartlett vbbartlett is offline
Newcomer
 
Join Date: Aug 2003
Location: Denver, Co
Posts: 20
Question How to resize control correctly?


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...
Reply With Quote
  #2  
Old 04-29-2005, 11:21 PM
Diurnal Diurnal is offline
Enthusiast

Retired Leader
* Expert *
 
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
Default

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...
Code:
Private Sub Form_Resize() 'Only move controls if form is visible. If Me.WindowState <> vbMinimized Then 'Status Bar. StatusBar.Move Me.ScaleLeft, Me.ScaleHeight - StatusBar.Height, Me.ScaleWidth 'Picture Box. Picture1.Move Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, Me.ScaleHeight - StatusBar.Height End If End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->