Disabling MDI Form window resizing


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Disabling MDI Form window resizing

  1. #1
    John Nelson Guest

    Disabling MDI Form window resizing


    Is there any way to either disable the resizing of an MDI form or simply disable
    the 'restore' button on the form (make minimize and maximize the only choices)?


  2. #2
    Jonathan Wood Guest

    Re: Disabling MDI Form window resizing

    You can prevent any form from resizing if you subclass it and catch the
    related messages.

    The subclass demo on our site has an example that does just this.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    John Nelson <john.nelson@alliancels.com> wrote in message
    news:39a2943a$1@news.devx.com...
    >
    > Is there any way to either disable the resizing of an MDI form or simply

    disable
    > the 'restore' button on the form (make minimize and maximize the only

    choices)?
    >




  3. #3
    Jonathan Wood Guest

    Re: Disabling MDI Form window resizing

    You can prevent any form from resizing if you subclass it and catch the
    related messages.

    The subclass demo on our site has an example that does just this.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    John Nelson <john.nelson@alliancels.com> wrote in message
    news:39a2943a$1@news.devx.com...
    >
    > Is there any way to either disable the resizing of an MDI form or simply

    disable
    > the 'restore' button on the form (make minimize and maximize the only

    choices)?
    >




  4. #4
    Bruno Paris Guest

    Re: Disabling MDI Form window resizing

    Hi, John

    ' mdiform code
    Option Explicit
    Private Const GWL_STYLE = (-16)
    Private Const WS_SYSMENU = &H80000
    Private Const WS_CAPTION = &HC00000
    Private Const WS_THICKFRAME = &H40000
    Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Sub EnableResizing(Form As Form, Enable As Boolean)
    Dim style As Long

    style = GetWindowLong(Form.hwnd, GWL_STYLE)
    If Enable Then
    style = style Or WS_THICKFRAME
    Else
    style = style And Not WS_THICKFRAME
    End If
    style = SetWindowLong(Form.hwnd, GWL_STYLE, style)
    End Sub

    Private Sub MDIForm_Load()
    Show
    EnableResizing Me, False
    End Sub

    Regards,
    Bruno



  5. #5
    Bruno Paris Guest

    Re: Disabling MDI Form window resizing

    Hi, John

    ' mdiform code
    Option Explicit
    Private Const GWL_STYLE = (-16)
    Private Const WS_SYSMENU = &H80000
    Private Const WS_CAPTION = &HC00000
    Private Const WS_THICKFRAME = &H40000
    Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Sub EnableResizing(Form As Form, Enable As Boolean)
    Dim style As Long

    style = GetWindowLong(Form.hwnd, GWL_STYLE)
    If Enable Then
    style = style Or WS_THICKFRAME
    Else
    style = style And Not WS_THICKFRAME
    End If
    style = SetWindowLong(Form.hwnd, GWL_STYLE, style)
    End Sub

    Private Sub MDIForm_Load()
    Show
    EnableResizing Me, False
    End Sub

    Regards,
    Bruno



  6. #6
    Arty Clark Guest

    Re: Disabling MDI Form window resizing

    How did you fix the Alt+Space then Left Arrow crash?

    --
    Arty Clark
    icq http://wwp.icq.com/scripts/contact.dll?msgto=3910140
    aclar@softhome.net
    Bruno Paris <nospam_ameba@zg.tel.hr> wrote in message
    news:39a3260a@news.devx.com...
    > Hi, John
    >
    > ' mdiform code
    > Option Explicit
    > Private Const GWL_STYLE = (-16)
    > Private Const WS_SYSMENU = &H80000
    > Private Const WS_CAPTION = &HC00000
    > Private Const WS_THICKFRAME = &H40000
    > Private Declare Function GetWindowLong Lib "user32" _
    > Alias "GetWindowLongA" (ByVal hwnd As Long, _
    > ByVal nIndex As Long) As Long
    > Private Declare Function SetWindowLong Lib "user32" _
    > Alias "SetWindowLongA" (ByVal hwnd As Long, _
    > ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    >
    > Public Sub EnableResizing(Form As Form, Enable As Boolean)
    > Dim style As Long
    >
    > style = GetWindowLong(Form.hwnd, GWL_STYLE)
    > If Enable Then
    > style = style Or WS_THICKFRAME
    > Else
    > style = style And Not WS_THICKFRAME
    > End If
    > style = SetWindowLong(Form.hwnd, GWL_STYLE, style)
    > End Sub
    >
    > Private Sub MDIForm_Load()
    > Show
    > EnableResizing Me, False
    > End Sub
    >
    > Regards,
    > Bruno
    >
    >




  7. #7
    Arty Clark Guest

    Re: Disabling MDI Form window resizing

    How did you fix the Alt+Space then Left Arrow crash?

    --
    Arty Clark
    icq http://wwp.icq.com/scripts/contact.dll?msgto=3910140
    aclar@softhome.net
    Bruno Paris <nospam_ameba@zg.tel.hr> wrote in message
    news:39a3260a@news.devx.com...
    > Hi, John
    >
    > ' mdiform code
    > Option Explicit
    > Private Const GWL_STYLE = (-16)
    > Private Const WS_SYSMENU = &H80000
    > Private Const WS_CAPTION = &HC00000
    > Private Const WS_THICKFRAME = &H40000
    > Private Declare Function GetWindowLong Lib "user32" _
    > Alias "GetWindowLongA" (ByVal hwnd As Long, _
    > ByVal nIndex As Long) As Long
    > Private Declare Function SetWindowLong Lib "user32" _
    > Alias "SetWindowLongA" (ByVal hwnd As Long, _
    > ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    >
    > Public Sub EnableResizing(Form As Form, Enable As Boolean)
    > Dim style As Long
    >
    > style = GetWindowLong(Form.hwnd, GWL_STYLE)
    > If Enable Then
    > style = style Or WS_THICKFRAME
    > Else
    > style = style And Not WS_THICKFRAME
    > End If
    > style = SetWindowLong(Form.hwnd, GWL_STYLE, style)
    > End Sub
    >
    > Private Sub MDIForm_Load()
    > Show
    > EnableResizing Me, False
    > End Sub
    >
    > Regards,
    > Bruno
    >
    >




  8. #8
    Bruno Paris Guest

    Re: Disabling MDI Form window resizing

    Hi, Arty
    >How did you fix the Alt+Space then Left Arrow crash?


    Thanks for testing the code. I reproduced the error (GPF), *only* with
    these conditions:
    - there is a MDIChild loaded
    - MDI does not have a menu (it has only system menu)
    - I pressed Alt+Space then few times Right Arrow to get GPF

    So, one possible workaround is:
    - add menu to MDI form
    - this is also 'UI standard' when dealing with multiple documents

    Regards,
    Bruno



  9. #9
    Bruno Paris Guest

    Re: Disabling MDI Form window resizing

    Hi, Arty
    >How did you fix the Alt+Space then Left Arrow crash?


    Thanks for testing the code. I reproduced the error (GPF), *only* with
    these conditions:
    - there is a MDIChild loaded
    - MDI does not have a menu (it has only system menu)
    - I pressed Alt+Space then few times Right Arrow to get GPF

    So, one possible workaround is:
    - add menu to MDI form
    - this is also 'UI standard' when dealing with multiple documents

    Regards,
    Bruno



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center