Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Image Management In Gambas
Including Help Comments in Source Code
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Window & Form Management

A window can be:
  • Top-level.

  • Embedded inside a container.

  • Embedded in another X window by the X-Embed protocol.

When the window is instanciated:
  • If a container is specified, then the window is embedded inside this container like a normal widget.

  • Otherwise, if the Application.Embedder property is defined, then the window is embedded with the X-Embed protocol.

  • Otherwise, the window is a normal top-level window.

At instanciation, the window is inserted in the global window list, unless it is embedded inside a container.

Each time a window is destroyed, it is removed from the global window list. If this list becomes void, then the application may quit, if there is no pending timers or watched file descriptors.

A window has:
  • A menu bar, visible or not, even if the window is not top-level.

  • A central area.

  • An optional "default" button.

  • An optional "cancel" button.

The Picture property defines the background picture used by the window. If the Mask property is set, then this background picture is used as window mask, provided it has some transparent part.

A Form is just a Window whose event observer is itself, and that has a static public Main method that instanciates and shows the auto-created instance of the Form.

You can show a window: Window.ShowModal returns the value passed to the Window.Close method.

Closing a window does nothing if:
  • The window has been already closed. You need one flag for that. Do not forget to clear this flag if the window is shown again.

  • The window is being closed. You need one other flag for that.

The Close event is raised only if the window has been effectively shown.

If Window.Persistent is set, then closing a window does not destroy it.

An embedded window must receive the Close event too.

Window.Raise automatically shows the window if needed.

Window.Hide calls Window.Close when the window is in modal mode.

The following properties depends on the freedesktop window manager specifications: Window.Minimized, Window.Maximized, Window.FullScreen, Window.Stacking, Window.SkipTaskBar, Window.Sticky

When you show a window for the first time, or that was closed, you must be careful to initialize all the previous properties.

When a window is shown, it is automatically raised and activated.

If a resizable window is shown in modal mode, then its initial size becomes automatically its minimum size.

The Resize and Move events are raised only if the window is shown, or once just before the window is shown.

Pressing the RETURN key must activate the default button if it is defined. Pressing the ESC key must activate the "cancel" button if it is defined.

The first created window becomes automatically the "main" window. If this window is closed, then all other windows are closed automatically. Once the main window is closed, you can create another window. This new window then becomes the new main window.

Reparenting a window can change its top-level state.

A top-level window, or an embedded window that implements the Activate event handler can become the current active window.

If a control gets the focus, then its window becomes the active window, provided this window can become the current active window as explained above. If its window cannot become the current active window, then the parent window of this window is tried, and so on, until a top-level window is reached.

Activating a window sends a Deactivate event to the old current active window, and an Activate event to the new one.

When the application is iconified, then the current active window is deactivated. When the application is uniconified, then the current active window is reactivated again.

Setting the focus to an hidden control is just memorized by the window, so that this focus is applied when the window is effectively opened.