Jump to content

A little help with GDI +


Andreik
 Share

Recommended Posts

GDI+ Is fun >_<

#include <GDIPlus.au3>
#include <misc.au3>

Global Const $width=500, $height=400
Global $rw=50,$rh=50; Rect size
Global $x=$width/2-$rw/2,$y=$height/2-$rh/2
Global $user32=DllOpen("user32.dll")

Opt("GUIOnEventMode",1)
$hwnd=GUICreate("GDI+",$width,$height)
GUISetState()
GUISetOnEvent(-3,"close")


_GDIPlus_Startup()
$graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap=_GDIPlus_BitmapCreateFromGraphics($width,$height,$graphics)
$backbuffer=_GDIPlus_ImageGetGraphicsContext($bitmap)
$pen=_GDIPlus_PenCreate(0xFFFF0000,4)

Do
    _GDIPlus_GraphicsCLear($backbuffer)
    
    If _IsPressed("25",$user32) Then
        $x-=3
    EndIf
    If _IsPressed("26",$user32) Then
        $y-=3
    EndIf
    If _IsPressed("27",$user32) Then
        $x+=3
    EndIf
    If _IsPressed("28",$user32) Then
        $y+=3
    EndIf
    
    
    _GDIPlus_GraphicsDrawRect($backbuffer,$x,$y,$rw,$rh,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,0,$x+$rw/2,$y,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,0,$y+$rh/2,$x,$y+$rh/2,$pen)
    _GDIplus_GraphicsDrawLine($backbuffer,$width,$y+$rh/2,$x+$rw,$y+$rh/2,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,$height,$x+$rw/2,$y+$rh,$pen)
    
    
    _GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,$width,$height)
    Sleep(10)
Until False




Func close()
    _GDIPlus_PenDispose($pen)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc

:)

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

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...