2

The Task

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.

The Problem

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).

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 &H2000000
        Else
            cp.ExStyle = defaultEX
        End If
        Return cp
    End Get
End Property

If I comment this out, it works fine but the flickering is unbearable.

The Question

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?

The Example

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

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.

4

1 回答 1

1

运行演示应用程序后,我能看到的唯一区别是 ImActive 标志。

修改添加到测试项目集中的类似标志对我来说有不同的结果,我建议更改设置的位置,直到获得所需的结果。

显示表单后设置为 false 似乎效果最好。

于 2013-10-31T10:41:43.157 回答