Sign in to follow this  
Followers 0
Aceguy

graphics, and how to

4 posts in this topic

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>



$y=150


    Local $hGUI, $hWnd, $hGraphic, $hPen

; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hWnd = WinGetHandle("GDI+")
    GUISetState()

; Draw line
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    $hPen = _GDIPlus_PenCreate ()
    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, $y, 390, 150, $hPen)

; Loop until user exits
    for $y=150 to 200



    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, $y, 390, 150, $hPen)
        sleep(250)

next    
sleep(5000)

; Clean up resources
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()#

how do i destroy the previous line.? so only 1line is displayed (moving)

;)

Share this post


Link to post
Share on other sites

_GDIPlus_graphicsClear

;)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>



$y=150


    Local $hGUI, $hWnd, $hGraphic, $hPen

; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hWnd = WinGetHandle("GDI+")
    GUISetState()

; Draw line
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    $hPen = _GDIPlus_PenCreate ()
    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, $y, 390, 150, $hPen)

; Loop until user exits
    for $y=150 to 200



    _GDIPlus_GraphicsDrawLine ($hGraphic, 10, $y, 390, 150, $hPen)
        sleep(250)

next    
sleep(5000)

; Clean up resources
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()#

how do i destroy the previous line.? so only 1line is displayed (moving)

;)

Use

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))

Originally from http://www.autoitscript.com/forum/index.ph...st&p=560052

A good post explaining its use is here

http://www.autoitscript.com/forum/index.ph...st&p=570134

The _AntiAlias( ) function from here

http://www.autoitscript.com/forum/index.ph...st&p=557051

You may or may not find graphic improvement using AntiAlias.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

$y = 150

Local $hGUI, $hWnd, $hGraphic, $hPen

; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
GUISetState()

; Draw line
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
_GDIPlus_GraphicsDrawLine($hGraphic, 10, $y, 390, 150, $hPen)
_AntiAlias($hGraphic)

; Loop until user exits
For $y = 150 To 200
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, $y, 390, 150, $hPen)
    
    Sleep(250)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))
Next
Sleep(5000)

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

Func _AntiAlias($hGraphics)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", 2)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_AntiAlias

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0