Note that there are some explanatory texts on larger screens.

plurals
  1. POCreateParams() property shows default icon on inherited form
    text
    copied!<p><strong>The Task</strong></p> <p>I manage a big application that is based on a main MDI form. All other forms are children of this MDI form or dialogs of the children. As it is a big application, opening and closing the child windows causes some flickering in the whole application. I was tasked to remove this flickering effect as it looks untidy. My main thought was to make all child windows inherit a "Master" form that would deal with all the commonplace functionality that all forms had to include. From here, I could fix any problems in this one central point which would make managing the application much easier.</p> <p><strong>The Problem</strong></p> <p>To resolve the flickering, I found a solution on the web that solves my problem. However, not long ago I found that this also introduced a new problem on the "Master" form where if any form had its "ShowIcon" property to false, the "Master" form would force it to be the default visual studio form icon. I narrowed this down to the anti-flicker solution I found on the web (below).</p> <pre><code>Private imActive As Boolean = False Private defaultEX As Integer = -1 Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams If defaultEX = -1 Then defaultEX = cp.ExStyle End If If DesignMode = False and imActive = False Then cp.ExStyle = cp.ExStyle Or &amp;H2000000 Else cp.ExStyle = defaultEX End If Return cp End Get End Property </code></pre> <p>If I comment this out, it works fine but the flickering is unbearable.</p> <p><strong>The Question</strong></p> <p>I would like to know if there is an alternative to the current solution or if there is something I can set within the "cp" variable that would remove the icon?</p> <p><strong>The Example</strong></p> <p>I have created a quick application that emulates part of my problem. I could not replicate the flickering as this is down to the application being big. However, in this test project, I have replicated a form that inherits a "Master" form with the above code on. This then disallows the icon to be removed (even in the designer). dropbox.com/s/mg9fyfoshakc69z/TestProject.zip</p> <p>For this replication, I did not need to include the MDI parent, I have however got an inherited form (MasterForm) and a form that inherits it (Form1). MasterForm has code that overrides the CreateParams property. This effects Form1 in such a way that when the toggle for ShowIcon for the window is set to false, it shows the default VB window icon instead of removing it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload