PDA

Click to See Complete Forum and Search --> : PowerBASIC - WinLIFT Skin Engine + animated bitmap


ZAP
Feb 25th, 2003, 01:19 PM
'This is a PowerBASIC example (http://www.powerbasic.com)
'
'However it could be easily translated to either C, Delphi or VB.
'because it uses only native Windows SDK API syntax code.
'
'source code + exe could be downloaded from there:
'http://www.zapsolution.com/preview/skinwin.zip
'(size of the ZIP file: 137115 bytes)
'(size of SKINWIN.EXE 10240 bytes)
'(size of SKINENGINE.DLL + SKSDKAPI.DLL 79822 + 22528 bytes)
'No runtime required.
'
' ---------------------------------------------------------------------------------
'
'There are more than 40 skins available for the WinLIFT SkinEngine
'You can learn more about the engine from this url:
'http://www.zapsolution.com/winlift/index.htm
'
'The main WinLIFT demo including the GDI+ helper is available from:
'http://www.zapsolution.com/preview/WinLIFT.exe
'
'
'You just require one single line of code to skin a window!
'Ret& = skSkinMainWindow(hWnd&, CaptionTip$)
'
'
'+--------------------------------------------------------------------------+
'| |
'| SkinWIN |
'| |
'| Windows SDK programming style template. |
'| |
'| WinLIFT SkinEngine |
'| |
'| Version 3.00 |
'| |
'+--------------------------------------------------------------------------+
'| |
'| Author Patrice TERRIER |
'| 8 Domaine de Rochagnon. 38800 Champagnier FRANCE |
'| http://www.zapsolution.com |
'| E-mail: pterrier@zapsolution.com |
'| |
'| copyright (c) 2003 Patrice TERRIER |
'| |
'+--------------------------------------------------------------------------+
'| Project started on : 02-24-2003 |
'| Last revised : 02-24-2003 |
'+--------------------------------------------------------------------------+

#COMPILE EXE "skinwin.exe"
#INCLUDE "win32api.inc"

'/////////////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION skAnimate LIB "SKENGINE.DLL" ALIAS "SKANIMATE" (BYVAL hParent&, BYVAL hBitmap&, BYVAL x&, BYVAL y&) AS LONG
DECLARE FUNCTION skLoadImage LIB "SKENGINE.DLL" ALIAS "SKLOADIMAGE" (BYVAL BmpFile$) AS LONG
DECLARE FUNCTION skSkinMainWindow LIB "skSDKapi.dll" ALIAS "skSkinMainWindow" (BYVAL hWnd&, OPTIONAL BYVAL SysButTip$) AS LONG
'/////////////////////////////////////////////////////////////////////////////////////

FUNCTION WndProc(BYVAL hWnd& , BYVAL Msg&, BYVAL wParam&, BYVAL lParam&) AS LONG

LOCAL rc AS RECT
LOCAL ps AS PAINTSTRUCT

SELECT CASE Msg&
CASE %WM_DESTROY
CALL PostQuitMessage(0)
END SELECT

FUNCTION = DefWindowProc(hWnd&, Msg&, wParam&, lParam&)

END FUNCTION

FUNCTION WinMain (BYVAL hInstance AS LONG, _
BYVAL hPrevInstance AS LONG, _
BYVAL lpCmdLine AS ASCIIZ PTR, _
BYVAL iCmdShow AS LONG) AS LONG

LOCAL msg AS tagMSG
LOCAL wc AS WNDCLASSEX
LOCAL szClassName AS ASCIIZ * 128
szClassName = "SkinWin"

IF ISFALSE(hPrevInstance&) THEN
wc.cbSize = SIZEOF(wc)
wc.style = %CS_HREDRAW OR %CS_VREDRAW
wc.lpfnWndProc = CODEPTR(WndProc)
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hInstance&
wc.hIcon = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
wc.hCursor = LoadCursor(%NULL, BYVAL %IDC_ARROW)
wc.hbrBackground = GetStockObject(%BLACK_BRUSH)
wc.lpszMenuName = %NULL
wc.lpszClassName = VARPTR(szClassName)
wc.hIconSm = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
CALL RegisterClassEx(wc)
END IF
hWnd& = CreateWindowEx(0, _
szClassName, _ ' window class name
"WinLIFT http://www.zapsolution.com", _ ' window caption
%WS_OVERLAPPEDWINDOW, _ ' window style
%CW_USEDEFAULT, _ ' initial x position
%CW_USEDEFAULT, _ ' initial y position
%CW_USEDEFAULT, _ ' initial x size
%CW_USEDEFAULT, _ ' initial y size
%NULL, _ ' parent window handle
%NULL, _ ' window menu handle
hInstance&, _ ' program instance handle
BYVAL %NULL) ' creation parameters
IF hWnd& THEN

'///////////////////////////////////////////////////////////////////////
CaptionTip$ = "Dock|Undock|Minimize|Maximize|Restore|Close"
Ret& = skSkinMainWindow(hWnd&, CaptionTip$)
' Ret& = %FALSE means unable to skin the window
' Ret& = %TRUE skinning has been done

CALL skAnimate(hWnd&, skLoadImage("HEART.BMP"), 20, 50)

'///////////////////////////////////////////////////////////////////////

CALL ShowWindow(hWnd&, %SW_SHOW)
CALL UpdateWindow(hWnd&)

DO WHILE GetMessage(msg, %NULL, 0, 0)
TranslateMessage msg
DispatchMessage msg
LOOP

FUNCTION = msg.wParam
END IF

END FUNCTION
'

ZAP
Feb 26th, 2003, 02:27 PM
I just updated the SkinWin.ZIP demo with new WinLIFT controls
and a new skin for the fun.

The new controls are:


CALL skButtonPush(hWnd&, "My push button", 0, 100, 20, 120, 20, 1)

CALL skButtonRadio(hWnd&, "My radio button 1", 0, 100, 50, 140, 20, 2)
CALL skButtonRadio(hWnd&, "My radio button 2", 0, 100, 70, 140, 20, 2)

CALL skButtonCheck(hWnd&, "My check button", 0, 100, 100, 140, 20, 3)


See the header section of the provided source code for declaration prototype

Here is the link to download the new file:
http://www.zapsolution.com/preview/skinwin.zip