#include <GDIPlus.au3>
$Form1 = GUICreate("Form1", 623, 448)
$Pic1 = GUICtrlCreatePic('', 120, 72, 113, 50)
_GDIPlus_Startup()
_ImageRectToControl('AddMore.bmp', 339, 0, 113, 50, GUICtrlGetHandle(-1))
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd
Func _ImageRectToControl($sInPic, $iSrcX, $iSrcY, $iSrcW, $iSrcH, $hWnd)
Local $iDstX = 0, $iDstY = 0, $iDstW = $iSrcW, $iDstH = $iSrcH
$hImage = _GDIPlus_ImageLoadFromFile($sInPic)
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
$hImage1 = _GDIPlus_BitmapCreateFromGraphics($iDstW, $iDstH, $hGraphics)
$hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hImage1)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics1, $hImage, $iSrcX, $iSrcY, $iSrcW, $iSrcH, $iDstX, $iDstY, $iDstW, $iDstH)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_GraphicsDispose($hGraphics1)
_GDIPlus_ImageDispose($hImage)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
_GDIPlus_ImageDispose($hImage1)
Local $hPrev = _SendMessage($hWnd, 0x0172, 0, $hBitmap) ;$STM_SETIMAGE = 0x0172
If $hPrev Then _WinAPI_DeleteObject($hPrev)
$hPrev = _SendMessage($hWnd, 0x0173) ;$STM_GETIMAGE = 0x0173
If $hPrev <> $hBitmap Then _WinAPI_DeleteObject($hBitmap)
EndFunc ;==>_ImageRectToControl
|