CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2000
    Posts
    163

    Lock form resizing

    Hi

    I wan't to make form Maximize and without option to resize it.

    I set that form properties:
    BorderStyle = 1 - FixedSingle
    WindowState = Maximized

    I run the program and the form is Maximizes without option to resize...
    But if i DblClicked on the form Caption the form resize to normal size.

    How can I prevent that action ???
    (without set the size to Maximize in the Resize event!)

    Thank you for help.


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Lock form resizing

    There is a solution that involves subclassing and is a bit involved if you actually are a beginner - it's posted at http://www.merrioncomputing.com in the advanced section of the Visual Basic index.



    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Lock form resizing

    Make

    Me.Height = Screen.Height
    Me.Width = Screen.Width

    Now, with the BorderStyle set to fixed single, you get a maximized form that will not resize. But it will move still.
    If you remove the Move item from a form's control menu, the user will not be able to move it in any way.
    Here is a code sample that will prevent the user from both moving and resizing a form by modifying the system menu.



    private Declare Function GetSystemMenu Lib "User" (byval hWnd%, byval bRevert%) as Integer
    private Declare Function DeleteMenu Lib "user" (byval hMenu%, byval iditem%, byval wflags%) as Integer

    private Const SC_SIZE = &HF000
    private Const SC_MOVE = &HF010
    private Const MF_BYCOMMAND = &H0

    Sub Form_Load()
    Dim hWnd%, hMenu%, Success%
    hWnd% = me.hWnd
    hMenu% = GetSystemMenu(hWnd%, 0)
    Success% = deletemenu(hMenu%, SC_SIZE, MF_BYCOMMAND)
    Success% = deletemenu(hMenu%, SC_MOVE, MF_BYCOMMAND)
    End Sub






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured