Articles in this section
Category / Section

How to avoid flickering in WinForms Office2010 control loading time?

4 mins read

Syncfusion Form controls like MetroFormOffice2007Form and Office2010Form is inherited from Microsoft Form and has many customization option like alignment, appearance, Caption Images, Caption Labels and much more and additionally we have used Native Function for rendering purpose in our Form controls. So, there is slight more delay in compared with Microsoft Form. But user can reduce the flickering problem by using below code Example.

 

 

Code Example: [C#]

 

//Add below codes in Form constructor for avoid form flickering.
 
int style = NativeWinAPI.GetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE); 
 
style |= NativeWinAPI.WS_EX_COMPOSITED; 
 
NativeWinAPI.SetWindowLong(this.Handle, NativeWinAPI.GWL_EXSTYLE, style); 
 
/// <summary>
/// For avoid flickering Form
/// </summary>
 
internal static class NativeWinAPI 
{ 
 
internal static readonly int GWL_EXSTYLE = -20; 
 
internal static readonly int WS_EX_COMPOSITED = 0x02000000; 
 
[DllImport("user32")] 
internal static extern int GetWindowLong(IntPtr hWnd, int nIndex); 
 
[DllImport("user32")] 
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 
 
} 
 

  

Code Example: [VB]

 

'Add below codes in Form constructor for avoid form flickering.
 
Dim style As Integer = NativeWinAPI.GetWindowLong(Me.Handle, NativeWinAPI.GWL_EXSTYLE)
 
style = style Or NativeWinAPI.WS_EX_COMPOSITED
 
NativeWinAPI.SetWindowLong(Me.Handle, NativeWinAPI.GWL_EXSTYLE, style)
 
''' <summary>
 
''' For avoid flickering Form
 
''' </summary>
 
Friend Module NativeWinAPI
 
Friend ReadOnly GWL_EXSTYLE As Integer = -20
 
Friend ReadOnly WS_EX_COMPOSITED As Integer = &H2000000
 
<DllImport("user32")>
 
Friend Function GetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As Integer
 
End Function
 
<DllImport("user32")>
 
Friend Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
 
End Function
 
End Module

 

Sample

 

C#:  MetroForm Office2010Form Sample

 

VB:  MetroForm Office2010Form Sample


Conclusion

I hope you enjoyed learning about how to avoid flickering in WinForms Office2010 control loading time.

You can refer to our WinForms Office2007Form feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Office2007Form documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied