Sign in to follow this  
Followers 0
kylomas

Flickering GUI even with WS_EX_COMPOSITED

3 posts in this topic

Can anyone tell what I'm doing wrong  (Novice with graphics)?  All controls flicker when button is pushed...

; bagels

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Local $gnum = 10, $glen = 5, $box = 20, $left = $box, $top = $box

Local $ag[$gnum][$glen * 2]

Local $gui010 = GUICreate('Bagels')
Local $aSize = WinGetClientSize($gui010)

If GUISetStyle(BitOR($ws_popup, $WS_dlgframe), BitOR($WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED), $gui010) = 0 Then Exit MsgBox(17, 'Error', 'GUISetStyle Error')
;guisetstyle(bitor($ws_popup, $ws_dlgframe),bitor($WS_EX_clientedge,$ws_ex_composited), $gui010)
;GUISetStyle(-1, $ws_ex_composited, $gui010)

For $1 = 0 To UBound($ag) - 1
    If $1 = 0 Then $top += 50
    For $2 = 0 To UBound($ag, 2) - 1
        If $2 <= $glen - 1 Then
            $ag[$1][$2] = GUICtrlCreateInput('', $left, $top, $box, $box, $es_number)
            GUICtrlSetLimit(-1, 1)
            GUICtrlSetFont(-1, 10, 800, -1, 'arial black')
        Else
            $ag[$1][$2] = GUICtrlCreateGraphic($left + 20, $top, $box, $box)
            GUICtrlSetState(-1, $GUI_DISABLE)
        EndIf
        $left += $box + 15
    Next
    $left = $box
    $top += $box + 5
Next

Local $iExit = GUICtrlCreateLabel('X', $aSize[0] - 25, 3, 20, 20, BitOR($ss_center, $ss_centerimage))
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetCursor(-1, 0)
Local $iHelp = GUICtrlCreateLabel('?', $aSize[0] - 50, 3, 20, 20, BitOR($ss_center, $ss_centerimage))
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetCursor(-1, 0)

Local $testgraphics = GUICtrlCreateButton('Test Graphics', 20, 370, 100, 20)

GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $gui_event_close
            Exit
        Case $testgraphics
            _Test_Graphics()
        Case $iExit
            _Fini()
        Case $iHelp
            _Help()
    EndSwitch
WEnd

Func _Help()

EndFunc   ;==>_Help

Func _Fini()

    Exit

EndFunc   ;==>_Fini

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $ag[0][0] To $ag[UBound($ag) - 1][$glen]
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlSend('', '', BitAND($wParam, 0xffff), '{tab}')
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

Func _Test_Graphics()

    Local $acolors = [0xff0000, 0x00ff00, 0x00]

    For $1 = 0 To UBound($ag) - 1
        For $2 = $glen - 1 To UBound($ag, 2) - 1
            $color = $acolors[Random(0, UBound($acolors) - 1, 1)]
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_COLOR, $color, $color)
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_ELLIPSE, 0, 0, $box, $box)
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_refresh)
        Next
    Next

EndFunc   ;==>_Test_Graphics

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just a guess but maybe the GUICtrlSetGraphic causes a WM_PAINT message after every call. Using GUISetState(@SW_LOCK, $gui010) before the double for loops in _Test_Graphics and GUISetState(@SW_UNLOCK, $gui010) after the loops are done helps.

This does the same thing as @SW_(UN)LOCK

; bagels

#include <array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

Local $gnum = 10, $glen = 5, $box = 20, $left = $box, $top = $box

Local $ag[$gnum][$glen * 2]

Local $gui010 = GUICreate('Bagels')
Local $aSize = WinGetClientSize($gui010)

If GUISetStyle(BitOR($ws_popup, $WS_dlgframe), BitOR($WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED), $gui010) = 0 Then Exit MsgBox(17, 'Error', 'GUISetStyle Error')
;guisetstyle(bitor($ws_popup, $ws_dlgframe),bitor($WS_EX_clientedge,$ws_ex_composited), $gui010)
;GUISetStyle(-1, $ws_ex_composited, $gui010)

For $1 = 0 To UBound($ag) - 1
    If $1 = 0 Then $top += 50
    For $2 = 0 To UBound($ag, 2) - 1
        If $2 <= $glen - 1 Then
            $ag[$1][$2] = GUICtrlCreateInput('', $left, $top, $box, $box, $es_number)
            GUICtrlSetLimit(-1, 1)
            GUICtrlSetFont(-1, 10, 800, -1, 'arial black')
        Else
            $ag[$1][$2] = GUICtrlCreateGraphic($left + 20, $top, $box, $box)
            GUICtrlSetState(-1, $GUI_DISABLE)
        EndIf
        $left += $box + 15
    Next
    $left = $box
    $top += $box + 5
Next

Local $iExit = GUICtrlCreateLabel('X', $aSize[0] - 25, 3, 20, 20, BitOR($ss_center, $ss_centerimage))
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetCursor(-1, 0)
Local $iHelp = GUICtrlCreateLabel('?', $aSize[0] - 50, 3, 20, 20, BitOR($ss_center, $ss_centerimage))
GUICtrlSetFont(-1, 12, 800)
GUICtrlSetCursor(-1, 0)

Local $testgraphics = GUICtrlCreateButton('Test Graphics', 20, 370, 100, 20)

Global $bSetting = False

GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUIRegisterMsg($WM_PAINT, WM_PAINT)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $gui_event_close
            Exit
        Case $testgraphics
            _Test_Graphics()
        Case $iExit
            _Fini()
        Case $iHelp
            _Help()
    EndSwitch
WEnd

Func _Help()

EndFunc   ;==>_Help

Func _Fini()

    Exit

EndFunc   ;==>_Fini

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $ag[0][0] To $ag[UBound($ag) - 1][$glen]
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlSend('', '', BitAND($wParam, 0xffff), '{tab}')
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND


Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    If ($bSetting) Then Return False
    Return $GUI_RUNDEFMSG
EndFunc

Func _Test_Graphics()

    Local $acolors = [0xff0000, 0x00ff00, 0x00]
    $bSetting = True
    For $1 = 0 To UBound($ag) - 1
        For $2 = $glen - 1 To UBound($ag, 2) - 1
            $color = $acolors[Random(0, UBound($acolors) - 1, 1)]
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_COLOR, $color, $color)
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_ELLIPSE, 0, 0, $box, $box)
            GUICtrlSetGraphic($ag[$1][$2], $GUI_GR_refresh)
        Next
    Next
    $bSetting = False
    _WinAPI_RedrawWindow($gui010)
EndFunc   ;==>_Test_Graphics

Perhaps a creating a second GUI with the $WS_POPUP style and making it a child to the main window to hold all the graphics to bypass the flicker of all of the other controls. Or using GDI+ to create your graphics

Edited by InunoTaishou

Share this post


Link to post
Share on other sites

InunoTaishou,

@SW_LOCK, @SW_UNLOCK did the trick.  I thought I had tried that but apparently not.  Thanks for looking at this!

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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