[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1046
  • Last Modified:

Visual Studio windows app - disable the screen updating

Hi all
I would like to know what i can do to disable the screan updating when i open a form in my project.

If a run below code, I see the screen updating all the time:

 carrier_name.MdiParent = Me
            carrier_name.Show()
            carrier_name.Focus()

Open in new window


Thanks again for your help
0
Wilder1626
Asked:
Wilder1626
  • 11
  • 10
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
what do you mean by Update?
0
 
Wilder1626Author Commented:
The screen is flickering when i open the multiple project forms.

Is there a way to stop the flickering?

In VB macro for excel, i was using ApplicationScreenUpdating = False.

Do we have a look a like for Visual studio?
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
Wilder1626Author Commented:
I have just tried, but still having the flickering.
0
 
Éric MoreauSenior .Net ConsultantCommented:
it would take a sample to repro on my side. do you have one?
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
Wilder1626Author Commented:
Let me try again both solutions you gave me. Cause when i replicate the same thing in another project, everything looks good.

Pretty strange. Wonder if the Transparence on labels can cause the problem.
0
 
Wilder1626Author Commented:
I was able to replicate cause i still have the same problem.

On form1, on your left, go under Carrier / New setting. The form that will show will do some flickering.
WindowsApplication1.zip
0
 
Éric MoreauSenior .Net ConsultantCommented:
have you tried the other link code?
0
 
Wilder1626Author Commented:
not yet. but i'm testing it now.
0
 
Éric MoreauSenior .Net ConsultantCommented:
I'll wait until I get more news from you then
0
 
Wilder1626Author Commented:
I cant seems to figure this one out. How it really work and where to place the code.

sorry, i'm a newby
0
 
Éric MoreauSenior .Net ConsultantCommented:
do you have a very slow PC? I just tried and it is not that bad.

can you also try to put these lines in your Form2:
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        SetStyle(ControlStyles.DoubleBuffer, True)
    End Sub

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
add this code to your form2:


    'PREVENT FLICKERING 
    Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or 33554432
            Return cp
        End Get
    End Property
    Private Sub PreVentFlicker()
        With Me
            .SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
            .SetStyle(ControlStyles.UserPaint, True)
            .SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            .UpdateStyles()
        End With

    End Sub

Open in new window


and change the constructor of your Form2 for:
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        'SetStyle(ControlStyles.DoubleBuffer, True)
        PreVentFlicker()
    End Sub

Open in new window

0
 
Wilder1626Author Commented:
wow, looks like it's did stop flickering.

let me do one last test
0
 
Wilder1626Author Commented:
Thank you so much for your help

this is perfect
0
 
Wilder1626Author Commented:
HI Éric

I was wondering if it was normal that once the form2 opened, now other functionalities are not working anymore?

Ex: clear button or the send to grid button.

was i to put the below code in the Form2.load?

  ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        'SetStyle(ControlStyles.DoubleBuffer, True)
        PreVentFlicker()

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
try removing the call to preventflicker and you will quickly discover if it is related or not
0
 
Wilder1626Author Commented:
Hi

i actualy  did the test, and once removed, it does work.
0
 
Éric MoreauSenior .Net ConsultantCommented:
reactivate the PreventFlicker and comment out this line:
.SetStyle(ControlStyles.AllPaintingInWmPaint, True)

Open in new window

0
 
Wilder1626Author Commented:
Thanks, i will test this and let you know shortly
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now