Jump to content
Sign in to follow this  
4Eyes

Lines drawn with GDI get 'erased'

Recommended Posts

4Eyes

I've been using _GDIPlus_GraphicsDrawLine() to draw a dividing line between sections of a GUI but found today that the lines get erased by any other window being overlapped with it, or even by minimising/maximising the window.

Is there a way to prevent this or is there a better way to do it? I've tried using labels and - or _ chars but that's pretty poor. I've also tried GUICtrlControlGroup() but had some difficulty but right now I don't recall what it was, and in any case that's not what I want... just a simple divider.

4Eyes

Share this post


Link to post
Share on other sites
Alek

you need to register the WM_PAINT event

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Gdiplus.au3>

_GDIPlus_Startup()

$Form = GUICreate("Hello world", 400, 400)
GUISetState()

$Main_Graphics = _GDIPlus_GraphicsCreateFromHWND($Form)
_GDIPlus_GraphicsDrawLine($Main_Graphics, 0, 200, 400, 200)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

_GDIPlus_GraphicsDispose($Main_Graphics)
_GDIPlus_Shutdown()

Func WM_PAINT($hWnd, $nMsg, $wParam, $lParam)
    _GDIPlus_GraphicsDrawLine($Main_Graphics, 0, 200, 400, 200)
EndFunc

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites
4Eyes

Alek,

That's excellent! Simple and elegent, thank you. That will save a lot of experimenting with alternatives.

Regards,

Mike H

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  

×