Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

preventing form resizing...

Posted on 2000-03-25
5
Medium Priority
?
189 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 45 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

647 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