# User32Addition

{% hint style="info" %}
Module

**Windows only! Some features are available for macOS too in** [**AppKitAddition**](/add-ons/cstruecolors/documentation/appkitaddition.md)**.**
{% endhint %}

## Overview

### Methods

| Overview                                                                                                                                        |                                                                                                                                                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [BringToFront](/add-ons/cstruecolors/documentation/user32addition.md#bringtofront-expands-w-as-window)                                          | [IdealHeight](/add-ons/cstruecolors/documentation/user32addition.md#idealheight-expands-p-as-pushbutton-as-integer)                                                                                                                                             |
| [IdealWidth](/add-ons/cstruecolors/documentation/user32addition.md#idealwidth-expands-p-as-pushbutton-as-integer)                               | [Image](/add-ons/cstruecolors/documentation/user32addition.md#image-extends-s-as-pushbutton-radiobutton-scaling-as-nsimagescaling-nsimagescaling-none-position-as-nscellimageposition-nscellimageposition-imageleft-assigns-pic-as-picture-mac-win)             |
| [Images](/add-ons/cstruecolors/documentation/user32addition.md#images-extends-parent-as-menuitem-s-as-menuitem-assigns-pics-as-picture-mac-win) | [MakeComposited](/add-ons/cstruecolors/documentation/user32addition.md#makecomposited-extends-w-as-window-rectcontrol)                                                                                                                                          |
| [MakeLayered](/add-ons/cstruecolors/documentation/user32addition.md#makelayered-extends-w-as-window-rectcontrol-redraw-as-boolean-true)         | [MakeTransparent](/add-ons/cstruecolors/documentation/user32addition.md#maketransparent-extends-w-as-rectcontrol-window-transparencycolor-as-color-and-cffffffff-alpha-as-byte-0)                                                                               |
| [SizeToFit](/add-ons/cstruecolors/documentation/user32addition.md#sizetofit-extends-p-as-pushbutton-radiobutton)                                | [Template](/add-ons/cstruecolors/documentation/user32addition.md#template-extends-s-as-pushbutton-scaling-as-nsimagescaling-nsimagescaling-proportionallyupordown-position-as-nscellimageposition-nscellimageposition-imageleft-assigns-pic-as-picture-mac-win) |

## Documentation

### Methods

#### BringToFront (expands w As Window) `[mac + win]`

Brings the window to the front of the z oder.&#x20;

#### IdealHeight(expands p As PushButton) As Integer

Returns the ideal height of a pushbutton, or -1 if it cannot be calculated.

#### IdealWidth(expands p As PushButton) As Integer

Returns the ideal width of a pushbutton, or -1 if it cannot be calculated.

#### Image(extends s As PushButton / RadioButton, scaling As NSImageScaling = NSImageScaling.None, position As NSCellImageposition = NSCellImageposition.imageleft, assigns pic As Picture) `[mac + win]`

Sets the image that appears on the button when it’s in an off state, or nil if there is no such image.

{% hint style="danger" %}
This currently crashes the project under Windows silently when an image or template is assigned second time to a button – because of getting its handle, not because of the declare.
{% endhint %}

{% hint style="info" %}
Scaling and Position are ignored on Windows.
{% endhint %}

#### Images(extends parent As Menuitem, s As Menuitem, assigns pics() As Picture) `[mac + win]`

Sets the offstate and onstate images for a menuitem. \
Example: If you have a menuitem mi with a child miChild and want to set off- and onstateimage for miChild:\
`mi.Images(miChild) = Array(onStateImage, offStateImage)`

#### MakeComposited(extends w as Window / RectControl)

Makes the window or control a composited (buffered) window to avoid flicker in a non-transparent environment.

{% hint style="warning" %}
You should make a window either compositied or layered, not both.
{% endhint %}

#### MakeLayered(extends w as Window / RectControl, Redraw As Boolean = True)

Makes a window a layered window, redrawing it optionally. Use Layered Windows to avoid flicker in situations where transparencies are rendered.

#### MakeTransparent(extends w As RectControl / Window, TransparencyColor as Color = \&cffffffff, Alpha As Byte = 0)

Makes a rectcontrol or a window transparent by turning every appearance of transparencyColor into transparency with an alpha value between 0 (fully) and 255 (opaque). Sets the window to PopupStyle to allow a fully transparent window without title bar. Makes the Window or control layered too.

{% hint style="info" %}
Works for windows on macOS too. Use [Alpha](/add-ons/cstruecolors/documentation/appkitaddition.md#alpha-extends-w-as-window-rectcontrol-assigns-value-as-integer-as-integer) for controls under macOS.
{% endhint %}

#### SizeToFit(extends p as Pushbutton / RadioButton)

Resizes a button to the optimum space to show all content if possible.

#### Template(extends s As PushButton, scaling As NSImageScaling = NSImageScaling.ProportionallyUpOrDown, position As NSCellImageposition = NSCellImageposition.imageleft, assigns pic As Picture) `[mac + win]`

Identical to [*Image*](/add-ons/cstruecolors/documentation/appkitaddition.md#image-extends-s-as-segmentedcontrol-index-as-integer-scaling-as-nsimagescaling-nsimagescaling-proportionallyupordown-assigns-pic-as-picture), only that here the template representation of the image is being used.

{% hint style="danger" %}
This currently crashes the project under Windows silently when an image or template is assigned second time to a button – because of getting its handle, not because of the declare.
{% endhint %}


---

# 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://xojo.gitbook.io/add-ons/cstruecolors/documentation/user32addition.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.
