Sign in to follow this  
Followers 0
Aceguy

Graphcis again.

9 posts in this topic

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



Global $hGUI, $hWnd, $hGraphic, $hPen,$Slider1
GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL")
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
$Slider1=GUICtrlCreateSlider(5,5,150,25,$TBS_NOTICKS)
GUISetState()

; Draw line
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)



while 1 
sleep(200)
WEnd

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()



Func WM_HVSCROLL($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $LParam
        Case GUICtrlGetHandle($Slider1)
     _GDIPlus_GraphicsDrawLine($hGraphic, 10, GUICtrlRead($Slider1)+150, 390, 150, $hPen)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))      
        
EndSwitch

EndFunc  ;==>WM_HVSCROLL

:)

Share this post


Link to post
Share on other sites



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



Global $hGUI, $hWnd, $hGraphic, $hPen,$Slider1
GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL")
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
$Slider1=GUICtrlCreateSlider(5,5,150,25,$TBS_NOTICKS)
GUISetState()

; Draw line
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)



while 1 
sleep(200)
WEnd

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()



Func WM_HVSCROLL($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $LParam
        Case GUICtrlGetHandle($Slider1)
     _GDIPlus_GraphicsDrawLine($hGraphic, 10, GUICtrlRead($Slider1)+150, 390, 150, $hPen)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))      
        
EndSwitch

EndFunc ;==>WM_HVSCROLL

:)

Easy... Once you shutdown GDI you can't just call one of the functions =)

Share this post


Link to post
Share on other sites

I tried taking out the _GDIPlus_Shutdown() function to see what would happen and it resulted in the same behavior so I doubt that _GDIPlus_Shutdown() alone is the cause.

Share this post


Link to post
Share on other sites

aaaah, thanks for quick response, but i dont have a clue how to sort it.

You know what. I'm a nib.

You don't ever reach the _ShutDown()

I tried this script and it draws a GDI line when I move the slider. Is that what it's supposed to do?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

yes just want it to move the left Y axis for the moment but, it flickers like crazy, and when i stop moving the slider, nothing appears. (line dissapears)

Try this?

Edit: WAY less flicker (if any)

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



Global $hGUI, $hWnd, $hGraphic, $hPen,$Slider1
GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL")
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
$hWnd = WinGetHandle("GDI+")
$Slider1=GUICtrlCreateSlider(5,5,150,25,$TBS_NOTICKS)
GUISetState()

; Draw line
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)



while 1    
sleep(200)
WEnd

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()



Func WM_HVSCROLL($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $LParam
        Case GUICtrlGetHandle($Slider1)
            GUISetBkColor(0xF0F0F0)
            Sleep(1)
            _GDIPlus_GraphicsDrawLine($hGraphic, 10, GUICtrlRead($Slider1)+150, 390, 150, $hPen)
            _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME, $RDW_ALLCHILDREN))   
            Sleep(50)
        
    EndSwitch

EndFunc ;==>WM_HVSCROLL
Edited by Szhlopp

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

To avoid flickering, use a backbuffer, I posted an example a couple of days ago :)

#577036

If you wish to keep everything in the GUI, you better register the WM_PAINT message.

Also, I think you should call RedrawWindow before you start painting.

>_<

Edited by monoceres

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

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  
Followers 0