# Create window at runtime from scratch

**URL:** <https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297>\
**Category:** Other\
**Created:** [21 March 2025 19:55 UTC](https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297 "2025-03-21T19:55:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [21 March 2025 19:55 UTC](https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297/1 "2025-03-21T19:55:05Z")

</div>

> **[Making desktopwindow at runtime with controls inside?](https://forum.xojo.com/t/making-desktopwindow-at-runtime-with-controls-inside/84653)**
>
> in the attached project, I want to make a window the width of a button, and display a listbox inside to edit. 1/ how to display the window just below the button ? 2/ why can’t I resize the window vertically ? 3/ why does the close button of the...

@JeanYves  
This CANT work  
When you call

```auto
mainWindow = New DesktopWindow

```

that calls the OS to set the TYPE of window - floating etc  
So the window is created with that TYPE then

And later trying to do

```auto
mainWindow.Type = DesktopWindow.Types.Document

```

will have no effect

And its not a bug  
The OS works the way it works  
Its why you design the window classs with this value already set and then when you create a new instance the TYPE gets used as expected

---

<div class="post-metadata">

**Author:** ![JeanYves](https://ifnotnil.com/user_avatar/ifnotnil.com/jeanyves/32/4870_2.png) [@JeanYves](https://ifnotnil.com/u/JeanYves)\
**Post date:** [21 March 2025 20:25 UTC](https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297/2 "2025-03-21T20:25:59Z")

</div>

thanks Norman for this explaination !  
so not only the type but also the resizable and close button and everything ?

---

<div class="post-metadata">

**Author:** ![npalardy](https://ifnotnil.com/user_avatar/ifnotnil.com/npalardy/32/10_2.png) [@npalardy](https://ifnotnil.com/u/npalardy)\
**Post date:** [21 March 2025 21:18 UTC](https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297/3 "2025-03-21T21:18:22Z")

</div>

SOME of these things are NOT changeable at runtime after the window is created

> **[DesktopWindow — Xojo documentation](https://documentation.xojo.com/api/user_interface/desktop/desktopwindow.html#desktopwindow-type)**

Several properties are supposed to be Design Time Only properties but dont behave that way - I forget why that is  
Possibly because on Windows & Linux you can change the type after it s created but on MacOS you cant  
I really dont remember

But thats why you cant create a window of the right type from scratch the way your code reads  
It just doesnt work

Sad no one there could answer you correctly

---

<div class="post-metadata">

**Author:** ![anic297](https://ifnotnil.com/user_avatar/ifnotnil.com/anic297/32/18_2.png) [@anic297](https://ifnotnil.com/u/anic297)\
**Post date:** [23 March 2025 08:24 UTC](https://ifnotnil.com/t/create-window-at-runtime-from-scratch/4297/4 "2025-03-23T08:24:07Z")

</div>

> [@JeanYves](#):
>
> so not only the type but also the resizable and close button and everything?

In plain Xojo code, yes, but the OS supports changing most of them. The MBS plugin, for example, allows to change closable, zoomable and minimise-able properties.
