Aide et conseils concernant AutoIt et ses outils.
Amesamana
Niveau 5
Messages : 108 Enregistré le : dim. 09 sept. 2012 16:37
Status :
Hors ligne
#1
Message
par Amesamana » sam. 23 nov. 2013 18:53
Bonjour,
L'image .png disparait si je déplace la gui dans le barre de tâche même voir que la moitié de l'image .png ???
Idem si je déplace une autre fenêtre par dessus la GUI.
Même compilé j'ai le même résultat.
Savez-vous pourquoi ?
Merci
► Afficher le texte ShowPNG.au3
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
; ===============================================================================================================================
; Description ...: Shows how to display a PNG image
; Author ........: Paul Campbell (PaulIA)
; Notes .........:
; ===============================================================================================================================
; ===============================================================================================================================
; Global variables
; ===============================================================================================================================
Global $hGUI, $hImage, $hGraphic
; Create GUI
$hGUI = GUICreate("Show PNG", 240, 240)
GUISetState()
; Load PNG image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("..\Torus.png")
; Draw PNG image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Modifié en dernier par
Amesamana le dim. 24 nov. 2013 12:14, modifié 1 fois.
TT22
Membre émérite
Messages : 1566 Enregistré le : lun. 18 avr. 2011 15:21
Localisation : La Quatrième Dimension
Status :
Hors ligne
#2
Message
par TT22 » sam. 23 nov. 2013 21:57
Salut, la solution la plus simple est de redessiner l'image en continu dans la boucle :
Code : Tout sélectionner
; Loop until user exits
Do
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Cordialement,
TT22
mikell
Spammer !
Messages : 6292 Enregistré le : dim. 29 mai 2011 17:32
Localisation : Deep Cévennes
Status :
Hors ligne
#3
Message
par mikell » dim. 24 nov. 2013 01:26
Titoo, ok c'est la solution la plus simple mais bonjour la charge cpu ^^
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
$image = "G:\Program Files\AutoIt3\Examples\GUI\Torus.png" ; chemin perso
$hGUI = GUICreate("GDI+", 200, 200)
$Pic = GUICtrlCreatePic("", 0, 0, 200, 200)
GUISetState()
_SetPic($hGui, GuiCtrlGetHandle($Pic), $image)
Do
Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE
;===================================================
Func _SetPic($hWnd, $hPic, $png)
Local $aBmp, $hbmp, $MainImage, $MainGraphic, $hGraphic
_GDIPlus_Startup()
; on charge le png
$hImg = _GDIPlus_ImageLoadFromFile($png)
$w = _GDIPlus_ImageGetWidth($hImg)
$h = _GDIPlus_ImageGetHeight($hImg)
; on crée une image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$MainImage = _GDIPlus_BitmapCreateFromGraphics(200, 200, $hGraphic)
$MainGraphic = _GDIPlus_ImageGetGraphicsContext($MainImage)
; on y met ce qu'on veut
_GDIPlus_GraphicsDrawImageRect($MainGraphic, $hImg, 10, 10, $w, $h)
; on balance l'image dans le controle
$hbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($MainImage)
$aBmp = DllCall("user32.dll", "hwnd", "SendMessage", "hwnd", $hPic, "int", "0x0172", "int", "0", "int", $hbmp)
If $aBmp[0] <> 0 Then _WinAPI_DeleteObject($aBmp[0])
_WinAPI_DeleteObject($hbmp)
; et on fait le ménage
_GDIPlus_ImageDispose($hImg)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($MainImage)
_GDIPlus_GraphicsDispose($MainGraphic)
_GDIPlus_Shutdown()
EndFunc
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
Amesamana
Niveau 5
Messages : 108 Enregistré le : dim. 09 sept. 2012 16:37
Status :
Hors ligne
#4
Message
par Amesamana » dim. 24 nov. 2013 12:14
Bonjour,
Merci ça fonctionne nickel