BBjSysGui::addWindow

Description

Creates a top level GUI window in the current or specified context, depending on the syntax used.

Syntax

Return Value Method
BBjTopLevelWindow addWindow(number x, number y, number w, number h, string title)
BBjTopLevelWindow addWindow(number x, number y, number w, number h, string title, byte[] flags)
BBjTopLevelWindow addWindow(number x, number y, number w, number h, string title, byte[] flags, byte[] event_mask)
BBjTopLevelWindow addWindow(int context, number x, number y, number w, number h, string title)
BBjTopLevelWindow addWindow(int context, number x, number y, number w, number h, string title, byte[] flags)
BBjTopLevelWindow addWindow(int context, number x, number y, number w, number h, string title, byte[] flags, byte[] event_mask)
BBjTopLevelWindow addWindow(string title)
BBjTopLevelWindow addWindow(string title, byte[] flags)
BBjTopLevelWindow addWindow(string title, byte[] flags, byte[] event_mask)
BBjTopLevelWindow addWindow(int context, string title)
BBjTopLevelWindow addWindow(int context, string title, byte[] flags)
BBjTopLevelWindow addWindow(int context, byte[] flags, byte[] event_mask)

Parameters

Variable

Description

context Specifies a new SYSGUI device context in which to create the window.
x Horizontal position of the upper-left corner of the window in current units.
y Vertical position of the upper-left corner of the window in current units. This value does not take into account the space taken by menus or title bars. If a window is defined with a menu and a title bar and its y parameter is set to zero, the menu and title bar will not be visible when a BBj program displays the window. The y parameter should be adjusted by about 20 pixels to account for a menu and about 20 pixels for a title bar. For example, if a window has a menu and a title bar and the y parameter is set to 60, the top of the title bar will appear about 20 pixels from the top of the screen when a BBj program displays the window. See the Remarks section below.
w Width of the window in current units.
h Height of the window in current units.
title The title of the new window. This is the initial title and can be changed at any time with the 'TITLE' mnemonic.
flags

Window flags, as follows:

Flag Description
$00000001$

Resizable: Allows the window to be resized.

$00000002$ Close box: Includes a close box with the window.
$00000004$

Horizontal Scrollbar: Causes a horizontal scroll bar to appear when the window is resized to be smaller than its initial size and setTrack(0) is specified.

Note: Pair this with flag $80000000$ to set 'TRACK'(0).

$00000008$

Vertical Scrollbar: Causes a vertical scroll bar to appear when the window is resized to be smaller than its initial size and setTrack(0) is specified.

Note: Pair this with flag $80000000$ to set 'TRACK'(0).

$00000010$ Invisible: Sets the window to be initially invisible.
$00000020$ Disabled: Sets the window to be initially disabled.
$00000080$ Maximizable and Minimizable: Allows the window to be maximized or minimized.
$00000100$ Minimized: Sets the window to be initially minimized.
$00000800$ Menu Bar: Include menu bar. Creates a menu bar.
$00001000$ Maximized: Sets the window to be initially maximized.
$00002000$ Prevents the separator line between the menu and client area of a window from being drawn.
$00010000$ Keyboard Navigation: Activates keyboard navigation in the window. If this flag is specified, key pressed ("t") events for arrow keys and the tab key will not be reported.
$00020000$ Always On Top: Always positions the window on top of other windows.
$00040000$ Border: Creates a border around the dialog.
$00080000$ Dialog: Sets the window to behave as a dialog.
$00100000$

Automatic Layout: Automatically arranges all controls and child windows placed in the window to fit. In the DWC client, this flag causes the window to use dynamic flow layout, ignoring all absolute control sizes and positions.

DWC logoNote:

When creating a child window through an ARC file in WindowBuilder, this flag is not currently exposed in the UI, and corresponds to the "GRAVITY" flag. To enable flow layout in the DWC, add a line with the keyword GRAVITY to the ARC source file in the section with the child window properties.

$00400000$ Custom Colors: Allows use of a custom color palette. This provides a more accurate display of colors in bitmapped images.
$00800000$ Enter as Tab: Sets the Enter key to behave as a Tab key.
$01000000$ No Title Bar: Creates the window without a title bar.
$02000000$ MDI Desktop Modal: In BBj 23.04 and higher, sets the window to be desktop modal within an MDI desktop. This flag is ignored if the window isn't on an MDI desktop.
$04000000$ SYSCOLOR Events: Sets the window to automatically manage SYSCOLOR events.
$08000000$ Unique Names: In BBj 8.00 and higher, causes the window to enforce unique control names. See BBjWindow::getControl.
$10000000$ All Mouse Events: In BBj 15.00 and higher, causes the window to report all mouse events for all controls.
$20000000$ All Keypress Events: In BBj 15.00 and higher, causes the window to report all keypress events for all controls.
$40000000$ MDI Group Modal: Sets the window to be group-modal within an MDI group.
$80000000$ TRACK(0): In BBj 17.00 and higher, creates the window with 'TRACK'(0) instead of the default 'TRACK'(1).
event_mask Event masks to be applied to the window:

Flag

Description

$80000000$User changed system colors.
$40000000$Window Activation.
$20000000$Right mouse button down.
$02000000$Check or uncheck or check box or radio button.
$01000000$Click or double click on list item.
None -Always sent Close box operated.
$00400000$Edit or list edit modified.
$00800000$Edit, list edit, or text edit focus change.
$00000800$ Mouse button click (BBj 23 and higher).
$00000400$Key pressed.
None -Always sent Menu selection made.
$00000200$Mouse button double click.
$00000020$Mouse wheel scroll.
$00000040$Mouse button down.
$00000080$Mouse button up.
$00000100$Mouse moved.
$10000000$Mouse enter or exit control or window.
None -Always sent Push button operated.
$00100000$Scroll bar position changed.
None -Always sent Tool button operated.
$00000008$Window resized.
$00000004$Window focus change
$00000001$Popup request.
None -Always Sent Popup Menu Selection.

Return Value

All versions of the addWindow method return a BBjTopLevelWindow object.

Remarks

In BBj 15.00 and higher, the LEGACY_WINDOW_POSITION !COMPAT setting can be set to TRUE to position windows according to the documented Visual PRO/5 rules ("The x,y,w,h bounding rectangle of a window describes the location of the inside (the usable drawing area or client area) of the window. Note that if a window is placed at (0,0), the title bar will not be visible."). By default, BBj positions windows according to the rules defined by Java and the host operating system. This might differ from Visual PRO/5 by 20-30 pixels vertically and several pixels horizontally.

If the x, y, width, and height parameters are not specified, they are all initialized to 0. This is typically for use with DWC windows that dynamically arrange their contents (window creation flag $00100000$).

Example 1

rem ' BBjSysGui::addWindow

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(300,300,400,400,"BBjSysGui::addWindow",$00010003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
legacy$ = iff(pos("TRUE"=stbl("!COMPAT","LEGACY_WINDOW_POSITION")),$0004$,$0000$)
legacy! = window!.addCheckBox(101,25,25,350,25,"LEGACY_WINDOW_POSITION",legacy$)
legacy!.setCallback(legacy!.ON_CHECK_ON,"legacy_true")
legacy!.setCallback(legacy!.ON_CHECK_OFF,"legacy_false")
resizable! = window!.addCheckBox(102,25,75,350,25,"Resizable",$$)
resizable!.setCallback(resizable!.ON_CHECK_ON,"resizable_on")
resizable!.setCallback(resizable!.ON_CHECK_OFF,"resizable_off")
closebox! = window!.addCheckBox(103,25,125,350,25,"Close Box",$$)
closebox!.setCallback(closebox!.ON_CHECK_ON,"closebox_on")
closebox!.setCallback(closebox!.ON_CHECK_OFF,"closebox_off")
menubar! = window!.addCheckBox(104,25,175,350,25,"Menu Bar",$$)
menubar!.setCallback(menubar!.ON_CHECK_ON,"menubar_on")
menubar!.setCallback(menubar!.ON_CHECK_OFF,"menubar_off")
titlebar! = window!.addCheckBox(105,25,225,350,25,"Title Bar",$0004$)
titlebar!.setCallback(titlebar!.ON_CHECK_ON,"titlebar_on")
titlebar!.setCallback(titlebar!.ON_CHECK_OFF,"titlebar_off")
addWindow! = window!.addButton(1,25,350,350,25,"addWindow",$$)
addWindow!.setCallback(addWindow!.ON_BUTTON_PUSH,"addWindow")
x = 100
y = 100
w = 200
h = 200
title$ = "window"
flags$ = $00000000$
process_events

eoj:
release

legacy_true:
    print stbl("!COMPAT","LEGACY_WINDOW_POSITION=TRUE")
return

legacy_false:
    print stbl("!COMPAT","LEGACY_WINDOW_POSITION=FALSE")
return

resizable_on:
    flags$ = ior(flags$,$00000001$)
    print hta(flags$)
return

resizable_off:
    flags$ = and(flags$,not($00000001$))
    print hta(flags$)
return

closebox_on:
    flags$ = ior(flags$,$00000002$)
    print hta(flags$)
return

closebox_off:
    flags$ = and(flags$,not($00000002$))
    print hta(flags$)
return

menubar_on:
    flags$ = ior(flags$,$00000800$)
    print hta(flags$)
return

menubar_off:
    flags$ = and(flags$,not($00000800$))
    print hta(flags$)
return

titlebar_on:
    flags$ = and(flags$,not($01000000$))
    print hta(flags$)
return

titlebar_off:
    flags$ = ior(flags$,$01000000$)
    print hta(flags$)
return

addWindow:
    context = sysgui!.getAvailableContext()
    addWindow! = sysgui!.addWindow(context,x,y,w,h,title$,flags$)
    addWindow!.setCallback(addWindow!.ON_CLOSE,"destroy")
    destroy! = addWindow!.addButton(2,25,25,100,25,"Destroy",$$)
    destroy!.setCallback(destroy!.ON_BUTTON_PUSH,"destroy")
return

destroy:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    if control!.isDestroyed() then return
    window! = control!.getParentWindow()
    if window!.isDestroyed() then return
    window!.destroy()
return

DWC logoExample 2: DWC Dynamic Flow Layout (BBj 22.01 and higher)

rem ' hello.txt

sysgui = unt
open (sysgui)"X0"
bbjapi! = bbjapi()
sysgui! = bbjapi!.getSysGui()
flow = info(3,6)="6" and msgbox("Dynamic Flow Layout?",4+32+256)=6
flags$ = iff(flow,$00190083$,$00090083$)
title$ = "Hello"
if (flow) then
    window! = sysgui!.addWindow(title$,flags$)
else
    window! = sysgui!.addWindow(25,25,275,125,title$,flags$)
endif
window!.setCallback(bbjapi!.ON_CLOSE,"eoj")
if (flow) then
    hello! = window!.addButton(1,"Hello!")
else
    hello! = window!.addButton(1,25,25,100,25,"Hello!")
endif
hello!.focus()
hello!.setCallback(bbjapi!.ON_BUTTON_PUSH,"msgbox")
if (flow) then
    goodbye! = window!.addButton(2,"Goodbye!")
else
    goodbye! = window!.addButton(2,150,25,100,25,"Goodbye!")
endif
goodbye!.setCallback(bbjapi!.ON_BUTTON_PUSH,"eoj")
if (flow) then
    console! = window!.addButton("Console")
else
    console! = window!.addButton(3,25,75,100,25,"Console")
endif
console!.setCallback(bbjapi!.ON_BUTTON_PUSH,"console")
process_events

eoj:
release

msgbox:
    i = msgbox(info(1,4),64,fnmode$(info(3,6)))
    hello!.focus()
return

def fnmode$(mode$)
    if mode$="0" then return "Fat Client"
    if mode$="1" then return "Thin Client"
    if mode$="2" then return "Java Applet"
    if mode$="3" then return "Java Web Start"
    if mode$="4" then return "JavaBBjBridge"
    if mode$="5" then return "BUI (Browser)"
    if mode$="6" then return "DWC (Browser)"
    return mode$
fnend

console:
    escape
return

See Also

BBjAPI

BBjWindow

WINDOW Mnemonic - Create a SYSGUI Window

Object Variables

EVENTMASK Mnemonic - Change Event Mask

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.