SkinSetDefault

Syntax

Success = SkinSetDefault(Skin)

Description

Sets the specified skin object as the default skin for the application.

Parameters

Skin
The handle of the skin object (created with CreateSkin() or LoadSkin()) to set as the default.

Return Value

Returns #True if the default skin was successfully set, or #False if the provided skin handle was invalid.

Remarks

The default skin is used by widgets that do not have a specific skin assigned via WidgetSetSkin(). It is also the target for skin commands where the optional `Skin` parameter is omitted (e.g., SkinSetValue() called with `Skin=#Null`). Changing the default skin may affect the appearance of existing widgets that rely on it, potentially requiring a redraw (WindowUpdate(0) might be needed).

Example

IncludeFile "ProGUI_PB.pbi"
StartProGUI()

; Create or load two different skins
Skin1 = CreateSkin("Skin1")
SkinSetValue("button", "", "", "background-color", "red", Skin1)

Skin2 = CreateSkin("Skin2")
SkinSetValue("button", "", "", "background-color", "green", Skin2)

If Skin1 And Skin2

; Initially, the default skin might be an internal one or Skin1 if set first
Debug "Initial default skin handle: " + SkinGetDefault()

; Set Skin2 as the default
SkinSetDefault(Skin2)
Debug "New default skin handle: " + SkinGetDefault() ; Should be Skin2's handle

; Create a widget - it will use Skin2 because it's the default
MyWindow = CreateWindow(0, 0, 200, 100, "Default Skin Test")
Layout = WindowGetLayout(MyWindow)
MyButton = CreateWidget(10, 10, 100, 30)
WidgetSetClass(MyButton, "button") ; Button should appear green

WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow

EndIf

StopProGUI()

See Also

SkinGetDefault, CreateSkin, LoadSkin, WidgetSetSkin

Supported OS

Windows, Linux