SkinCrafter DLL interface for PB 3.94
Posted: Thu Mar 02, 2006 8:53 pm
Code updated For 5.20+
This enables the simple use of the SkinCrafter DLL with PureBasic 3.x. It was tested with PB 3.94 and the SkinCrafter DLL Version 1.8.2.0 - not all functions are mapped but all important ones are. The "UpdateWnd" functions is mapped as "UpdateWindow" as thats what it is named in the documentation.
This code is hereby put into the public domain. Have fun
Sample application to use the SkinCrafter library. Just copy the "SkincrafterDll.dll" and the "Azurix.skf" Skin into the directory of your PB sources/project.
This enables the simple use of the SkinCrafter DLL with PureBasic 3.x. It was tested with PB 3.94 and the SkinCrafter DLL Version 1.8.2.0 - not all functions are mapped but all important ones are. The "UpdateWnd" functions is mapped as "UpdateWindow" as thats what it is named in the documentation.
This code is hereby put into the public domain. Have fun

Code: Select all
; SkinCrafter interface routines for PureBasic 3.94
; only the commonly needed routines are mapped
; call SkinCrafter_Init() before opening any window and SkinCrafter_Exit() before exiting
; the SkinCrafter_Init() parameters are the registration params for "InitLicenKeys()"
Structure SkinCrafter_DLL_type
dll.l
; function adresses of SkinCrafter DLL functions
ApplySkin.l
DecorateAs.l
DefineLanguage.l
DeInitDecoration.l
InitDecoration.l
InitLicenKeys.l
LoadSkinFromFile.l
RemoveSkin.l
UpdateControl.l
UpdateWindow.l
dummyvalue.l
EndStructure
Global SkinCrafter.SkinCrafter_DLL_type
Procedure.l BSTR(ansi.s)
size.l = MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0) + 1
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size)
ProcedureReturn unicode()
EndProcedure
Procedure.l SkinCrafter_ApplySkin()
If (SkinCrafter\dll <> 0)
ProcedureReturn CallCFunctionFast(SkinCrafter\ApplySkin)
EndIf
ProcedureReturn -1
EndProcedure
Procedure SkinCrafter_DefineLanguage(langID.l)
If (SkinCrafter\dll <> 0)
CallCFunctionFast(SkinCrafter\DefineLanguage, langID)
EndIf
EndProcedure
Procedure SkinCrafter_DecorateAs(hWnd.l, type.l)
If (SkinCrafter\dll <> 0)
CallCFunctionFast(SkinCrafter\DecorateAs, hWnd, type)
EndIf
EndProcedure
Procedure SkinCrafter_DeInitDecoration()
If (SkinCrafter\dll <> 0)
CallCFunctionFast(SkinCrafter\DeInitDecoration, p1)
EndIf
EndProcedure
Procedure.l SkinCrafter_InitDecoration(p1.l)
If (SkinCrafter\dll <> 0)
ProcedureReturn CallCFunctionFast(SkinCrafter\InitDecoration, p1)
EndIf
ProcedureReturn -1
EndProcedure
Procedure.l SkinCrafter_InitLicenKeys(p1$, p2$, p3$, p4$, p5$)
result = -1
If (SkinCrafter\dll <> 0)
result = CallCFunctionFast(SkinCrafter\InitLicenKeys, BSTR(p1$), BSTR(p2$), BSTR(p3$), BSTR(p4$), BSTR(p5$))
EndIf
ProcedureReturn result
EndProcedure
Procedure.l SkinCrafter_LoadSkinFromFile(filename$)
If (SkinCrafter\dll <> 0)
result = CallCFunctionFast(SkinCrafter\LoadSkinFromFile, BSTR(filename$))
ProcedureReturn result
EndIf
ProcedureReturn -1
EndProcedure
Procedure.l SkinCrafter_RemoveSkin()
If (SkinCrafter\dll <> 0)
ProcedureReturn CallCFunctionFast(SkinCrafter\RemoveSkin)
EndIf
ProcedureReturn -1
EndProcedure
Procedure.l SkinCrafter_UpdateControl(nID.l)
If (SkinCrafter\dll <> 0)
ProcedureReturn CallCFunctionFast(SkinCrafter\UpdateControl, nID)
EndIf
ProcedureReturn -1
EndProcedure
Procedure.l SkinCrafter_UpdateWindow(hWnd.l)
If (SkinCrafter\dll <> 0)
ProcedureReturn CallCFunctionFast(SkinCrafter\UpdateWindow, hWnd)
EndIf
ProcedureReturn -1
EndProcedure
; Initialisation of SkinCrafter Library
; returns:
;
; 1 - SkinCrafter Lib successfully inited
; -1 - couldnt open lib
; -2 - a necessary function in the lib is missing
Procedure SkinCrafter_Init(p1$, p2$, p3$, p4$, p5$)
SkinCrafter\dll = OpenLibrary(#PB_Any, "SkinCrafterDll.dll")
If (SkinCrafter\dll <> 0)
SkinCrafter\ApplySkin = GetFunction(SkinCrafter\dll, "ApplySkin")
SkinCrafter\DecorateAs = GetFunction(SkinCrafter\dll, "DecorateAs")
SkinCrafter\DefineLanguage = GetFunction(SkinCrafter\dll, "DefineLanguage")
SkinCrafter\DeInitDecoration = GetFunction(SkinCrafter\dll, "DeInitDecoration")
SkinCrafter\InitDecoration = GetFunction(SkinCrafter\dll, "InitDecoration")
SkinCrafter\InitLicenKeys = GetFunction(SkinCrafter\dll, "InitLicenKeys")
SkinCrafter\LoadSkinFromFile = GetFunction(SkinCrafter\dll, "LoadSkinFromFile")
SkinCrafter\RemoveSkin = GetFunction(SkinCrafter\dll, "RemoveSkin")
SkinCrafter\UpdateControl = GetFunction(SkinCrafter\dll, "UpdateControl")
SkinCrafter\UpdateWindow = GetFunction(SkinCrafter\dll, "UpdateWnd")
; Functions of SkinCrafter 1.8.2.0 Library
; FName: AboutSkinCrafter
; FName: AddAdditionalThread
; FName: AddDrawImage
; FName: AddDrawText
; FName: ApplySkin
; FName: DeInitDecoration
; FName: DecorateAs
; FName: DefineLanguage
; FName: DeleteAdditionalThread
; FName: DoDecorate
; FName: DoNotDecorate
; FName: ExcludeWnd
; FName: GetSkinCopyRight
; FName: IncludeWnd
; FName: InitDecoration
; FName: InitLicenKeys
; FName: LoadSkinFromFile
; FName: RemoveDrawItem
; FName: RemoveSkin
; FName: SetCustomSkinWnd
; FName: UpdateControl
; FName: UpdateWnd
; dump DLL function names
; If (ExamineLibraryFunctions(SkinCrafter\dll) <> 0)
; While (NextLibraryFunction() <> 0)
; Debug "FName: " + LibraryFunctionName()
; Wend
; EndIf
valid = 1
sptr.l = @SkinCrafter\ApplySkin
While (sptr < @SkinCrafter\dummyvalue)
If (PeekL(sptr) = 0)
valid = 0
EndIf
sptr + SizeOf(SkinCrafter\ApplySkin)
Wend
If (valid <> 1)
CloseLibrary(SkinCrafter\dll)
SkinCrafter\dll = 0
ProcedureReturn -2
EndIf
SkinCrafter_InitLicenKeys(p1$, p2$, p3$, p4$, p5$)
SkinCrafter_DefineLanguage(3) ; use Delphi - using VB results in skinning bugs
SkinCrafter_InitDecoration(1)
ProcedureReturn 1
EndIf
ProcedureReturn -1
EndProcedure
Procedure SkinCrafter_Exit()
If (SkinCrafter\dll <> 0)
SkinCrafter_DeInitDecoration()
SkinCrafter_RemoveSkin()
CloseLibrary(SkinCrafter\dll)
SkinCrafter\dll = 0
EndIf
EndProcedure
Code: Select all
XIncludeFile "skincrafter.pb"
SkinCrafter_Init("0","SKINCRAFTER","SKINCRAFTER.COM","support@skincrafter.com","DEMOSKINCRAFTERLICENCE")
SkinCrafter_LoadSkinFromFile("azurix.skf")
If OpenWindow(0,50,50,320,240,"SkinCrafter PB Test",#PB_Window_SystemMenu)
ExplorerTreeGadget(0,5,5,200,200,"c:\")
ButtonGadget(1,210,5,90,30,"button")
SkinCrafter_ApplySkin()
SkinCrafter_UpdateControl(0)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
SkinCrafter_Exit()
End