charvi Posted December 8, 2008 Posted December 8, 2008 Hello there, Are there some rules we need to know about GDI+ used in AutoIt ? GDI+ functions are put between _GDIPlus_Startup() and _GDIPlus_Shutdown(). Is this correct ? Can we add later other GDI+ elements in the same $Pic handle after a _GDIPlus_Shutdown() has been done? or do we need to leave it open, as long as the program will add more elements later? Is there a GDI+ tutorial somewhere in the AutoIt environment?
PsaltyDS Posted December 8, 2008 Posted December 8, 2008 Hello there,Are there some rules we need to know about GDI+ used in AutoIt ?GDI+ functions are put between _GDIPlus_Startup() and _GDIPlus_Shutdown(). Is this correct ?Can we add later other GDI+ elements in the same $Pic handle after a _GDIPlus_Shutdown() has been done? or do we need to leave it open, as long as the program will add more elements later?Is there a GDI+ tutorial somewhere in the AutoIt environment?I think you can get a reference to it again later with _GDIPlus_GraphicsCreateFromHDC() or _GDIPlus_GraphicsCreateFromHwnd(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
charvi Posted December 8, 2008 Author Posted December 8, 2008 Thank you PsaltyDS, I then looked for the _GDIPlus_GraphicsCreateFromHwnd() example, and it seems to work well. I was asking that because I would like to write separate functions that will each open and close a GDI+ session on a common handle. expandcollapse popup#include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $hGUI, $hWnd ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) $hWnd = WinGetHandle("GDI+") GUISetState() _First($hGUI, $hWnd) _Second($hGUI, $hWnd) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _First($hGUI, $hWnd) Local $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout ; Draw a string _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) $hBrush = _GDIPlus_BrushCreateSolid (0x7F00007F) $hFormat = _GDIPlus_StringFormatCreate () $hFamily = _GDIPlus_FontFamilyCreate ("Arial") $hFont = _GDIPlus_FontCreate ($hFamily, 12, 2) $tLayout = _GDIPlus_RectFCreate (140, 110, 100, 20) _GDIPlus_GraphicsDrawStringEx ($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush) ; Clean up resources _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc ;==>_First Func _Second($hGUI, $hWnd) Local $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout ; Draw a string _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) $hBrush = _GDIPlus_BrushCreateSolid (0x7F00007F) $hFormat = _GDIPlus_StringFormatCreate () $hFamily = _GDIPlus_FontFamilyCreate ("Arial") $hFont = _GDIPlus_FontCreate ($hFamily, 12, 2) $tLayout = _GDIPlus_RectFCreate (140, 150, 100, 20) _GDIPlus_GraphicsDrawStringEx ($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush) ; Clean up resources _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_Shutdown () EndFunc ;==>_Second
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now