本帖最后由 水木子 于 2016-9-17 21:36 编辑
这是API的效果,和我的一毛一样,根本不懂大神们如何做到的
431852 发表于 2016-9-17 20:24
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
Global $iGuiWidth = 600, $iGuiHeight = 450
Global $iImageWidth = $iGuiWidth - 20, $iImageHeight = $iGuiHeight - 20
OnAutoItExitRegister('_Exit')
_GDIPlus_Startup() ;初始化 GDI+
$hBMP = _ScreenCapture_Capture('', 0, 0, $iGuiWidth, $iGuiHeight)
$hBitmap1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
$hGui1 = GUICreate('', $iGuiWidth, $iGuiHeight)
$Pic1 = GUICtrlCreatePic('', 10, 10, $iImageWidth, $iImageHeight)
$hPic1 = GUICtrlGetHandle($Pic1)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hPic1)
$hGraphics = _GDIPlus_BitmapCreateFromGraphics($iImageWidth, $iImageHeight, $hGraphic)
$hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($hGraphics)
_GDIPlus_GraphicsDrawImageRectRect($hGfxCtxt, $hBitmap1, 0, 0, $iImageWidth, $iImageHeight, 0, 0, $iImageWidth, $iImageHeight)
$hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hGraphics)
_SetBitmap($hPic1, $hBitmap2)
_GDIPlus_BitmapDispose($hBitmap1)
_GDIPlus_BitmapDispose($hGraphics)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hGfxCtxt)
GUISetState()
Do
Until GUIGetMsg() = -3
Func _SetBitmap($hWnd, $hBitmap)
$hObj = _SendMessage($hWnd, 0x0172, 0, $hBitmap) ;$STM_SETIMAGE = 0x0172
_WinAPI_DeleteObject($hObj)
Local $hObj = _SendMessage($hWnd, 0x0173) ;$STM_GETIMAGE = 0x0173
If $hObj <> $hBitmap Then
_WinAPI_DeleteObject($hBitmap)
EndIf
EndFunc ;==>_SetBitmap
Func _Exit();清理 GDI+ 资源
_GDIPlus_Shutdown()
GUIDelete($hGui1)
Exit
EndFunc ;==>_Exit
|