Results 1 to 14 of 14

Thread: Disable window resizing

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    24
    How can i disable users from resizing (stretching) a window??
    What API function call do i need to make??

    Can i use SetWindowLong() api call since i am already using that for disabling the Maximize button??

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Set your borders to "NONE" for your forms.

    If using API, use SetWindowPos with the lastparameter as NO_Size.

    The No_Size should be a constant, if you look up in the API viewer.
    Chemically Formulated As:
    Dr. Nitro

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    24
    Its an MDI form so there is no borderstyle property... & also i did use the SW_NOSIZE constant as the last parameter in the setwindowpos api function call....
    I can still resize it even after this....
    Any other suggestions??

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    During the form_Load or form_Activate, set it a certain size. Assing the width and height to variables. In your form_resize, reassign these variables to me.width and me.height

    That is the only other way I know. Yes, it is the cheating's man way.

    I will try to think of something more professional in the mean time.

    BTW...
    Keep the variables on a module level not a prodcedural level. Meaning Dim the variables in the declaration.

    [Edited by Nitro on 04-05-2000 at 08:25 PM]
    Chemically Formulated As:
    Dr. Nitro

  5. #5
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    What is SetWindowLong() - I have the same prob with resizing

    Please help

  6. #6
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    arif,

    please could you send me the code for disabling the Maximize button. I will look out for the thing that stops people stretching a window

    Thanks#

    Richard Charlton

  7. #7
    Junior Member
    Join Date
    Apr 2000
    Posts
    22
    RCharlton, there is no code for the Maximize button, all you have to do is disable it in the Properties window of the form (MaxButton to False) at design time
    This sentence is a lie.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    24

    Wrong Info on this thread

    Although u can set the maxbutton property to false at design time, this only works with NON-MDI forms....for your MDI forms u have to do it in code using windows API functions....i looked up several in the API text viewer & the code below will show how to disable the Maximize button on an MDI form & also how to prevent resizing:

    Code:
    -----

    In the General declartions of a Module
    ----------------------------------------

    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

    Private Const WS_THICKFRAME = &H40000
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const GWL_STYLE = (-16)


    'This function will make sure the form that is passed to it
    ' thru its paramater has the Maximize button disabled & cannot
    ' be resized

    Public Sub MaxBox(ByRef PsdForm As Form)
    Dim lStyle As Long
    lStyle = GetWindowLong(PsdForm.hwnd, GWL_STYLE)

    lStyle = lStyle Xor WS_MAXIMIZEBOX Xor WS_THICKFRAME

    Call SetWindowLong(PsdForm.hwnd, GWL_STYLE, lStyle)

    End Sub

    In the Load Event of the MDI form:
    ----------------------------------

    Maxbox Me

  9. #9
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    Is there a way of having a maximise button disabled,

    a minimize button AND no stretching?

    Thanks

    Richard Charlton

  10. #10
    Simply change borderstyle to 0-NONE from 2-Sizable

  11. #11
    New Member
    Join Date
    Apr 2000
    Location
    Manchester, U.K.
    Posts
    10
    Not on an MDI form though.

  12. #12
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    MaxBox problem

    Originally posted by arif
    Although u can set the maxbutton property to false at design time, this only works with NON-MDI forms....for your MDI forms u have to do it in code using windows API functions....i looked up several in the API text viewer & the code below will show how to disable the Maximize button on an MDI form & also how to prevent resizing:

    Code:
    -----

    In the General declartions of a Module
    ----------------------------------------

    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

    Private Const WS_THICKFRAME = &H40000
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const GWL_STYLE = (-16)


    'This function will make sure the form that is passed to it
    ' thru its paramater has the Maximize button disabled & cannot
    ' be resized

    Public Sub MaxBox(ByRef PsdForm As Form)
    Dim lStyle As Long
    lStyle = GetWindowLong(PsdForm.hwnd, GWL_STYLE)

    lStyle = lStyle Xor WS_MAXIMIZEBOX Xor WS_THICKFRAME

    Call SetWindowLong(PsdForm.hwnd, GWL_STYLE, lStyle)

    End Sub

    In the Load Event of the MDI form:
    ----------------------------------

    Maxbox Me

    The problem I find with this is that there is a blue/yellow border around the ourside of the window, belown the title bar. Why does this happen and can I stop it?

    Thanks

  13. #13
    Guest
    Try this.
    Code:
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        RemoveMenu GetSystemMenu(hwnd, 0), 2, MF_BYPOSITION
    End Sub

  14. #14
    Addicted Member RCharlton's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    202

    Arrow Thanks Megatron, but it still does not seem to work

    If you would like I will post a screenshot of it on the net so u can see the problem. Please reply if you want to see it.

    Richard Charlton

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