Aide sur les Interfaces Graphique Utilisateurs (GUI).
-
ELGAMALI
- Niveau 5

- Messages : 184
- Enregistré le : mar. 13 sept. 2011 00:06
-
Status :
Hors ligne
#1
Message
par ELGAMALI »
Bonjour
Je ne comprends pas pourquoi ce script marche avec photo .jpg mais pas avec .png.
Merci pour votre aide
Code : Tout sélectionner
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1,$widthCell,$nMsg
$Form1 = GUICreate(" ",960,690,167,20,-1,-1) ;-1,-1,$DS_MODALFRAME) ; $WS_EX_TOOLWINDOW, $DS_MODALFRAME ;,470,440,407,160,0)
GUISetBkColor(0xD4D0E8);0x113366 ;0x00066CC ;0xD4D0C8;0xD4D0A8;0xD4D0B8;0xF0FFFF;0xA6CAF0;0xA6CAF0
Global $background = GUICtrlCreatePic(@ScriptDir &"\Data\background GUI.png", 8, 8, 577, 441)
Global $background = GUICtrlCreatePic("photo.png", 0, 0, 960, 690)
GUICtrlSetState(-1,$GUI_DISABLE)
$widthCell = 150 ; first cell 70 width
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;
EndSwitch
WEnd
Modifié en dernier par
ELGAMALI le ven. 27 juil. 2012 21:03, modifié 1 fois.
-
mikell
- Spammer !

- Messages : 6292
- Enregistré le : dim. 29 mai 2011 17:32
- Localisation : Deep Cévennes
-
Status :
Hors ligne
#2
Message
par mikell »
Parce que c'est comme ça, et que dans ce genre de situation lire l'aide peut parfois être une bonne idée
Pour GUICtrlCreatePic, l'aide a écrit :PNG can be used with GDI+. See example 3.
" L'échec est le fondement de la réussite. " (Lao-Tseu )
" Plus ça rate, plus on a de chances que ça marche " (les Shadoks )
-
ELGAMALI
- Niveau 5

- Messages : 184
- Enregistré le : mar. 13 sept. 2011 00:06
-
Status :
Hors ligne
#3
Message
par ELGAMALI »
Voici la solution OK mikell merci
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
Opt("MustDeclareVars", 1)
Global $hGUI, $hImage, $hGraphic
; Create GUI
$hGUI = GUICreate("Show PNG", 960, 720)
GUISetState()
; Load PNG image
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\image.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()
-
matwachich
- Membre émérite

- Messages : 986
- Enregistré le : lun. 19 oct. 2009 04:04
- Localisation : Algérie
-
Status :
Hors ligne
#4
Message
par matwachich »
Il faut faire ça pour que l'image reste visible même après une réduction de la fenêtre
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
; Create GUI
$hGUI = GUICreate("Show PNG", 256, 256)
$Label = GUICtrlCreateLabel("", 64, 64, 128, 128)
GUISetState()
GUIRegisterMsg(0x000F, "_WM_PAINT") ; WM_PAINT = 0x000F (pour éviter d'include WindowsConstants.au3)
; Load PNG image
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile("C:\Users\Homer\Pictures\Icones\3d\3D_Icon_BlueBlue.png")
; Draw PNG image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($Label))
_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()
Func _WM_PAINT($hWnd, $iCode, $ilParam, $iwParam)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
Return 0
EndFunc
-
mikell
- Spammer !

- Messages : 6292
- Enregistré le : dim. 29 mai 2011 17:32
- Localisation : Deep Cévennes
-
Status :
Hors ligne
#5
Message
par mikell »
@mat
je préfère ça
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
; Create GUI
$hGUI = GUICreate("Show PNG", 256, 256)
$Label = GUICtrlCreateLabel("", 64, 64, 128, 128)
GUISetState()
GUIRegisterMsg($WM_PAINT, "_WM_PAINT")
; Load PNG image
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile("file.png")
; Draw PNG image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($Label))
_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()
Func _WM_PAINT($hWnd, $iCode, $ilParam, $iwParam)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
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 )