?
Solved

Resizing controls on a form...

Posted on 2003-02-24
5
Medium Priority
?
190 Views
Last Modified: 2010-05-01
Hello,

I was wondering if anyone has got some code that will resize controls on a form when the form itself is
resized.

thx,
0
Comment
Question by:taylorrr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8010106
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 300 total points
ID: 8010170
0
 
LVL 2

Expert Comment

by:JoaTex
ID: 8015070
Hi
Open a form and put some controls on it.
Open a Module and put the code module on It.
Put the Code in form Code.
Run project and wash all the controls.

Module:

Option Explicit

Type ScaleStruct
      Top As Integer
      Left As Integer
      Width As Integer
      Height As Integer
      ParentHeight As Integer
      ParentWidth As Integer
      FontSize As Integer
End Type

Global Ctrl() As ScaleStruct

Code:

Option Explicit
Dim N

Private Sub Form_Load()
      On Error Resume Next
      ReDim Ctrl(0 To Controls.Count - 1)
      For N = 0 To Controls.Count - 1
            Ctrl(N).Top = Controls(N).Top
            Ctrl(N).Left = Controls(N).Left
            Ctrl(N).Width = Controls(N).Width
            Ctrl(N).Height = Controls(N).Height
            Ctrl(N).ParentHeight = Controls(N).Parent.ScaleHeight
            Ctrl(N).ParentWidth = Controls(N).Parent.ScaleWidth
            Ctrl(N).FontSize = Controls(N).FontSize
      Next N
      Me.Top = Screen.Height / 2 - Me.Height / 2
      Me.Left = Screen.Width / 2 - Me.Width / 2
End Sub

Private Sub Form_Resize()
      On Error Resume Next
      For N = 0 To Controls.Count - 1
            Controls(N).Visible = False
            Controls(N).Top = Ctrl(N).Top * (Controls(N).Parent.ScaleHeight / Ctrl(N).ParentHeight)
            Controls(N).Left = Ctrl(N).Left * (Controls(N).Parent.ScaleWidth / Ctrl(N).ParentWidth)
            Controls(N).Width = Ctrl(N).Width * (Controls(N).Parent.ScaleWidth / Ctrl(N).ParentWidth)
            Controls(N).Height = Ctrl(N).Height * (Controls(N).Parent.ScaleHeight / Ctrl(N).ParentHeight)
            Controls(N).FontSize = Ctrl(N).FontSize * (Controls(N).Parent.ScaleHeight / Ctrl(N).ParentHeight)
            If Controls(N).FontSize < 4 Then Controls(N).FontSize = 4
            Controls(N).Visible = True
      Next N
End Sub

Hope it Suites you.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question