-->>Hope Its Cull to all,Iam having this proble of MDI form...I have a Child form with a cute interface but what discourage me is when I maxmise or recise MDI form the Interface of the child form becomes some what Ugly as all the controlls seems to align from Top Left conner of the form leaving a Big space at Right.So I find it is better to Disable it from Recising or Maximise.Can any one help please as I'v tried to write the codes of the MDI form on Recise to have a specific Height and Widht but an Error occured,so I'll appreciate for it guyz.

-->>I hope this 'll do now:
-->>On load my MDI Form code is Lyk this...

`Private Sub MDIForm_Load()
Me.Width = 11600
Me.Height = 11600

Me.Top = (Screen.Height - Height) / 2
Me.Left = (Screen.Width - Width) / 2
fmMenus_Window.Show
End Sub`

-->>And as I want it to maintain the same properties when recised this is my code on recising....

Private Sub MDIForm_Resize() Me.Width = 11600 Me.Height = 11600 Me.Top = (Screen.Height - Height) / 2 Me.Left = (Screen.Width - Width) / 2 End Sub

-->>The Error Generated it's aRun time error,here it is...

"Run-time error '384':"

"A from can't be moved or sized while minimized or maximized"

Also here is an attachement to my project.Tanx all

There are a few options available...

1) trap the error, this will still resize the mdi form, but no error will occur -

Private Sub MDIForm_Resize()

If Me.Width > 11600 Then
    MsgBox "I'm Resized with no error!"
        Else
    Me.Width = 11600
    Me.Height = 11600
End If
End Sub

2) Disable the Min and Max buttons (some more complexed code involved)...

''In a module, paste the following Api's/Constants

Public Declare Function GetWindowLong Lib "user32" Alias _
          "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias _
          "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
          ByVal dwNewLong As Long) As Long

Public Const GWL_STYLE = (-16)
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000

Now the MDI form load event....
FIRST, REMOVE THE ICON AND FORMS CAPTION!!! iT WILL NOT BE DISABLED OTHERWISE...

'The following code strips out the minimize and maximize buttons from the main MDI Frame.
'There is no other way to do this.  Note that if you want to set the form caption dynamically, you 
''must do this first, because
'the caption sets the window style when set dynamically, and undoes all the work.

'Get current window style value
ret = GetWindowLong(Me.hwnd, GWL_STYLE)
'Remove style settings for the buttons
ret = ret Xor WS_MINIMIZEBOX
ret = ret Xor WS_MAXIMIZEBOX
'Put the style back
ret = SetWindowLong(Me.hwnd, GWL_STYLE, ret)

Lastly, we need to disable the X-Button....

In your module, paste the following...

Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000

Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
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

Public Sub RemoveX(frm As Form)

  Dim hMenu As Long
  Dim menuItemCount As Long

  hMenu = GetSystemMenu(frm.hwnd, 0)

  If hMenu Then

      menuItemCount = GetMenuItemCount(hMenu)

      Call RemoveMenu(hMenu, menuItemCount - 1, MF_REMOVE Or MF_BYPOSITION)

      Call RemoveMenu(hMenu, menuItemCount - 2, MF_REMOVE Or MF_BYPOSITION)

      Call DrawMenuBar(frm.hwnd)
   End If
End Sub

Now, in your form load event, the following...

Call RemoveX(Me)

Hope this helped... :)

-->>Well it was briliant AndreRet,exactly NO Recising Buttons (Maximum & Minimun) and just something happened I hope its not a big deal there was a compile error: 'Cant find project or library' and it was ther variable "ret" I hope for (AndreRet) I think it was not declared so I declared it on the module level as "Public ret As String" and things went on.
-->>Now I appreciate for this as it helped a lot but before I mark this thread as SOLVED how about manualy recising the form from its boders? It still annoys my interface as well...

Hehehe, seems I've been held hostage here. :)

I'll play around with your code if time allows, will post a solution later on.

This article has been dead for over six months. Start a new discussion instead.