lokipoki Posted May 10, 2013 Share Posted May 10, 2013 (edited) Hi there.Here we go again.I want to move a picture. This is my codeexpandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) GUICtrlSetBkColor($hgui, 0x000000) GUICtrlCreatePic('SNES.jpg', 0, 0, @DesktopWidth, @DesktopHeight) GUISetState() _GDIPlus_Startup() $hcartridge = _GDIPlus_ImageLoadFromFile('D:\HTPC\Games\SNES\Roms\cartridge\Batman Forever (E) [!].jpg') $iWidth = _GDIPlus_ImageGetWidth($hcartridge) $iHeight = _GDIPlus_ImageGetHeight($hcartridge) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $inc = 0 $x = 625 $y = -75 Do _GDIPlus_GraphicsDrawImage($hGraphic, $hcartridge, $x, $y) $y = $y + 1 Sleep(15) $inc = $inc + 1 Until $inc = 135 While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEndThis is the result after I mover the picture from the top. It makes those marks:https://skydrive.live.com/embed?cid=F6554FE8FA489447&resid=F6554FE8FA489447%21187&authkey=ACAyCLroOvnjYzUWhat am I doing wrong? Im pretty sure its simple Edited May 10, 2013 by lokipoki Link to comment Share on other sites More sharing options...
Artisan Posted May 10, 2013 Share Posted May 10, 2013 Looks like you need to repaint your background image. You could try using GUICtrlSetImage to redraw it.A less-likely cause of the problem is the GDI+ image you're moving. It's funny when it comes to repainting. Check out the code here. I put a GDI repainting function at the very bottom. Don't forget to register the function. If the problem is GDI repainting, this should help fix it. Link to comment Share on other sites More sharing options...
lokipoki Posted May 10, 2013 Author Share Posted May 10, 2013 Looks like you need to repaint your background image. You could try using GUICtrlSetImage to redraw it.A less-likely cause of the problem is the GDI+ image you're moving. It's funny when it comes to repainting. Check out the code here. I put a GDI repainting function at the very bottom. Don't forget to register the function. If the problem is GDI repainting, this should help fix it.How do I use GUICtrlSetImage??? Link to comment Share on other sites More sharing options...
Artisan Posted May 10, 2013 Share Posted May 10, 2013 http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetImage.htm You need to have a handle to the picture you created. Try something like: $hPic = GUICtrlCreatePic('SNES.jpg', 0, 0, @DesktopWidth, @DesktopHeight) Then you use GUICtrlSetImage to update the picture whenever you need to. Something like: GUICtrlSetImage($hPic, 'SNES.jpg') You'd probably want to have that in your Do..Until loop. Link to comment Share on other sites More sharing options...
lokipoki Posted May 17, 2013 Author Share Posted May 17, 2013 http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetImage.htm You need to have a handle to the picture you created. Try something like: $hPic = GUICtrlCreatePic('SNES.jpg', 0, 0, @DesktopWidth, @DesktopHeight) Then you use GUICtrlSetImage to update the picture whenever you need to. Something like: GUICtrlSetImage($hPic, 'SNES.jpg') You'd probably want to have that in your Do..Until loop. Hi there. Thanks for your reply. It works indeed. But my moving picture starts to blink now. What can I do? Cheers. Link to comment Share on other sites More sharing options...
Artisan Posted May 17, 2013 Share Posted May 17, 2013 Without seeing your code, I can't say exactly why it's flashing. It probably flashes when it gets redrawn. Make sure you're not calling GUICtrlSetImage more than you need to. If you're only calling it when you absolutely need to and it's still flashing, you may need to look into using the GDI+ UDF instead. I'm not an expert on graphics, though, so there may be other options. Link to comment Share on other sites More sharing options...
lokipoki Posted May 18, 2013 Author Share Posted May 18, 2013 Without seeing your code, I can't say exactly why it's flashing. It probably flashes when it gets redrawn. Make sure you're not calling GUICtrlSetImage more than you need to. If you're only calling it when you absolutely need to and it's still flashing, you may need to look into using the GDI+ UDF instead. I'm not an expert on graphics, though, so there may be other options. expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) GUICtrlSetBkColor($hGUI, 0x000000) $hbpic = GUICtrlCreatePic('SNES.jpg', 0, 0, @DesktopWidth, @DesktopHeight) GUISetState() _GDIPlus_Startup() $hcartridge = _GDIPlus_ImageLoadFromFile('D:\HTPC\Games\SNES\Roms\cartridge\Batman Forever (E) [!].jpg') $iWidth = _GDIPlus_ImageGetWidth($hcartridge) $iHeight = _GDIPlus_ImageGetHeight($hcartridge) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $inc = 0 $x = 625 $y = -75 Do $y = $y + 1 GUICtrlSetImage($hbpic, 'SNES.jpg') _GDIPlus_GraphicsDrawImage($hGraphic, $hcartridge, $x, $y) Sleep(15) $inc = $inc + 1 Until $inc = 135 While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Link to comment Share on other sites More sharing options...
Artisan Posted May 19, 2013 Share Posted May 19, 2013 (edited) Using GDI+ here isn't needed. You just want to show & move a picture. Try something like this:#include <WindowsConstants.au3> #include <GUIConstants.au3> $x = 625 $y = -75 $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) ; GUICtrlSetBkColor($hGUI, 0x000000) ; Not really needed since the background covers the whole screen $hbpic = GUICtrlCreatePic(@ScriptDir & '\SNES.bmp', 0, 0, @DesktopWidth, @DesktopHeight) $hcartridge = GUICtrlCreatePic(@ScriptDir & '\FF3.jpg', $x, $y) GUISetState() For $y = -75 To 60 GUICtrlSetPos($hcartridge, $x, $y) Sleep(15) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEndMake sure to update the image names, of course. There's no flicker that I can see with this version. Edited May 19, 2013 by Artisan Link to comment Share on other sites More sharing options...
lokipoki Posted May 23, 2013 Author Share Posted May 23, 2013 (edited) Using GDI+ here isn't needed. You just want to show & move a picture. Try something like this: #include <WindowsConstants.au3> #include <GUIConstants.au3> $x = 625 $y = -75 $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) ; GUICtrlSetBkColor($hGUI, 0x000000) ; Not really needed since the background covers the whole screen $hbpic = GUICtrlCreatePic(@ScriptDir & '\SNES.bmp', 0, 0, @DesktopWidth, @DesktopHeight) $hcartridge = GUICtrlCreatePic(@ScriptDir & '\FF3.jpg', $x, $y) GUISetState() For $y = -75 To 60 GUICtrlSetPos($hcartridge, $x, $y) Sleep(15) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Make sure to update the image names, of course. There's no flicker that I can see with this version. Thanks a lot. The script is working although it still flickers. But not as much as before. Cheers. Edited May 23, 2013 by lokipoki Link to comment Share on other sites More sharing options...
Artisan Posted May 28, 2013 Share Posted May 28, 2013 That's odd. It didn't flicker at all when I tested it. Anyone have any ideas why it's flickering? If it matters, I was testing it on a 32-bit Win7 laptop. Link to comment Share on other sites More sharing options...
UEZ Posted May 28, 2013 Share Posted May 28, 2013 (edited) Try this:#include <WindowsConstants.au3> #include <GUIConstants.au3> $x = 625 $y = -75 $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) ; GUICtrlSetBkColor($hGUI, 0x000000) ; Not really needed since the background covers the whole screen $hbpic = GUICtrlCreatePic(@ScriptDir & '\SNES.bmp', 0, 0, @DesktopWidth, @DesktopHeight) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW, $hGUI) $hGUI_Child = GUICreate('', 420, 340, @DesktopWidth / 2 - 210, - 75, $WS_POPUP, Default, $hGUI) $hcartridge = GUICtrlCreatePic(@ScriptDir & '\FF3.jpg', 0, 0, 420, 340) GUISetState(@SW_SHOW, $hGUI_Child) For $y = -75 To 160 WinMove($hGUI_Child, "", @DesktopWidth / 2 - 210, $y) Sleep(15) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEndBr,UEZ Edited May 28, 2013 by UEZ 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...
Solution lokipoki Posted June 2, 2013 Author Solution Share Posted June 2, 2013 (edited) Try this: #include <WindowsConstants.au3> #include <GUIConstants.au3> $x = 625 $y = -75 $hGUI = GUICreate('MyGUI', @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) ; GUICtrlSetBkColor($hGUI, 0x000000) ; Not really needed since the background covers the whole screen $hbpic = GUICtrlCreatePic(@ScriptDir & '\SNES.bmp', 0, 0, @DesktopWidth, @DesktopHeight) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW, $hGUI) $hGUI_Child = GUICreate('', 420, 340, @DesktopWidth / 2 - 210, - 75, $WS_POPUP, Default, $hGUI) $hcartridge = GUICtrlCreatePic(@ScriptDir & '\FF3.jpg', 0, 0, 420, 340) GUISetState(@SW_SHOW, $hGUI_Child) For $y = -75 To 160 WinMove($hGUI_Child, "", @DesktopWidth / 2 - 210, $y) Sleep(15) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Br, UEZ Thanks mate. Its working perfectly!!! Thanks for all your help guys. Cheers. Edited June 2, 2013 by lokipoki 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