Sign in to follow this  
Followers 0
Synapse

Some flicker problem with images

8 posts in this topic

#1 ·  Posted (edited)

Hi...sorry for my question...even if for someone seams a dumb question I tryed everything i know and still creates some flickering thing when changing the images in my GUI. To make myself clear i created a GUI that uses images for the controls controls (buttons etc.), i have a background that is made the same out of an image etc...

I`ve created a menu that acts like a tabbing system. When i click a button from the menu it hides every image in my GUI and shows the other menu`s buttons, text, input etc. The problem lies here. It creates an ugly flickering during the hiding/showing of the controls (i`ve made even a flagging method to block the procedure of re-hiding/re-showing of the same content if its already showed).

Is there a way to change pics without flickering ?

I used JPG`s file as images....is there any difference by using BMP`s or other kind of images.

Here is the code that hides and shows the content.

Func _ShowHide_Status($todo)
    Switch $todo
        Case 0
            If $StatusPos = 1 Then
                For $i = 1 To 32
                    GUICtrlSetState( $Status[$i], $GUI_HIDE);
                Next
                $StatusPos = 0
            Else
                Return
            EndIf
        Case 1
            If $StatusPos = 0 Then
                For $i = 1 To 32
                    GUICtrlSetState( $Status[$i], $GUI_SHOW);
                Next
            $StatusPos = 1
            Else
                Return
            EndIf
    EndSwitch
EndFunc

SOURCE

Thank you.

Edited by Synapse

Share this post


Link to post
Share on other sites



You could try locking the GUI window at the beginning of your Show/Hide function to prevent repainting the controls. Then at the end of the function, once all controls have been updated, unlock the GUI and all the changes should be made at the same time. This should go some way towards reducing flicker.

The commands you'll need are:

GUISetState(@SW_LOCK)

&

GUISetState(@SW_UNLOCK)

Share this post


Link to post
Share on other sites

You could try locking the GUI window at the beginning of your Show/Hide function to prevent repainting the controls. Then at the end of the function, once all controls have been updated, unlock the GUI and all the changes should be made at the same time. This should go some way towards reducing flicker.

The commands you'll need are:

GUISetState(@SW_LOCK)

&

GUISetState(@SW_UNLOCK)

Thx...i think it`s kinda better...but I still need to do something :)...Thanks for the help ^_^

Share this post


Link to post
Share on other sites
Here is the source and the images if it may help..

Share this post


Link to post
Share on other sites

Instead of hiding/showing all controls one by one using loops, I would place each set of controls into separate GUIs (children of the main GUI), so I can hide/show them at once. I believe this is more sensible approach in many ways.

Other than that, I'd also try RedrawWindow API (beta), to disallow repainting outside the "tab" (validate whole window, invalidate only tab rectangle).


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Instead of hiding/showing all controls one by one using loops, I would place each set of controls into separate GUIs (children of the main GUI), so I can hide/show them at once. I believe this is more sensible approach in many ways.

Other than that, I'd also try RedrawWindow API (beta), to disallow repainting outside the "tab" (validate whole window, invalidate only tab rectangle).

It`s a very good idea...

If u have some time can u post a example of a parent/child gui...? Please :)

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

$sTitle = "Blah"

$hGui = GUICreate($sTitle, 400, 300, -1, -1, -1, -1)

$cBtn1 = GUICtrlCreateButton("Page 1", 10, 10, 100, 30)
$cBtn2 = GUICtrlCreateButton("Page 2", 110, 10, 100, 30)

;page 1 and its controls
$hPage1 = GUICreate("", 380, 240, 10, 50, $WS_CHILD+$WS_BORDER, -1, $hGui)
$cLabelP1 = GUICtrlCreateLabel("Control in page 1", 50, 50, 200, 50)
$cCheckP1 = GUICtrlCreateCheckbox("p1", 50, 100, 200, 50)

;page 2 and its controls
$hPage2 = GUICreate("", 380, 240, 10, 50, $WS_CHILD+$WS_BORDER, -1, $hGui)
$cLabelP2 = GUICtrlCreateLabel("Control in page 2", 50, 100, 200, 50)
$cCheckP2 = GUICtrlCreateCheckbox("p2", 50, 150, 200, 50)
    
GUISetState(@SW_SHOW, $hPage1) ;default page to show

GUISwitch($hGui)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cBtn1
            GUISetState(@SW_HIDE, $hPage2)
            GUISetState(@SW_SHOW, $hPage1)      
        Case $cBtn2
            GUISetState(@SW_HIDE, $hPage1)
            GUISetState(@SW_SHOW, $hPage2)
    EndSwitch
WEnd

Exit


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Thank you....:)

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