Jump to content

Lines drawn with GDI get 'erased'


4Eyes
 Share

Recommended Posts

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

Link to comment
Share on other sites

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]

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