Solved

preventing form resizing...

Posted on 2000-03-25
5
182 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
5 Comments
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
'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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now