Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Resizing controls in VB6

Posted on 2006-04-20
8
Medium Priority
?
348 Views
Last Modified: 2010-04-07
How can I resize a control in my Form in VB6 so that the control resizes automatically when the user resizes the Form? It would be something similar to the Anchoring property in .Net.

Thanks.
0
Comment
Question by:MyersA
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16499503
Hi MyersA,

see http://www.lyoung.com/

Cheers!
0
 
LVL 2

Author Comment

by:MyersA
ID: 16502004

Is it possible to do this without purchasing 3rd party components? Can I write code that does this?

Thanks.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16503243
It is possible. be ready to write a lot of code.

When I was doing VB6 apps, I was trying to put some controls into groupbox. When a form was resized, the groupbox was often following a margin. It was easier then having to move each control. A grid was also in the center of the form which was resized to fit the empty space.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 28

Accepted Solution

by:
vinnyd79 earned 100 total points
ID: 16503973
You could try downloading this module and adding it to your project:

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=42291&lngWId=1

to use,just add the following to each form:

Private Sub Form_Resize()
  ResizeFormFor Me
End Sub



Also, check this out:
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B182070
0
 
LVL 6

Assisted Solution

by:saravananvg
saravananvg earned 100 total points
ID: 16505510
Hello Sir,

  Check the following site if it is of any use to you.

http://www.freevbcode.com/ShowCode.asp?ID=6075

with regards,
padmaja.
0
 
LVL 4

Expert Comment

by:HTorres
ID: 16531780

i wrote two routines

one to resize control
one to attach to the right of a window a control

here some sample


Private Sub Form_Resize()

'resizes fragenerales in that proportion
'dont bother if the form is minimized
    ResizeCTRL Me, Me.fraGenerales, 3, 16, 4000, 4000

End Sub

'here the routines

Sub ResizeCTRL(ReferralControl As Object, Ctrl As Control, WidthUnits As Long, HeightUnits As Long, Optional MinWidth As Long, Optional MinHeight As Long, Optional AdjustLeftPosUnits As Long, Optional adjustTopPosUnits As Long)
   
    Dim t As Long
   
    'If IsMissing(ReferralControl) Then ReferralControl = Ctrl.Container
    If IsMissing(MinWidth) Then MinWidth = 0
    If IsMissing(MinHeight) Then MinHeight = 0
    If IsMissing(AdjustLeftPosUnits) Then AdjustLeftPosUnits = -1
    If IsMissing(adjustTopPosUnits) Then adjustTopPosUnits = -1
   
    If WidthUnits <> -1 Then
        If ReferralControl.Width > MinWidth Then
            Ctrl.Width = ReferralControl.Width - (120 * WidthUnits)
        End If
    End If
    If AdjustLeftPosUnits <> -1 And AdjustLeftPosUnits <> 0 Then
        If ReferralControl.Width > MinWidth Then
        'If t > MinWidth Then
            Ctrl.Left = ReferralControl.Width - (120 * AdjustLeftPosUnits)
        End If
    End If
   
    If HeightUnits <> -1 Then
        t = ReferralControl.Height - (120 * HeightUnits)
        If t > 0 + MinHeight Then
            Ctrl.Height = t
        End If
    End If
    If adjustTopPosUnits <> -1 And adjustTopPosUnits <> 0 Then
        t = ReferralControl.Height - (120 * adjustTopPosUnits)
        If t > MinHeight Then
            Ctrl.Top = t
        End If
    End If
   
End Sub

Sub AttachToRight(F As Form, C As Control, AdditionalUnits As Long, MinWidth As Long)

    If F.Width > MinWidth Then
        C.Left = F.Width - (C.Width + ((2 + AdditionalUnits) * 120))
    End If
   
End Sub

okay maybe the routine is too big, but the coding is a snap and does not get too much resources at runtime.

:)

hope this helps
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

580 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