tarretarretarre Posted October 21, 2012 Share Posted October 21, 2012 Im new to GDIPLUS and im trying to set another position to my _GDIPlus_GraphicsDrawImage which is created from a file. Also i cant find a way to just remove the picture just the whole Gui which setts another background and removes my other pictures Thanks Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) Link to comment Share on other sites More sharing options...
UEZ Posted October 22, 2012 Share Posted October 22, 2012 (edited) If your are moving your bitmap you have to clear the current GDI+ graphic handle usually. I assume in you case with another background image you have to set your background image again and move the foreground image to the new possition. There is no other way to do it if you working directly on the graphic handle. Other possibility is to create a child gui which is moving over the background. Br, UEZ Edited October 22, 2012 by UEZ IgImAx 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
tarretarretarre Posted October 22, 2012 Author Share Posted October 22, 2012 It worked, thanks Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) Link to comment Share on other sites More sharing options...
IgImAx Posted February 5, 2013 Share Posted February 5, 2013 Hi UEZOther possibility is to create a child gui which is moving over the background.Your first way works for me too! Thanks. But I loke to learn about second way too! to learn how can I create a child GUI and ... can you give me a sample code? Teach Others to learn more yourself My eBooks and Articles in Persian: IgImAx Home! * and more here Link to comment Share on other sites More sharing options...
UEZ Posted February 5, 2013 Share Posted February 5, 2013 Here one way to do it: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> Opt("GUICoordMode", 1) _GDIPlus_Startup() Global Const $hBgImage = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\msoobe.jpg")) Global Const $iW = _GDIPlus_ImageGetWidth($hBgImage) Global Const $iH = _GDIPlus_ImageGetHeight($hBgImage) Global Const $hGUI = GUICreate("GDI+ Test", $iW, $iH) Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) Global Const $hFgImage = _GDIPlus_ImageLoadFromFile(StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\Torus.png")) Global Const $iW_Fg = _GDIPlus_ImageGetWidth($hFgImage), $iH_Fg = _GDIPlus_ImageGetHeight($hFgImage) Global $iPosX = 0, $iPosY = 0 Global Const $hGUI_Child = GUICreate("",$iW_Fg , $iH_Fg, $iPosX, $iPosY, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_TRANSPARENT, $hGUI) Global Const $hGraphic_Child = _GDIPlus_GraphicsCreateFromHWND($hGUI_Child) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_Child) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) _GDIPlus_GraphicsDrawImage($hContext, $hBgImage, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) SetTransparentBitmap($hGUI_Child, $hFgImage) Global $fVectorX = Random(1, 3) Global $fVectorY = Random(1, 3) AdlibRegister("MoveGUI", 20) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE AdlibUnRegister("MoveGUI") _GDIPlus_ImageDispose($hBgImage) _GDIPlus_ImageDispose($hFgImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic_Child) _GDIPlus_GraphicsDispose($hGraphic) GUIDelete($hGUI_Child) GUIDelete($hGUI) _GDIPlus_Shutdown() Exit EndSwitch Until False Func MoveGUI() Local $aPos = WinGetPos ($hGUI) $iPosX += $fVectorX $iPosY += $fVectorY WinMove($hGUI_Child, "", $aPos[0] + $iPosX + $iXFixedFrame, $aPos[1] + $iPosY + $iYCaption + $iYFixedFrame) If $iPosX < 0 Or ($iPosX + $iW_Fg) > $iW Then $fVectorX *= -1 If $iPosY < 0 Or ($iPosY + $iH_Fg) > $iH Then $fVectorY *= -1 EndFunc Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Br, UEZ IgImAx 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
IgImAx Posted February 5, 2013 Share Posted February 5, 2013 Hi UEZWooooooooooW!!!! That's wonderful!!? I did not expect that Autoit can do this!?!?! Thanks! WoooW!!! Teach Others to learn more yourself My eBooks and Articles in Persian: IgImAx Home! * and more here Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now