Sign in to follow this  
Followers 0
andybiochem

[SOLVED] Clearing GDI+ drawings

4 posts in this topic

#1 ·  Posted (edited)

Hi!,

I want to know how to clear GDI+ drawings from a GUI, without clearing the whole GUI.

Currently, using "_GDIPlus_GraphicsClear" causes the whole GUI to turn black (or whatever color selected).

In this reproducer (below) I want the GDI+ line to appear for 3 seconds, and then go away when I shut down GDI+.

The button (and any other controls in the GUI) should remain throughout.

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

_Main()

Func _Main()
    Local $hGUI, $hWnd, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hWnd = WinGetHandle("GDI+")
    GUICtrlCreateButton("Button",20,20,50,15)
    GUISetState()

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

    ; Show line for 3 seconds
    Sleep(3000)

    ; Remove line & Clean up resources
    _GDIPlus_GraphicsClear($hGraphic) ;HOW TO CLEAR PROPERLY??????????????
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

I've trawled the forum and MSDN, but can't find a suitable approach.

Thanks for any advice!

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites



Genius.

"_WinAPI_InvalidateRect" ... how on earth did I miss that? :)

Thank you!!!


- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

Another way if you want to draw only to certain parts of the GUI is to create a label, get the handle to the label and use it as a regular window.


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

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