Page 1 sur 1
[R] Problème de stabilité avec GDIplus
Posté : lun. 02 sept. 2013 14:26
par loockys
Salut le tout le monde
Je voudrais savoir, si c'est normal que mon tableau en forme de damier n'est pas stable.
Exemple : quand je réduis la fenêtre et que j'agrandie par la suite de mes actions, le tableau en forme de damier disparait,
ou bien si je m'amuse à déplacer la fenêtre par la même occasion et de la faire déborder légèrement de mon écran, certaines structures disparaissent aussi.
J'aimerais savoir si ce problème est commun a GDIplus.
Par avance merci
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
Global $PosY = 10
Global $PosX = 10
Global $R
$Form1 = GUICreate("Form1", 350, 350, 192, 124)
GUISetState(@SW_SHOW)
; GDIplus
;----------------------------------------------------------
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1)
$hPen = _GDIPlus_PenCreate(0xFF000000, 8)
_GDIPlus_PenSetWidth($hPen, 2)
;----------------------------------------------------------
For $i = 0 To 8 Step 1
For $j = 0 To 8 Step 1
_GDIPlus_GraphicsDrawRect($hGraphic, $PosY, $PosX, 32, 32, $hPen)
$PosY = $PosY +37
Next
$PosY = 10
$PosX = $PosX +37
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Re: [..] Problème de stabilité avec GDIplus
Posté : lun. 02 sept. 2013 16:33
par TommyDDR
Re: [..] Problème de stabilité avec GDIplus
Posté : lun. 02 sept. 2013 16:53
par mikell
Ouiii ! complètement oublié ce topic-là
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
Global $PosY = 10
Global $PosX = 10
Global $R
$hGUI = GUICreate("GDI+", 350, 350)
$Pic = GUICtrlCreatePic("", 0, 0, 350, 350)
GUISetState()
_SetPic($hGui, ControlGetHandle($hGui, "", $Pic))
Do
Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE
Func _SetPic($hWnd, $hPic )
Local $aBmp, $hbmp, $MainImage, $MainGraphic, $hGraphic
_GDIPlus_Startup()
;on crée une image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$MainImage = _GDIPlus_BitmapCreateFromGraphics(350, 350, $hGraphic)
$MainGraphic = _GDIPlus_ImageGetGraphicsContext($MainImage)
_GDIPlus_GraphicsClear($MainGraphic, 0xff0000)
; on y met ce qu'on veut
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
For $i = 0 To 8 Step 1
For $j = 0 To 8 Step 1
_GDIPlus_GraphicsDrawRect($MainGraphic, $PosY, $PosX, 32, 32, $hPen)
$PosY = $PosY +37
Next
$PosY = 10
$PosX = $PosX +37
Next
; 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 nettoie
_GDIPlus_PenDispose ($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($MainImage)
_GDIPlus_GraphicsDispose($MainGraphic)
_GDIPlus_Shutdown()
EndFunc
Re: [..] Problème de stabilité avec GDIplus
Posté : lun. 02 sept. 2013 18:24
par loockys
Merci pour la réponse au sujet de la stabilité de GDIplus.
J'aurais une autre question au sujet de l'image qu'on peut utiliser grâce à la fonction (_GDIPlus_ImageLoadFromFile) de GDIplus.
► Afficher le texte
Code : Tout sélectionner
$hImage1 = _GDIPlus_ImageLoadFromFile(@DesktopDir & "\Img\cercle-bleu.png")
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage1, $PosY, $PosX, 32, 32)
Comment on s'y prend pour placer l'image dans le code s'il vous plait, car de mon côté j'ai un peu de mal à comprendre la fonction (Func _SetPic($hWnd, $hPic )).
D'avance merci
Re: [..] Problème de stabilité avec GDIplus
Posté : lun. 02 sept. 2013 20:09
par mikell
J'admets que ta 1ère question était un vrai problème, mais là les exemples d'intégration d'image avec GDI+ foisonnent sur le forum
Je te mets le code mais ce serait bien que tu bosses un peu avant de poser ta prochaine question ^^
► Afficher le texte
Code : Tout sélectionner
#include <GDIPlus.au3>
Global $PosY = 10
Global $PosX = 10
Global $R
$hGUI = GUICreate("GDI+", 350, 350)
$Pic = GUICtrlCreatePic("", 0, 0, 350, 350)
GUISetState()
_SetPic($hGui, ControlGetHandle($hGui, "", $Pic))
Do
Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE
Func _SetPic($hWnd, $hPic )
Local $aBmp, $hbmp, $MainImage, $MainGraphic, $hGraphic
_GDIPlus_Startup()
;charge le png
$hImg = _GDIPlus_ImageLoadFromFile("cercle-bleu.png")
$w = _GDIPlus_ImageGetWidth($hImg)
$h = _GDIPlus_ImageGetHeight($hImg)
;on crée une image
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$MainImage = _GDIPlus_BitmapCreateFromGraphics(350, 350, $hGraphic)
$MainGraphic = _GDIPlus_ImageGetGraphicsContext($MainImage)
_GDIPlus_GraphicsClear($MainGraphic, 0xff0000)
; on y met ce qu'on veut
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
For $i = 0 To 8 Step 1
For $j = 0 To 8 Step 1
_GDIPlus_GraphicsDrawRect($MainGraphic, $PosY, $PosX, 32, 32, $hPen)
_GDIPlus_GraphicsDrawImageRect($MainGraphic, $hImg, $PosY, $PosX, $w, $h)
$PosY = $PosY +37
Next
$PosY = 10
$PosX = $PosX +37
Next
; 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 nettoie
_GDIPlus_ImageDispose($hImg)
_GDIPlus_PenDispose ($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($MainImage)
_GDIPlus_GraphicsDispose($MainGraphic)
_GDIPlus_Shutdown()
EndFunc
Re: [..] Problème de stabilité avec GDIplus
Posté : ven. 06 sept. 2013 12:48
par loockys
mikell a écrit :J'admets que ta 1ère question était un vrai problème, mais là les exemples d'intégration d'image avec GDI+ foisonnent sur le forum
Je te mets le code mais ce serait bien que tu bosses un peu avant de poser ta prochaine question
Autant pour moi Mikell,
sur ce coup la j'admets que j'ai été feignant pour la recherche, mais tout le monde a ces petites excuses,
pour ma part, je voulais en finir avec le GDI+ en pensant que c'était une chose simple et au fur à mesure de mon avancement de ma programmation, je me rends compte que c'est un peu prise de tête à le manoeuvrer,
mais en vain, j'ai travaillé dessus et je suis assez content de mon résultat de ce que je voulais en faire, alors je vous le partage et s'il y a des suggestions ou des améliorations là-dessus, faite le savoir sur mes prochains poste, par avance merci.
Sur ce je mets résolu et encore merci de l'aide.
