XWindow
Below is the CrossBasic API reference for the XWindow class.
Class: XWindow
Creates and manages a native window with customizable style bits, geometry, background color, and events.
' Create a new window instance
Dim win As New XWindow
Constructor & Destructor
| Function | Signature | Description |
| Close | Close() | Closes and destroys the window instance. |
Dim h As New XWindow
' … use window …
h.Close
Events
| Name | Type | Description |
| Opening | String | Fires once when the window is first shown. Use with AddHandler. |
| Closing | String | Fires when the user closes the window (WM_CLOSE/WM_DESTROY). Use with AddHandler. |
' Register an Opening handler:
AddHandler(win.Opening, AddressOf(OnWindowOpening))
' Handler callback:
Sub OnWindowOpening()
Print "Window opened!"
End Sub
Properties
| Name | Type | Get / Set | Description |
| Handle | Integer | get-only | Numeric handle identifying this window. |
| Top | Integer | Top_GET / Top_SET | Y‑coordinate of window’s client area. |
| Left | Integer | Left_GET / Left_SET | X‑coordinate of window’s client area. |
| Width | Integer | Width_GET / Width_SET | Width of the window in pixels. |
| Height | Integer | Height_GET / Height_SET | Height of the window in pixels. |
| Title | String | Title_GET / Title_SET | Text displayed in the title bar. |
| Enabled | Boolean | Enabled_GET / Enabled_SET | Whether window can receive input. |
| Visible | Boolean | Visible_GET / Visible_SET | Show or hide the window. |
| ViewType | Integer | Type_GET / Type_SET | Predefined style presets (0–5). |
| BackgroundColor | Color | BackgroundColor_GET / BackgroundColor_SET | Fill color behind client area. |
| HasCloseButton | Boolean | HasCloseButton_GET / HasCloseButton_SET | Toggle display of the Close (×) button. |
| HasMinimizeButton | Boolean | HasMinimizeButton_GET / HasMinimizeButton_SET | Toggle display of the Minimize button. |
| HasMaximizeButton | Boolean | HasMaximizeButton_GET / HasMaximizeButton_SET | Toggle display of the Maximize button. |
| HasFullScreenButton | Boolean | HasFullScreenButton_GET / HasFullScreenButton_SET | Stub (uses Maximize style bit). |
| HasTitleBar | Boolean | HasTitleBar_GET / HasTitleBar_SET | Toggle display of the title bar. |
| Resizable | Boolean | Resizable_GET / Resizable_SET | Toggle ability to resize via border. |
' Position and size:
win.Left = 100
win.Top = 50
win.Width = 640
win.Height = 480
' Title and visibility:
win.Title = "My CrossBasic Window"
win.Visible = True
' Style toggles:
win.HasCloseButton = False
win.Resizable = False
' Change background to dark blue:
win.BackgroundColor = &c000080
Methods
| Name | Signature | Description |
| Minimize | Minimize() | Minimize the window. |
| Maximize | Maximize() | Maximize the window. |
| MessageBox | MessageBox(Message As String) | Display a modal MessageBox |
| SetIcon | SetIcon(Path As Sting) | Set the window icon. |
| Show | Show() | Restore or show the window. |
| ShowModal | ShowModal(ParentWindow.Handle) | Restore or show the modal window |
| Hide | Hide() | Hide the window without destroying it. |
| Close | Close() | Alias to the exported Close function. |
' Hook Closing event:
AddHandler(win.Closing, AddressOf(OnWindowClosing))
Sub OnWindowClosing()
Print "Window is closing, cleanup here."
End Sub
' Control window state:
win.Minimize()
Sleep 1000
win.Maximize()
Sleep 1000
win.Hide()
Sleep 500
win.Show()
Complete Example
Sub Main()
' Create and show window
Dim w As New XWindow
w.Title = "Demo Window"
w.Width = 800
w.Height = 600
w.Visible = True
' Register events
AddHandler(w.Handle, w.Opening, AddressOf(OnOpen))
AddHandler(w.Handle, w.Closing, AddressOf(OnClose))
win.Show()
' ...program loop...
' Wait until closed
' (CrossBasic script will exit once the window posts WM_QUIT)
End Sub
Sub OnOpen()
Print "Window opened"
End Sub
Sub OnClose()
Print "Window closing"
End Sub