Transparent Button

Homepage: An easy way to create transparent button

TransBtnHwnd := DllCall("AHKCtrlSupport\CreateTransBtnID", Str, "BtnText", DWORD, dwexStyle, DWORD, Button1HWnd, "Cdecl Int")
You have two alternatives to create such a button:
* Place a Button on the dialog (Gui, Add, Button, x6 y20 w70 h60) and call CreateTransBtnID to replace the button with the transparent one or
* call CreateTransBtn and give the position, Size and ID as parameters.


TransBtnHwnd NULL if there was an error
The handle to the control. You must store this HWND to access the Dllcall of AdjustTransBtn to set the properties of the newly created button
Str "BtnText" Specifies the text to display on the button
dwexStyle See GUI styles in the AHK-help
Button1HWnd The HWND to the existing button which should be replaced. Use Button1HWnd := GetChildHWND(HWND, "Button1") to retrieve the handle



nRC := DllCall("AHKCtrlSupport\AdjustTransBtn", int, TransBtnHWND, int, nDark, int, nLight, int, 117, int, 114, int, 128, "Cdecl Int")


nRC returnvalue: 0 = error
1 = ok
TransBtnHWND Handle to the button from CreateTransBtnID
nDark BGR-Color of the dark text
nLight BGR-Color of the highlighted text
117 ID of the bmp-resource of the resourcedll
114 ID of the icon-resource of the resourcedll (shown when mouse is not over the button)
128 ID of the icon-resource of the resourcedll (shown when mouse is over the button)



Example:
; --------------- Create a Transparent Button ---------------------------
; -----------------------------------------------------------------------
;You have two possibilities: Replace a Standard-Button on a dialog (you have to use the function with the ID of an existing button) or creating a new one (you have to use the function with the x, y, width, height values)
dwexStyle := 0x40000000 | 0x10000000 | 0x00010000 | 0x0000000B | 0x00004000
; Parameters:
; in str, Text you wish on the Button
; in dword, Buttonstyles (See AHK-Help)
; in HWND, HWND of an existing button
; out, New handle to the control
TransBtnHwnd := DllCall("AHKCtrlSupport\CreateTransBtnID", Str, "BtnText", DWORD, dwexStyle, DWORD, Button1HWnd, "Cdecl Int")
if (errorlevel <> 0) || (TransBtnHwnd = 0)
{
	MsgBox error while calling CreateTransBtn Errorlevel: %errorlevel% - RC: %TransBtnHwnd%
	return
}

; Parameters:
; in Handle to the control
nDark=0x000000  ;BGR not RGB! -> Set the normal color when the mouse is not over the control
nLight=0x0000FF ;BGR not RGB! -> Set the Hilite color when the mouse is     over the control
; in ID of the button of the resource dll
nRC := DllCall("AHKCtrlSupport\AdjustTransBtn", int, TransBtnHWND, int, nDark, int, nLight, int, 117, int, 114, int, 128, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
	MsgBox error while calling AdjustTransBtn Errorlevel: %errorlevel% - RC: %nRC%
	return
}