flickering form on resize with a background image.

Hi,

I have a background image to the form. The form is divided into two horizontal split containers the top container is fixed and both the containers are made transperent. i have a listview docked to fill in the container. when i resize the form i have a flickering issue and i see that the background image of form is being displayed during the time duration when the listview gets to the resized position of form resulting in a flickering. I have already applied the double buffering and set the styles as follows:

SetStyle(ControlStyles.UserPaint, True)
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer,
True)

How can i solve this Help me!!!

Atheeque Pasha




Answer this question

flickering form on resize with a background image.

  • Srreh

    Hi,

    Unfortunately not as I don't have their application or source. If you have their application you can use Spy++ to see how their windows (which will translate to controls) are laid out. As to how they are doing the backgroundimage etc I cannot tell.

    You might want to take a look at this tool: http://msdn.microsoft.com/msdnmag/issues/06/04/ManagedSpy/

    Martin



  • Critcho

    Thank You  J2Associates

     it works fine.  and the form doesnot gets resized until we reach the final position. Thats looks odd with my application i would like to have the form controls to move along with the form resize. I wonder how the itunes guys did the top panel. which doesnot flicker when we resize the form. If  Can somebody explain the process or the layout followed by itunes design.

     

     

     

     



  • dredrunde

    Hello,

    I'm sorry that I don't have code, but I saw an interesting discussion once where all you do in the Resize event is set an event handler for the Windows Idle event. So while the user is resizing, all you see is the the form outline pretty similar to what we see when we drag a textbox on to a form at design time and size it. Then when the Idle event fires, the form is painted there. Don't know if this will help you or not but Good Luck!


  • dronick

    I even tried by applying the background image to only the top panel. and when kept a textbox on top of the same panel and resized the form i can see the textbox background being overlapped by the background image of the panel when the form is resized. it takes few seconds to set back to the normal background of the textbox. this happens when i resize the form with holding the mouse by increasing and decreasing the form size. is there any way where I can the resize of the form happen only when the user leaves the mouse after reaching the desired location.

    The form i my trying to design looks some what similar to itunes top panel with the play button and textbox to search.

    Thanks and I would greatly appreciate your help.

    Atheeque



  • Mike12345

    Hi Martin,

    Can You explain how the itunes layout has been designed which ddoesnot have the flickering effect when resized. i am trying to design the same format on the toppanel and i see the flickering.

    Thanks



  • Rory Becker

    Hi,

    This is super-expensive as the WM_PAINT of the splitterpanel has to call the paint of the splitcontainer, has to call the paint of the form.

    I have a background image to the form. The form is divided into two horizontal split containers the top container is fixed and both the containers are made transperent. i have a listview docked to fill in the container. when i resize the form i have a flickering issue and i see that the background image of form is being displayed during the time duration when the listview gets to the resized position of form resulting in a flickering.

    If you handle the paint event yourself to draw the background image into the splitterpanel, you will gain quite a bit in performance.
    Also there's some recommendations
    Martin


  • Joe McGrath

    Hi Martin,

    can you help me in the process how can attach the mangedspy with the process of itunes form.

    Thanks



  • Big H

    Hi Martin,

    Thanks for replying. Is there any way i could set the image to top container panel and rather than apply the image to the complete form and leave the bottom panel to be used by listbox.

    Atheeque



  • spillai

    Have you tried it What happens when you do

  • Seb_london

    Hi,

    Thank You for the idea I had the same idea in mind . but If you could provide me with a code of how to do it that will be great.

    Atheeque



  • jinjun

    ' Following stops continuous resizing of controls while the form is being resized by
    ' trapping the Application.Idle event only in OnResize and then Invalidating in Idle.

    Private m_IdleHooked As Boolean = False

    Protected Overrides Sub OnResize(ByVal e As EventArgs)
    If Not m_IdleHooked Then
    m_IdleHooked = Not m_IdleHooked
    AddHandler Application.Idle, AddressOf OnIdle
    End If
    End Sub 'OnResize

    Private Sub OnIdle(ByVal s As Object, ByVal e As EventArgs)
    Invalidate()
    PerformLayout()
    If m_IdleHooked Then
    m_IdleHooked = Not m_IdleHooked
    RemoveHandler Application.Idle, New EventHandler(AddressOf OnIdle)
    End If
    End Sub 'OnIdle



  • flickering form on resize with a background image.