ParentW Command

Purpose

Creates a MDI parent window using API style flags to configure the window.

Syntax

ParentW [options] [#]n [, x, y, w, h][, style]

n, x, y, w, h, style:iexp
options:[Tool] [Center] [Full] [Hidden] [Client3D] [Help] [Top] [Palette] [NoCaption] [NoTitle] [Fixed][Default]

Description

ParentW n creates the window specified in n (between 0 and 31), whose upper left corner is given in x and y coordinates, the width in w and the height in h. The last parameter style is used to configure the window. style can take the following values which are "Or-ed":

WS_BORDER ($00800000) window with a border
WS_CAPTION ($00C00000) creates a window with a title. To make a system menu visible in such a window the WS_CAPTION and WS_POPUPWINDOW style elements must be combined.
WS_CLIPCHILDREN ($02000000) clips all window output to the area outside of a child window.
WS_CLIPSIBLINGS ($04000000) clips all window output within a child window to its client area.
WS_DISABLED ($08000000) a window, which is initially inactive.
WS_DGLFRAME ($00400000) a window with a double border but without a title.
WS_HSCROLL ($00100000) a window with a horizontal scroll bar.
WS_ICONIC ($20000000) a window which is initially displayed as an icon.
WS_MAXIMIZE ($01000000) a window with maximum dimensions
WS_MAXIMIZEBOX ($00010000) a window with a maximize box.
WS_MINIMIZE ($20000000) a window with minimal dimensions.
WS_MINIMIZEBOX ($00020000) a window with a minimize box.
WS_OVERLAPPED ($00000000) an overlapping window. The window contains a border and a title. The client area overlaps with window border and title.
WS_OVERLAPPEDWINDOW (0xCF0000) an overlapping window with following style elements: WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
WS_POPUP ($80000000) a popup window. Such window can't have the WS_CHILD attribute.
WS_POPUPWINDOW (0x80880000) a popup window with following style elements: WS_BORDER | WS_POPUP | WS_SYSMENU
WS_SYSMENU ($00080000) a window with a system menu in the title bar. Used only in windows with a title bar.
WS_TABSTOP ($00010000) a window with a number of control elements which the user can arrive at by tapping the tab key. Used only in dialog boxes.
WS_THICKFRAME ($00040000) a window with a thick border which is used to "size" the window.
WS_TILED (0x00000000)  
WS_VISIBLE ($10000000) a window which is initially visible.
WS_VSCROLL ($00200000) a window with a vertical scroll bar.

The ParentW command isn't the only way to create a parent MDI window in code. The alternative is to create a Form using the Form editor and setting MdiParent = True. At runtime MdiParent is read-only.

A MDI parent window can also be created using Form MdiParent or OpenW MdiParent, or by setting the MdiParent property in the Form Editor.

The options argument specifies additional window state settings.

Center - centers the form.

Full - creates a maximized window, excludes Hidden (full windows are always visible).

Hidden - opens invisible

Client3D - sets WS_EX_CLIENTEDGE

Tool - creates a WS_EX_TOOLWINDOW

Help - includes a Help button in the window caption, excludes minimize an maximize buttons

Top - creates a topmost window

Palette - creates a WS_EX_PALETTEWINDOW

Fixed - a non-sizable window

NoCaption - no title bar

NoTitle - no title bar, alias

Default - uses Windows default values

Example

' Ocx Form left aligned in a MDI parent window

' only way to create MDI parent in code:

ParentW 1, 20, 20, _X / 2, _Y / 2

Dim m$(80) : Local i%

For i = 0 To 60

m(i) = i

Next

For i = 20 To 60 Step 20

m(i) = ""

Next

m(61) = "&Window"

m(62) = "#1000#Cascade"

m(63) = "#1001#&Tile"

m(64) = "#1002#Tile 1"

m(65) = "#1003#Next"

m(66) = "#1004#&Previous"

Menu m()

Me.MenuItem(1004).Default = 1

Me.MdiSetMenu 3

Dim stpanel As Panel    ' create statusbar ocx

Ocx StatusBar stBar

.Panels.Add

Set stpanel = .Panels.Add : stpanel.AutoSize = 1

.Panels(1).ToolTipText = "Panel #1"

.Panels(2).ToolTipText = "Panel #2"

Ocx Form cld            ' create form ocx

.Width = 32 * Screen.TwipsPerPixelX

.Align = basLeft

.BackColor = RGB(192, 64, 64)

Me.ToolTipText = "ToolTip(ParentW)"

For i = 2 To 17         ' create mdi-child windows

ChildW i, 1

Me.Caption = Format(i, "'Window #'0")

Me.ToolTipText = Format(i, "'This is a ToolTip for Window #'0")

Next

Do                      ' message loop

Sleep

Loop Until Me Is Nothing

 

Sub Win_1_MenuOver(Idx%)

'Trace "ov" & Idx

If Idx < 0

stBar.SimpleText = ""

Else

stBar.SimpleText = "MenuOver" & Idx

End If

EndSub

 

Sub Win_1_MenuEvent(Idx%)

'Trace "Ev" & Idx

Switch Idx

Case 1000 : Win_1.MdiCascade

Case 1001 : Win_1.MdiTile

Case 1002 : Win_1.MdiTile 1

Case 1003 : Win_1.MdiNext

Case 1004 : Win_1.MdiPrev

Default : stpanel.Text = "MenuEvent" & Idx

EndSwitch

End Sub

 

Sub cld_Paint

Local i%

Set Me = cld

Color Me.ForeColor, Me.BackColor

For i = 0 To 15

Box 0, i * 16, _X, i * 16 + 16

DrawText 1, i * 16, _X, i * 16 + 16, Format(i), _

DT_CENTER | DT_VCENTER | DT_SINGLELINE

Next

End Sub

 

Sub cld_MouseDown(Button&, Shift&, x!, y!)

Local i%

If Button == 1

i = Int(y / 16)

stpanel.Text = "red click" & i

End If

End Sub

 

Sub cld_MouseMove(Button&, Shift&, x!, y!)

Static Int lastI = -1

Local i%

i = Int(y / 16)

If(i >= 16) i = 999

If lastI != i

lastI = i

If i = 999

cld.ToolTipText = "free"

Else

cld.ToolTipText = "red(Button)" & i

End If

End If

End Sub

Opens a parent window at position 20,20 with width _X/2 and height _Y/2, with a default style.

See Also

Form Object, Form, OpenW, ChildW, SaveFormPos, LoadFormPos, ModifyStyle, ModifyExStyle, WinDpi, ScaleToDpi, ScaleXYWHToDpi, WM_DPICHANGED.

{Created by Sjouke Hamstra; Last updated: 09/05/2020 by James Gaite}