Solved

preventing form resizing...

Posted on 2000-03-25
5
186 Views
Last Modified: 2010-05-18
What is the best way to prevent the user from resizing the form?

I don't want to set the BroderStyle of the from to Fixed Single (because that hides the minimize button). I want it Resizable yet I don't want the user to be able to resize the form and miss up the carefully drawn controls.
0
Comment
Question by:mhdhallak
[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
5 Comments
 
LVL 14

Expert Comment

by:wsh2
ID: 2657051
On your form.. Set the BorderStyle property to Fixed Single.. and then Set the MinButton and MaxButton properties to True.. and it will do all that you want it to.. <smile>.
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2657112
You can use subclassing to get information when the user tries to resize the form. Check out...

http://www.vbaccelerator.com/codelib/ssubtmr/ctrlres.htm
0
 
LVL 2

Expert Comment

by:heheman3000
ID: 2657434
When the user resizes the from, you can get the controls to automatically resize themselves so they still fill up the form and get smaller and larger according to the form size (top, left, height, and width properties) Also, you can set the form so that it can't  go smaller then a specific size, so the controls are still visible.
0
 
LVL 3

Accepted Solution

by:
Foyal earned 15 total points
ID: 2657558
'Put all your controls inside a frame (fraMain)...

Option Explicit

    Dim DesiredWidth as Single
    Dim DesiredHeight as Single

Private Sub Form_Load()
   
    DesiredWidth = fraMain.Width + 360
    DesiredHeight = fraMain.Height + 600

End Sub

Private Sub Form_Resize()

    If me.WindowState <> vbMinimized then
        If Me.Width < DesiredWidth then
            Me.Width = DesiredWidth
        End If

        If Me.Height < DesiredHeight then
           Me.Height = DesiredHeight
        End If
   
    frmMain.Move (Me.Width - fraMain.Width)/ 2, (Me.Height - fraMain.Height) / 2
     
    End If

End Sub


0
 
LVL 3

Expert Comment

by:Foyal
ID: 2657562
ooops...
    In the Form_Resize that should be
    fraMain.Move instead of frmMain.Move

Experiment with the values set in the Form_Load to get the effect you want.

If your form.ScaleMode is set to pixels you will have to adjust things accordingly.

See 'ya
Foyal

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

733 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