Jump to content

Skincrafter using DllCall


Recommended Posts

I'm trying to use skincrafter to skin a label with the default color, however this won't work:

DllCall("./SkincrafterDLL.dll", "int:cdecl", "SetCustomSkinWnd", "long", $GUI, "bstr", $test, "bool", "false")

Here is the syntax etc..

Description
Applies a custom skin for the proper window/control.

Syntax

void SetCustomSkinWnd(
   long hWnd,
   BSTR skinName,
   BOOL isFrame,
) 

Parameters
hWnd 
Handle to the window the custom skin will be applied to. 
skinName 
The string identifier of the proper custom skin 
isFrame 
The boolean value used to indicate whether the window specified by hWnd should use a custom skinning for its frame (TRUE) or apply custom skin to the window itself (FALSE) 
  
  
Remarks
If the custom skin specified by skinName does not exist in a loaded .skf file, the default skinning is applied.

Example
  public DMSoft.SkinCrafter SkinOb;
  public System.Windows.Forms.Button Button1;
  public System.Windows.Forms.Button Button2;
  public System.Windows.Forms.Form Form1;

  //Button1 will be skinned with Default button skin applied
  //Button2 will be skinned with "MyButtonGreen" button skin applied

  SkinOb.SetCustomSkinWnd(Button2.Handle.ToInt32() , "MyButtonGreen", false);

  //Form1 frame will be skinned with "MyDialogFrame" frame skin applied
  //Note: the third parameter is set to true, otherwise the Dialog background is applied;
  SkinOb.SetCustomSkinWnd(Form1.Handle.ToInt32(), "MyDialogFrame", true);
Link to comment
Share on other sites

Alight I looked at the datatypes for the DllCall function, and I can't quite figure out the return types for the last 2 functions in the dllcall.

This isn't working:

DllCall("./SkincrafterDLL.dll", "int:cdecl", "SetCustomSkinWnd", "hwnd", $GUI, "str", $test, "str", "false")

The first function is the Handle, of course the return type will be hwnd, right?

Second function is the label I am skinning using GUICtrlCreateLabel()

Third is a boolean, true or false.

Link to comment
Share on other sites

  • Moderators

All this time using skincrafter, and you can't use your old resources?

http://www.autoitscript.com/forum/index.ph...st&p=342206

BSTR is a Visual Basic string.

Why he used "long"

void SetCustomSkinWnd(

long hWnd,

BSTR skinName,

BOOL isFrame,

)

So you probably have to open the dll and initiate the license first, then set the skin. You'd use the BSTR function for BSTR, and we use "int" for Bool (1 = True, 0 = False).

"long", hwnd, "int", BSTR("Skin Name/Would be in the skin directory"), "int", 0

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks for the summary Smoke_N, I have not used skincrafter in a long time, and a lot in skincrafter has changed since that code you posted. (Plus I did not write that code)

Anyways, I am confused on how to specify what label to not skin. Notice in the example, it specifies the button in which to not skin, how would this be in autoit since there is only a parameter for the window handle, and not the control handle.

Link to comment
Share on other sites

  • Moderators

Thanks for the summary Smoke_N, I have not used skincrafter in a long time, and a lot in skincrafter has changed since that code you posted. (Plus I did not write that code)

Anyways, I am confused on how to specify what label to not skin. Notice in the example, it specifies the button in which to not skin, how would this be in autoit since there is only a parameter for the window handle, and not the control handle.

Do you see this in the summary you posted

Button2.Handle.ToInt32()

?

That would tell you that it's not the hwnd of the window it wants, the hwnd (handle) of the button it wants.

Next question from you I'm sure: "How do I get the handle to the button?" << Is that right? :P

You undoubtedly gave your button a variable name, which when using the native GUICtrlCreateButton() function will return a control ID and not a HWND.

So I would probably do something like:

$hWnd = ControlGetHandle($hGUI, "", $i_MyButtonICreated)
Then use the $hWnd as the handle/Long to pass.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks for the reply, you guess on my next question was exactly right!

So far I have this:

Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
    $Dll = DllOpen($SkincrafterDll)
    DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "SKINCRAFTER", "wstr", "SKINCRAFTER.COM", "wstr", "support@skincrafter.com", "wstr", "DEMOSKINCRAFTERLICENCE")
    DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
    DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
    DllCall($Dll, "int:cdecl", "DecorateAs", "int", $GUI, "int", 25)
    DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc  ;==>_SkinGUI
Func BSTR($str)
$len = StringLen($str)
$buff = DllCall("oleaut32.dll", "int", "SysAllocStringLen", "int", 0, "int", $len)
DllCall("kernel32.dll", "int", "MultiByteToWideChar", "int", 0, "int", 0, "str", $str, "int", $len, "ptr", $buff[0], "int", $len)
Return $buff[0]
EndFunc

#Include <GUIConstants.au3>

$GUI = GUICreate("")
_SkinGUI("./SkinCrafterDll.dll", "./Skin.skf", $GUI)
$Marker7 = GUICtrlCreateLabel("?", 50, 50, 53, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Marker7, 0x00FF00)
$Handle = ControlGetHandle($GUI, "", $Marker7)
DllCall("./SkinCrafterDLL.dll", "int:cdecl", "SetCustomSkinWnd", "long", $Handle, "int", BSTR("./Skin.skf"), "int", 0)
GUISetState(@SW_Show)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
EndSwitch
WEnd

However, nothing seems to happen to $Marker7, the skin remains the same. My goal is to try to get it back to the windows default, so it will be green.

Link to comment
Share on other sites

  • Moderators

Thanks for the reply, you guess on my next question was exactly right!

So far I have this:

Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
    $Dll = DllOpen($SkincrafterDll)
    DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "SKINCRAFTER", "wstr", "SKINCRAFTER.COM", "wstr", "support@skincrafter.com", "wstr", "DEMOSKINCRAFTERLICENCE")
    DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
    DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
    DllCall($Dll, "int:cdecl", "DecorateAs", "int", $GUI, "int", 25)
    DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc;==>_SkinGUI
Func BSTR($str)
$len = StringLen($str)
$buff = DllCall("oleaut32.dll", "int", "SysAllocStringLen", "int", 0, "int", $len)
DllCall("kernel32.dll", "int", "MultiByteToWideChar", "int", 0, "int", 0, "str", $str, "int", $len, "ptr", $buff[0], "int", $len)
Return $buff[0]
EndFunc

#Include <GUIConstants.au3>

$GUI = GUICreate("")
_SkinGUI("./SkinCrafterDll.dll", "./Skin.skf", $GUI)
$Marker7 = GUICtrlCreateLabel("?", 50, 50, 53, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Marker7, 0x00FF00)
$Handle = ControlGetHandle($GUI, "", $Marker7)
DllCall("./SkinCrafterDLL.dll", "int:cdecl", "SetCustomSkinWnd", "long", $Handle, "int", BSTR("./Skin.skf"), "int", 0)
GUISetState(@SW_Show)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
EndSwitch
WEnd

However, nothing seems to happen to $Marker7, the skin remains the same. My goal is to try to get it back to the windows default, so it will be green.

I'm not exactly sure what this function does for you. You assume it removes the skin, but I'm reading it as it sets a skin and will not skin something if you so request it.

I would use it after my initialization of my license (while the dll is open), as I stated before. And you seem to assume the "./Skin.skf" is acceptable, are you sure it doesn't need the full path? After all, that dll is not made in autoit, so you can't assume the same rules apply.

Edit:

P.S. That sets a skin, if you are using the same skin, you're like a fly hitting a window. I don't think this function prevents any hwnd from "not" being skinned, because if it's false, then it reverts to default skin (which the skin you initialized to begin with).

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I asked in the skincrafter support forum on how to change the color of a skinned label, and Paul (Admin) told me to use that function.

Yeah, but he's assuming you are going to use your own skin to do it I would think.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I think you are right, seeing as how the DoNotDecorate function works fine, however, the background of the label is not transparent, which is most likely a autoit problem. Do you how to set a label's background transparent.

--edit--

making the labels background transparent will not show the background of the skinned GUI, instead it just shows white. strange.

Edited by =sinister=
Link to comment
Share on other sites

  • Moderators

I think you are right, seeing as how the DoNotDecorate function works fine, however, the background of the label is not transparent, which is most likely a autoit problem. Do you how to set a label's background transparent.

--edit--

making the labels background transparent will not show the background of the skinned GUI, instead it just shows white. strange.

And now you know what your task is. To create a custom skin for each thing you want to change.

BTW, what version of skf are you using?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...