Window

From Real Software Documentation

Jump to: navigation, search
Class (inherits from Object)

Any window. A window can be converted to a ContainerControl by changing its Super Class in the Properties pane. However, you cannot change the default window to a ContainerControl.


Events
Activate DropObject MouseMove
CancelClose EnableMenuItems MouseUp
Close KeyDown MouseWheel
ConstructContextualMenu KeyUp Moved
ContentsChanged Maximize Open
ContextualMenuAction Minimize Paint
Deactivate MouseDown Resized
DragEnter MouseDrag Resizing
DragExit MouseEnter Restore
DragOver MouseExit


Properties
Backcolor HasBackColor MinimizeButton
Backdrop Height MouseCursor
CloseButton ImplicitInstance MouseX
Composite Left MouseY
ContentsChanged LiveResize Placement
Control MacProcID Resizeable
ControlCount MaxHeight Title
DockItem MaxWidth Top
Focus MaximizeButton TrueWindow
Frame MenuBar Visible
FullScreen MenuBarVisible Width
MinHeight
Handle MinWidth


Methods
AcceptFileDrop Getpid SetFocus
AcceptPictureDrop Hide Show
AcceptRawDataDrop Maximize ShowModal
AcceptTextDrop Minimize ShowModalWithin
Close NewDragItem ShowWithin
DrawInto Refresh UpdateNow
FocusNext RefreshRect
FocusPrevious Restore


Class Constants

The following class constants of the DragItem class can be used to specify the value of the Action parameter of the DragEnter, DragExit, and DragOver events.

Class Constant Description
DragActionDefault Default action.
DragActionCopy Copy the dragged item.
DragActionMove Move the dragged item.
DragActionLink Link the dragged item.

Notes

Window constructors are called after the window and its controls are created, but before the Open events are called.


The Composite Property

The Composite property solves a display problem that occurs under Mac OS X Carbon (Under Cocoa, all windows are automatically composite, so the property has no effect). In certain cases, a control that is placed in a Metal or Drawer window or on top of another control shows its rectangular border as a white background unless the window’s Composite property is turned on. The problem doesn’t come up if the controls are intrinsically rectangular. For Drawer and Metal window types, the Composite property is turned on automatically. The problem can also occur in regular Document windows.

For example, some controls that are placed on top of a Placard control in a Document window show this problem.

Composite property off.

In this example, PushButtons, RadioButtons, and a GroupBox are inside a Placard control and the window’s Composite property is off. Turning on the Composite property removes the unsightly white rectangles around each control.

Composite property on.

Understanding Sheet Windows

A "Sheet window" is the official name for drop-down dialog boxes that were introduced with Mac OS X. Mac OS X uses them in place of modal dialog boxes. Sheet windows behave as such only on Mac OS X. On other platforms, they behave as ordinary modal dialog boxes.

A Sheet window behaves like a Modal dialog window, except that the animation makes it appear to drop down from the parent window's Title bar. It can't be moved from that position and it puts the user interface in a modal state. The user must respond to the choices presented in the Sheet window.

Sheet windows behave as sheets only under Mac OS X. On Windows and Linux, Sheet windows behave like Movable Modal dialog windows.

A Sheet window can be displayed by calling the Show method. If SheetWindow is defined as a Sheet window and MainWindow is a Document window, then the statement

SheetWindow.Show


will show the Sheet window using the calling window (in this case, MainWindow) as the Parent window.

In general, you will want to use the ShowWithin or ShowModal because you can specify both the Parent and Sheet

SheetWindow.ShowWithin(Window3)


will specify the correct parent and sheet windows, no mater which window is the calling window.

Since a Sheet Window is inherently modal, the ShowModalWithin method can be used interchangeably. The use of the Show, ShowWithin, and ShowModalWithin assume that the ImplicitInstance property is True for the Sheet window. If the parent window is not currently displayed when method is called, it should also have ImplicitInstance set to True.

Custom Window Types

If the MacProcID property is set to a non-zero value (which can be done in the IDE only), the window will be drawn according to this value. When you do so, the behaviour of the window will correspond to the value of the Frame property, but the appearance is controlled by the Window Definition provided by MacProcID.This feature allows you to define window types that are not defined directly by Real Studio (i.e, via the Frame property).

For a discussion of MacProcID values, see the Apple developer documentation "Window Definition IDs" at http://developer.apple.com/techpubs/macos8/HumanInterfaceToolbox/WindowManager/WindowMgr8Ref/WindowMgrRef.b.html.

The following table summarizes the possible values of MacProcID. Values of 1024 to 1087 require the Appearance Manager; other values are pre-Appearance Manager. On Windows, the value of the Frame property controls the window type regardless of the value of MacProcID.

Value Description
1 Modal dialog box
2 Modeless dialog box
3 Modeless dialog box with shadow
4 Movable window with no size box
5 Movable dialog box with title bar
8 Movable window with zoom box and size box
12 Movable window with zoom box and no size box
16 Round corner window (adding 2, 4, or 6 to 16 changes the curvature of the corners)
1024 Movable window with no size box or zoom box
1025 Movable window with size box
1026 Movable window with vertical zoom box and no size box
1027 Movable window with vertical zoom box and size box
1028 Movable window with horizontal zoom box and no size box
1029 Movable window with horizontal zoom box and size box
1030 Movable window with full zoom box and no size box
1031 Movable window with full zoom box and size box
1040 Modeless dialog box
1041 Modeless dialog box with shadow
1042 Modal dialog box
1043 Movable modal dialog box
1044 Alert box
1045 Movable alert box
1046 Movable modal dialog box with size box
1057 Floating window with no size box or zoom box
1059 Floating window with size box
1061 Floating window with vertical zoom box
1063 Floating window with vertical zoom box and size box
1065 Floating window with horizontal zoom box
1067 Floating window with horizontal zoom box and size box
1069 Floating window with full zoom box
1071 Floating window with full zoom box and size box
1073 Floating window with side title bar
1075 Floating window with side title bar and size box
1077 Floating window with side title bar and vertical zoom box
1079 Floating window with side title bar, vertical zoom box, and size box
1081 Floating window with side title bar and horizontal zoom box
1083 Floating window with side title bar, horizontal zoom box, and size box
1085 Floating window with side title bar and full zoom box
1087 Floating window with side title bar, full zoom box, and size box
1985 Floating window with no size box or zoom box
1987 Floating window with size box
1989 Floating window with zoom box
1991 Floating window with zoom box and size box
1993 Floating window with side title bar and no size or zoom boxes
1995 Floating window with side title bar and size box
1997 Floating window with side title bar and zoom box
1999 Floating window with side title bar, size box, and zoom box.

Custom Cursors

The MouseCursor property controls the appearance of the pointer when it is over the window, provided the MouseCursor property of the Application class is Nil. If you also want the pointer to change to another shape when it is over a control within the window, you must either assign the new value to the Window's MouseCursor property or temporarily set the window's MouseCursor property to Nil and the control's MouseCursor property to the desired cursor. See the section on the MouseCursor class for an example.

You can assign a MouseCursor using the library of cursors in the Cursors module.

Examples

This example sets the background color of the window to grey, provided the HasBackColor property is set to True.

backcolor=RGB(80,80,80)


This example increases the width of the window by 20 pixels.

width=width+20


This example changes the title of the window.

title="Document 1"


The Resizing Event Handler

This example resizes three TextFields on the form in the Resizing event.The three TextFields are aligned horizontally. As the user stretches or shrinks the window, the TextFields' widths change proportionally.

Dim availableSpace as Integer
Dim field1size, field2size, field3size as Integer

//subtract 40 pixels for the space between the
//three fields and on left and right side of the window
availableSpace=me.width-40

//calculate the size of each field based on a percentage
Field1size=availableSpace*.6 //60 percent
Field2size=availableSpace*.3 //30 percent
Field3size=availableSpace*.1 //10 percent

//Set the field widths
TextField1.width=field1size
TextField2.width=field2size
TextField3.width=field3size

//reposition the fields based on the new sizes
TextField2.left=TextField1.left+TextField1.width+10
TextField3.left=TextField2.left+TextField2.width+10


Contextual Menu Example

The following example shows how to present and handle a contextual menu in a window using the ConstructContextualMenu and ContextualMenuAction event handlers. This is the recommended method because it is completely cross-platform.

The following code in a ConstructContextualMenu event builds a simple contextual menu. The parameter Base as MenuItem is passed in as a parameter.

base.append(New MenuItem("Import"))
base.append(New MenuItem("Export"))
Return True //display the contextual menu


The following Select statement in the ContextualMenuAction event handler inspects the selected menu item, which is passed in as the HitItem as MenuItem parameter.

Select Case hititem.text
case "Import"
MsgBox "You chose Import"
case "Export"
MsgBox "You chose export"
End select

Return True


Drawinto Example

This example draws the contents of a window into a Graphics object. For example, add a second window to a new project and add a Canvas control to the second window. In the Paint event of the first window, put:

Self.drawinto(dialog1.canvas1.Graphics,0,0)


The contents of the first window will be drawn into the Canvas control on the second window.

Accessing Controls and Properties in Other Windows

When changing a window property from another window, there are two possible approaches you can take. If you have only one instance of the window you need to reference, you can use the window's object name as a reference. For example, if you had a window called window1 that had a TextField called TextField1 and you wanted to assign the value "Fred" to the text property of that TextField, you would using the following syntax:

window1.TextField1.text="Fred"


If you have multiple instances of the same window class open at the same time, then a reference to the target window must be included as in this example where a new window is opened and its window title changed. "anotherWindow" is a window class in the Project Editor.

Dim w As anotherWindow
w=New anotherWindow
w.title="Your Results"


Handling Drag and Drop

For an explanation of handling drag and drop, see the Control class and the DragItem class.

See Also

Window function; MessageDialog class.

Personal tools