_WinAPI_BitBlt的问题[已解决]
本帖最后由 kyniel 于 2011-11-10 16:52 编辑#Include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <array.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("", 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")
While 1
$nMsg = GUIGetMsg()
GUICtrlSetImage($pic3,"shell32.dll", 22)
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $List1
$rop=GUICtrlRead($List1)
GUICtrlSetImage($pic3,@ScriptDir&"\1.JPG")
_WinAPI_BitBlt($hwnd3,($p3pos-$p2pos)/2,($p3pos-$p2pos)/2,$p2pos,$p2pos,$hwnd2,0,0,$rop)
EndSwitch
WEnd
为什么我做不出http://www.cnblogs.com/del/archive/2008/06/25/1229469.html的效果,是不是控件的样式问题,应该怎么弄,难道要用gdi+? 这个恐怕要用 WinAPIEx 类函数吧。。。 #include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
$himage1=_GDIPlus_BitmapCreateFromFile(@ScriptDir&"\1.jpg")
$himage2=_GDIPlus_BitmapCreateFromFile(@ScriptDir&"\2.jpg")
$hwidth=_GDIPlus_ImageGetWidth($himage1)
$hheight=_GDIPlus_ImageGetHeight($himage1)
$hGUI=GUICreate("",$hwidth,$hheight)
GUISetState(@SW_SHOW)
$hgraphic=_GDIPlus_ImageGetGraphicsContext($himage1)
$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hgraphic,$himage2,32,24)
Do
_GDIPlus_GraphicsDrawImage($hGraphic2, $hImage1, 0, 0)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
UntilGUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_ImageDispose($himage1)
_GDIPlus_ImageDispose($himage1)
_GDIPlus_Shutdown()使用gdi+ 我把两张图片叠加显示在gui上了,发现要_WinAPI_RedrawWindow否者gui上的东西不会刷新,但我用_WinAPI_BitBlt的时候返回值为0,也就没有成功,和_WinAPI_RedrawWindow也就没关系了,谁知道_WinAPI_BitBlt到底怎么用地啊? 本帖最后由 kyniel 于 2011-11-10 16:50 编辑
又仔细研究了下发现_WinAPI_BitBlt函数发现它需要的环境句柄(谁能解释下有什么区别),所以加了如下代码:$hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hwnd2)
$hdc2=_GDIPlus_GraphicsGetDC($hGraphic2)神奇的发现可以实现了。
然而,接着又有新的问题,我使用$rop=GUICtrlRead($List1)来获取列表的值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-$p2pos)/2,($p3pos-$p2pos)/2,$p2pos,$p2pos,$hdc2,0,0,$rop)
EndSwitch
WEnd
_GDIPlus_Shutdown()
本帖最后由 kyniel 于 2011-11-10 16:48 编辑
学到两个函数getvartype和eval,eval可以获取字符串变量的值。我发现api帮助部分例子太少了,很难搞清楚。最后终于搞好了,自己做个标记吧!
#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=Eval(GUICtrlRead($List1))
_WinAPI_RedrawWindow($hwnd3)
_WinAPI_BitBlt($hdc3,($p3pos-$p2pos)/2,($p3pos-$p2pos)/2,$p2pos,$p2pos,$hdc2,0,0,$rop)
EndSwitch
WEnd
_GDIPlus_Shutdown()
效果图:
打酱油的,混点分数提高下等级,谁然我是路过,但是也不是水帖子
Dragon Nest Gold,vindictus gold,swg credits,silkroad gold,NosTale Gold,Knight Noah,Eden Eternal gold, Elsword ED,tibia gold,shaiya gold,rs2 gold,rohan gold,RIFT Platinum,RIFT Plat,RIFT Gold,rappelz gold,rappelz rupees,perfect world gold,pw gold,Metin2 Yang,Metin2 Gold,maplestory mesos,mabinogi gold,lineage 2 adena,guild wars gold,ffxiv gil,ffxi gil,2moons dil, 4story money, 4story Luna, 4Story Gold, 9Dragons gold, Aion Kinah, Buy Aion Kinah, Buy Aion Gold, apb gold, Cabal Alz, Cabal Gold, dfo gold, dofus kamas, EVE ISK, eq2 plat, 希望版主多关注一下api帮助部分例子的哈。。 wo lu guo w zhan qian
页:
[1]