找回密码
 加入
搜索
楼主: nmgwddj

[GUI管理] 如何读取BMP图片中某个位图的资源(已解决)

 火.. [复制链接]
发表于 2012-2-5 19:59:24 | 显示全部楼层
#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
 楼主| 发表于 2012-2-5 22:33:39 | 显示全部楼层
回复 16# afan


    A版牛X,像风一样的男子!!佩服。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-19 16:42 , Processed in 0.064692 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表