本帖最后由 kyniel 于 2011-11-10 16:50 编辑
又仔细研究了下发现_WinAPI_BitBlt函数发现它需要的环境句柄(谁能解释下有什么区别),所以加了如下代码:$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hwnd2)
$hdc2=_GDIPlus_GraphicsGetDC($hGraphic2)
神奇的发现可以实现了。
然而,接着又有新的问题,我使用来获取列表的值GUICtrlSetData(-1, "$BLACKNESS |$CAPTUREBLT|$DSTINVERT|$MERGECOPY|$MERGEPAINT|$NOMIRRORBITMAP|$NOTSRCCOPY|$NOTSRCERASE|$PATCOPY |$PATINVERT|$PATPAINT|$SRCAND|$SRCCOPY|$SRCERASE|$SRCINVERT|$SRCPAINT|$WHITENESS")
这些值不知道是不是带有“$”,结果显示的不对,估计是变量引用变量的字符串,结果不能获取变量值。有什么函数可以直接解决呢?
附上最后的代码#Include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 401, 401, 381, 287)
$Pic1 = GUICtrlCreatePic(@ScriptDir&"\1.JPG", 24, 24, 193, 161)
$Pic2 = GUICtrlCreatePic(@ScriptDir&"\2.JPG", 248, 24, 129, 113)
$Pic3 = GUICtrlCreatePic(@ScriptDir&"\1.JPG", 24, 208, 193, 161)
$List1 = GUICtrlCreateList("", 240, 168, 145, 201)
GUICtrlSetData(-1, "BLACKNESS |CAPTUREBLT|DSTINVERT|MERGECOPY|MERGEPAINT|$NOMIRRORBITMAP|$NOTSRCCOPY|$NOTSRCERASE|$PATCOPY |$PATINVERT|$PATPAINT|$SRCAND|$SRCCOPY|$SRCERASE|$SRCINVERT|$SRCPAINT|$WHITENESS")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$hwnd3=ControlGetHandle("Form1","","Static3")
$hwnd2=ControlGetHandle("Form1","","Static2")
$p3pos=ControlGetPos("Form1","","Static3")
$p2pos=ControlGetPos("Form1","","Static2")
_GDIPlus_Startup()
$hGraphic3 = _GDIPlus_GraphicsCreateFromHWND($hwnd3)
$hdc3=_GDIPlus_GraphicsGetDC($hGraphic3)
$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hwnd2)
$hdc2=_GDIPlus_GraphicsGetDC($hGraphic2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $List1
$rop=GUICtrlRead($List1)
_WinAPI_RedrawWindow($hwnd3)
_WinAPI_BitBlt($hdc3,($p3pos[2]-$p2pos[2])/2,($p3pos[3]-$p2pos[3])/2,$p2pos[2],$p2pos[3],$hdc2,0,0,$rop)
EndSwitch
WEnd
_GDIPlus_Shutdown()
|