Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>
#Include <File.au3>
#include <FileListToArrayNT.au3>
#include <ButtonConstants.au3>
#include <GDIPlus.au3>
#include <EditConstants.au3>
#Include <Misc.au3>
;On initialise les variables
Global $Width3, $Height3, $Width2, $Height2
$img = ""
Global $Form1 = GUICreate("1", 1067, 604, -1, -1,BitOR($WS_MINIMIZEBOX,$WS_MAXIMIZEBOX))
Global $Pic1 = GUICtrlCreatePic("", 320, 64, 716, 524,$SS_SIMPLE)
Global $L_form2 = GUICtrlCreateLabel("appel form 2", 80, 512, 151, 20,BitOR($SS_CENTER,$WS_BORDER))
GUISetState(@SW_SHOW)
;-------------------------------------------------------
Global $Form2 = GUICreate("", 565, 280, 192, 124,BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX),"",$Form1)
GUISetState(@SW_HIDE)
While 1
Sleep(30)
$nMsg = GUIGetMsg(1)
Switch $nMsg[1]
case $Form1
Switch $nMsg[0]
Case $L_form2
_Afficher_image($img)
GUISetState(@SW_SHOW,$Form2)
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
Case $Form2
Switch $nMsg[0]
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE,$Form2)
EndSwitch
EndSwitch
WEnd
func _picdim ($rp, $rp1, $rp2);$picture, $maxwidth, $maxheight
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($rp)
$Width = _GDIPlus_ImageGetWidth($hImage)
$Height = _GDIPlus_ImageGetHeight($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
$i = $rp1
$xa = $Width / $rp1
while $Height / $xa > $rp2
$i -= 1
$xa = $Width / $i
wend
$Width2 = $Width
$Height2 = $Height
if $Width > $rp1 or $Height > $rp2 then
$Width2 = int($Width / $xa)
$Height2 = int($Height / $xa)
endif
$Width3 = 0
$Height3 = 0
if int(($rp1 - $Width2) / 2) > 1 then $Width3 = int(($rp1 - $Width2) / 2)
if int(($rp2 - $Height2) / 2) > 1 then $Height3 = int(($rp2 - $Height2) / 2)
endfunc
Func _ShowGUI($image)
_picdim ($image, 500, 300)
Global $Pic1 = GUICtrlCreatePic($image, 250, 150, $Width2, $Height2)
EndFunc
Func _Afficher_image($num_photo)
Dim $Pic1
GUICtrlDelete($Pic1)
$img = "C:\Users\mon_user\Desktop\1.jpg"
_ShowGUI($img)
EndFunc