TSkin
Fuente: source/classes/skin.prg
Inherits from: TControl
TSkin applies a custom bitmap-based skin to a window, replacing the standard Windows title bar, borders and caption buttons with styled images. It loads 11 component bitmaps from a skin folder (corner pieces, edge tiles, close/maximize/minimize buttons) and handles hit-testing, window dragging and resizing. A convenience function SKIN() provides one-line activation.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
aBmp | Array | Array of 11 TBitmap objects forming the skin: corners (1-3,5-7), edges (4,8), buttons (9-11) |
cSkin | Character | Path to the skin folder containing w01-w12, close, max, min .bmp files |
nTrans | Numeric | Window transparency level (0-255) |
lReSize | Logical | Enable window resizing by dragging skin edges/corners |
nTextColor | Numeric | Color of the title bar text |
Methods
| Method | Description |
|---|---|
New( oWnd, cSkin, nTrans, lReSize, nTextColor, nTextTop ) | Create a skin overlay. Loads all 11 bitmap components from the skin folder |
Update() | Reposition and redraw all skin elements to match the current window size and position |
Position( oBmp, nTop, nLeft, nWidth, nHeight ) | Position a skin bitmap at the given coordinates and dimensions |
Transparent( nTrans ) | Adjust the transparency level of the skin |
End() | Clean up and remove the skin |
SKIN() Function
| Syntax | Description |
|---|---|
SKIN( oWnd, cSkinFolder ) | Free function that creates a TSkin instance attached to the given window |
Example: Apply Custom Skin to Window
#include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Skinned Window" SIZE 600, 400
SKIN( oWnd, "c:\skins\mySkin\" )
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- The skin folder must contain at least 8 bitmap files: w01.bmp through w12.bmp, plus close.bmp, max.bmp, and min.bmp for the caption buttons.
- The 11 bitmaps are arranged as: top-left corner (w01), top edge tile (w02), top-right corner (w04), left edge tile (w05), right-bottom corner (w12), bottom-center tile (w10), bottom-left corner (w09), right edge tile (w08), close button, maximize button, minimize button.
- When
lReSizeis enabled, the edge and corner pieces change cursors to indicate resizable areas (EW, NS, NESW, NWSE). - The center-top bitmap (w02) is draggable to move the window; its
bLClickedsendsWM_SYSCOMMAND / MOUSE_MOVE. - TSkin uses
bPaintedon the parent window to callUpdate()after each window repaint, ensuring the skin stays aligned. - Transparency is applied per the
nTransvalue (0 = fully transparent, 255 = fully opaque).