#Include <APIConstants.au3>
#Include <GDIPlus.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
#Include <Array.au3>
#Include <Skinfile.au3>
_GDIPlus_Startup()
$Path = FileOpenDialog("Выберите скин", @ScriptDir, "AutoIt Skin(*.ask)")
If Not @error Then
$hPart = _SkinLoad($Path)
If Not @error Then
ReDim $hPart[$hPart[0][0] + 1][3]
For $i = 1 To $hPart[0][0]
$Size = _GDIPlus_GetImageDimension($hPart[$i][0])
For $j = 1 To 2
$hPart[$i][$j] = $Size[$j - 1]
Next
Next
Else
Exit
EndIf
Else
Exit
EndIf
$hForm = GUICreate('', -1, -1, -1, -1, BitOR($WS_POPUP, $WS_SIZEBOX), $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, ComposeBitmap(400, 400, $hPart), 255, 1)
GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
$iPos = WinGetPos($hForm)
$hGui = GUICreate('', 382, 363, $iPos[0] + 8, $iPos[1] + 28, BitOR($WS_CLIPCHILDREN, $WS_POPUP), -1, $hForm)
GUISetBkColor(0xEDEAE4)
$hExit = GUICtrlCreateButton("Exit", 20, 20, 50, 20)
GUISetState(@SW_SHOW, $hGui)
GUISetState(@SW_SHOW, $hForm)
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $hExit
Exit
EndSwitch
WEnd
Func ComposeBitmap($iWidth, $iHeight, ByRef $hPart)
Local $hGraphic, $hImage, $hThumb, $hBitmap
If IsArray($hPart) Then
$hImage = _GDIPlus_CreateBitmapFromScan0($iWidth, $iHeight)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[1][0], 0, 0, $hPart[1][1], $hPart[1][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[3][0], $iWidth - $hPart[3][1], 0, $hPart[3][1], $hPart[3][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[9][0], $iWidth - $hPart[9][1], $iHeight - $hPart[9][2], $hPart[9][1], $hPart[9][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[7][0], 0, $iHeight - $hPart[7][2], $hPart[7][1], $hPart[7][2])
$hThumb = _GDIPlus_GetImageThumbnail($hPart[2][0], $iWidth - ($hPart[1][1] + $hPart[3][1]), $hPart[2][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[1][1], 0, $iWidth - ($hPart[1][1] + $hPart[3][1]), $hPart[2][2])
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[6][0], $hPart[6][1], $iHeight - ($hPart[3][2] + $hPart[7][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $iWidth - $hPart[6][1], $hPart[3][2], $hPart[6][1], $iHeight - ($hPart[3][2] + $hPart[7][2]))
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[8][0], $iWidth - ($hPart[7][1] + $hPart[9][1]), $hPart[8][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[7][1], $iHeight - $hPart[8][2], $iWidth - ($hPart[7][1] + $hPart[9][1]), $hPart[8][2])
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[4][0], $hPart[4][1], $iHeight - ($hPart[1][2] + $hPart[7][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, 0, $hPart[1][2], $hPart[4][1], $iHeight - ($hPart[1][2] + $hPart[7][2]))
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[5][0], $iWidth - ($hPart[4][1] + $hPart[6][1]), $iHeight - ($hPart[1][2] + $hPart[7][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[4][1], $hPart[1][2], $iWidth - ($hPart[4][1] + $hPart[6][1]), $iHeight - ($hPart[1][2] + $hPart[7][2]))
_GDIPlus_ImageDispose($hThumb)
; Ставим иконку ---------------------------------------------------
$hIcon = _WinAPI_ShellExtractIcon(@AutoItExe, -99, 16, 16)
$aInfo = _WinAPI_GetIconInfo($hIcon)
$tBits = DllStructCreate('byte[' & (4 * 16 * 16) & ']')
$pBits = DllStructGetPtr($tBits)
_WinAPI_GetBitmapBits($aInfo[5], DllStructGetSize($tBits), $pBits)
$hBitmap = _GDIPlus_CreateBitmapFromScan0(16, 16, 4 * 16, $GDIP_PXF32ARGB, $pBits)
_WinAPI_DestroyIcon($hIcon)
For $i = 4 To 5
_WinAPI_DeleteObject($aInfo[$i])
Next
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 5, 5, 16, 16)
_GDIPlus_ImageDispose($hBitmap)
; Пишем заголовок окна --------------------------------------------
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 10, 0)
$tLayout = _GDIPlus_RectFCreate(25, 6, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "Window title", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphic, "Window title", $hFont, $aInfo[0], $hFormat, $hBrush)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "Window title", $hFont, $tLayout, $hFormat)
DllStructSetData($aInfo[0], 1, 24)
DllStructSetData($aInfo[0], 2, 5)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFEFEFE)
_GDIPlus_GraphicsDrawStringEx($hGraphic, "Window title", $hFont, $aInfo[0], $hFormat, $hBrush)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
Else
Return SetError(@error, @extended, 0)
EndIf
Return $hBitmap
EndFunc
Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipSetTextRenderingHint', 'ptr', $hGraphics, 'int', $iTextRenderingHint)
If (@error) Or ($Ret[0]) Then
Return SetError(@error, @extended, 0)
EndIf
Return 1
EndFunc ;==>_GDIPlus_GraphicsSetTextRenderingHint
Func _GDIPlus_CreateBitmapFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', $iStride, 'int', $iPixelFormat, 'ptr', $pScan0, 'ptr*', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(@error, @extended, 0)
EndIf
Return $Ret[6]
EndFunc
Func _GDIPlus_GetImageDimension($hImage)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hImage, 'float*', 0, 'float*', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(@error, @extended, 0)
EndIf
Local $Result[2]
For $i = 0 To 1
$Result[$i] = $Ret[$i + 2]
Next
Return $Result
EndFunc ;==>_GDIPlus_GetImageDimension
Func _GDIPlus_GetImageThumbnail($hImage, $iWidth, $iHeight)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageThumbnail', 'ptr', $hImage, 'uint', $iWidth, 'uint', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(@error, @extended, 0)
EndIf
Return $Ret[4]
EndFunc
Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case $hForm
Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
DllStructSetData($tMMI, 'MinTrackSize', 40, 1)
DllStructSetData($tMMI, 'MinTrackSize', 40, 2)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case $hForm
Local $iPos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
_WinAPI_UpdateLayeredWindowEx($hWnd, $iPos[0], $iPos[1], ComposeBitmap($iPos[2], $iPos[3], $hPart), 255, 1)
WinMove($hGui, "", $iPos[0] + 8, $iPos[1] + 28, $iPos[2] - 17, $iPos[3] - 37)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case $hForm
Switch _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
Case $HTCLIENT
Local $Info = GUIGetCursorInfo($hForm)
If (Not @error) And ($Info[1] < 25) Then
Return $HTCAPTION
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
Switch $hWnd
Case $hForm
Local $Pos = _WinAPI_GetPosFromRect(_WinAPI_GetWindowRect($hForm))
WinMove($hGui, "", $Pos[0] + 8, $Pos[1] + 28, $Pos[2] - 17, $Pos[3] - 37)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc