# Creating a window

## Preface

In Windows 96, all windows inherit the [`StandardWindow`](https://apidocs.windows96.net/interfaces/StandardWindow.html) class, which is found in `w96.StandardWindow`.

It is not recommended to instantiate this class directly, as you're meant to be using [`this.createWindow`](https://apidocs.windows96.net/interfaces/WApplication.html#createWindow) inside a WApplication instance, for resource management reasons.

## How windows are created

As mentioned before, windows are created with the function below

```javascript
createWindow(params: WindowParams, isAppWindow: Boolean): StandardWindow
```

The `params` parameter is an object that contains the initialization parameters to use to create the window. These parameters include fields like `title`, `resizable`, etc.

The `isAppWindow` parameter specifies if the window is an app window (main window). An app window will destroy all child dialogs that have been created inside the `WApplication` instance when closed, and will trigger an application termination event.

## Creating a basic window

Here is an application that creates a very basic window with some text as the HTML body. You can run it with `basic-window-test` through the run box or the terminal.

```javascript
const { register } = w96.app;
const { Theme } = w96.ui;

class BasicWindowTest extends WApplication {
    constructor() { super(); }
    
    async main(argv) {
        super.main(argv);
        
        // 1. Create the window and assign it to a variable
        const mainwnd = this.createWindow({
            title: "Basic Window",
            body: "this is a very basic window."
        }, true);
        
        // 2. Show it
        mainwnd.show();
    }
}

register({
    command: "basic-window-test",
    type: "gui",
    cls: BasicWindowTest,
    meta: {
        icon: Theme.getIconUrl("exec"),
        friendlyName: "Basic Window Test"
    }
});
```

The result should be something like this:

![The resultant window. It has no icon and does not show itself in the taskbar.](https://543967396-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McsE7-aoYBgJN2_hYWT%2F-MgLKUoGb1h0h9Fc_OQQ%2F-MgLMKf_H5v5UictKQIw%2Fimage.png?alt=media\&token=9f6677ea-3d10-46bd-a7a6-ff7b2317a592)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windows96.gitbook.io/dev-docs/api-usage/gui/creating-a-window.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
