Jump to content

Delete a line in gdi


nend
 Share

Recommended Posts

Hoi all,

How can a delete a line which I made with gdi?

See the codebox

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
Local $hGUI, $hGraphic, $hPen
_GDIPlus_Startup ()
$hGUI = GUICreate("GDI+ test", 400, 300)
$make = GUICtrlCreateButton("Make line", 10, 10, 100, 20)
$delete = GUICtrlCreateButton("Delete line", 120, 10, 100, 20)
GUISetState()
 
While 1
$msg = GUIGetMsg()
Switch $msg
  Case $make
   $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
   $hPen = _GDIPlus_PenCreate ()
   _GDIPlus_GraphicsDrawLine ($hGraphic, 10, 150, 390, 150, $hPen)
  Case $delete
   ;code ???
  Case $GUI_EVENT_CLOSE
   _GDIPlus_PenDispose ($hPen)
   _GDIPlus_GraphicsDispose ($hGraphic)
   _GDIPlus_Shutdown ()
   Exit
EndSwitch
Sleep(20)
WEnd
Link to comment
Share on other sites

@ramzes,

I've already looked at this function but I don't see how I insert this into the code.

I already thought it had something to do with that function but i don't see how to insert it into my code.

Edited by nend
Link to comment
Share on other sites

Replace 'code ???' with function.

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
Local $hGUI, $hGraphic, $hPen
_GDIPlus_Startup()
$hGUI = GUICreate("GDI+ test", 400, 300)
$make = GUICtrlCreateButton("Make line", 10, 10, 100, 20)
$delete = GUICtrlCreateButton("Delete line", 120, 10, 100, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
  Case $make
   $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
   $hPen = _GDIPlus_PenCreate()
   _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
  Case $delete
   _GDIPlus_GraphicsClear($hGraphic)
  Case $GUI_EVENT_CLOSE
   _GDIPlus_PenDispose($hPen)
   _GDIPlus_GraphicsDispose($hGraphic)
   _GDIPlus_Shutdown()
   Exit
EndSwitch
Sleep(20)
WEnd

You should change color.

Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]

Link to comment
Share on other sites

@ramzes,

I've I used this function he fills up my complete gui with one color.

This code is a small piece of a lot bigger code and I use a picture at the background.

I've I fills this up with one color the picture is not visible anymore.

Have got a other idea?

Link to comment
Share on other sites

@ahmet,

The background is a picture from a scanner with a lot of different colors so I don't think this can help me.

I thinks it has something to do with layers, so you can draw on a layer and delete the layer with the button deleted, but I don't know how to do this.

Anyway thanks for your help.

Link to comment
Share on other sites

You would need to have some way to redraw all the lines except the line you want to delete, or you save a copy of every new version and have an UNDO/REDO otion.

You can store the picture as a bitmap, and have the lines drawn on another bitmap. You could have another bitmap for another layer. When a change is made you change the relevant layer(bitmap) and then recombine them all again and redraw the result.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...