MDIWindow

From Xojo Documentation

Class (inherits from Object)


Used to configure the MDI window on Multiple Document Interface applications. Specify the Multiple Document Interface option in the Properties pane for the App class.

Events
Moved Resized
Open Restore
Properties
Handle fa-lock-32.png MaxWidth Top
Height MinHeight Visible
Left MinWidth Width
MaxHeight Title
Methods
Maximize Restore
Minimize

Notes

You have the option of using the Multiple Document Interface (MDI) for the Windows build of your application. If you select this option, all of your application's windows will be enclosed in a "parent" window called the MDI window. If you don't select the MDI interface, then your application will be a Single Document Interface (SDI) application and your application's windows will be directly on the desktop (since there is no MDI window). This class allows you to set certain properties and behaviors of the MDI window.

You can set the MDIWindow property of the App class to a new instance of an MDIWindow subclass. Use this technique to implement the events for an MDIWindow.

Getting the Handle of a Child Window

There are two handles that a Declare writer may need when it comes to MDIWindows. The Handle property returns the frame window's handle. If you want the MDICLIENT handle for doing things like cascading child windows, then you need to get the child window based on the Handle with a code snippet like this:

Module MDIWindowExtensions
Private Dim mClientHandle As Integer

Function MDIClientHandle(Extends w As MDIWindow) As Integer
// There's two different handles used for an MDI window. The frame
// handle (which is MDIWindow.Handle), and the client handle. This
// gets the client handle, which is used for things like tiling or cascading
// child windows.
If mClientHandle <> 0 Then Return mClientHandle
#If TargetWindows
Declare Sub EnumChildWindows Lib "User32" ( parent As Integer, _
proc As Ptr, lParam As Integer )
mClientHandle = 0
// Do the enumeration
EnumChildWindows(w.Handle, AddressOf enumChildProc, 0)
// Return the client's handle
Return mClientHandle
#Endif
End Function

Function EnumChildProc(hwnd As Integer, lParam As Integer) As Boolean
#If TargetWindows Then
// We need to figure out what class this window belongs to
Soft Declare Function GetClassNameW Lib "User32" (hwnd As Integer,_
name As Ptr, count As Integer) As Integer
Soft Declare Function GetClassNameA Lib "User32" (hwnd As Integer, _
name As Ptr, count As Integer) As Integer
Var classNamePtr As New MemoryBlock(256)
Var className As String
If System.IsFunctionAvailable("GetClassNameW", "User32") Then
Var cnt As Integer = GetClassNameW(hwnd, classNamePtr, classNamePtr.Size)
className = classNamePtr.WString(0)
Else
Var cnt As Integer = GetClassNameW(hwnd, classNamePtr, classNamePtr.Size)
className = classNamePtr.CString(0)
End If
// If the name is MDICLIENT, then we're done
If className = "MDICLIENT" Then
mClientHandle = hwnd
Return False
End If
Return True
#Endif
End Function
End Module

Sample Code

This example sets several properties of the MDIWindow. It is in the Open event of the app.

App.MDIWindow.Height = 300
App.MDIWindow.Width = 450
App.MDIWindow.Left = 15
App.MDIWindow.Top = 10
App.MDIWindow.Title = "MDIWindow Title"
App.MDIWindow.MinWidth = 250
App.MDIWindow.MinHeight = 100
App.MDIWindow.MaxHeight = 400
App.MDIWindow.MaxWidth = 600
App.MDIWindow.Visible = True

See Also

Application class; App object.