Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Screen Flicker in VB.net

Options
  • 29-11-2008 7:14pm
    #1
    Closed Accounts Posts: 2,268 ✭✭✭


    In VBA there is a command
    ScreenUpdating = false
    This switches off screen changes until
    Screen Updating=true is turned on.

    Is there a vb.net equivalent

    I've Tried Suspend Layout but I really need a system level event rather than a form level event.

    RGDS

    MM


Comments

  • Registered Users Posts: 2,931 ✭✭✭Ginger


    If you add the following to the forms constructor

    this.SetStyle(ControlStyles.DoubleBuffer, true);
    this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

    It should do it...

    I had something similar and created a custom panel with these properties set and it removed the flicker.


  • Closed Accounts Posts: 815 ✭✭✭KStaford


    Ginger wrote: »
    If you add the following to the forms constructor

    this.SetStyle(ControlStyles.DoubleBuffer, true);
    this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

    It should do it...

    I had something similar and created a custom panel with these properties set and it removed the flicker.

    What Ginger rer refer to here is called Double Buffering. It creates 2 buffers similtaneously, one can be written to while the other one is read. It really doe smake a huge difference to screen updates especially if you are using GDI to draw to your forms etc.


  • Closed Accounts Posts: 2,268 ✭✭✭mountainyman


    Thanksd Ginger,

    That is a very useful snippet. I want to pause screen events which is harder than it used to be . when I get it sorted I will postr the code for the good of boards.

    MM


  • Closed Accounts Posts: 2,268 ✭✭✭mountainyman


    Sorry for dredging up this old thread but thought it was only good manners to answer my own question now that I have an answer. Might help someone searching on boards in the future.

    To pause screen updating in vb.net

    In class variables for form or global variables.
        Friend Declare Function LockWindowUpdate Lib "user32.dll" (ByVal hWndLock As IntPtr) As Boolean
    

    To pause screen updating
    LockWindowUpdate(Me.Handle.ToInt32)
    


    To turn screen updating back on
    LockWindowUpdate(0)
    

    Sorry about dredging up the old thread but better to have the answer in I think.


Advertisement