CreateSkin

Syntax

Skin = CreateSkin(Name$)

Description

Creates a new, empty skin object in memory. This skin can then be populated with styling rules using SkinSetValue() or potentially saved later using SkinSave().

Parameters

Name$
A string identifying the name of the skin. This name is used when saving the skin.

Return Value

Returns a handle to the newly created skin object if successful, or #Null if the name was invalid or memory allocation failed.

Remarks

Creating a skin object is the first step if you intend to define skin properties programmatically rather than loading them from files. The created skin will be empty initially. You can set it as the default skin using SkinSetDefault().

Example

IncludeFile "ProGUI_PB.pbi"
StartProGUI()

; Create a new skin named "MyCustomSkin"
MySkin = CreateSkin("MyCustomSkin")

If MySkin
Debug "Skin 'MyCustomSkin' created successfully."

; Set it as the default
SkinSetDefault(MySkin)

; Define some rules for it programmatically
SkinSetValue("button", "", "", "background-color", "blue")
SkinSetValue("button", "hover", "", "background-color", "lightblue")

; ... create window and widgets that will use this skin ...
MyWindow = CreateWindow(0, 0, 200, 100, "Custom Skin")
Layout = WindowGetLayout(MyWindow)
LayoutSetPadding(Layout, 10)

MyButton = CreateWidget(0, 0, 100, 30)
WidgetSetClass(MyButton, "button") ; Match the skin rule

WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

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

Else
Debug "Failed to create skin."
EndIf

StopProGUI()

See Also

LoadSkin, SkinSave, SkinSetValue, SkinSetDefault

Supported OS

Windows, Linux