Jump to content
Sign in to follow this  
torels

GDI+ refreshing problem

Recommended Posts

torels

Hi there... How can I prevent a part of a gdi+ graphic from being erased when it gets out of the screen or has a window ontop of it ?

thanks in advance :mellow:


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites
Richard Robertson

You'll have to use a double buffer system. Otherwise you just lose it if you don't hold on to it yourself.

Share this post


Link to post
Share on other sites
monoceres

Hi!

You can't stop it from happening but when it does happen windows send you a message called WM_PAINT. This mean you use GUIRegisterMsg() to know when you need to redraw your graphic. The easiest way to fix this is to draw all your stuff into an memory bitmap and then draw that bitmap into the screen everytime you need to redraw or show something new to the user (aka double buffering).

Here's an example, that also registers WM_PAINT, try dragging it outside the screen :mellow:

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

$hwnd=GUICreate("Test!",400,300)
GUISetState()

_GDIPlus_Startup()
$graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap=_GDIPlus_BitmapCreateFromGraphics(400,300,$graphics)
$backbuffer=_GDIPlus_ImageGetGraphicsContext($bitmap)
$brush=_GDIPlus_BrushCreateSolid(0xFFFFFF00)

_GDIPlus_GraphicsClear($backbuffer)
_GDIPlus_GraphicsFillEllipse($backbuffer,10,10,380,280,$brush)
_GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,400,300)
GUIRegisterMsg($WM_PAINT,"_ReDraw")

Do
Until GUIGetMsg()=-3

Func _ReDraw()
    _GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,400,300)
EndFunc

:(


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

Share this post


Link to post
Share on other sites
torels

Thanks Monoceres :mellow:


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

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  

×