#include <WinAPIEX.au3>
#include <GUIConstantsEx.au3>
Global $hCalc, $hIcon, $hIconCopy, $aInfo, $tSize, $iW, $iH
$hCalc = WinGetHandle('[Class:CalcFrame]')
If Not $hCalc Then
Run('calc.exe')
$hCalc = WinWait('[Class:CalcFrame]', '', 3)
EndIf
If Not $hCalc Then Exit 1
$hIcon = _WinAPI_GetClassLongEx($hCalc, -14);$GCL_HICON = -14
If Not $hIcon Then Exit 2
$hIconCopy = _WinAPI_CopyIcon($hIcon)
_WinAPI_DestroyIcon($hIcon)
If Not $hIconCopy Then Exit 3
$aInfo = _WinAPI_GetIconInfo($hIconCopy)
If @error Then Exit 4
$tSize = _WinAPI_GetBitmapDimension($aInfo[5])
$iW = DllStructGetData($tSize, 1)
$iH = DllStructGetData($tSize, 2)
If Not $iW Then $iW = 32
If Not $iH Then $iH = 32
For $i = 4 To 5
_WinAPI_DeleteObject($aInfo[$i])
Next
$aInfo = 0
$tSize = 0
GUICreate('Test', $iW * 5, $iH * 3)
GUICtrlCreateIcon('', 0, $iW * 2, $iH, $iW, $iH)
GUICtrlSendMsg(-1, 0x0172, 1, $hIconCopy);$STM_SETIMAGE = 0x0172
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_WinAPI_DestroyIcon($hIconCopy)