SkinCrafter DLL interface for PB 3.94

Share your advanced PureBasic knowledge/code with the community.
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

SkinCrafter DLL interface for PB 3.94

Post by Ramihyn_ »

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 :)

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


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.

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

Roberth_12
User
User
Posts: 15
Joined: Thu Oct 03, 2013 4:21 am
Location: Colombia
Contact:

Re: SkinCrafter DLL interface for PB 3.94

Post by Roberth_12 »

Ramihyn_, good morning.

I'm testing the code with SkinCrafterDll_vs2005.dll version 3.8.1.0 and PB 5.31 but I can not make it work. The SkinCrafterDll.dll Version 1.8.2.0 can not get it. It takes for this DLL ?.

Regards
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: SkinCrafter DLL interface for PB 3.94

Post by Bisonte »

Have you tried to compile it in ASCII and with PB x86 ?
This may helps....
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: SkinCrafter DLL interface for PB 3.94

Post by IdeasVacuum »

SkinCrafter seems to have moved on and do not use a DLL now? Also, the license is 499USD :shock:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Roberth_12
User
User
Posts: 15
Joined: Thu Oct 03, 2013 4:21 am
Location: Colombia
Contact:

Re: SkinCrafter DLL interface for PB 3.94

Post by Roberth_12 »

If I have compiled com PB x86, I found the version 3.0.2 and does not work, it seems to have changed. I will look for other options.

Thank you.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: SkinCrafter DLL interface for PB 3.94

Post by ricardo »

Using 5.73 onb W10 getting error here

Code: Select all

Procedure.l BSTR(ansi.s)
  size.l = MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0) + 1 ; ERROR HERE SAYS THIS IS NOT A FUNCTION
  Dim unicode.w(size)
  MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size) ; ERROR HERE SAYS THIS IS NOT A FUNCTION
  ProcedureReturn unicode()
EndProcedure

ARGENTINA WORLD CHAMPION
User avatar
mk-soft
Always Here
Always Here
Posts: 6205
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SkinCrafter DLL interface for PB 3.94

Post by mk-soft »

Purebasic is UC16

Code: Select all

*bstr = SysAllocString_("Hello World")

Debug PeekS(*bstr)
Debug PeekL(*bstr - SizeOf(Long))

SysFreeString_(*bstr)
SysAllocString create a BSTR
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Bitblazer
Enthusiast
Enthusiast
Posts: 761
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: SkinCrafter DLL interface for PB 3.94

Post by Bitblazer »

WindowBlinds would be a better and more affordable option. In 2021 a html5 based engine like sciter should be evaluated, but not before PureBasic 6 is released.
Post Reply