But How do i use it ? All the functions are called in the same way the only one that is slightly changed is _GDIPlus_Startup() can take a parameter.
Damn what the hell have you done to the start up ? See the following
; Syntax.........: _GDIPlus_Startup($fConsoleOut = False) ; Parameters ....: $fConsoleOut - Set true or False for feed back in console of created and destoryed graphic objects
SO what does it do again ?? As you create GDI objects they are stored in variables, you can dispose of them in the normal way and they will be removed from the list, any that you dont dispose of yourself will be disposed of automatically when you call '_GDIPlus_Shutdown'
Here is an example script
#include <GDIPlusDispose.au3> #include <GuiConstants.au3> #include <WindowsConstants.au3> Global $hGraphicGUI, $hBMPBuff _GdiGui() Func _GdiGui() Local $hGui, $GuiSizeX = 300, $GuiSizeY = 300 $hGui = GUICreate("GDIPlus Example", $GuiSizeX, $GuiSizeY) GUISetState() _GDIPlus_Startup(True) $hPen = _GDIPlus_PenCreate(0xFFFF0000, 3) ; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hGui) ;Draw to this graphics, $hGraphicGUI, to display on GUI $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI); $hBMPBuff is a bitmap in memory $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff); Draw to this graphics, $hGraphic, being the graphics of $hBMPBuff ;End Double Buffer add-in 1 of 3 $hStoreAsBitmapInMemory = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI) $hMyGraphicGraphic = _GDIPlus_ImageGetGraphicsContext($hStoreAsBitmapInMemory) _GDIPlus_GraphicsDrawRect($hMyGraphicGraphic, 20, 20, 260, 260, $hPen) _GDIPlus_GraphicsDrawImage($hGraphic, $hStoreAsBitmapInMemory, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0); Draw bitmap, $hBMPBuff, to the GUI's graphics, $hGraphicGUI. _GDIPlus_GraphicsDrawLine($hGraphic, 20, 150, 280, 150, $hPen) GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) GUIRegisterMsg(0x85, "MY_PAINT") ; $WM_NCPAINT = 0x0085 (WindowsConstants.au3)Restore after Minimize. _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0); Draw bitmap, $hBMPBuff, to the GUI's graphics, $hGraphicGUI. $hTestArrowCapCreate = _GDIPlus_ArrowCapCreate(10, 10) $hTestBrushCreate = _GDIPlus_BrushCreateSolid() $hTestFamilyCreate = _GDIPlus_FontFamilyCreate("Arial") $hTestFontCreate = _GDIPlus_FontCreate($hTestFamilyCreate, 12, 2) $hTestMatrixCreate = _GDIPlus_MatrixCreate() $hTestFormatCreate = _GDIPlus_StringFormatCreate() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd EndFunc ;==>_GdiGui ;Func to auto-redraw on Windows internal PAINT messages. Func MY_PAINT($hWnd, $msg, $wParam, $lParam) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ;_WinAPI_RedrawWindow($hGui, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT Func _Exit() _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit
The output to console from this is as follows
0x017D3758 - Added as type: Pen 0x017D3918 - Added as type: Graphics 0x017D3BF0 - Added as type: Bitmap 0x017D43B8 - Added as type: Bitmap 0x022706E0 - Added as type: ArrowCap 36113096 - Added as type: Brush 0x017D4E80 - Added as type: FontFamily 0x017D7F30 - Added as type: Font 0x0227E438 - Added as type: Matrix 0x017DFE50 - Added as type: String ****** Disposing of GdiPlus Objects Before shuting down dll ****** 0x022706E0 - Successfully Auto disposed of type: ArrowCap 0x017D3BF0 - Successfully Auto disposed of type: Bitmap 0x017D43B8 - Successfully Auto disposed of type: Bitmap 36113096 - Successfully Auto disposed of type: Brush 0x017D7F30 - Successfully Auto disposed of type: Font 0x017D4E80 - Successfully Auto disposed of type: FontFamily 0x017D3918 - Successfully Auto disposed of type: Graphics 0x0227E438 - Successfully Auto disposed of type: Matrix 0x017D3758 - Successfully Auto disposed of type: Pen 0x017DFE50 - Successfully Auto disposed of type: String
Edit: This no longer require's the use of AutoitObject, its totally self contained and is now named 'GDIPlusDispose'
Edited by Yoriz, 11 June 2010 - 09:47 PM.