#Include <APIConstants.au3>
#Include <GDIPlus.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
#Include <Array.au3>
Global $hPart[9][3]
;$hFolder = FileSelectFolder("Выберите скин", @ScriptDir, 7)
_GDIPlus_Startup()
For $i = 0 To 8
$hPart[$i][0] = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Vista Aero\" & ($i + 1) & '.png')
$hPart[$i][1] = _GDIPlus_ImageGetWidth($hPart[$i][0])
$hPart[$i][2] = _GDIPlus_ImageGetHeight($hPart[$i][0])
Next
_ArrayDisplay($hPart)
$hForm = GUICreate('', 400, 400, -1, -1, BitOR($WS_POPUP, $WS_SIZEBOX), $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, ComposeBitmap(400, 400, $hPart), 255, 1)
$iPos = WinGetPos($hForm)
$hGui = GUICreate('', 382, 363, $iPos[0] + 8, $iPos[1] + 28, BitOR($WS_CLIPCHILDREN, $WS_POPUP), -1, $hForm)
GUISetBkColor(0xEFEFEF)
$hExit = GUICtrlCreateButton("Exit", 20, 20, 50, 20)
GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUISetState(@SW_SHOW, $hGui)
GUISetState(@SW_SHOW, $hForm)
While True
Switch GUIGetMsg()
Case -3, $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[0][0], 0, 0, $hPart[0][1], $hPart[0][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[2][0], $iWidth - $hPart[2][1], 0, $hPart[2][1], $hPart[2][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[8][0], $iWidth - $hPart[8][1], $iHeight - $hPart[8][2], $hPart[8][1], $hPart[8][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hPart[6][0], 0, $iHeight - $hPart[6][2], $hPart[6][1], $hPart[6][2])
$hThumb = _GDIPlus_GetImageThumbnail($hPart[1][0], $iWidth - ($hPart[0][1] + $hPart[2][1]), $hPart[1][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[0][1], 0, $iWidth - ($hPart[0][1] + $hPart[2][1]), $hPart[1][2])
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[5][0], $hPart[5][1], $iHeight - ($hPart[2][2] + $hPart[6][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $iWidth - $hPart[5][1], $hPart[2][2], $hPart[5][1], $iHeight - ($hPart[2][2] + $hPart[6][2]))
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[7][0], $iWidth - ($hPart[6][1] + $hPart[8][1]), $hPart[7][2])
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[6][1], $iHeight - $hPart[7][2], $iWidth - ($hPart[6][1] + $hPart[8][1]), $hPart[7][2])
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[3][0], $hPart[3][1], $iHeight - ($hPart[0][2] + $hPart[6][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, 0, $hPart[0][2], $hPart[3][1], $iHeight - ($hPart[0][2] + $hPart[6][2]))
_GDIPlus_ImageDispose($hThumb)
$hThumb = _GDIPlus_GetImageThumbnail($hPart[4][0], $iWidth - ($hPart[3][1] + $hPart[5][1]), $iHeight - ($hPart[0][2] + $hPart[6][2]))
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumb, $hPart[3][1], $hPart[0][2], $iWidth - ($hPart[3][1] + $hPart[5][1]), $iHeight - ($hPart[0][2] + $hPart[6][2]))
_GDIPlus_ImageDispose($hThumb)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
Else
Return SetError(@error, @extended, 0)
EndIf
Return $hBitmap
EndFunc
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_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 $Pos = _WinAPI_GetPosFromRect(DllStructCreate($tagRECT, $lParam))
_WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, ComposeBitmap($Pos[2], $Pos[3], $hPart), 255, 1)
WinMove($hWnd, "", $Pos[0], $Pos[1], $Pos[2], $Pos[3])
WinMove($hGui, "", $Pos[0] + 8, $Pos[1] + 28, $Pos[2] - 17, $Pos[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
Return $HTCAPTION
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_MOVE
Local $tRECT = _WinAPI_GetWindowRect($hWnd)
$X = DllStructGetData($tRECT, "Left")
$Y = DllStructGetData($tRECT, "Top")
$W = DllStructGetData($tRECT, "Right") - DllStructGetData($tRECT, "Left")
$H = DllStructGetData($tRECT, "Bottom") - DllStructGetData($tRECT, "Top")
WinMove($hGui, "", $X + 8, $Y + 28, $W - 17, $H - 37)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc