# VMainWindow: ejemplos

## 1. Cambiar titulo de la ventana principal

```javascript
// Escribiendo el título directamente
theMainWindow.setWindowTitle( "Nuevo título" );

// Usando variables
var szTitulo = "Aplicación " + szAppName;
theMainWindow.setWindowTitle( szAppName );
```

## 2. Cambiar a modo MDI

```javascript
theMainWindow.setBootMode(1);
```

## 3. Cambiar features de un dock

```javascript
// Barra de titulo vertical + Cerrable
theMainWindow.setDockFeatures( "DOCK_MAIN", 0x09 );
```

## 4. Ver/Ocultar un dock

```javascript
// -----------------------------------------------------------
// Muestra u oculta un dock en función de si está visible o no
// -----------------------------------------------------------
if ( theMainWindow.isDockVisible( "DOCK_MAIN" ) )
{
    theMainWindow.hideDock( "DOCK_MAIN" );
}
else
{
    theMainWindow.showDock( "DOCK_MAIN" );
};
```

## 5. Apagar el boton cerrar del marco

```javascript
theMainWindow.customizeWindowHint(0x01|0x02|0x04|0x08);
```

## 6. Tener una opción de menú abierta sólo una vez en una pestaña

```javascript
// --------------------------------------------------------------------------------
// Busca una vista con el título y si la encuentra la habilita
// Si no la encuentra ejecuta la acción
//
// El proceso recibe 2 parámetros a través de las variables locales
// TITULO = Título de la pestaña
// ACCION = Acción a ejecutar
// -------------------------- 
var numVistas = theMainWindow.viewsCount();
var ejecutar = true;

for ( i = 0; i < numVistas + 1; i++ )
{
    var vista = theMainWindow.currentView()
    if ( vista.title() == theRoot.varToString( "TITULO" ) )
    {
        ejecutar = false;
    }
    else
    {
        theMainWindow.nextView();
    };
}

// Si no se ha encontrado se lanza la acción para abrir la vista y se retorna true (para seguir)
if ( ejecutar == true )
{
    theMainWindow.runAction( theRoot.varToString( "ACCION" ) );
};
```

## 7. Deshabilitar los controles de un formulario

```javascript
/**
 * --------------------------------------------------------------------------------
 * Deshabilita los controles del formulario
 *
 * @param {VFormDataView} formularioParam Formulario a procesar
 * --------------------------------------------------------------------------------
 */
var deshabilitaControles = function ( formularioParam )
{
    if ( formularioParam )
    {        
        var tiposEnabled = [ VMainWindow.WTypeDataView, VMainWindow.WTypeMdiView, 
                             VMainWindow.WTypeWebView, VMainWindow.WTypeTabWidget,
                             VMainWindow.WTypeStackedWidget, VMainWindow.WTypeToolBox,
                             VMainWindow.WTypeSplitter, VMainWindow.WTypeGroupBox ];
        var control;

        for ( var numControl = 0; numControl < formulario.controlCount(); numControl++ )
        {
            control = formulario.control( numControl );

            if ( control )
            {
                tipo = theMainWindow.widgetType( control );
                if ( tiposEnabled.indexOf( tipo ) === -1 )
                {
                    control.enabled = false;
                };
            };
        };
    };
};
```


---

# 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://doc.velneo.com/32/velneo-vdevelop/scripts/lenguajes/javascript/clases/vmainwindow/vmainwindow-ejemplos.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.
