Page 1 of 1

SkinCrafter DLL interface for PB 3.94

Posted: Thu Mar 02, 2006 8:53 pm
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


Re: SkinCrafter DLL interface for PB 3.94

Posted: Thu Jun 18, 2015 3:04 pm
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

Re: SkinCrafter DLL interface for PB 3.94

Posted: Thu Jun 18, 2015 8:31 pm
by Bisonte
Have you tried to compile it in ASCII and with PB x86 ?
This may helps....

Re: SkinCrafter DLL interface for PB 3.94

Posted: Thu Jun 18, 2015 10:09 pm
by IdeasVacuum
SkinCrafter seems to have moved on and do not use a DLL now? Also, the license is 499USD :shock:

Re: SkinCrafter DLL interface for PB 3.94

Posted: Mon Jun 22, 2015 6:57 am
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.

Re: SkinCrafter DLL interface for PB 3.94

Posted: Sat Aug 07, 2021 7:17 pm
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


Re: SkinCrafter DLL interface for PB 3.94

Posted: Sat Aug 07, 2021 11:15 pm
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

Re: SkinCrafter DLL interface for PB 3.94

Posted: Sun Aug 08, 2021 12:20 am
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.